Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
Add new user setup command banchan for module building.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marstj committed Apr 13, 2021
1 parent 5f2d88b commit f692c75
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
25 changes: 25 additions & 0 deletions banchanHelp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# locate some directories
cd "$(dirname $0)"
SCRIPT_DIR="${PWD}"
cd ../..
TOP="${PWD}"

message='usage: banchan <module> ... [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"
55 changes: 55 additions & 0 deletions envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<App1> <App2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
Sets up the build environment for building unbundled apps (APKs).
- banchan: banchan <module1> [<module2> ...] [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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f692c75

Please sign in to comment.