Allowlist fake_device_config in order to build some java_aconfig_library for host.
Bug: 305255550 Test: CI Change-Id: Ic073a5fef0acccb7fcbbacb93c9f42ea80e8e154
This commit is contained in:
@@ -99,6 +99,7 @@ type bazelJavaAconfigLibraryAttributes struct {
|
|||||||
Aconfig_declarations bazel.LabelAttribute
|
Aconfig_declarations bazel.LabelAttribute
|
||||||
Test *bool
|
Test *bool
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
Libs bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) Bp2build(ctx android.Bp2buildMutatorContext, module *java.GeneratedJavaLibraryModule) {
|
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.
|
// 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.
|
// TODO(b/302148527): change soong to default to system_current as well.
|
||||||
sdkVersion := "system_current"
|
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{
|
attrs := bazelJavaAconfigLibraryAttributes{
|
||||||
Aconfig_declarations: *bazel.MakeLabelAttribute(android.BazelLabelForModuleDepSingle(ctx, callbacks.properties.Aconfig_declarations).Label),
|
Aconfig_declarations: *bazel.MakeLabelAttribute(android.BazelLabelForModuleDepSingle(ctx, callbacks.properties.Aconfig_declarations).Label),
|
||||||
Test: callbacks.properties.Test,
|
Test: callbacks.properties.Test,
|
||||||
Sdk_version: &sdkVersion,
|
Sdk_version: &sdkVersion,
|
||||||
|
Libs: libs,
|
||||||
}
|
}
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "java_aconfig_library",
|
Rule_class: "java_aconfig_library",
|
||||||
|
@@ -1009,6 +1009,8 @@ var (
|
|||||||
"libservice-connectivity",
|
"libservice-connectivity",
|
||||||
|
|
||||||
"mainline_modules_sdks_test",
|
"mainline_modules_sdks_test",
|
||||||
|
|
||||||
|
"fake_device_config",
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
|
@@ -147,9 +147,15 @@ func TestJavaAconfigLibrary(t *testing.T) {
|
|||||||
],
|
],
|
||||||
package: "com.android.foo",
|
package: "com.android.foo",
|
||||||
}
|
}
|
||||||
|
java_library {
|
||||||
|
name: "foo_java_library",
|
||||||
|
srcs: ["foo.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
}
|
||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
aconfig_declarations: "foo_aconfig_declarations",
|
aconfig_declarations: "foo_aconfig_declarations",
|
||||||
|
libs: ["foo_java_library"],
|
||||||
test: true,
|
test: true,
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@@ -162,11 +168,22 @@ func TestJavaAconfigLibrary(t *testing.T) {
|
|||||||
"package": `"com.android.foo"`,
|
"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(
|
MakeBazelTargetNoRestrictions(
|
||||||
"java_aconfig_library",
|
"java_aconfig_library",
|
||||||
"foo",
|
"foo",
|
||||||
AttrNameToString{
|
AttrNameToString{
|
||||||
"aconfig_declarations": `":foo_aconfig_declarations"`,
|
"aconfig_declarations": `":foo_aconfig_declarations"`,
|
||||||
|
"libs": `[":foo_java_library-neverlink"]`,
|
||||||
"test": `True`,
|
"test": `True`,
|
||||||
"sdk_version": `"system_current"`,
|
"sdk_version": `"system_current"`,
|
||||||
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
|
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
|
||||||
|
Reference in New Issue
Block a user