Merge "Allowlist fake_device_config in order to build some java_aconfig_library for host." into main
This commit is contained in:
commit
281288177e
3 changed files with 38 additions and 0 deletions
|
@ -99,6 +99,7 @@ type bazelJavaAconfigLibraryAttributes struct {
|
|||
Aconfig_declarations bazel.LabelAttribute
|
||||
Test *bool
|
||||
Sdk_version *string
|
||||
Libs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) Bp2build(ctx android.Bp2buildMutatorContext, module *java.GeneratedJavaLibraryModule) {
|
||||
|
@ -118,10 +119,28 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) Bp2build(ctx android.B
|
|||
// modules in framework/base use core_platform which is not supported by bazel yet.
|
||||
// TODO(b/302148527): change soong to default to system_current as well.
|
||||
sdkVersion := "system_current"
|
||||
|
||||
var libs bazel.LabelListAttribute
|
||||
archVariantProps := module.GetArchVariantProperties(ctx, &java.CommonProperties{})
|
||||
for axis, configToProps := range archVariantProps {
|
||||
for config, p := range configToProps {
|
||||
if archProps, ok := p.(*java.CommonProperties); ok {
|
||||
var libLabels []bazel.Label
|
||||
for _, d := range archProps.Libs {
|
||||
neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
|
||||
neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
|
||||
libLabels = append(libLabels, neverlinkLabel)
|
||||
}
|
||||
libs.SetSelectValue(axis, config, (bazel.MakeLabelList(libLabels)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attrs := bazelJavaAconfigLibraryAttributes{
|
||||
Aconfig_declarations: *bazel.MakeLabelAttribute(android.BazelLabelForModuleDepSingle(ctx, callbacks.properties.Aconfig_declarations).Label),
|
||||
Test: callbacks.properties.Test,
|
||||
Sdk_version: &sdkVersion,
|
||||
Libs: libs,
|
||||
}
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "java_aconfig_library",
|
||||
|
|
|
@ -1007,6 +1007,8 @@ var (
|
|||
"libservice-connectivity",
|
||||
|
||||
"mainline_modules_sdks_test",
|
||||
|
||||
"fake_device_config",
|
||||
}
|
||||
|
||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||
|
|
|
@ -147,9 +147,15 @@ func TestJavaAconfigLibrary(t *testing.T) {
|
|||
],
|
||||
package: "com.android.foo",
|
||||
}
|
||||
java_library {
|
||||
name: "foo_java_library",
|
||||
srcs: ["foo.java"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
java_aconfig_library {
|
||||
name: "foo",
|
||||
aconfig_declarations: "foo_aconfig_declarations",
|
||||
libs: ["foo_java_library"],
|
||||
test: true,
|
||||
}
|
||||
`
|
||||
|
@ -162,11 +168,22 @@ func TestJavaAconfigLibrary(t *testing.T) {
|
|||
"package": `"com.android.foo"`,
|
||||
},
|
||||
),
|
||||
MakeBazelTargetNoRestrictions(
|
||||
"java_library",
|
||||
"foo_java_library",
|
||||
AttrNameToString{
|
||||
"srcs": `["foo.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
|
||||
},
|
||||
),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "foo_java_library"),
|
||||
MakeBazelTargetNoRestrictions(
|
||||
"java_aconfig_library",
|
||||
"foo",
|
||||
AttrNameToString{
|
||||
"aconfig_declarations": `":foo_aconfig_declarations"`,
|
||||
"libs": `[":foo_java_library-neverlink"]`,
|
||||
"test": `True`,
|
||||
"sdk_version": `"system_current"`,
|
||||
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
|
||||
|
|
Loading…
Reference in a new issue