summaryrefslogtreecommitdiff
path: root/envsetup.sh
diff options
context:
space:
mode:
author Jingwen Chen <jingwen@google.com> 2023-10-16 09:52:27 +0000
committer Jingwen Chen <jingwen@google.com> 2023-10-17 06:21:46 +0000
commit688e5d606be891cba2ccff63513c4b23d4f0a3e1 (patch)
treecf0d3926736da964da6891fe4ea3aa7ffd9ab843 /envsetup.sh
parent82ae713895abcef187b0934d6c34e5b3de65318b (diff)
Support multiple module name queries with bmod.
Test: bmod libc libm libdl Test: bmod adb framework-minus-apex libdl Change-Id: I156cc31185d3f97d6b5d74c232bd6cd9287cee02
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh31
1 files changed, 18 insertions, 13 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 63837ecbe9..9d27c9d178 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1613,8 +1613,8 @@ function allmod() {
# Return the Bazel label of a Soong module if it is converted with bp2build.
function bmod()
(
- if [ $# -ne 1 ]; then
- echo "usage: bmod <module>" >&2
+ if [ $# -eq 0 ]; then
+ echo "usage: bmod <module 1> <module 2> ... <module n>" >&2
return 1
fi
@@ -1631,19 +1631,24 @@ function bmod()
return 1
fi
- local target_label=$(python3 -c "import json
-module = '$1'
+ modules=()
+ for m in "$@"; do
+ modules+=("\"$m\",")
+ done
+ local res=$(python3 -c "import json
+modules = [${modules[*]}]
converted_json='$converted_json'
bp2build_converted_map = json.load(open(converted_json))
-if module not in bp2build_converted_map:
- exit(1)
-print(bp2build_converted_map[module] + ':' + module)")
-
- if [ -z "${target_label}" ]; then
- echo "$1 is not converted to Bazel." >&2
- return 1
- else
- echo "${target_label}"
+for module in modules:
+ if module not in bp2build_converted_map:
+ print(module + ' is not converted to Bazel.')
+ else:
+ print(bp2build_converted_map[module] + ':' + module)")
+
+ echo "${res}"
+ unconverted_count=$(echo "${res}" | grep -c "not converted to Bazel")
+ if [[ ${unconverted_count} -ne 0 ]]; then
+ return 1
fi
)