Merge "Handle arch/cpu variants in mixed builds" am: 9b0af33cc8

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2033126

Change-Id: I8414b4143d9d75b0ce7280f023cb14997a9954ca
This commit is contained in:
Treehugger Robot
2022-03-22 16:12:12 +00:00
committed by Automerger Merge Worker
4 changed files with 13 additions and 8 deletions

View File

@@ -50,8 +50,8 @@ type cqueryRequest interface {
// 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 getCqueryId(key cqueryKey) string {
}
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 getConfigString(key cqueryKey) string {
}
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(),
}
}

View File

@@ -9,9 +9,9 @@ import (
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 {

View File

@@ -119,12 +119,12 @@ func (fg *fileGroup) maybeGenerateBazelBuildActions(ctx ModuleContext) {
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
}

View File

@@ -86,6 +86,7 @@ function create_mock_soong {
symlink_directory prebuilts/go
symlink_directory prebuilts/build-tools
symlink_directory prebuilts/clang/host
symlink_directory external/go-cmp
symlink_directory external/golang-protobuf