summaryrefslogtreecommitdiff
path: root/build_kzip.bash
diff options
context:
space:
mode:
author Sasha Smundak <asmundak@google.com> 2019-08-08 12:51:15 -0700
committer Sasha Smundak <asmundak@google.com> 2019-08-13 14:45:52 -0700
commitcb86c3c53253978dfa739db5a7cc44e7dce0b726 (patch)
tree26776ffa949cf7465b09c086a0a0ad17cd96232b /build_kzip.bash
parentdfee9b436481c1fe3c36396c557116c20090ae37 (diff)
The script to generate input for the cross-referencing pipeline.
Bug: 137977523 Test: manual Change-Id: I80faee8db12f0d8e85a09aa9d96fbfc04af19bf8
Diffstat (limited to 'build_kzip.bash')
-rwxr-xr-xbuild_kzip.bash25
1 files changed, 25 insertions, 0 deletions
diff --git a/build_kzip.bash b/build_kzip.bash
new file mode 100755
index 000000000..62ea7a23d
--- /dev/null
+++ b/build_kzip.bash
@@ -0,0 +1,25 @@
+# /bin/bash -uv
+#
+# Build kzip files (source files for the indexing pipeline) for the given configuration,
+# merge them and place the resulting all.kzip into $DIST_DIR.
+# It is assumed that the current directory is the top of the source tree.
+# The following enviromnet variables affect the result:
+# TARGET_PRODUCT target device name, e.g., `aosp_blueline`
+# TARGET_BUILD_VARIANT variant, e.g., `userdebug`
+# OUT_DIR where the build is happening (./out if not specified)
+# DIST_DIR where the resulting all.kzip will be placed
+# XREF_CORPUS source code repository URI, e.g.,
+# `android.googlesource.com/platform/superproject`
+
+# The extraction might fail for some source files, so run with -k
+build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java
+
+# We build with -k, so check that we have generated at least 100K files
+# (the actual number is 180K+)
+declare -r kzip_count=$(find $OUT_DIR -name '*.kzip' | wc -l)
+(($kzip_count>100000)) || { printf "Too few kzip files were generated: %d\n" $kzip_count; exit 1; }
+
+# Pack
+# TODO(asmundak): this should be done by soong.
+declare -r allkzip=all.kzip
+"$OUT_DIR/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find $OUT_DIR -name '*.kzip')