blob: 22ff504535ed609ae99cc3bcad54adea8590d4ae [file] [log] [blame]
Sasha Smundakcb86c3c2019-08-08 12:51:15 -07001# /bin/bash -uv
2#
3# Build kzip files (source files for the indexing pipeline) for the given configuration,
4# merge them and place the resulting all.kzip into $DIST_DIR.
5# It is assumed that the current directory is the top of the source tree.
Sasha Smundak69ee7b02019-09-23 19:13:37 -07006# The following environment variables affect the result:
7# TARGET_PRODUCT target device name, e.g., 'aosp_blueline'
Sasha Smundakcb86c3c2019-08-08 12:51:15 -07008# TARGET_BUILD_VARIANT variant, e.g., `userdebug`
9# OUT_DIR where the build is happening (./out if not specified)
10# DIST_DIR where the resulting all.kzip will be placed
Sasha Smundak69ee7b02019-09-23 19:13:37 -070011# XREF_CORPUS source code repository URI, e.g., 'android.googlesource.com/platform/superproject'
12# BUILD_NUMBER build number, used to generate unique ID (will use UUID if not set)
Sasha Smundakcb86c3c2019-08-08 12:51:15 -070013
14# The extraction might fail for some source files, so run with -k
15build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java
16
17# We build with -k, so check that we have generated at least 100K files
18# (the actual number is 180K+)
19declare -r kzip_count=$(find $OUT_DIR -name '*.kzip' | wc -l)
20(($kzip_count>100000)) || { printf "Too few kzip files were generated: %d\n" $kzip_count; exit 1; }
21
22# Pack
23# TODO(asmundak): this should be done by soong.
24declare -r allkzip=all.kzip
Sasha Smundakb13f9c52019-08-15 11:10:26 -070025"${OUT_DIR:-out}/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find $OUT_DIR -name '*.kzip')
Sasha Smundak69ee7b02019-09-23 19:13:37 -070026echo "${BUILD_NUMBER:-$(uuidgen)}" >"$DIST_DIR/revision.txt"