浏览代码

Index Go code in the build/make/tools

Test: manual
Change-Id: Iae326016074cbed8b83940dd188ca1171cc4d696
Sasha Smundak 1 年之前
父节点
当前提交
08253a0901
共有 1 个文件被更改,包括 10 次插入6 次删除
  1. 10 6
      build_kzip.bash

+ 10 - 6
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