Reduce the number of Soong invocations, and various other minor script fixes.

-  We can pass all targets at once to build-aml-prebuilts.sh.
-  Less noise from build-mainline-modules.sh.
-  Default to the same out directory in both build scripts.
-  Addressed post-submit comments on https://r.android.com/1170907.
-  Various minor cleanups.

Test: build/soong/scripts/build-mainline-modules.sh
Change-Id: Id21ef80c2334462836e217032fc5bf63b7cd04e1
This commit is contained in:
Martin Stjernholm
2020-05-06 22:03:26 +01:00
parent e051d0d324
commit 691503ea0b
2 changed files with 58 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/bash -ex
#!/bin/bash -e
# Non exhaustive list of modules where we want prebuilts. More can be added as
# needed.
@@ -23,42 +23,45 @@ MODULES_SDK_AND_EXPORTS=(
# We want to create apex modules for all supported architectures.
PRODUCTS=(
aosp_arm
aosp_arm64
aosp_x86
aosp_x86_64
aosp_arm
aosp_arm64
aosp_x86
aosp_x86_64
)
if [ ! -e "build/make/core/Makefile" ]; then
echo "$0 must be run from the top of the tree"
exit 1
echo "$0 must be run from the top of the tree"
exit 1
fi
echo_and_run() {
echo "$*"
"$@"
}
OUT_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var OUT_DIR)
DIST_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var DIST_DIR)
for product in "${PRODUCTS[@]}"; do
build/soong/soong_ui.bash --make-mode $@ \
TARGET_PRODUCT=${product} \
${MAINLINE_MODULES[@]}
echo_and_run build/soong/soong_ui.bash --make-mode $@ \
TARGET_PRODUCT=${product} \
${MAINLINE_MODULES[@]}
PRODUCT_OUT=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var PRODUCT_OUT)
TARGET_ARCH=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var TARGET_ARCH)
rm -rf ${DIST_DIR}/${TARGET_ARCH}/
mkdir -p ${DIST_DIR}/${TARGET_ARCH}/
for module in "${MAINLINE_MODULES[@]}"; do
cp ${PWD}/${PRODUCT_OUT}/system/apex/${module}.apex ${DIST_DIR}/${TARGET_ARCH}/
done
PRODUCT_OUT=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var PRODUCT_OUT)
TARGET_ARCH=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var TARGET_ARCH)
rm -rf ${DIST_DIR}/${TARGET_ARCH}/
mkdir -p ${DIST_DIR}/${TARGET_ARCH}/
for module in "${MAINLINE_MODULES[@]}"; do
echo_and_run cp ${PWD}/${PRODUCT_OUT}/system/apex/${module}.apex ${DIST_DIR}/${TARGET_ARCH}/
done
done
# Create multi-archs SDKs in a different out directory. The multi-arch script
# uses soong directly and therefore needs its own directory that doesn't clash
# with make.
export OUT_DIR=${OUT_DIR}/aml/
for sdk in "${MODULES_SDK_AND_EXPORTS[@]}"; do
build/soong/scripts/build-aml-prebuilts.sh ${sdk}
done
# uses Soong in --skip-make mode which cannot use the same directory as normal
# mode with make.
export OUT_DIR=${OUT_DIR}/aml
echo_and_run build/soong/scripts/build-aml-prebuilts.sh ${MODULES_SDK_AND_EXPORTS[@]}
rm -rf ${DIST_DIR}/mainline-sdks
cp -R ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}
echo_and_run cp -R ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}