diff options
author | 2023-10-13 18:19:48 +0000 | |
---|---|---|
committer | 2023-10-13 20:50:56 +0000 | |
commit | 873ad35f8772936b7179660477f3378f17735fd3 (patch) | |
tree | 544034a5168edf651ea87b3ed7c8943527d7d2ec | |
parent | a51d0d7d5c34b9af4b6bc121fe422e2567d409fc (diff) |
Allowlist fake_device_config in order to build some java_aconfig_library for host.
Bug: 305255550
Test: CI
Change-Id: Ic073a5fef0acccb7fcbbacb93c9f42ea80e8e154
-rw-r--r-- | aconfig/java_aconfig_library.go | 19 | ||||
-rw-r--r-- | android/allowlists/allowlists.go | 2 | ||||
-rw-r--r-- | bp2build/aconfig_conversion_test.go | 17 |
3 files changed, 38 insertions, 0 deletions
diff --git a/aconfig/java_aconfig_library.go b/aconfig/java_aconfig_library.go index 79573c787..f7f8db85d 100644 --- a/aconfig/java_aconfig_library.go +++ b/aconfig/java_aconfig_library.go @@ -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", diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go index cc428e934..31aff76c5 100644 --- a/android/allowlists/allowlists.go +++ b/android/allowlists/allowlists.go @@ -1009,6 +1009,8 @@ var ( "libservice-connectivity", "mainline_modules_sdks_test", + + "fake_device_config", } Bp2buildModuleTypeAlwaysConvertList = []string{ diff --git a/bp2build/aconfig_conversion_test.go b/bp2build/aconfig_conversion_test.go index be9a33db1..ca41680a6 100644 --- a/bp2build/aconfig_conversion_test.go +++ b/bp2build/aconfig_conversion_test.go @@ -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, } ` @@ -163,10 +169,21 @@ func TestJavaAconfigLibrary(t *testing.T) { }, ), 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"]`, |