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

Allow buildozer target to be aliased #23

Merged
merged 1 commit into from
Jan 25, 2025
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
3 changes: 2 additions & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ bcr_test_module:
# Workaround for https://github.com/bazelbuild/bazel/issues/3268
- echo bazel-bcr/>> .bazelignore
run_targets:
- //:run_buildozer
- //:buildozer_alias # Run the alias with no args.
- //:run_buildozer # Will modify a test target.
build_targets:
- //...
test_targets:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ jobs:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
working-directory: tests/bcr
run: |
bazel run //:buildozer_alias
bazel run //:run_buildozer
bazel test //...
8 changes: 5 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# A buildozer binary that will run in the root repository's workspace directory
# when executed with `bazel run`.
# Can be aliased or used as a data dependency of other targets executed via
# `bazel run`.
sh_binary(
name = "buildozer",
srcs = ["buildozer.sh"],
data = [
"@buildozer_binary//:buildozer.exe",
],
env = {
"BUILDOZER_RLOCATIONPATH": "$(rlocationpath @buildozer_binary//:buildozer.exe)",
},
deps = [
"@bazel_tools//tools/bash/runfiles",
],
visibility = ["//visibility:public"],
)

exports_files(["buildozer.bzl"])
Expand Down
5 changes: 3 additions & 2 deletions buildozer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

buildozer_path=$(rlocation $BUILDOZER_RLOCATIONPATH)
buildozer_rlocationpath=buildozer_binary/buildozer.exe
buildozer_path=$(rlocation $buildozer_rlocationpath)
if [[ ! -f "$buildozer_path" ]]; then
echo "buildozer.exe not found at runfiles path $BUILDOZER_RLOCATIONPATH and resolved path $buildozer_path."
echo "buildozer.exe not found at runfiles path $buildozer_rlocationpath and resolved path $buildozer_path."
exit 1
fi

Expand Down
5 changes: 5 additions & 0 deletions tests/bcr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ sh_binary(
},
srcs = ["run_buildozer.sh"],
)

alias(
name = "buildozer_alias",
actual = "@buildozer",
)
Loading