Use SDK prebuilt 'aapt2' in 'apexer' in source trees without "frameworks/base".
Test: system/apex/apexer/runtests.sh on a master source tree
Test: system/apex/apexer/runtests.sh on a master-art source tree
Bug: 113373927
Bug: 112458021
Change-Id: Ie23eab3f7e4961ebbe011b1fe25ce819f99767a2
diff --git a/apex/apex.go b/apex/apex.go
index 07a53b3..41c7a97 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -81,7 +81,18 @@
func init() {
pctx.Import("android/soong/common")
pctx.HostBinToolVariable("apexer", "apexer")
- pctx.HostBinToolVariable("aapt2", "aapt2")
+ // ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
+ // projects, and hence cannot built 'aapt2'. Use the SDK prebuilt instead.
+ hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
+ pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
+ if !android.ExistentPathForSource(ctx, "frameworks/base").Valid() {
+ return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
+ } else {
+ return pctx.HostBinToolPath(ctx, tool).String()
+ }
+ })
+ }
+ hostBinToolVariableWithPrebuilt("aapt2", "prebuilts/sdk/tools", "aapt2")
pctx.HostBinToolVariable("avbtool", "avbtool")
pctx.HostBinToolVariable("e2fsdroid", "e2fsdroid")
pctx.HostBinToolVariable("merge_zips", "merge_zips")