Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78046151 authored by Yu Liu's avatar Yu Liu Committed by Automerger Merge Worker
Browse files

Merge "Allowlist fake_device_config in order to build some...

Merge "Allowlist fake_device_config in order to build some java_aconfig_library for host." into main am: 28128817 am: de1e9982

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2788313



Change-Id: I3eb76bc9c5e1b72de98729d79dc0b3c2ccff9c2e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4988cba2 de1e9982
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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",
+2 −0
Original line number Diff line number Diff line
@@ -1007,6 +1007,8 @@ var (
		"libservice-connectivity",

		"mainline_modules_sdks_test",

		"fake_device_config",
	}

	Bp2buildModuleTypeAlwaysConvertList = []string{
+17 −0
Original line number Diff line number Diff line
@@ -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"]`,