Merge changes I2325e199,I534caab0
* changes: skip soong tests by default for b command insert --config=bp2build before -- in b args
This commit is contained in:
32
envsetup.sh
32
envsetup.sh
@@ -1838,10 +1838,20 @@ function _trigger_build()
|
||||
# Convenience entry point (like m) to use Bazel in AOSP.
|
||||
function b()
|
||||
(
|
||||
# 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).
|
||||
_trigger_build "all-modules" bp2build USE_BAZEL_ANALYSIS= || return 1
|
||||
# Then, run Bazel using the synthetic workspace as the --package_path.
|
||||
if [[ -z "$@" ]]; then
|
||||
if [[ -z "$bazel_args" ]]; then
|
||||
# If there are no args, show help.
|
||||
bazel help
|
||||
else
|
||||
@@ -1849,17 +1859,21 @@ function b()
|
||||
# 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 previous_args=""
|
||||
for arg in $@;
|
||||
do
|
||||
previous_args+="$arg "
|
||||
shift
|
||||
if [[ $arg != -* ]]; # if $arg doesn't start with a dash
|
||||
local config_set=0
|
||||
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
|
||||
break
|
||||
bazel_args_with_config+="--config=bp2build -- "
|
||||
config_set=1
|
||||
else
|
||||
bazel_args_with_config+="$arg "
|
||||
fi
|
||||
done
|
||||
bazel $previous_args --config=bp2build $@
|
||||
if [[ $config_set -ne 1 ]]; then
|
||||
bazel_args_with_config+="--config=bp2build "
|
||||
fi
|
||||
eval "bazel $bazel_args_with_config"
|
||||
fi
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user