Sasha Smundak | cb86c3c | 2019-08-08 12:51:15 -0700 | [diff] [blame] | 1 | # /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 Smundak | 69ee7b0 | 2019-09-23 19:13:37 -0700 | [diff] [blame^] | 6 | # The following environment variables affect the result: |
| 7 | # TARGET_PRODUCT target device name, e.g., 'aosp_blueline' |
Sasha Smundak | cb86c3c | 2019-08-08 12:51:15 -0700 | [diff] [blame] | 8 | # 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 Smundak | 69ee7b0 | 2019-09-23 19:13:37 -0700 | [diff] [blame^] | 11 | # 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 Smundak | cb86c3c | 2019-08-08 12:51:15 -0700 | [diff] [blame] | 13 | |
| 14 | # The extraction might fail for some source files, so run with -k |
| 15 | build/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+) |
| 19 | declare -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. |
| 24 | declare -r allkzip=all.kzip |
Sasha Smundak | b13f9c5 | 2019-08-15 11:10:26 -0700 | [diff] [blame] | 25 | "${OUT_DIR:-out}/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find $OUT_DIR -name '*.kzip') |
Sasha Smundak | 69ee7b0 | 2019-09-23 19:13:37 -0700 | [diff] [blame^] | 26 | echo "${BUILD_NUMBER:-$(uuidgen)}" >"$DIST_DIR/revision.txt" |