Merge changes from topic "cc_stem"
* changes: Remove modules from denylist Update runpath for jni libs bp2build support for stem
This commit is contained in:
@@ -837,7 +837,6 @@ var (
|
|||||||
|
|
||||||
"linker", // TODO(b/228316882): cc_binary uses link_crt
|
"linker", // TODO(b/228316882): cc_binary uses link_crt
|
||||||
"versioner", // TODO(b/228313961): depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library
|
"versioner", // TODO(b/228313961): depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library
|
||||||
"tjbench", // TODO(b/240563612): Stem property
|
|
||||||
|
|
||||||
// requires host tools for apexer
|
// requires host tools for apexer
|
||||||
"apexer_test", "apexer_test_host_tools", "host_apex_verifier",
|
"apexer_test", "apexer_test_host_tools", "host_apex_verifier",
|
||||||
@@ -1510,9 +1509,6 @@ var (
|
|||||||
"libadb_pairing_connection_static",
|
"libadb_pairing_connection_static",
|
||||||
"libadb_pairing_server", "libadb_pairing_server_static",
|
"libadb_pairing_server", "libadb_pairing_server_static",
|
||||||
|
|
||||||
// TODO(b/240563612) Needing `stem` selection support for cc_binary
|
|
||||||
"crasher",
|
|
||||||
|
|
||||||
// java_import[_host] issues
|
// java_import[_host] issues
|
||||||
// tradefed prebuilts depend on libprotobuf
|
// tradefed prebuilts depend on libprotobuf
|
||||||
"prebuilt_tradefed",
|
"prebuilt_tradefed",
|
||||||
|
@@ -1106,3 +1106,40 @@ func TestCcBinaryWithCfiAndCfiAssemblySupport(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcBinaryStem(t *testing.T) {
|
||||||
|
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
|
||||||
|
description: "cc_binary with stem property",
|
||||||
|
blueprint: `
|
||||||
|
cc_binary {
|
||||||
|
name: "foo_with_stem_simple",
|
||||||
|
stem: "foo",
|
||||||
|
}
|
||||||
|
cc_binary {
|
||||||
|
name: "foo_with_arch_variant_stem",
|
||||||
|
arch: {
|
||||||
|
arm: {
|
||||||
|
stem: "foo-arm",
|
||||||
|
},
|
||||||
|
arm64: {
|
||||||
|
stem: "foo-arm64",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
targets: []testBazelTarget{
|
||||||
|
{"cc_binary", "foo_with_stem_simple", AttrNameToString{
|
||||||
|
"stem": `"foo"`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}},
|
||||||
|
{"cc_binary", "foo_with_arch_variant_stem", AttrNameToString{
|
||||||
|
"stem": `select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "foo-arm",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "foo-arm64",
|
||||||
|
"//conditions:default": None,
|
||||||
|
})`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -4812,3 +4812,42 @@ cc_library {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryWithStem(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library with stem property",
|
||||||
|
ModuleTypeUnderTest: "cc_library_shared",
|
||||||
|
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||||
|
Blueprint: soongCcLibraryPreamble + `
|
||||||
|
cc_library_shared {
|
||||||
|
name: "foo_with_stem_simple",
|
||||||
|
stem: "foo",
|
||||||
|
}
|
||||||
|
cc_library_shared {
|
||||||
|
name: "foo_with_arch_variant_stem",
|
||||||
|
arch: {
|
||||||
|
arm: {
|
||||||
|
stem: "foo-arm",
|
||||||
|
},
|
||||||
|
arm64: {
|
||||||
|
stem: "foo-arm64",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("cc_library_shared", "foo_with_stem_simple", AttrNameToString{
|
||||||
|
"stem": `"foo"`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}),
|
||||||
|
MakeBazelTarget("cc_library_shared", "foo_with_arch_variant_stem", AttrNameToString{
|
||||||
|
"stem": `select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "foo-arm",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "foo-arm64",
|
||||||
|
"//conditions:default": None,
|
||||||
|
})`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -68,7 +68,7 @@ func TestJavaBinaryHost(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
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/jni-lib-1"]`,
|
||||||
"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": [],
|
||||||
|
@@ -434,6 +434,7 @@ type compilerAttributes struct {
|
|||||||
|
|
||||||
features bazel.StringListAttribute
|
features bazel.StringListAttribute
|
||||||
|
|
||||||
|
stem bazel.StringAttribute
|
||||||
suffix bazel.StringAttribute
|
suffix bazel.StringAttribute
|
||||||
|
|
||||||
fdoProfile bazel.LabelAttribute
|
fdoProfile bazel.LabelAttribute
|
||||||
@@ -819,6 +820,9 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
compilerAttrs.stubsVersions.SetSelectValue(axis, cfg, versions)
|
compilerAttrs.stubsVersions.SetSelectValue(axis, cfg, versions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if stem := libraryProps.Stem; stem != nil {
|
||||||
|
compilerAttrs.stem.SetSelectValue(axis, cfg, stem)
|
||||||
|
}
|
||||||
if suffix := libraryProps.Suffix; suffix != nil {
|
if suffix := libraryProps.Suffix; suffix != nil {
|
||||||
compilerAttrs.suffix.SetSelectValue(axis, cfg, suffix)
|
compilerAttrs.suffix.SetSelectValue(axis, cfg, suffix)
|
||||||
}
|
}
|
||||||
@@ -1737,6 +1741,7 @@ func bazelLabelForSharedDepsExcludes(ctx android.BazelConversionPathContext, mod
|
|||||||
|
|
||||||
type binaryLinkerAttrs struct {
|
type binaryLinkerAttrs struct {
|
||||||
Linkshared *bool
|
Linkshared *bool
|
||||||
|
Stem bazel.StringAttribute
|
||||||
Suffix bazel.StringAttribute
|
Suffix bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1754,6 +1759,9 @@ func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module
|
|||||||
// nonconfigurable attribute. Only 4 AOSP modules use this feature, defer handling
|
// nonconfigurable attribute. Only 4 AOSP modules use this feature, defer handling
|
||||||
ctx.ModuleErrorf("bp2build cannot migrate a module with arch/target-specific static_executable values")
|
ctx.ModuleErrorf("bp2build cannot migrate a module with arch/target-specific static_executable values")
|
||||||
}
|
}
|
||||||
|
if stem := linkerProps.Stem; stem != nil {
|
||||||
|
attrs.Stem.SetSelectValue(axis, config, stem)
|
||||||
|
}
|
||||||
if suffix := linkerProps.Suffix; suffix != nil {
|
if suffix := linkerProps.Suffix; suffix != nil {
|
||||||
attrs.Suffix.SetSelectValue(axis, config, suffix)
|
attrs.Suffix.SetSelectValue(axis, config, suffix)
|
||||||
}
|
}
|
||||||
|
@@ -408,6 +408,7 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
|||||||
sharedTargetAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
|
sharedTargetAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sharedTargetAttrs.Stem = compilerAttrs.stem
|
||||||
sharedTargetAttrs.Suffix = compilerAttrs.suffix
|
sharedTargetAttrs.Suffix = compilerAttrs.suffix
|
||||||
|
|
||||||
for axis, configToProps := range m.GetArchVariantProperties(ctx, &LibraryProperties{}) {
|
for axis, configToProps := range m.GetArchVariantProperties(ctx, &LibraryProperties{}) {
|
||||||
@@ -2987,6 +2988,7 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||||||
|
|
||||||
Features: *features,
|
Features: *features,
|
||||||
|
|
||||||
|
Stem: compilerAttrs.stem,
|
||||||
Suffix: compilerAttrs.suffix,
|
Suffix: compilerAttrs.suffix,
|
||||||
|
|
||||||
bazelCcHeaderAbiCheckerAttributes: bp2buildParseAbiCheckerProps(ctx, module),
|
bazelCcHeaderAbiCheckerAttributes: bp2buildParseAbiCheckerProps(ctx, module),
|
||||||
@@ -3072,6 +3074,7 @@ type bazelCcLibrarySharedAttributes struct {
|
|||||||
|
|
||||||
Inject_bssl_hash bazel.BoolAttribute
|
Inject_bssl_hash bazel.BoolAttribute
|
||||||
|
|
||||||
|
Stem bazel.StringAttribute
|
||||||
Suffix bazel.StringAttribute
|
Suffix bazel.StringAttribute
|
||||||
|
|
||||||
bazelCcHeaderAbiCheckerAttributes
|
bazelCcHeaderAbiCheckerAttributes
|
||||||
|
39
java/java.go
39
java/java.go
@@ -3104,24 +3104,15 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
|
|||||||
// Attribute jvm_flags
|
// Attribute jvm_flags
|
||||||
var jvmFlags bazel.StringListAttribute
|
var jvmFlags bazel.StringListAttribute
|
||||||
if m.binaryProperties.Jni_libs != nil {
|
if m.binaryProperties.Jni_libs != nil {
|
||||||
jniLibPackages := map[string]bool{}
|
jniLibPackages := []string{}
|
||||||
for _, jniLibLabel := range android.BazelLabelForModuleDeps(ctx, m.binaryProperties.Jni_libs).Includes {
|
for _, jniLib := range m.binaryProperties.Jni_libs {
|
||||||
jniLibPackage := jniLibLabel.Label
|
if jniLibModule, exists := ctx.ModuleFromName(jniLib); exists {
|
||||||
indexOfColon := strings.Index(jniLibLabel.Label, ":")
|
otherDir := ctx.OtherModuleDir(jniLibModule)
|
||||||
if indexOfColon > 0 {
|
jniLibPackages = append(jniLibPackages, filepath.Join(otherDir, jniLib))
|
||||||
// JNI lib from other package
|
|
||||||
jniLibPackage = jniLibLabel.Label[2:indexOfColon]
|
|
||||||
} else if indexOfColon == 0 {
|
|
||||||
// JNI lib in the same package of java_binary
|
|
||||||
packageOfCurrentModule := m.GetBazelLabel(ctx, m)
|
|
||||||
jniLibPackage = packageOfCurrentModule[2:strings.Index(packageOfCurrentModule, ":")]
|
|
||||||
}
|
|
||||||
if _, inMap := jniLibPackages[jniLibPackage]; !inMap {
|
|
||||||
jniLibPackages[jniLibPackage] = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jniLibPaths := []string{}
|
jniLibPaths := []string{}
|
||||||
for jniLibPackage, _ := range jniLibPackages {
|
for _, jniLibPackage := range jniLibPackages {
|
||||||
// See cs/f:.*/third_party/bazel/.*java_stub_template.txt for the use of RUNPATH
|
// See cs/f:.*/third_party/bazel/.*java_stub_template.txt for the use of RUNPATH
|
||||||
jniLibPaths = append(jniLibPaths, "$${RUNPATH}"+jniLibPackage)
|
jniLibPaths = append(jniLibPaths, "$${RUNPATH}"+jniLibPackage)
|
||||||
}
|
}
|
||||||
@@ -3145,9 +3136,9 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libInfo := libraryCreationInfo{
|
libInfo := libraryCreationInfo{
|
||||||
deps: deps,
|
deps: deps,
|
||||||
attrs: commonAttrs,
|
attrs: commonAttrs,
|
||||||
baseName: m.Name(),
|
baseName: m.Name(),
|
||||||
hasKotlin: bp2BuildInfo.hasKotlin,
|
hasKotlin: bp2BuildInfo.hasKotlin,
|
||||||
}
|
}
|
||||||
libName := createLibraryTarget(ctx, libInfo)
|
libName := createLibraryTarget(ctx, libInfo)
|
||||||
@@ -3189,9 +3180,9 @@ func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libInfo := libraryCreationInfo{
|
libInfo := libraryCreationInfo{
|
||||||
deps: deps,
|
deps: deps,
|
||||||
attrs: commonAttrs,
|
attrs: commonAttrs,
|
||||||
baseName: m.Name(),
|
baseName: m.Name(),
|
||||||
hasKotlin: bp2BuildInfo.hasKotlin,
|
hasKotlin: bp2BuildInfo.hasKotlin,
|
||||||
}
|
}
|
||||||
libName := createLibraryTarget(ctx, libInfo)
|
libName := createLibraryTarget(ctx, libInfo)
|
||||||
@@ -3204,9 +3195,9 @@ func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) {
|
|||||||
// libraryCreationInfo encapsulates the info needed to create java_library target from
|
// libraryCreationInfo encapsulates the info needed to create java_library target from
|
||||||
// java_binary_host or java_test_host.
|
// java_binary_host or java_test_host.
|
||||||
type libraryCreationInfo struct {
|
type libraryCreationInfo struct {
|
||||||
deps bazel.LabelListAttribute
|
deps bazel.LabelListAttribute
|
||||||
attrs *javaCommonAttributes
|
attrs *javaCommonAttributes
|
||||||
baseName string
|
baseName string
|
||||||
hasKotlin bool
|
hasKotlin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user