From 08253a0901ccd65a2d08dce797e410cd06054e61 Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Mon, 1 Aug 2022 16:11:25 -0700 Subject: [PATCH] Index Go code in the build/make/tools Test: manual Change-Id: Iae326016074cbed8b83940dd188ca1171cc4d696 --- build_kzip.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build_kzip.bash b/build_kzip.bash index 6219021cf..fa616b94d 100755 --- a/build_kzip.bash +++ b/build_kzip.bash @@ -44,14 +44,18 @@ declare -r go_extractor=$(realpath prebuilts/build-tools/linux-x86/bin/go_extrac 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