Merge "Use excludes from OS axis for OsAndInApex"
This commit is contained in:
@@ -203,6 +203,11 @@ var (
|
||||
osAndInApexMap = map[string]string{
|
||||
AndroidAndInApex: "//build/bazel/rules/apex:android-in_apex",
|
||||
AndroidAndNonApex: "//build/bazel/rules/apex:android-non_apex",
|
||||
osDarwin: "//build/bazel/platforms/os:darwin",
|
||||
osLinux: "//build/bazel/platforms/os:linux",
|
||||
osLinuxMusl: "//build/bazel/platforms/os:linux_musl",
|
||||
osLinuxBionic: "//build/bazel/platforms/os:linux_bionic",
|
||||
osWindows: "//build/bazel/platforms/os:windows",
|
||||
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
|
||||
}
|
||||
|
||||
|
@@ -843,6 +843,26 @@ func (lla *LabelListAttribute) Exclude(axis ConfigurationAxis, config string, la
|
||||
// ResolveExcludes handles excludes across the various axes, ensuring that items are removed from
|
||||
// the base value and included in default values as appropriate.
|
||||
func (lla *LabelListAttribute) ResolveExcludes() {
|
||||
// If there are OsAndInApexAxis, we need to use
|
||||
// * includes from the OS & in APEX Axis for non-Android configs for libraries that need to be
|
||||
// included in non-Android OSes
|
||||
// * excludes from the OS Axis for non-Android configs, to exclude libraries that should _not_
|
||||
// be included in the non-Android OSes
|
||||
if _, ok := lla.ConfigurableValues[OsAndInApexAxis]; ok {
|
||||
inApexLabels := lla.ConfigurableValues[OsAndInApexAxis][ConditionsDefaultConfigKey]
|
||||
for config, labels := range lla.ConfigurableValues[OsConfigurationAxis] {
|
||||
// OsAndroid has already handled its excludes.
|
||||
// We only need to copy the excludes from other arches, so if there are none, skip it.
|
||||
if config == OsAndroid || len(labels.Excludes) == 0 {
|
||||
continue
|
||||
}
|
||||
lla.ConfigurableValues[OsAndInApexAxis][config] = LabelList{
|
||||
Includes: inApexLabels.Includes,
|
||||
Excludes: labels.Excludes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for axis, configToLabels := range lla.ConfigurableValues {
|
||||
baseLabels := lla.Value.deepCopy()
|
||||
for config, val := range configToLabels {
|
||||
|
@@ -2976,6 +2976,63 @@ cc_library {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryExcludesLibsHost(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"bar.map.txt": "",
|
||||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("cc_library", "bazlib") + `
|
||||
cc_library {
|
||||
name: "quxlib",
|
||||
stubs: { symbol_file: "bar.map.txt", versions: ["current"] },
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library {
|
||||
name: "barlib",
|
||||
stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] },
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library {
|
||||
name: "foolib",
|
||||
shared_libs: ["barlib", "quxlib"],
|
||||
target: {
|
||||
host: {
|
||||
shared_libs: ["bazlib"],
|
||||
exclude_shared_libs: ["barlib"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
|
||||
"implementation_dynamic_deps": `select({
|
||||
"//build/bazel/platforms/os:darwin": [":bazlib"],
|
||||
"//build/bazel/platforms/os:linux": [":bazlib"],
|
||||
"//build/bazel/platforms/os:linux_bionic": [":bazlib"],
|
||||
"//build/bazel/platforms/os:linux_musl": [":bazlib"],
|
||||
"//build/bazel/platforms/os:windows": [":bazlib"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/platforms/os:darwin": [":quxlib"],
|
||||
"//build/bazel/platforms/os:linux": [":quxlib"],
|
||||
"//build/bazel/platforms/os:linux_bionic": [":quxlib"],
|
||||
"//build/bazel/platforms/os:linux_musl": [":quxlib"],
|
||||
"//build/bazel/platforms/os:windows": [":quxlib"],
|
||||
"//build/bazel/rules/apex:android-in_apex": [
|
||||
":barlib_stub_libs_current",
|
||||
":quxlib_stub_libs_current",
|
||||
],
|
||||
"//conditions:default": [
|
||||
":barlib",
|
||||
":quxlib",
|
||||
],
|
||||
})`,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryEscapeLdflags(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
|
@@ -90,6 +90,7 @@ type Bp2buildTestCase struct {
|
||||
}
|
||||
|
||||
func RunBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
bp2buildSetup := func(ctx *android.TestContext) {
|
||||
registerModuleTypes(ctx)
|
||||
ctx.RegisterForBazelConversion()
|
||||
@@ -98,6 +99,7 @@ func RunBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi
|
||||
}
|
||||
|
||||
func RunApiBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
apiBp2BuildSetup := func(ctx *android.TestContext) {
|
||||
registerModuleTypes(ctx)
|
||||
ctx.RegisterForApiBazelConversion()
|
||||
|
Reference in New Issue
Block a user