Merge changes from topic "revert-2786699-import-sdk-version-none-WYNCDQGHTE" into main am: 8e592ad109
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2796694 Change-Id: I1e10e6c0e51430e30823274460ef6d76a802025b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -52,15 +52,13 @@ java_import {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("filegroup", "example_import-jars", AttrNameToString{
|
|
||||||
"srcs": `["import.jar"]`,
|
|
||||||
}),
|
|
||||||
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
||||||
"jars": `[":example_import-jars"]`,
|
"jars": `["import.jar"]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_import", "example_import-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"jars": `[":example_import-jars"]`,
|
"exports": `[":example_import"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -88,19 +86,17 @@ java_import {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("filegroup", "example_import-jars", AttrNameToString{
|
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
||||||
"srcs": `select({
|
"jars": `select({
|
||||||
"//build/bazel_common_rules/platforms/os:android": ["android.jar"],
|
"//build/bazel_common_rules/platforms/os:android": ["android.jar"],
|
||||||
"//build/bazel_common_rules/platforms/os:linux_glibc": ["linux.jar"],
|
"//build/bazel_common_rules/platforms/os:linux_glibc": ["linux.jar"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`,
|
})`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"jars": `[":example_import-jars"]`,
|
"exports": `[":example_import"]`,
|
||||||
}),
|
"neverlink": `True`,
|
||||||
MakeBazelTarget("java_import", "example_import-neverlink", AttrNameToString{
|
"sdk_version": `"none"`,
|
||||||
"jars": `[":example_import-jars"]`,
|
|
||||||
"neverlink": `True`,
|
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -121,15 +117,13 @@ java_import_host {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("filegroup", "example_import-jars", AttrNameToString{
|
|
||||||
"srcs": `["import.jar"]`,
|
|
||||||
}),
|
|
||||||
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
MakeBazelTarget("java_import", "example_import", AttrNameToString{
|
||||||
"jars": `[":example_import-jars"]`,
|
"jars": `["import.jar"]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_import", "example_import-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"jars": `[":example_import-jars"]`,
|
"exports": `[":example_import"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -148,15 +142,13 @@ func TestJavaImportSameNameAsJavaLibrary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("filegroup", "test_lib-jars", AttrNameToString{
|
|
||||||
"srcs": `["test.jar"]`,
|
|
||||||
}),
|
|
||||||
MakeBazelTarget("java_import", "test_lib", AttrNameToString{
|
MakeBazelTarget("java_import", "test_lib", AttrNameToString{
|
||||||
"jars": `[":test_lib-jars"]`,
|
"jars": `["test.jar"]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_import", "test_lib-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "test_lib-neverlink", AttrNameToString{
|
||||||
"jars": `[":test_lib-jars"]`,
|
"exports": `[":test_lib"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}, func(ctx android.RegistrationContext) {
|
}, func(ctx android.RegistrationContext) {
|
||||||
|
47
java/java.go
47
java/java.go
@@ -2971,10 +2971,6 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext
|
|||||||
// TODO(b/297356582): handle core_platform in bp2build
|
// TODO(b/297356582): handle core_platform in bp2build
|
||||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version core_platform")
|
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version core_platform")
|
||||||
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
|
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
|
||||||
} else if proptools.String(m.deviceProperties.Sdk_version) == "none" {
|
|
||||||
// TODO(b/297356703): handle system_modules
|
|
||||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version none")
|
|
||||||
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
||||||
@@ -3409,14 +3405,9 @@ func createLibraryTarget(ctx android.Bp2buildMutatorContext, libInfo libraryCrea
|
|||||||
return libName
|
return libName
|
||||||
}
|
}
|
||||||
|
|
||||||
type importAttributes struct {
|
type bazelJavaImportAttributes struct {
|
||||||
Jars bazel.LabelListAttribute
|
Jars bazel.LabelListAttribute
|
||||||
Exports bazel.LabelListAttribute
|
Exports bazel.LabelListAttribute
|
||||||
Neverlink *bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type filegroupAttrs struct {
|
|
||||||
Srcs bazel.LabelListAttribute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// java_import bp2Build converter.
|
// java_import bp2Build converter.
|
||||||
@@ -3432,36 +3423,28 @@ func (i *Import) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
name := android.RemoveOptionalPrebuiltPrefix(i.Name())
|
attrs := &bazelJavaImportAttributes{
|
||||||
filegroupTargetName := name + "-jars"
|
Jars: jars,
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(
|
|
||||||
bazel.BazelTargetModuleProperties{
|
|
||||||
Rule_class: "filegroup",
|
|
||||||
Bzl_load_location: "//build/bazel/rules:filegroup.bzl",
|
|
||||||
},
|
|
||||||
android.CommonAttributes{Name: filegroupTargetName},
|
|
||||||
&filegroupAttrs{
|
|
||||||
Srcs: jars,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
attrs := &importAttributes{
|
|
||||||
Jars: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + filegroupTargetName}),
|
|
||||||
}
|
}
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "java_import",
|
Rule_class: "java_import",
|
||||||
Bzl_load_location: "//build/bazel/rules/java:import.bzl",
|
Bzl_load_location: "//build/bazel/rules/java:import.bzl",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := android.RemoveOptionalPrebuiltPrefix(i.Name())
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
||||||
|
|
||||||
neverlinkAttrs := &importAttributes{
|
neverlink := true
|
||||||
Jars: attrs.Jars,
|
neverlinkAttrs := &javaLibraryAttributes{
|
||||||
Neverlink: proptools.BoolPtr(true),
|
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
||||||
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
props,
|
javaLibraryBazelTargetModuleProperties(),
|
||||||
android.CommonAttributes{Name: name + "-neverlink"},
|
android.CommonAttributes{Name: name + "-neverlink"},
|
||||||
neverlinkAttrs)
|
neverlinkAttrs)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user