diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 6efe67f..ab59839 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] bazel_mode: [workspace, module] - version: ["5.4.1", "6.4.0", "7.0.0", "8.0.0rc6"] + version: ["5.4.1", "6.4.0", "7.0.0", "8.0.0"] include: # Bazel 5.4.1 does not find Visual Studio on windows-2022. So, we # test it on windows-2019. @@ -82,5 +82,7 @@ jobs: if: ${{ always() }} steps: - uses: cgrindel/gha_join_jobs@794a2d117251f22607f1aab937d3fd3eaaf9a2f5 # v1 + env: + USE_BAZEL_VERSION: '7.x' with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index ad1eb88..772faf2 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -8,7 +8,7 @@ local_path_override( bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "platforms", version = "0.0.10") -bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc") +bazel_dep(name = "stardoc", version = "0.6.2", repo_name = "io_bazel_stardoc") sh_configure = use_extension("@rules_sh//bzlmod:extensions.bzl", "sh_configure") use_repo(sh_configure, "local_posix_config", "rules_sh_shim_exe") diff --git a/tests/import/create_shim_test.sh b/tests/import/create_shim_test.sh index d1d0185..7d6fc80 100755 --- a/tests/import/create_shim_test.sh +++ b/tests/import/create_shim_test.sh @@ -1,14 +1,17 @@ #!/usr/bin/env bash -# --- begin runfiles.bash initialization v2 --- -# Copy-pasted from the Bazel Bash runfiles library v2. -set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash + +# --- begin runfiles.bash initialization v3 --- +# Copy-pasted from the Bazel Bash runfiles library v3. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +# shellcheck disable=SC1090 source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ - source "$0.runfiles/$f" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ - { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e -# --- end runfiles.bash initialization v2 --- + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v3 --- + set -euo pipefail SHIM_EXE="$(rlocation "$1")" diff --git a/tests/import/import_test.bzl b/tests/import/import_test.bzl index c78437c..62b9d6b 100644 --- a/tests/import/import_test.bzl +++ b/tests/import/import_test.bzl @@ -17,12 +17,12 @@ def _create_shim_test(): "@rules_sh_import_test_create_shim_test_shim//prefix:another.shim", ], args = [ - "rules_sh_tests/$(rootpath @rules_sh_shim_exe//:shim.exe)", - "rules_sh_tests/$(rootpath @rules_sh_import_test_create_shim_test_source//:empty.exe)", - "rules_sh_tests/$(rootpath @rules_sh_import_test_create_shim_test_shim//:shimmed.exe)", - "rules_sh_tests/$(rootpath @rules_sh_import_test_create_shim_test_shim//:shimmed.shim)", - "rules_sh_tests/$(rootpath @rules_sh_import_test_create_shim_test_shim//prefix:another.exe)", - "rules_sh_tests/$(rootpath @rules_sh_import_test_create_shim_test_shim//prefix:another.shim)", + "$(rlocationpath @rules_sh_shim_exe//:shim.exe)", + "$(rlocationpath @rules_sh_import_test_create_shim_test_source//:empty.exe)", + "$(rlocationpath @rules_sh_import_test_create_shim_test_shim//:shimmed.exe)", + "$(rlocationpath @rules_sh_import_test_create_shim_test_shim//:shimmed.shim)", + "$(rlocationpath @rules_sh_import_test_create_shim_test_shim//prefix:another.exe)", + "$(rlocationpath @rules_sh_import_test_create_shim_test_shim//prefix:another.shim)", ], ) diff --git a/tools/bazel b/tools/bazel index 3a516f2..1d13dd1 100755 --- a/tools/bazel +++ b/tools/bazel @@ -12,20 +12,24 @@ bazel_version=$( # enable config per each major version, i.e. bazel6, bazel7, bazel8, ... config="--config=bazel${bazel_version%%.*}" -declare -a startup_options=() +declare -a args=() while [ "$#" -gt 0 ]; do option="$1" if [[ "$option" = -* ]]; then - startup_options+=( "$option" ) + args+=( "$option" ) shift else break fi done -command=$1 ; shift +if [ "$#" -gt 0 ]; then + command="$1" ; shift + args+=( "$command" "$config" "$@" ) +elif [ "${#args[@]}" -eq 0 ]; then + # no startup options, no command + exec "$BAZEL_REAL" +fi -# N.B. using a default value if unset for `startup_options` is needed for compatiblity with Bash 3 -# which treats an empty array as unset -exec "$BAZEL_REAL" "${startup_options[@]-}" "$command" "$config" "$@" +exec "$BAZEL_REAL" "${args[@]}" diff --git a/tools/bazel.bat b/tools/bazel.bat index dc4b2d2..3d94db1 100644 --- a/tools/bazel.bat +++ b/tools/bazel.bat @@ -1 +1,15 @@ -@pwsh -File "%~dp0bazel_wrapper.ps1" %* +@echo off + +:: Check if bash is available +where bash >nul 2>nul +if errorlevel 1 ( + echo Bash is not installed or not in PATH. Please install WSL or add bash to PATH. + exit /b 1 +) + +# disable POSIX-to-Windows path conversion for MINGW / MSYS2 +set MSYS_NO_PATHCONV=1 + +:: Call the Bash wrapper +bash --noprofile --norc -o errexit -o nounset -o pipefail "%~dp0bazel" %* + diff --git a/tools/bazel_wrapper.ps1 b/tools/bazel_wrapper.ps1 deleted file mode 100644 index 1a15798..0000000 --- a/tools/bazel_wrapper.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# Exit immediately if a command fails, if a variable is used without being defined, or if a pipeline fails -Set-StrictMode -Version Latest -$ErrorActionPreference = "Stop" - -# Get the Bazel version -$bazel_version = & $Env:BAZEL_REAL --version | ForEach-Object { ($_ -split ' ')[1] } - -# Construct the config flag based on the major version -$config = "--config=bazel$($bazel_version -split '\.' | Select-Object -First 1)" - -# Initialize an array for startup options -$startup_options = @() - -# Parse command-line arguments for options -while ($args.Count -gt 0) { - $option = $args[0] - if ($option -match '^-') { - $startup_options += $option - $args = $args[1..$($args.Count - 1)] - } else { - break - } -} - -# Get the command and remaining arguments -$command = $args[0] -$args = $args[1..$($args.Count - 1)] - -# Execute Bazel with the collected options and arguments -& $Env:BAZEL_REAL @startup_options $command $config @args