-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure the xcodeproj project generation uses the correct Bazel b…
…inary in the `firebase_example` (#1401) The `rules_xcodeproj` project generator calls Bazel. By default, it looks for `bazel` on the `PATH`. When running under `rules_bazel_integration_test` this will pick up the default Bazel version on the system. If that is Bazelisk, it will pull down the latest Bazel. The fix is to explicitly tell `xcodeproj` which Bazel binary to use. - Add `tools/bazel` to the `firebase_example`. It inspects environment variables to determine the Bazel version to use and writes `tools/bazel_for_xcodeproj` which executes Bazel commands against the correct Bazel binary. - Use `sanbox` for `rules_xcodeproj` builds in firebase example. This avoids the duplicate definition error. - Add `print_and_run` bash function to `examples/firebase_example/do_test` to ease debugging future issues.
- Loading branch information
Showing
5 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | ||
|
||
# Order of Bazel selection: | ||
# 1. BAZEL_REAL: Use Bazel specified by Bazelisk | ||
# 2. BIT_BAZEL_BINARY: Use Bazel specified by rules_bazel_integration_test. | ||
# 3: bazel: Try to find Bazel on the PATH | ||
# | ||
# NOTE: Do not put BIT_BAZEL_BINARY first in the evaluation. It can lead to | ||
# recursive loop when using rules_bazel_integration_test. | ||
bazel="${BAZEL_REAL:-${BIT_BAZEL_BINARY:-bazel}}" | ||
|
||
# Generate a bazel script for rules_xcodeproj to use. This script ensures that | ||
# the xcodeproj runner uses the Bazel that is under test. We configure the | ||
# xcodeproj macro to find this generated bazel script. | ||
bazel_for_xcodeproj="${script_dir}/bazel_for_xcodeproj" | ||
cat >"${bazel_for_xcodeproj}" <<-EOF | ||
#!/usr/bin/env bash | ||
# NOTE: This file is generated by tools/bazel. It is used by the xcodeproj | ||
# macro. | ||
set -o errexit -o nounset -o pipefail | ||
# Use the Bazel binary that we specify. | ||
bazel="${bazel}" | ||
# Execute the Bazel command | ||
"\${bazel}" "\${@}" | ||
EOF | ||
chmod +x "${bazel_for_xcodeproj}" | ||
|
||
# Execute the command | ||
"${bazel}" "${@}" |