2019-09-27 05:14:28 +02:00
|
|
|
#! /bin/bash -uv
|
2019-08-08 21:51:15 +02:00
|
|
|
#
|
|
|
|
# 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.
|
2019-09-24 04:13:37 +02:00
|
|
|
# The following environment variables affect the result:
|
2019-09-27 05:14:28 +02:00
|
|
|
# BUILD_NUMBER build number, used to generate unique ID (will use UUID if not set)
|
2019-08-08 21:51:15 +02:00
|
|
|
# DIST_DIR where the resulting all.kzip will be placed
|
2019-09-27 05:14:28 +02:00
|
|
|
# OUT_DIR output directory (out if not specified})
|
|
|
|
# TARGET_BUILD_VARIANT variant, e.g., `userdebug`
|
|
|
|
# TARGET_PRODUCT target device name, e.g., 'aosp_blueline'
|
2019-09-24 04:13:37 +02:00
|
|
|
# XREF_CORPUS source code repository URI, e.g., 'android.googlesource.com/platform/superproject'
|
2019-08-08 21:51:15 +02:00
|
|
|
|
2019-09-26 23:54:19 +02:00
|
|
|
: ${BUILD_NUMBER:=$(uuidgen)}
|
2019-09-24 20:57:58 +02:00
|
|
|
|
2019-09-27 05:14:28 +02:00
|
|
|
# The extraction might fail for some source files, so run with -k and then check that
|
|
|
|
# sufficiently many files were generated.
|
|
|
|
declare -r out="${OUT_DIR:-out}"
|
2019-12-20 23:25:50 +01:00
|
|
|
# Build extraction files for C++ and Java. Build `merge_zips` which we use later.
|
|
|
|
build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java
|
|
|
|
#Build extraction file for Go files in build/soong directory.
|
|
|
|
(cd build/soong;
|
|
|
|
../../prebuilts/build-tools/linux-x86/bin/go_extractor \
|
|
|
|
--goroot="${PWD}/../../prebuilts/go/linux-x86" \
|
|
|
|
--rules=vnames.go.json \
|
|
|
|
--canonicalize_package_corpus \
|
|
|
|
--output "${out}/soong/all.go.kzip" \
|
|
|
|
./... )
|
|
|
|
|
2019-09-27 05:14:28 +02:00
|
|
|
declare -r kzip_count=$(find "$out" -name '*.kzip' | wc -l)
|
2019-08-08 21:51:15 +02:00
|
|
|
(($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.
|
2019-09-26 23:54:19 +02:00
|
|
|
declare -r allkzip="$BUILD_NUMBER.kzip"
|
2019-09-27 05:14:28 +02:00
|
|
|
"$out/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find "$out" -name '*.kzip')
|
2019-09-26 23:54:19 +02:00
|
|
|
|