Merge "bp2build: Handle target.linux"
This commit is contained in:
@@ -2005,16 +2005,37 @@ func (m *ModuleBase) GetArchVariantProperties(ctx ArchVariantContext, propertySe
|
|||||||
|
|
||||||
osToProp := ArchVariantProperties{}
|
osToProp := ArchVariantProperties{}
|
||||||
archOsToProp := ArchVariantProperties{}
|
archOsToProp := ArchVariantProperties{}
|
||||||
|
|
||||||
|
var linuxStructs, bionicStructs []reflect.Value
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
linuxStructs, ok = getTargetStructs(ctx, archProperties, "Linux")
|
||||||
|
if !ok {
|
||||||
|
linuxStructs = make([]reflect.Value, 0)
|
||||||
|
}
|
||||||
|
bionicStructs, ok = getTargetStructs(ctx, archProperties, "Bionic")
|
||||||
|
if !ok {
|
||||||
|
bionicStructs = make([]reflect.Value, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// For android, linux, ...
|
// For android, linux, ...
|
||||||
for _, os := range osTypeList {
|
for _, os := range osTypeList {
|
||||||
if os == CommonOS {
|
if os == CommonOS {
|
||||||
// It looks like this OS value is not used in Blueprint files
|
// It looks like this OS value is not used in Blueprint files
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
osStructs, ok := getTargetStructs(ctx, archProperties, os.Field)
|
osStructs := make([]reflect.Value, 0)
|
||||||
|
osSpecificStructs, ok := getTargetStructs(ctx, archProperties, os.Field)
|
||||||
if ok {
|
if ok {
|
||||||
osToProp[os.Name] = mergeStructs(ctx, osStructs, propertySet)
|
osStructs = append(osStructs, osSpecificStructs...)
|
||||||
}
|
}
|
||||||
|
if os.Linux() {
|
||||||
|
osStructs = append(osStructs, linuxStructs...)
|
||||||
|
}
|
||||||
|
if os.Bionic() {
|
||||||
|
osStructs = append(osStructs, bionicStructs...)
|
||||||
|
}
|
||||||
|
osToProp[os.Name] = mergeStructs(ctx, osStructs, propertySet)
|
||||||
|
|
||||||
// For arm, x86, ...
|
// For arm, x86, ...
|
||||||
for _, arch := range osArchTypeMap[os] {
|
for _, arch := range osArchTypeMap[os] {
|
||||||
@@ -2048,15 +2069,9 @@ func (m *ModuleBase) GetArchVariantProperties(ctx ArchVariantContext, propertySe
|
|||||||
archOsToProp[targetName] = mergeStructs(ctx, osArchStructs, propertySet)
|
archOsToProp[targetName] = mergeStructs(ctx, osArchStructs, propertySet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
axisToProps[bazel.OsConfigurationAxis] = osToProp
|
axisToProps[bazel.OsConfigurationAxis] = osToProp
|
||||||
axisToProps[bazel.OsArchConfigurationAxis] = archOsToProp
|
axisToProps[bazel.OsArchConfigurationAxis] = archOsToProp
|
||||||
|
|
||||||
bionicStructs, ok := getTargetStructs(ctx, archProperties, "Bionic")
|
|
||||||
if ok {
|
|
||||||
axisToProps[bazel.BionicConfigurationAxis] = map[string]interface{}{
|
|
||||||
"bionic": mergeStructs(ctx, bionicStructs, propertySet)}
|
|
||||||
}
|
|
||||||
|
|
||||||
return axisToProps
|
return axisToProps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -223,9 +223,6 @@ var (
|
|||||||
"libc_malloc_debug", // http://b/186824339, cc_library_static, depends on //system/libbase:libbase (http://b/186823646)
|
"libc_malloc_debug", // http://b/186824339, cc_library_static, depends on //system/libbase:libbase (http://b/186823646)
|
||||||
"libc_malloc_debug_backtrace", // http://b/186824112, cc_library_static, depends on //external/libcxxabi:libc++demangle (http://b/186823773)
|
"libc_malloc_debug_backtrace", // http://b/186824112, cc_library_static, depends on //external/libcxxabi:libc++demangle (http://b/186823773)
|
||||||
|
|
||||||
//"libcutils", // http://b/186827426, cc_library, depends on //system/core/libprocessgroup:libprocessgroup_headers (http://b/186826841)
|
|
||||||
//"libcutils_sockets", // http://b/186826853, cc_library, depends on //system/libbase:libbase (http://b/186826479)
|
|
||||||
|
|
||||||
"liblinker_debuggerd_stub", // http://b/186824327, cc_library_static, depends on //external/zlib:libz (http://b/186823782)
|
"liblinker_debuggerd_stub", // http://b/186824327, cc_library_static, depends on //external/zlib:libz (http://b/186823782)
|
||||||
// also depends on //system/libziparchive:libziparchive (http://b/186823656)
|
// also depends on //system/libziparchive:libziparchive (http://b/186823656)
|
||||||
// also depends on //system/logging/liblog:liblog (http://b/186822772)
|
// also depends on //system/logging/liblog:liblog (http://b/186822772)
|
||||||
@@ -285,24 +282,6 @@ var (
|
|||||||
"libadb_protos_static", // b/200601772: Requires cc_library proto support
|
"libadb_protos_static", // b/200601772: Requires cc_library proto support
|
||||||
"libadb_protos", // b/200601772: Requires cc_library proto support
|
"libadb_protos", // b/200601772: Requires cc_library proto support
|
||||||
"libapp_processes_protos_lite", // b/200601772: Requires cc_library proto support
|
"libapp_processes_protos_lite", // b/200601772: Requires cc_library proto support
|
||||||
|
|
||||||
"libbase", // TODO(cparsons): Breaks libandroidfw. Investigate.
|
|
||||||
|
|
||||||
// The below items depend on libbase.
|
|
||||||
"libadb_pairing_auth",
|
|
||||||
"libadb_pairing_auth_static",
|
|
||||||
"libadb_sysdeps",
|
|
||||||
"libadb_tls_connection",
|
|
||||||
"libadb_tls_connection_static",
|
|
||||||
"libadbconnection_client",
|
|
||||||
"libadbconnection_server",
|
|
||||||
"libadbd_auth",
|
|
||||||
"libadbd_fs",
|
|
||||||
"libcutils",
|
|
||||||
"libcutils_sockets",
|
|
||||||
"libdiagnose_usb",
|
|
||||||
// ---
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-module denylist of cc_library modules to only generate the static
|
// Per-module denylist of cc_library modules to only generate the static
|
||||||
|
@@ -91,11 +91,6 @@ var (
|
|||||||
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, // The default condition of an os select map.
|
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, // The default condition of an os select map.
|
||||||
}
|
}
|
||||||
|
|
||||||
platformBionicMap = map[string]string{
|
|
||||||
"bionic": "//build/bazel/platforms/os:bionic",
|
|
||||||
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, // The default condition of an os select map.
|
|
||||||
}
|
|
||||||
|
|
||||||
platformOsArchMap = map[string]string{
|
platformOsArchMap = map[string]string{
|
||||||
osArchAndroidArm: "//build/bazel/platforms/os_arch:android_arm",
|
osArchAndroidArm: "//build/bazel/platforms/os_arch:android_arm",
|
||||||
osArchAndroidArm64: "//build/bazel/platforms/os_arch:android_arm64",
|
osArchAndroidArm64: "//build/bazel/platforms/os_arch:android_arm64",
|
||||||
@@ -122,7 +117,6 @@ const (
|
|||||||
arch
|
arch
|
||||||
os
|
os
|
||||||
osArch
|
osArch
|
||||||
bionic
|
|
||||||
productVariables
|
productVariables
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -132,7 +126,6 @@ func (ct configurationType) String() string {
|
|||||||
arch: "arch",
|
arch: "arch",
|
||||||
os: "os",
|
os: "os",
|
||||||
osArch: "arch_os",
|
osArch: "arch_os",
|
||||||
bionic: "bionic",
|
|
||||||
productVariables: "product_variables",
|
productVariables: "product_variables",
|
||||||
}[ct]
|
}[ct]
|
||||||
}
|
}
|
||||||
@@ -155,10 +148,6 @@ func (ct configurationType) validateConfig(config string) {
|
|||||||
if _, ok := platformOsArchMap[config]; !ok {
|
if _, ok := platformOsArchMap[config]; !ok {
|
||||||
panic(fmt.Errorf("Unknown os+arch: %s", config))
|
panic(fmt.Errorf("Unknown os+arch: %s", config))
|
||||||
}
|
}
|
||||||
case bionic:
|
|
||||||
if _, ok := platformBionicMap[config]; !ok {
|
|
||||||
panic(fmt.Errorf("Unknown for %s: %s", ct.String(), config))
|
|
||||||
}
|
|
||||||
case productVariables:
|
case productVariables:
|
||||||
// do nothing
|
// do nothing
|
||||||
default:
|
default:
|
||||||
@@ -178,8 +167,6 @@ func (ct configurationType) SelectKey(config string) string {
|
|||||||
return platformOsMap[config]
|
return platformOsMap[config]
|
||||||
case osArch:
|
case osArch:
|
||||||
return platformOsArchMap[config]
|
return platformOsArchMap[config]
|
||||||
case bionic:
|
|
||||||
return platformBionicMap[config]
|
|
||||||
case productVariables:
|
case productVariables:
|
||||||
if config == ConditionsDefaultConfigKey {
|
if config == ConditionsDefaultConfigKey {
|
||||||
return ConditionsDefaultSelectKey
|
return ConditionsDefaultSelectKey
|
||||||
@@ -199,8 +186,6 @@ var (
|
|||||||
OsConfigurationAxis = ConfigurationAxis{configurationType: os}
|
OsConfigurationAxis = ConfigurationAxis{configurationType: os}
|
||||||
// An axis for arch+os-specific configurations
|
// An axis for arch+os-specific configurations
|
||||||
OsArchConfigurationAxis = ConfigurationAxis{configurationType: osArch}
|
OsArchConfigurationAxis = ConfigurationAxis{configurationType: osArch}
|
||||||
// An axis for bionic os-specific configurations
|
|
||||||
BionicConfigurationAxis = ConfigurationAxis{configurationType: bionic}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProductVariableConfigurationAxis returns an axis for the given product variable
|
// ProductVariableConfigurationAxis returns an axis for the given product variable
|
||||||
|
@@ -264,7 +264,7 @@ func (la *LabelAttribute) SetSelectValue(axis ConfigurationAxis, config string,
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
la.Value = &value
|
la.Value = &value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
if la.ConfigurableValues == nil {
|
if la.ConfigurableValues == nil {
|
||||||
la.ConfigurableValues = make(configurableLabels)
|
la.ConfigurableValues = make(configurableLabels)
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ func (la *LabelAttribute) SelectValue(axis ConfigurationAxis, config string) Lab
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
return *la.Value
|
return *la.Value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
return *la.ConfigurableValues[axis][config]
|
return *la.ConfigurableValues[axis][config]
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
||||||
@@ -337,7 +337,7 @@ func (ba *BoolAttribute) SetSelectValue(axis ConfigurationAxis, config string, v
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
ba.Value = value
|
ba.Value = value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
if ba.ConfigurableValues == nil {
|
if ba.ConfigurableValues == nil {
|
||||||
ba.ConfigurableValues = make(configurableBools)
|
ba.ConfigurableValues = make(configurableBools)
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ func (ba BoolAttribute) SelectValue(axis ConfigurationAxis, config string) *bool
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
return ba.Value
|
return ba.Value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
if v, ok := ba.ConfigurableValues[axis][config]; ok {
|
if v, ok := ba.ConfigurableValues[axis][config]; ok {
|
||||||
return &v
|
return &v
|
||||||
} else {
|
} else {
|
||||||
@@ -459,7 +459,7 @@ func (lla *LabelListAttribute) SetSelectValue(axis ConfigurationAxis, config str
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
lla.Value = list
|
lla.Value = list
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
if lla.ConfigurableValues == nil {
|
if lla.ConfigurableValues == nil {
|
||||||
lla.ConfigurableValues = make(configurableLabelLists)
|
lla.ConfigurableValues = make(configurableLabelLists)
|
||||||
}
|
}
|
||||||
@@ -475,7 +475,7 @@ func (lla *LabelListAttribute) SelectValue(axis ConfigurationAxis, config string
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
return lla.Value
|
return lla.Value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
return lla.ConfigurableValues[axis][config]
|
return lla.ConfigurableValues[axis][config]
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
||||||
@@ -773,7 +773,7 @@ func (sla *StringListAttribute) SetSelectValue(axis ConfigurationAxis, config st
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
sla.Value = list
|
sla.Value = list
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
if sla.ConfigurableValues == nil {
|
if sla.ConfigurableValues == nil {
|
||||||
sla.ConfigurableValues = make(configurableStringLists)
|
sla.ConfigurableValues = make(configurableStringLists)
|
||||||
}
|
}
|
||||||
@@ -789,7 +789,7 @@ func (sla *StringListAttribute) SelectValue(axis ConfigurationAxis, config strin
|
|||||||
switch axis.configurationType {
|
switch axis.configurationType {
|
||||||
case noConfig:
|
case noConfig:
|
||||||
return sla.Value
|
return sla.Value
|
||||||
case arch, os, osArch, bionic, productVariables:
|
case arch, os, osArch, productVariables:
|
||||||
return sla.ConfigurableValues[axis][config]
|
return sla.ConfigurableValues[axis][config]
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
|
||||||
|
@@ -131,12 +131,13 @@ cc_library {
|
|||||||
"//build/bazel/platforms/arch:x86_64": ["x86_64.cpp"],
|
"//build/bazel/platforms/arch:x86_64": ["x86_64.cpp"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}) + select({
|
}) + select({
|
||||||
"//build/bazel/platforms/os:android": ["android.cpp"],
|
"//build/bazel/platforms/os:android": [
|
||||||
|
"android.cpp",
|
||||||
|
"bionic.cpp",
|
||||||
|
],
|
||||||
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
|
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
|
||||||
"//build/bazel/platforms/os:linux": ["linux.cpp"],
|
"//build/bazel/platforms/os:linux": ["linux.cpp"],
|
||||||
"//conditions:default": [],
|
"//build/bazel/platforms/os:linux_bionic": ["bionic.cpp"],
|
||||||
}) + select({
|
|
||||||
"//build/bazel/platforms/os:bionic": ["bionic.cpp"],
|
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
)`}})
|
)`}})
|
||||||
@@ -1571,3 +1572,68 @@ cc_library {
|
|||||||
)`},
|
)`},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryOsSelects(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
|
description: "cc_library - selects for all os targets",
|
||||||
|
moduleTypeUnderTest: "cc_library",
|
||||||
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
|
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||||
|
filesystem: map[string]string{},
|
||||||
|
blueprint: soongCcLibraryPreamble + `
|
||||||
|
cc_library_headers { name: "some-headers" }
|
||||||
|
cc_library {
|
||||||
|
name: "foo-lib",
|
||||||
|
srcs: ["base.cpp"],
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
srcs: ["android.cpp"],
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
srcs: ["linux.cpp"],
|
||||||
|
},
|
||||||
|
linux_glibc: {
|
||||||
|
srcs: ["linux_glibc.cpp"],
|
||||||
|
},
|
||||||
|
darwin: {
|
||||||
|
srcs: ["darwin.cpp"],
|
||||||
|
},
|
||||||
|
bionic: {
|
||||||
|
srcs: ["bionic.cpp"],
|
||||||
|
},
|
||||||
|
linux_musl: {
|
||||||
|
srcs: ["linux_musl.cpp"],
|
||||||
|
},
|
||||||
|
windows: {
|
||||||
|
srcs: ["windows.cpp"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include_build_directory: false,
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`cc_library(
|
||||||
|
name = "foo-lib",
|
||||||
|
srcs = ["base.cpp"] + select({
|
||||||
|
"//build/bazel/platforms/os:android": [
|
||||||
|
"android.cpp",
|
||||||
|
"bionic.cpp",
|
||||||
|
"linux.cpp",
|
||||||
|
],
|
||||||
|
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
|
||||||
|
"//build/bazel/platforms/os:linux": [
|
||||||
|
"linux.cpp",
|
||||||
|
"linux_glibc.cpp",
|
||||||
|
],
|
||||||
|
"//build/bazel/platforms/os:linux_bionic": [
|
||||||
|
"bionic.cpp",
|
||||||
|
"linux.cpp",
|
||||||
|
],
|
||||||
|
"//build/bazel/platforms/os:linux_musl": [
|
||||||
|
"linux.cpp",
|
||||||
|
"linux_musl.cpp",
|
||||||
|
],
|
||||||
|
"//build/bazel/platforms/os:windows": ["windows.cpp"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
|
)`}})
|
||||||
|
}
|
||||||
|
@@ -1382,7 +1382,8 @@ cc_library_static {
|
|||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "target_bionic",
|
name = "target_bionic",
|
||||||
system_dynamic_deps = select({
|
system_dynamic_deps = select({
|
||||||
"//build/bazel/platforms/os:bionic": [":libc"],
|
"//build/bazel/platforms/os:android": [":libc"],
|
||||||
|
"//build/bazel/platforms/os:linux_bionic": [":libc"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
)`},
|
)`},
|
||||||
|
Reference in New Issue
Block a user