From f692c756f779bc1f49db9d67e2325fd86991f887 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Mon, 12 Apr 2021 00:01:10 +0100 Subject: [PATCH] Add new user setup command banchan for module building. It currently uses TARGET_BUILD_APPS just like tapas, but the use case is different and it may diverge more in the future. Test: banchan com.android.art Test: banchan help Test: banchan Test: hmm Bug: 179779520 Change-Id: Iae718e65a2a7212c741c397e03c6f9a6d5ee8951 --- banchanHelp.sh | 25 +++++++++++++++++++++++ envsetup.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100755 banchanHelp.sh diff --git a/banchanHelp.sh b/banchanHelp.sh new file mode 100755 index 000000000..af7294c36 --- /dev/null +++ b/banchanHelp.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# locate some directories +cd "$(dirname $0)" +SCRIPT_DIR="${PWD}" +cd ../.. +TOP="${PWD}" + +message='usage: banchan ... [arm|x86|arm64|x86_64] [eng|userdebug|user] + +banchan selects individual APEX modules to be built by the Android build system. +Like "tapas", "banchan" does not request the building of images for a device but +instead configures it for an unbundled build of the given modules, suitable for +installing on any api-compatible device. + +The difference from "tapas" is that "banchan" sets the appropriate products etc +for building APEX modules rather than apps (APKs). + +The module names should match apex{} modules in Android.bp files, typically +starting with "com.android.". + +The usage of the other arguments matches that of the rest of the platform +build system and can be found by running `m help`' + +echo "$message" diff --git a/envsetup.sh b/envsetup.sh index 344a01af0..f4e5f4ee6 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -9,6 +9,9 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y build, and stores those selections in the environment to be read by subsequent invocations of 'm' etc. - tapas: tapas [ ...] [arm|x86|arm64|x86_64] [eng|userdebug|user] + Sets up the build environment for building unbundled apps (APKs). +- banchan: banchan [ ...] [arm|x86|arm64|x86_64] [eng|userdebug|user] + Sets up the build environment for building unbundled modules (APEXes). - croot: Changes directory to the top of the tree, or a subdirectory thereof. - m: Makes from the top of the tree. - mm: Builds and installs all of the modules in the current directory, and their @@ -791,6 +794,58 @@ function tapas() destroy_build_var_cache } +# Configures the build to build unbundled Android modules (APEXes). +# Run banchan with one or more module names (from apex{} modules). +function banchan() +{ + local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)" + local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|arm64|x86_64)$' | xargs)" + local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)" + local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|arm64|x86_64)$' | xargs)" + + if [ "$showHelp" != "" ]; then + $(gettop)/build/make/banchanHelp.sh + return + fi + + if [ $(echo $arch | wc -w) -gt 1 ]; then + echo "banchan: Error: Multiple build archs supplied: $arch" + return + fi + if [ $(echo $variant | wc -w) -gt 1 ]; then + echo "banchan: Error: Multiple build variants supplied: $variant" + return + fi + if [ -z "$apps" ]; then + echo "banchan: Error: No modules supplied" + return + fi + + local product=module_arm + case $arch in + x86) product=module_x86;; + arm64) product=module_arm64;; + x86_64) product=module_x86_64;; + esac + if [ -z "$variant" ]; then + variant=eng + fi + + export TARGET_PRODUCT=$product + export TARGET_BUILD_VARIANT=$variant + export TARGET_BUILD_DENSITY=alldpi + export TARGET_BUILD_TYPE=release + + # This setup currently uses TARGET_BUILD_APPS just like tapas, but the use + # case is different and it may diverge in the future. + export TARGET_BUILD_APPS=$apps + + build_build_var_cache + set_stuff_for_environment + printconfig + destroy_build_var_cache +} + function gettop { local TOPFILE=build/make/core/envsetup.mk