Move b from a shell function to a shell script at build/bazel/bin/b
Bug: 244766775 Test: b build //packages/modules/adb/apex:com.android.adbd Change-Id: I81b627965fcff636a142324e1eb221fd4c746e9d
This commit is contained in:
56
envsetup.sh
56
envsetup.sh
@@ -253,6 +253,9 @@ function setpaths()
|
|||||||
local ATEST_PATH="$T/prebuilts/asuite/atest/$os_arch"
|
local ATEST_PATH="$T/prebuilts/asuite/atest/$os_arch"
|
||||||
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ACLOUD_PATH:$AIDEGEN_PATH:$ATEST_PATH
|
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ACLOUD_PATH:$AIDEGEN_PATH:$ATEST_PATH
|
||||||
|
|
||||||
|
# Build system
|
||||||
|
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$T/build/bazel/bin
|
||||||
|
|
||||||
export ANDROID_BUILD_PATHS=$(tr -s : <<<"${ANDROID_BUILD_PATHS}:")
|
export ANDROID_BUILD_PATHS=$(tr -s : <<<"${ANDROID_BUILD_PATHS}:")
|
||||||
export PATH=$ANDROID_BUILD_PATHS$PATH
|
export PATH=$ANDROID_BUILD_PATHS$PATH
|
||||||
|
|
||||||
@@ -1842,59 +1845,6 @@ function _trigger_build()
|
|||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
# Convenience entry point (like m) to use Bazel in AOSP.
|
|
||||||
function b()
|
|
||||||
(
|
|
||||||
# zsh breaks posix by not doing string-splitting on unquoted args by default.
|
|
||||||
# See https://zsh.sourceforge.io/Guide/zshguide05.html section 5.4.4.
|
|
||||||
# Tell it to emulate Bourne shell for this function.
|
|
||||||
if [ -n "$ZSH_VERSION" ]; then emulate -L sh; fi
|
|
||||||
|
|
||||||
# Look for the --run-soong-tests flag and skip passing --skip-soong-tests to Soong if present
|
|
||||||
local bazel_args=""
|
|
||||||
local skip_tests="--skip-soong-tests"
|
|
||||||
for i in $@; do
|
|
||||||
if [[ $i != "--run-soong-tests" ]]; then
|
|
||||||
bazel_args+="$i "
|
|
||||||
else
|
|
||||||
skip_tests=""
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Generate BUILD, bzl files into the synthetic Bazel workspace (out/soong/workspace).
|
|
||||||
# RBE is disabled because it's not used with b builds and adds overhead: b/251441524
|
|
||||||
USE_RBE=false _trigger_build "all-modules" bp2build $skip_tests USE_BAZEL_ANALYSIS= || return 1
|
|
||||||
# Then, run Bazel using the synthetic workspace as the --package_path.
|
|
||||||
if [[ -z "$bazel_args" ]]; then
|
|
||||||
# If there are no args, show help and exit.
|
|
||||||
bazel help
|
|
||||||
else
|
|
||||||
# Else, always run with the bp2build configuration, which sets Bazel's package path to the synthetic workspace.
|
|
||||||
# Add the --config=bp2build after the first argument that doesn't start with a dash. That should be the bazel
|
|
||||||
# command. (build, test, run, ect) If the --config was added at the end, it wouldn't work with commands like:
|
|
||||||
# b run //foo -- --args-for-foo
|
|
||||||
local config_set=0
|
|
||||||
|
|
||||||
# Represent the args as an array, not a string.
|
|
||||||
local bazel_args_with_config=()
|
|
||||||
for arg in $bazel_args; do
|
|
||||||
if [[ $arg == "--" && $config_set -ne 1 ]]; # if we find --, insert config argument here
|
|
||||||
then
|
|
||||||
bazel_args_with_config+=("--config=bp2build -- ")
|
|
||||||
config_set=1
|
|
||||||
else
|
|
||||||
bazel_args_with_config+=("$arg ")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ $config_set -ne 1 ]]; then
|
|
||||||
bazel_args_with_config+=("--config=bp2build ")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Call Bazel.
|
|
||||||
bazel ${bazel_args_with_config[@]}
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
function m()
|
function m()
|
||||||
(
|
(
|
||||||
_trigger_build "all-modules" "$@"
|
_trigger_build "all-modules" "$@"
|
||||||
|
Reference in New Issue
Block a user