Index Go code in the build/make/tools
Test: manual
Change-Id: Iae326016074cbed8b83940dd188ca1171cc4d696
diff --git a/build_kzip.bash b/build_kzip.bash
index 6219021..fa616b9 100755
--- a/build_kzip.bash
+++ b/build_kzip.bash
@@ -44,14 +44,18 @@
declare -r go_root=$(realpath prebuilts/go/linux-x86)
declare -r source_root=$PWD
-# TODO(asmundak): Until b/182183061 is fixed, default corpus has to be specified
-# in the rules file. Generate this file on the fly with corpus value set from the
-# environment variable.
-for dir in blueprint soong; do
- (cd "build/$dir";
+# For the Go code, we invoke the extractor directly. The two caveats are that
+# the extractor's rewrite rules are generated on the fly as they depend on the XREF_CORPUS
+# value, and that the name of the kzip file is derived from the directory name
+# by replacing '/' with '_'.
+declare -ar go_modules=(build/blueprint build/soong
+ build/make/tools/canoninja build/make/tools/compliance build/make/tools/rbcrun)
+for dir in "${go_modules[@]}"; do
+ (cd "$dir";
+ outfile=$(echo "$dir" | sed -r 's|/|_|g;s|(.*)|\1.go.kzip|');
KYTHE_ROOT_DIRECTORY="${source_root}" "$go_extractor" --goroot="$go_root" \
--rules=<(printf '[{"pattern": "(.*)","vname": {"path": "@1@", "corpus":"%s"}}]' "${XREF_CORPUS}") \
- --canonicalize_package_corpus --output "${abspath_out}/soong/build_${dir}.go.kzip" ./...
+ --canonicalize_package_corpus --output "${abspath_out}/soong/$outfile" ./...
)
done