Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update bzlmod example #308

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .bazelci/bzlmod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@ tasks:
name: "Depend on Bazel module"
platform: ${{ all_platform }}
working_directory: ../bzlmod/01-depend_on_bazel_module
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:main"
02-override_bazel_module:
name: "Override Bazel module"
platform: ${{ all_platform }}
working_directory: ../bzlmod/02-override_bazel_module
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:main"
03-introduce_dependencies_with_module_extension:
name: "Introduce dependencies with module extension"
platform: ${{ all_platform }}
working_directory: ../bzlmod/03-introduce_dependencies_with_module_extension
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:city_count"
- "//:emoji_count"
Expand All @@ -34,23 +28,17 @@ tasks:
environment:
MY_SHELL_BIN_PATH: /foo/bar/sh
working_directory: ../bzlmod/04-local_config_and_register_toolchains
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:get_sh_path"
05-integrate_third_party_package_manager:
name: "Integrate third party package manager"
platform: ${{ all_platform }}
working_directory: ../bzlmod/05-integrate_third_party_package_manager
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:check_books"
06-specify_dev_dependency:
name: "Specify dev dependency"
platform: ${{ all_platform }}
working_directory: ../bzlmod/06-specify_dev_dependency
build_flags:
- "--enable_bzlmod"
build_targets:
- "//:check_books"
1 change: 1 addition & 0 deletions bzlmod/01-depend_on_bazel_module/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
1 change: 1 addition & 0 deletions bzlmod/01-depend_on_bazel_module/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.3.0
4 changes: 1 addition & 3 deletions bzlmod/01-depend_on_bazel_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ This is an example on how to introduce dependencies on Bazel modules in the MODU
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
bazelisk build --enable_bzlmod //:main
GLOG_logtostderr=1 ./bazel-bin/main
GLOG_logtostderr=1 bazel run main
```
1 change: 1 addition & 0 deletions bzlmod/02-override_bazel_module/.bazelrc
1 change: 1 addition & 0 deletions bzlmod/02-override_bazel_module/.bazelversion
4 changes: 1 addition & 3 deletions bzlmod/02-override_bazel_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ Note that the final source tree after overriding must contain a MODULE.bazel fil
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
bazelisk build --enable_bzlmod //:main
GLOG_logtostderr=1 ./bazel-bin/main
GLOG_logtostderr=1 bazel run main
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This is an example on how to introduce dependencies by invoking external reposit
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
bazelisk build --enable_bzlmod //:city_count //:emoji_count
bazel build //:city_count //:emoji_count
cat bazel-bin/city_number bazel-bin/emoji_number
```
1 change: 1 addition & 0 deletions bzlmod/04-local_config_and_register_toolchains/.bazelrc
4 changes: 1 addition & 3 deletions bzlmod/04-local_config_and_register_toolchains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ This is an example on how to generate local config repos and register toolchains
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
export MY_SHELL_BIN_PATH=/foo/bar/sh
bazelisk build --enable_bzlmod //:get_sh_path
MY_SHELL_BIN_PATH=/foo/bar/sh bazel build //:get_sh_path
cat ./bazel-bin/result
```
1 change: 1 addition & 0 deletions bzlmod/05-integrate_third_party_package_manager/.bazelrc
3 changes: 1 addition & 2 deletions bzlmod/05-integrate_third_party_package_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ It covers the following topics:
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
bazelisk build --enable_bzlmod //:check_books
bazel build check_books
cat ./bazel-bin/books
```

Expand Down
1 change: 1 addition & 0 deletions bzlmod/06-specify_dev_dependency/.bazelrc
1 change: 1 addition & 0 deletions bzlmod/06-specify_dev_dependency/.bazelversion
3 changes: 1 addition & 2 deletions bzlmod/06-specify_dev_dependency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Dev dependencies only take effect when the current module is the root module, an
To test it out, `cd` into this directory and run the following:

```bash
export USE_BAZEL_VERSION=last_green
bazelisk build --enable_bzlmod //:check_books
bazel build check_books
cat ./bazel-bin/books
```

Expand Down
7 changes: 3 additions & 4 deletions bzlmod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ This folder contains example usages of the new external dependency system for Ba
- The WORKSPACE file for defining equivalent dependencies with the old system.
- An empty WORKSPACE.bzlmod file to prevent fetching any dependencies from the old WORKSPACE system when Bzlmod is enabled. (Bzlmod and WORKSPACE can work at the same time, with dependencies from Bzlmod takes priority.)

To turn on Bzlmod, you'll need to pass `--experimental_enable_bzlmod` as a build flag.
With Bazel 6, you'll need to pass `--enable_bzlmod` as a build flag to turn
this feature on. Consider adding this to `.bazelrc`:

As of Jun 2022, Bzlmod is still in development, it's recommended to test with Bazel built at HEAD, you can use Bazel built at HEAD via [Bazelisk](https://github.com/bazelbuild/bazelisk/releases),
```
export USE_BAZEL_VERSION=last_green
bazelisk build <targets>
common --enable_bzlmod
```