Handle arch/cpu variants in mixed builds
Test: mixed_libc.sh
Change-Id: Ib5084060199b8e1a5955bd51bc3fd793bb83a1eb
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 3d6babc..d851a98 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -50,8 +50,8 @@
// Portion of cquery map key to describe target configuration.
type configKey struct {
- archType ArchType
- osType OsType
+ arch string
+ osType OsType
}
// Map key to describe bazel cquery requests.
@@ -862,7 +862,7 @@
}
func getConfigString(key cqueryKey) string {
- arch := key.configKey.archType.Name
+ arch := key.configKey.arch
if len(arch) == 0 || arch == "common" {
// Use host platform, which is currently hardcoded to be x86_64.
arch = "x86_64"
@@ -876,5 +876,9 @@
}
func GetConfigKey(ctx ModuleContext) configKey {
- return configKey{archType: ctx.Arch().ArchType, osType: ctx.Os()}
+ return configKey{
+ // use string because Arch is not a valid key in go
+ arch: ctx.Arch().String(),
+ osType: ctx.Os(),
+ }
}
diff --git a/android/bazel_handler_test.go b/android/bazel_handler_test.go
index ad5b63b..e5cff90 100644
--- a/android/bazel_handler_test.go
+++ b/android/bazel_handler_test.go
@@ -9,9 +9,9 @@
func TestRequestResultsAfterInvokeBazel(t *testing.T) {
label := "//foo:bar"
- cfg := configKey{Arm64, Android}
+ cfg := configKey{"arm64_armv8-a", Android}
bazelContext, _ := testBazelContext(t, map[bazelCommand]string{
- bazelCommand{command: "cquery", expression: "deps(@soong_injection//mixed_builds:buildroot, 2)"}: `//foo:bar|arm64|android>>out/foo/bar.txt`,
+ bazelCommand{command: "cquery", expression: "deps(@soong_injection//mixed_builds:buildroot, 2)"}: `//foo:bar|arm64_armv8-a|android>>out/foo/bar.txt`,
})
g, ok := bazelContext.GetOutputFiles(label, cfg)
if ok {
diff --git a/android/filegroup.go b/android/filegroup.go
index d2ff97d..50356d1 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -119,12 +119,12 @@
return
}
- archVariant := ctx.Arch().ArchType
+ archVariant := ctx.Arch().String()
osVariant := ctx.Os()
if len(fg.Srcs()) == 1 && fg.Srcs()[0].Base() == fg.Name() {
// This will be a regular file target, not filegroup, in Bazel.
// See FilegroupBp2Build for more information.
- archVariant = Common
+ archVariant = Common.String()
osVariant = CommonOS
}
diff --git a/tests/lib.sh b/tests/lib.sh
index e6074f8..55f9ab4 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -86,6 +86,7 @@
symlink_directory prebuilts/go
symlink_directory prebuilts/build-tools
+ symlink_directory prebuilts/clang/host
symlink_directory external/go-cmp
symlink_directory external/golang-protobuf