diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 46c3929..defde52 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -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: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17eb3d3..b3e24d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,5 +34,6 @@ jobs: USE_BAZEL_VERSION: ${{ matrix.bazel }} working-directory: tests/bcr run: | + bazel run //:buildozer_alias bazel run //:run_buildozer bazel test //... diff --git a/BUILD.bazel b/BUILD.bazel index 0c25f2d..517f73c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,12 +1,13 @@ +# 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 runfile in other binaries 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", ], diff --git a/buildozer.sh b/buildozer.sh index 5070e3c..6b8bd5d 100755 --- a/buildozer.sh +++ b/buildozer.sh @@ -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 diff --git a/tests/bcr/BUILD.bazel b/tests/bcr/BUILD.bazel index cd46c4f..a64368b 100644 --- a/tests/bcr/BUILD.bazel +++ b/tests/bcr/BUILD.bazel @@ -5,3 +5,8 @@ sh_binary( }, srcs = ["run_buildozer.sh"], ) + +alias( + name = "buildozer_alias", + actual = "@buildozer", +)