Handle target.bionic in bp2build.
Soong supports some hand-crafted target.<type> that match multiple os or arch types to simplify configuring for similar targets. target.bionic is used to match on both android and linux_bionic OSes for cases where they should be handled the same way. Test: build/bazel/ci/bp2build.sh Change-Id: I47b6aaf3279e4d242c4fd0e12f24117eb98e0665
This commit is contained in:
@@ -1987,6 +1987,10 @@ func (m *ModuleBase) GetArchVariantProperties(ctx ArchVariantContext, propertySe
|
|||||||
axisToProps[bazel.OsConfigurationAxis] = osToProp
|
axisToProps[bazel.OsConfigurationAxis] = osToProp
|
||||||
axisToProps[bazel.OsArchConfigurationAxis] = archOsToProp
|
axisToProps[bazel.OsArchConfigurationAxis] = archOsToProp
|
||||||
|
|
||||||
|
axisToProps[bazel.BionicConfigurationAxis] = map[string]interface{}{
|
||||||
|
"bionic": getTargetStruct(ctx, propertySet, archProperties, "Bionic"),
|
||||||
|
}
|
||||||
|
|
||||||
return axisToProps
|
return axisToProps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,6 +91,11 @@ var (
|
|||||||
conditionsDefault: ConditionsDefaultSelectKey, // The default condition of an os select map.
|
conditionsDefault: ConditionsDefaultSelectKey, // The default condition of an os select map.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platformBionicMap = map[string]string{
|
||||||
|
"bionic": "//build/bazel/platforms/os:bionic",
|
||||||
|
conditionsDefault: 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",
|
||||||
@@ -117,6 +122,7 @@ const (
|
|||||||
arch
|
arch
|
||||||
os
|
os
|
||||||
osArch
|
osArch
|
||||||
|
bionic
|
||||||
productVariables
|
productVariables
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -126,6 +132,7 @@ 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]
|
||||||
}
|
}
|
||||||
@@ -148,6 +155,10 @@ 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:
|
||||||
@@ -167,6 +178,8 @@ 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 == conditionsDefault {
|
if config == conditionsDefault {
|
||||||
return ConditionsDefaultSelectKey
|
return ConditionsDefaultSelectKey
|
||||||
@@ -186,6 +199,8 @@ 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
|
||||||
|
@@ -321,7 +321,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, productVariables:
|
case arch, os, osArch, bionic, productVariables:
|
||||||
if la.ConfigurableValues == nil {
|
if la.ConfigurableValues == nil {
|
||||||
la.ConfigurableValues = make(configurableLabels)
|
la.ConfigurableValues = make(configurableLabels)
|
||||||
}
|
}
|
||||||
@@ -337,7 +337,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, productVariables:
|
case arch, os, osArch, bionic, 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))
|
||||||
@@ -394,7 +394,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, productVariables:
|
case arch, os, osArch, bionic, productVariables:
|
||||||
if ba.ConfigurableValues == nil {
|
if ba.ConfigurableValues == nil {
|
||||||
ba.ConfigurableValues = make(configurableBools)
|
ba.ConfigurableValues = make(configurableBools)
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,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, productVariables:
|
case arch, os, osArch, bionic, productVariables:
|
||||||
if v, ok := ba.ConfigurableValues[axis][config]; ok {
|
if v, ok := ba.ConfigurableValues[axis][config]; ok {
|
||||||
return &v
|
return &v
|
||||||
} else {
|
} else {
|
||||||
@@ -509,7 +509,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, productVariables:
|
case arch, os, osArch, bionic, productVariables:
|
||||||
if lla.ConfigurableValues == nil {
|
if lla.ConfigurableValues == nil {
|
||||||
lla.ConfigurableValues = make(configurableLabelLists)
|
lla.ConfigurableValues = make(configurableLabelLists)
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,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, productVariables:
|
case arch, os, osArch, bionic, 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))
|
||||||
@@ -682,7 +682,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, productVariables:
|
case arch, os, osArch, bionic, productVariables:
|
||||||
if sla.ConfigurableValues == nil {
|
if sla.ConfigurableValues == nil {
|
||||||
sla.ConfigurableValues = make(configurableStringLists)
|
sla.ConfigurableValues = make(configurableStringLists)
|
||||||
}
|
}
|
||||||
@@ -698,7 +698,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, productVariables:
|
case arch, os, osArch, bionic, 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))
|
||||||
|
@@ -118,6 +118,7 @@ func TestCcLibrarySimple(t *testing.T) {
|
|||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"android.cpp": "",
|
"android.cpp": "",
|
||||||
|
"bionic.cpp": "",
|
||||||
"darwin.cpp": "",
|
"darwin.cpp": "",
|
||||||
// Refer to cc.headerExts for the supported header extensions in Soong.
|
// Refer to cc.headerExts for the supported header extensions in Soong.
|
||||||
"header.h": "",
|
"header.h": "",
|
||||||
@@ -164,6 +165,9 @@ cc_library {
|
|||||||
darwin: {
|
darwin: {
|
||||||
srcs: ["darwin.cpp"],
|
srcs: ["darwin.cpp"],
|
||||||
},
|
},
|
||||||
|
bionic: {
|
||||||
|
srcs: ["bionic.cpp"]
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@@ -190,6 +194,9 @@ cc_library {
|
|||||||
"//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": [],
|
"//conditions:default": [],
|
||||||
|
}) + select({
|
||||||
|
"//build/bazel/platforms/os:bionic": ["bionic.cpp"],
|
||||||
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
)`}})
|
)`}})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user