Bp2build support for sdk_version and java_version.
This CL adds java_version and sdk_version support to bp2build converters for - java library - java binary - android library - android binary - android library import Although java import doesn't support java_version and sdk_version, the neverlink java_library wrapper around a java_import must specify a sdk_version when targetting a device. "none" is used by convention. Change-Id: I22a69dea2e351858368df69ed6a703b568d613ea Bug: 215230098 Test: Presubmits
This commit is contained in:
@@ -406,8 +406,6 @@ var (
|
|||||||
// this BUILD file is globbed by //external/icu/icu4c/source:icu4c_test_data's "data/**/*".
|
// this BUILD file is globbed by //external/icu/icu4c/source:icu4c_test_data's "data/**/*".
|
||||||
"external/icu/icu4c/source/data/unidata/norm2":/* recursive = */ false,
|
"external/icu/icu4c/source/data/unidata/norm2":/* recursive = */ false,
|
||||||
|
|
||||||
"frameworks/ex/common":/* recursive = */ true,
|
|
||||||
|
|
||||||
// Building manually due to b/179889880: resource files cross package boundary
|
// Building manually due to b/179889880: resource files cross package boundary
|
||||||
"packages/apps/Music":/* recursive = */ true,
|
"packages/apps/Music":/* recursive = */ true,
|
||||||
|
|
||||||
@@ -687,7 +685,6 @@ var (
|
|||||||
"libcodec2_soft_common",
|
"libcodec2_soft_common",
|
||||||
|
|
||||||
// kotlin srcs in java libs
|
// kotlin srcs in java libs
|
||||||
"CtsPkgInstallerConstants",
|
|
||||||
"kotlinx_atomicfu",
|
"kotlinx_atomicfu",
|
||||||
|
|
||||||
// kotlin srcs in java binary
|
// kotlin srcs in java binary
|
||||||
@@ -700,6 +697,9 @@ var (
|
|||||||
//kotlin srcs in android_binary
|
//kotlin srcs in android_binary
|
||||||
"MusicKotlin",
|
"MusicKotlin",
|
||||||
|
|
||||||
|
// java_library with prebuilt sdk_version
|
||||||
|
"android-common",
|
||||||
|
|
||||||
// checked in current.txt for merged_txts
|
// checked in current.txt for merged_txts
|
||||||
"non-updatable-current.txt",
|
"non-updatable-current.txt",
|
||||||
"non-updatable-system-current.txt",
|
"non-updatable-system-current.txt",
|
||||||
@@ -722,7 +722,6 @@ var (
|
|||||||
|
|
||||||
// min_sdk_version in android_app
|
// min_sdk_version in android_app
|
||||||
"CtsShimUpgrade",
|
"CtsShimUpgrade",
|
||||||
"fake-framework",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
@@ -776,7 +775,8 @@ var (
|
|||||||
"tjbench", // TODO(b/240563612): Stem property
|
"tjbench", // TODO(b/240563612): Stem property
|
||||||
|
|
||||||
// java bugs
|
// java bugs
|
||||||
"libbase_ndk", // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases)
|
"libbase_ndk", // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases)
|
||||||
|
"bouncycastle", // TODO(b/274474005): Need support for custom system_modules.
|
||||||
|
|
||||||
// python protos
|
// python protos
|
||||||
"libprotobuf-python", // Has a handcrafted alternative
|
"libprotobuf-python", // Has a handcrafted alternative
|
||||||
@@ -843,7 +843,6 @@ var (
|
|||||||
"libgmock_ndk", // depends on unconverted modules: libgtest_ndk_c++
|
"libgmock_ndk", // depends on unconverted modules: libgtest_ndk_c++
|
||||||
"libnativehelper_lazy_mts_jni", "libnativehelper_mts_jni", // depends on unconverted modules: libnativetesthelper_jni, libgmock_ndk
|
"libnativehelper_lazy_mts_jni", "libnativehelper_mts_jni", // depends on unconverted modules: libnativetesthelper_jni, libgmock_ndk
|
||||||
"libnativetesthelper_jni", // depends on unconverted modules: libgtest_ndk_c++
|
"libnativetesthelper_jni", // depends on unconverted modules: libgtest_ndk_c++
|
||||||
"libprotobuf-java-nano", // b/220869005, depends on non-public_current SDK
|
|
||||||
"libstatslog", // depends on unconverted modules: libstatspull, statsd-aidl-ndk
|
"libstatslog", // depends on unconverted modules: libstatspull, statsd-aidl-ndk
|
||||||
"libstatslog_art", // depends on unconverted modules: statslog_art.cpp, statslog_art.h
|
"libstatslog_art", // depends on unconverted modules: statslog_art.cpp, statslog_art.h
|
||||||
"linker_reloc_bench_main", // depends on unconverted modules: liblinker_reloc_bench_*
|
"linker_reloc_bench_main", // depends on unconverted modules: liblinker_reloc_bench_*
|
||||||
@@ -1393,6 +1392,16 @@ var (
|
|||||||
|
|
||||||
// TODO(b/266459895): depends on libunwindstack
|
// TODO(b/266459895): depends on libunwindstack
|
||||||
"libutils_test",
|
"libutils_test",
|
||||||
|
|
||||||
|
// TODO(b/274805756): Support core_platform and current java APIs
|
||||||
|
"fake-framework",
|
||||||
|
|
||||||
|
// TODO(b/277616982): These modules depend on private java APIs, but maybe they don't need to.
|
||||||
|
"StreamingProtoTest",
|
||||||
|
"textclassifierprotoslite",
|
||||||
|
"styleprotoslite",
|
||||||
|
"CtsPkgInstallerConstants",
|
||||||
|
"guava-android-testlib",
|
||||||
}
|
}
|
||||||
|
|
||||||
MixedBuildsDisabledList = []string{
|
MixedBuildsDisabledList = []string{
|
||||||
|
@@ -66,9 +66,12 @@ android_library {
|
|||||||
"resource_files": `["res/res.png"]`,
|
"resource_files": `["res/res.png"]`,
|
||||||
"deps": `[":static_lib_dep"]`,
|
"deps": `[":static_lib_dep"]`,
|
||||||
"exports": `[":static_lib_dep"]`,
|
"exports": `[":static_lib_dep"]`,
|
||||||
"javacopts": `["-source 1.7 -target 1.7"]`,
|
"java_version": `"7"`,
|
||||||
}),
|
}),
|
||||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||||
|
"android_library",
|
||||||
|
"TestLib",
|
||||||
|
AttrNameToString{"java_version": `"7"`}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@ android_app {
|
|||||||
"srcs": `["app.java"]`,
|
"srcs": `["app.java"]`,
|
||||||
"manifest": `"AndroidManifest.xml"`,
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
"resource_files": `["res/res.png"]`,
|
"resource_files": `["res/res.png"]`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,8 @@ android_app {
|
|||||||
]`,
|
]`,
|
||||||
"custom_package": `"com.google"`,
|
"custom_package": `"com.google"`,
|
||||||
"deps": `[":static_lib_dep"]`,
|
"deps": `[":static_lib_dep"]`,
|
||||||
"javacopts": `["-source 1.7 -target 1.7"]`,
|
"java_version": `"7"`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
"certificate_name": `"foocert"`,
|
"certificate_name": `"foocert"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
@@ -131,6 +133,7 @@ android_app {
|
|||||||
})`,
|
})`,
|
||||||
"manifest": `"AndroidManifest.xml"`,
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
"resource_files": `["res/res.png"]`,
|
"resource_files": `["res/res.png"]`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -365,6 +368,7 @@ android_app {
|
|||||||
"manifest_values": `{
|
"manifest_values": `{
|
||||||
"minSdkVersion": "24",
|
"minSdkVersion": "24",
|
||||||
}`,
|
}`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -388,6 +392,7 @@ android_app {
|
|||||||
"manifest_values": `{
|
"manifest_values": `{
|
||||||
"minSdkVersion": "30",
|
"minSdkVersion": "30",
|
||||||
}`,
|
}`,
|
||||||
|
"sdk_version": `"30"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@@ -57,24 +57,24 @@ func TestJavaBinaryHost(t *testing.T) {
|
|||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("java_library", "java-binary-host-1_lib", AttrNameToString{
|
MakeBazelTarget("java_library", "java-binary-host-1_lib", AttrNameToString{
|
||||||
"srcs": `["a.java"]`,
|
"srcs": `["a.java"]`,
|
||||||
"deps": `["//other:jni-lib-1"]`,
|
"deps": `["//other:jni-lib-1"]`,
|
||||||
"javacopts": `[
|
"java_version": `"8"`,
|
||||||
"-Xdoclint:all/protected",
|
"javacopts": `["-Xdoclint:all/protected"]`,
|
||||||
"-source 1.8 -target 1.8",
|
|
||||||
]`,
|
|
||||||
"target_compatible_with": `select({
|
"target_compatible_with": `select({
|
||||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`}),
|
})`,
|
||||||
|
}),
|
||||||
MakeBazelTarget("java_binary", "java-binary-host-1", AttrNameToString{
|
MakeBazelTarget("java_binary", "java-binary-host-1", AttrNameToString{
|
||||||
"main_class": `"com.android.test.MainClass"`,
|
"main_class": `"com.android.test.MainClass"`,
|
||||||
"jvm_flags": `["-Djava.library.path=$${RUNPATH}other"]`,
|
"jvm_flags": `["-Djava.library.path=$${RUNPATH}other"]`,
|
||||||
"runtime_deps": `[":java-binary-host-1_lib"]`,
|
|
||||||
"target_compatible_with": `select({
|
"target_compatible_with": `select({
|
||||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`}),
|
})`,
|
||||||
|
"runtime_deps": `[":java-binary-host-1_lib"]`,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -51,9 +51,11 @@ java_library {
|
|||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("java_host_for_device", "java-lib-1", AttrNameToString{
|
MakeBazelTarget("java_host_for_device", "java-lib-1", AttrNameToString{
|
||||||
"deps": `[":java-lib-2"]`,
|
"exports": `[":java-lib-2"]`,
|
||||||
|
}),
|
||||||
|
MakeNeverlinkDuplicateTargetWithAttrs("java_library", "java-lib-1", AttrNameToString{
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
|
||||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||||
"srcs": `["b.java"]`,
|
"srcs": `["b.java"]`,
|
||||||
}),
|
}),
|
||||||
|
@@ -49,8 +49,9 @@ java_import {
|
|||||||
"jars": `["import.jar"]`,
|
"jars": `["import.jar"]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"exports": `[":example_import"]`,
|
"exports": `[":example_import"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -86,8 +87,9 @@ java_import {
|
|||||||
})`,
|
})`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"exports": `[":example_import"]`,
|
"exports": `[":example_import"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
@@ -112,8 +114,9 @@ java_import_host {
|
|||||||
"jars": `["import.jar"]`,
|
"jars": `["import.jar"]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
MakeBazelTarget("java_library", "example_import-neverlink", AttrNameToString{
|
||||||
"exports": `[":example_import"]`,
|
"exports": `[":example_import"]`,
|
||||||
"neverlink": `True`,
|
"neverlink": `True`,
|
||||||
|
"sdk_version": `"none"`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@@ -172,10 +172,13 @@ func TestJavaLibraryJavaVersion(t *testing.T) {
|
|||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||||
"srcs": `["a.java"]`,
|
"srcs": `["a.java"]`,
|
||||||
"javacopts": `["-source 11 -target 11"]`,
|
"java_version": `"11"`,
|
||||||
}),
|
}),
|
||||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||||
|
"java_library",
|
||||||
|
"java-lib-1",
|
||||||
|
AttrNameToString{"java_version": `"11"`}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -63,8 +63,8 @@ java_library_host {
|
|||||||
})`,
|
})`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "java-lib-host-2", AttrNameToString{
|
MakeBazelTarget("java_library", "java-lib-host-2", AttrNameToString{
|
||||||
"javacopts": `["-source 1.9 -target 1.9"]`,
|
"java_version": `"9"`,
|
||||||
"srcs": `["c.java"]`,
|
"srcs": `["c.java"]`,
|
||||||
"target_compatible_with": `select({
|
"target_compatible_with": `select({
|
||||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -77,6 +77,7 @@ java_library_host {
|
|||||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`,
|
})`,
|
||||||
|
"java_version": `"9"`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@@ -67,7 +67,7 @@ java_library {
|
|||||||
"a.java",
|
"a.java",
|
||||||
"b.java",
|
"b.java",
|
||||||
]`,
|
]`,
|
||||||
"javacopts": `["-source 1.7 -target 1.7"]`,
|
"java_version": `"7"`,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@@ -114,13 +114,17 @@ func TestJavaProtoDefault(t *testing.T) {
|
|||||||
"java_lite_proto_library",
|
"java_lite_proto_library",
|
||||||
"java-protos_java_proto_lite",
|
"java-protos_java_proto_lite",
|
||||||
AttrNameToString{
|
AttrNameToString{
|
||||||
"deps": `[":java-protos_proto"]`,
|
"deps": `[":java-protos_proto"]`,
|
||||||
|
"java_version": `"7"`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||||
"exports": `[":java-protos_java_proto_lite"]`,
|
"exports": `[":java-protos_java_proto_lite"]`,
|
||||||
"javacopts": `["-source 1.7 -target 1.7"]`,
|
"java_version": `"7"`,
|
||||||
}),
|
}),
|
||||||
MakeNeverlinkDuplicateTarget("java_library", "java-protos"),
|
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||||
|
"java_library",
|
||||||
|
"java-protos",
|
||||||
|
AttrNameToString{"java_version": `"7"`}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -642,10 +642,14 @@ func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MakeNeverlinkDuplicateTarget(moduleType string, name string) string {
|
func MakeNeverlinkDuplicateTarget(moduleType string, name string) string {
|
||||||
return MakeBazelTarget(moduleType, name+"-neverlink", AttrNameToString{
|
return MakeNeverlinkDuplicateTargetWithAttrs(moduleType, name, AttrNameToString{})
|
||||||
"neverlink": `True`,
|
}
|
||||||
"exports": `[":` + name + `"]`,
|
|
||||||
})
|
func MakeNeverlinkDuplicateTargetWithAttrs(moduleType string, name string, extraAttrs AttrNameToString) string {
|
||||||
|
attrs := extraAttrs
|
||||||
|
attrs["neverlink"] = `True`
|
||||||
|
attrs["exports"] = `[":` + name + `"]`
|
||||||
|
return MakeBazelTarget(moduleType, name+"-neverlink", attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTargetName(targetContent string) string {
|
func getTargetName(targetContent string) string {
|
||||||
|
21
java/aar.go
21
java/aar.go
@@ -1015,9 +1015,10 @@ type bazelAndroidLibrary struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type bazelAndroidLibraryImport struct {
|
type bazelAndroidLibraryImport struct {
|
||||||
Aar bazel.Label
|
Aar bazel.Label
|
||||||
Deps bazel.LabelListAttribute
|
Deps bazel.LabelListAttribute
|
||||||
Exports bazel.LabelListAttribute
|
Exports bazel.LabelListAttribute
|
||||||
|
Sdk_version bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) *bazelAapt {
|
func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) *bazelAapt {
|
||||||
@@ -1059,9 +1060,10 @@ func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
},
|
},
|
||||||
android.CommonAttributes{Name: name},
|
android.CommonAttributes{Name: name},
|
||||||
&bazelAndroidLibraryImport{
|
&bazelAndroidLibraryImport{
|
||||||
Aar: aars.Includes[0],
|
Aar: aars.Includes[0],
|
||||||
Deps: bazel.MakeLabelListAttribute(deps),
|
Deps: bazel.MakeLabelListAttribute(deps),
|
||||||
Exports: bazel.MakeLabelListAttribute(exports),
|
Exports: bazel.MakeLabelListAttribute(exports),
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: a.properties.Sdk_version},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1073,6 +1075,9 @@ func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
javaLibraryAttributes: &javaLibraryAttributes{
|
javaLibraryAttributes: &javaLibraryAttributes{
|
||||||
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
||||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: a.properties.Sdk_version},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1119,6 +1124,10 @@ func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext)
|
|||||||
javaLibraryAttributes: &javaLibraryAttributes{
|
javaLibraryAttributes: &javaLibraryAttributes{
|
||||||
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
||||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: a.deviceProperties.Sdk_version},
|
||||||
|
Java_version: bazel.StringAttribute{Value: a.properties.Java_version},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@@ -1565,6 +1565,9 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
appAttrs.bazelAapt = &bazelAapt{Manifest: aapt.Manifest}
|
appAttrs.bazelAapt = &bazelAapt{Manifest: aapt.Manifest}
|
||||||
appAttrs.Deps = bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + ktName})
|
appAttrs.Deps = bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + ktName})
|
||||||
|
appAttrs.javaCommonAttributes = &javaCommonAttributes{
|
||||||
|
Sdk_version: commonAttrs.Sdk_version,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
|
@@ -21,6 +21,8 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
"android/soong/dexpreopt"
|
"android/soong/dexpreopt"
|
||||||
|
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeviceHostConverter struct {
|
type DeviceHostConverter struct {
|
||||||
@@ -191,7 +193,7 @@ func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type bazelDeviceHostConverterAttributes struct {
|
type bazelDeviceHostConverterAttributes struct {
|
||||||
Deps bazel.LabelListAttribute
|
Exports bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
@@ -202,13 +204,15 @@ func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorCont
|
|||||||
},
|
},
|
||||||
android.CommonAttributes{Name: d.Name()},
|
android.CommonAttributes{Name: d.Name()},
|
||||||
&bazelDeviceHostConverterAttributes{
|
&bazelDeviceHostConverterAttributes{
|
||||||
Deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, d.properties.Libs)),
|
Exports: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, d.properties.Libs)),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
neverlinkProp := true
|
|
||||||
neverLinkAttrs := &javaLibraryAttributes{
|
neverLinkAttrs := &javaLibraryAttributes{
|
||||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + d.Name()}),
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + d.Name()}),
|
||||||
Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
|
Neverlink: bazel.BoolAttribute{Value: proptools.BoolPtr(true)},
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
javaLibraryBazelTargetModuleProperties(),
|
javaLibraryBazelTargetModuleProperties(),
|
||||||
|
33
java/java.go
33
java/java.go
@@ -2738,9 +2738,11 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
|
|||||||
type javaCommonAttributes struct {
|
type javaCommonAttributes struct {
|
||||||
*javaResourcesAttributes
|
*javaResourcesAttributes
|
||||||
*kotlinAttributes
|
*kotlinAttributes
|
||||||
Srcs bazel.LabelListAttribute
|
Srcs bazel.LabelListAttribute
|
||||||
Plugins bazel.LabelListAttribute
|
Plugins bazel.LabelListAttribute
|
||||||
Javacopts bazel.StringListAttribute
|
Javacopts bazel.StringListAttribute
|
||||||
|
Sdk_version bazel.StringAttribute
|
||||||
|
Java_version bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type javaDependencyLabels struct {
|
type javaDependencyLabels struct {
|
||||||
@@ -2871,10 +2873,6 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
if m.properties.Javacflags != nil {
|
if m.properties.Javacflags != nil {
|
||||||
javacopts = append(javacopts, m.properties.Javacflags...)
|
javacopts = append(javacopts, m.properties.Javacflags...)
|
||||||
}
|
}
|
||||||
if m.properties.Java_version != nil {
|
|
||||||
javaVersion := normalizeJavaVersion(ctx, *m.properties.Java_version).String()
|
|
||||||
javacopts = append(javacopts, fmt.Sprintf("-source %s -target %s", javaVersion, javaVersion))
|
|
||||||
}
|
|
||||||
|
|
||||||
epEnabled := m.properties.Errorprone.Enabled
|
epEnabled := m.properties.Errorprone.Enabled
|
||||||
//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable
|
//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable
|
||||||
@@ -2888,7 +2886,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
Plugins: bazel.MakeLabelListAttribute(
|
Plugins: bazel.MakeLabelListAttribute(
|
||||||
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
||||||
),
|
),
|
||||||
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
||||||
|
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
||||||
}
|
}
|
||||||
|
|
||||||
for axis, configToProps := range archVariantProps {
|
for axis, configToProps := range archVariantProps {
|
||||||
@@ -2979,19 +2979,9 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
|||||||
deps := depLabels.Deps
|
deps := depLabels.Deps
|
||||||
if !commonAttrs.Srcs.IsEmpty() {
|
if !commonAttrs.Srcs.IsEmpty() {
|
||||||
deps.Append(depLabels.StaticDeps) // we should only append these if there are sources to use them
|
deps.Append(depLabels.StaticDeps) // we should only append these if there are sources to use them
|
||||||
|
|
||||||
sdkVersion := m.SdkVersion(ctx)
|
|
||||||
if sdkVersion.Kind == android.SdkPublic && sdkVersion.ApiLevel == android.FutureApiLevel {
|
|
||||||
// TODO(b/220869005) remove forced dependency on current public android.jar
|
|
||||||
deps.Add(bazel.MakeLabelAttribute("//prebuilts/sdk:public_current_android_sdk_java_import"))
|
|
||||||
} else if sdkVersion.Kind == android.SdkSystem && sdkVersion.ApiLevel == android.FutureApiLevel {
|
|
||||||
// TODO(b/215230098) remove forced dependency on current public android.jar
|
|
||||||
deps.Add(bazel.MakeLabelAttribute("//prebuilts/sdk:system_current_android_sdk_java_import"))
|
|
||||||
}
|
|
||||||
} else if !deps.IsEmpty() {
|
} else if !deps.IsEmpty() {
|
||||||
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
|
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
|
||||||
}
|
}
|
||||||
|
|
||||||
var props bazel.BazelTargetModuleProperties
|
var props bazel.BazelTargetModuleProperties
|
||||||
attrs := &javaLibraryAttributes{
|
attrs := &javaLibraryAttributes{
|
||||||
javaCommonAttributes: commonAttrs,
|
javaCommonAttributes: commonAttrs,
|
||||||
@@ -3011,6 +3001,10 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
|||||||
neverLinkAttrs := &javaLibraryAttributes{
|
neverLinkAttrs := &javaLibraryAttributes{
|
||||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||||
Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
|
Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
||||||
|
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs)
|
||||||
|
|
||||||
@@ -3150,6 +3144,9 @@ func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
neverlinkAttrs := &javaLibraryAttributes{
|
neverlinkAttrs := &javaLibraryAttributes{
|
||||||
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
Neverlink: bazel.BoolAttribute{Value: &neverlink},
|
||||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||||
|
javaCommonAttributes: &javaCommonAttributes{
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
javaLibraryBazelTargetModuleProperties(),
|
javaLibraryBazelTargetModuleProperties(),
|
||||||
|
@@ -143,7 +143,9 @@ func protoFlags(ctx android.ModuleContext, j *CommonProperties, p *android.Proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
type protoAttributes struct {
|
type protoAttributes struct {
|
||||||
Deps bazel.LabelListAttribute
|
Deps bazel.LabelListAttribute
|
||||||
|
Sdk_version bazel.StringAttribute
|
||||||
|
Java_version bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute) *bazel.Label {
|
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute) *bazel.Label {
|
||||||
@@ -175,8 +177,11 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
|
|||||||
}
|
}
|
||||||
|
|
||||||
protoLabel := bazel.Label{Label: ":" + m.Name() + "_proto"}
|
protoLabel := bazel.Label{Label: ":" + m.Name() + "_proto"}
|
||||||
var protoAttrs protoAttributes
|
protoAttrs := &protoAttributes{
|
||||||
protoAttrs.Deps.SetValue(bazel.LabelList{Includes: []bazel.Label{protoLabel}})
|
Deps: bazel.MakeSingleLabelListAttribute(protoLabel),
|
||||||
|
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
||||||
|
}
|
||||||
|
|
||||||
name := m.Name() + suffix
|
name := m.Name() + suffix
|
||||||
|
|
||||||
@@ -186,7 +191,7 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
|
|||||||
Bzl_load_location: "//build/bazel/rules/java:proto.bzl",
|
Bzl_load_location: "//build/bazel/rules/java:proto.bzl",
|
||||||
},
|
},
|
||||||
android.CommonAttributes{Name: name},
|
android.CommonAttributes{Name: name},
|
||||||
&protoAttrs)
|
protoAttrs)
|
||||||
|
|
||||||
return &bazel.Label{Label: ":" + name}
|
return &bazel.Label{Label: ":" + name}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user