From d728ee1a065aafa0d4833d4f01225738bfaa249a Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Tue, 18 May 2021 06:02:53 +0000 Subject: [PATCH] Introduce `b` into envsetup.sh. `b` is a function that combines: 1. Integrated generation of a synthetic bazel workspace, containing symlinks to BUILD and bzl files alongside symlinks to the source tree. This is the --package_path of the bazel build. 2. Running the Bazel build itself with b's entire argv. A user accustomed to typing `bazel build ` would now type `b build `. Test: source build/envsetup.sh; b build //bionic/...; b cquery --output=label_kind //bionic/... Fixes: 188490434 Change-Id: I36e366108b024c09945d764a1115786658e03681 --- envsetup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/envsetup.sh b/envsetup.sh index 8a995c7fdc..6cb2cc4c7e 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1687,10 +1687,19 @@ function _trigger_build() if T="$(gettop)"; then _wrap_build "$T/build/soong/soong_ui.bash" --build-mode --${bc} --dir="$(pwd)" "$@" else - echo "Couldn't locate the top of the tree. Try setting TOP." + >&2 echo "Couldn't locate the top of the tree. Try setting TOP." + return 1 fi ) +function b() +( + # Generate BUILD, bzl files into the synthetic Bazel workspace (out/soong/workspace). + m nothing GENERATE_BAZEL_FILES=true || return 1 + # Then, run Bazel using the synthetic workspace as the --package_path. + "$(gettop)/tools/bazel" "$@" --config=bp2build +) + function m() ( _trigger_build "all-modules" "$@"