Don't include artifacts for host-cross targets
When building an APEX, the build system included artifacts from all
targets that are returned from ctx.MultiTargets(). This however has
became a problem as we add new host targets like linux_bionic_arm64.
When there are multiple host targets having different OSes,
ctx.MultiTargets() returns one target per a host OS. For example, when
linux_bionic_arm64 is enabled, ctx.MultiTargets() returns the following
two targets because linux_bionic != linux_glibc.
* linux_glibc_86_64
* linux_bionic_arm64
Some dependencies (like soong_zip, etc.) are not enabled for the new
host target (because they don't have to) and therefore the build fails.
Since the purpose of host APEX is to package some host tools for
testing, etc., we actually don't need the second target for APEX.
Fixing the problem by not skipping "cross host" targets which can't be
natively executed on the host machine.
Bug: 169454252
Test: HOST_CROSS_OS=linux_bionic HOST_CROSS_ARCH=arm64 m
Test: DIST_DIR=$(pwd)/out/dist \
./art/tools/dist_linux_bionic.sh com.android.support.apexer
Change-Id: Idaded56e4b4fc0195c8bbc760e4b4728016bd5b4
diff --git a/apex/apex.go b/apex/apex.go
index e8294a8..0b69111 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1499,6 +1499,12 @@
}
}
for i, target := range targets {
+ if target.HostCross {
+ // Don't include artifats for the host cross targets because there is no way
+ // for us to run those artifacts natively on host
+ continue
+ }
+
// When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies
// multilib.both
addDependenciesForNativeModules(ctx,