Support suffix
property in bp2build
Support this in cc_{binary,library{,_shared}} Bug: 204811222 Test: Suffix additions to cc_{binary,library{,_shared}}_conversion_test.go Test: mixed_{libc,droid}.sh also builds newly allowlisted Change-Id: I596694794b01b04c542cbcd7d54baeb7d914ba50
This commit is contained in:
parent
1520d7fb2d
commit
a56e97042c
@@ -591,30 +591,8 @@ 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/204811222) support suffix in cc_binary
|
// TODO(b/240563612) Needing `stem` selection support for cc_binary
|
||||||
"acvp_modulewrapper",
|
|
||||||
"android.hardware.media.c2@1.0-service-v4l2",
|
|
||||||
"app_process",
|
|
||||||
"bar_test",
|
|
||||||
"bench_cxa_atexit",
|
|
||||||
"bench_noop",
|
|
||||||
"bench_noop_nostl",
|
|
||||||
"bench_noop_static",
|
|
||||||
"boringssl_self_test",
|
|
||||||
"boringssl_self_test_vendor",
|
|
||||||
"bssl",
|
|
||||||
"cavp",
|
|
||||||
"crash_dump",
|
|
||||||
"crasher",
|
"crasher",
|
||||||
"libcxx_test_template",
|
|
||||||
"linker",
|
|
||||||
"memory_replay",
|
|
||||||
"native_bridge_guest_linker",
|
|
||||||
"native_bridge_stub_library_defaults",
|
|
||||||
"noop",
|
|
||||||
"simpleperf_ndk",
|
|
||||||
"toybox-static",
|
|
||||||
"zlib_bench",
|
|
||||||
|
|
||||||
// java_import[_host] issues
|
// java_import[_host] issues
|
||||||
// tradefed prebuilts depend on libprotobuf
|
// tradefed prebuilts depend on libprotobuf
|
||||||
|
@@ -605,8 +605,67 @@ func TestCcBinaryWithInstructionSet(t *testing.T) {
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`,
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
},
|
}},
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcBinaryEmptySuffix(t *testing.T) {
|
||||||
|
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
|
||||||
|
description: "binary with empty suffix",
|
||||||
|
blueprint: `
|
||||||
|
{rule_name} {
|
||||||
|
name: "foo",
|
||||||
|
suffix: "",
|
||||||
|
}`,
|
||||||
|
targets: []testBazelTarget{
|
||||||
|
{"cc_binary", "foo", AttrNameToString{
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"suffix": `""`,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcBinarySuffix(t *testing.T) {
|
||||||
|
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
|
||||||
|
description: "binary with suffix",
|
||||||
|
blueprint: `
|
||||||
|
{rule_name} {
|
||||||
|
name: "foo",
|
||||||
|
suffix: "-suf",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
targets: []testBazelTarget{
|
||||||
|
{"cc_binary", "foo", AttrNameToString{
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"suffix": `"-suf"`,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcArchVariantBinarySuffix(t *testing.T) {
|
||||||
|
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
|
||||||
|
description: "binary with suffix",
|
||||||
|
blueprint: `
|
||||||
|
{rule_name} {
|
||||||
|
name: "foo",
|
||||||
|
arch: {
|
||||||
|
arm64: { suffix: "-64" },
|
||||||
|
arm: { suffix: "-32" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
targets: []testBazelTarget{
|
||||||
|
{"cc_binary", "foo", AttrNameToString{
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"suffix": `select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "-32",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "-64",
|
||||||
|
"//conditions:default": None,
|
||||||
|
})`,
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -2593,6 +2593,91 @@ func TestCcLibraryWithInstructionSet(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryEmptySuffix(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library with empty suffix",
|
||||||
|
ModuleTypeUnderTest: "cc_library",
|
||||||
|
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: `cc_library {
|
||||||
|
name: "foo",
|
||||||
|
suffix: "",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
}),
|
||||||
|
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `""`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcLibrarySuffix(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library with suffix",
|
||||||
|
ModuleTypeUnderTest: "cc_library",
|
||||||
|
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: `cc_library {
|
||||||
|
name: "foo",
|
||||||
|
suffix: "-suf",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
}),
|
||||||
|
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `"-suf"`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryArchVariantSuffix(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library with arch-variant suffix",
|
||||||
|
ModuleTypeUnderTest: "cc_library",
|
||||||
|
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: `cc_library {
|
||||||
|
name: "foo",
|
||||||
|
arch: {
|
||||||
|
arm64: { suffix: "-64" },
|
||||||
|
arm: { suffix: "-32" },
|
||||||
|
},
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
}),
|
||||||
|
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "-32",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "-64",
|
||||||
|
"//conditions:default": None,
|
||||||
|
})`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestCcLibraryWithAidlSrcs(t *testing.T) {
|
func TestCcLibraryWithAidlSrcs(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
Description: "cc_library with aidl srcs",
|
Description: "cc_library with aidl srcs",
|
||||||
|
@@ -641,3 +641,76 @@ cc_library_shared {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcLibrarySharedEmptySuffix(t *testing.T) {
|
||||||
|
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library_shared with empty suffix",
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: soongCcLibrarySharedPreamble + `
|
||||||
|
cc_library_shared {
|
||||||
|
name: "foo_shared",
|
||||||
|
suffix: "",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `""`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcLibrarySharedSuffix(t *testing.T) {
|
||||||
|
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library_shared with suffix",
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: soongCcLibrarySharedPreamble + `
|
||||||
|
cc_library_shared {
|
||||||
|
name: "foo_shared",
|
||||||
|
suffix: "-suf",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `"-suf"`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcLibrarySharedArchVariantSuffix(t *testing.T) {
|
||||||
|
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library_shared with arch-variant suffix",
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foo.c": "",
|
||||||
|
},
|
||||||
|
Blueprint: soongCcLibrarySharedPreamble + `
|
||||||
|
cc_library_shared {
|
||||||
|
name: "foo_shared",
|
||||||
|
arch: {
|
||||||
|
arm64: { suffix: "-64" },
|
||||||
|
arm: { suffix: "-32" },
|
||||||
|
},
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||||
|
"srcs_c": `["foo.c"]`,
|
||||||
|
"suffix": `select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "-32",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "-64",
|
||||||
|
"//conditions:default": None,
|
||||||
|
})`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -339,6 +339,8 @@ type compilerAttributes struct {
|
|||||||
stubsVersions bazel.StringListAttribute
|
stubsVersions bazel.StringListAttribute
|
||||||
|
|
||||||
features bazel.StringListAttribute
|
features bazel.StringListAttribute
|
||||||
|
|
||||||
|
suffix bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type filterOutFn func(string) bool
|
type filterOutFn func(string) bool
|
||||||
@@ -694,6 +696,9 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
compilerAttrs.stubsSymbolFile = libraryProps.Stubs.Symbol_file
|
compilerAttrs.stubsSymbolFile = libraryProps.Stubs.Symbol_file
|
||||||
compilerAttrs.stubsVersions.SetSelectValue(axis, config, libraryProps.Stubs.Versions)
|
compilerAttrs.stubsVersions.SetSelectValue(axis, config, libraryProps.Stubs.Versions)
|
||||||
}
|
}
|
||||||
|
if suffix := libraryProps.Suffix; suffix != nil {
|
||||||
|
compilerAttrs.suffix.SetSelectValue(axis, config, suffix)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1201,6 +1206,7 @@ func bazelLabelForSharedDepsExcludes(ctx android.BazelConversionPathContext, mod
|
|||||||
|
|
||||||
type binaryLinkerAttrs struct {
|
type binaryLinkerAttrs struct {
|
||||||
Linkshared *bool
|
Linkshared *bool
|
||||||
|
Suffix bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module) binaryLinkerAttrs {
|
func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module) binaryLinkerAttrs {
|
||||||
@@ -1217,6 +1223,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 suffix := linkerProps.Suffix; suffix != nil {
|
||||||
|
attrs.Suffix.SetSelectValue(axis, config, suffix)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
@@ -408,6 +408,8 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
|||||||
sharedTargetAttrs.Has_stubs.SetValue(&hasStubs)
|
sharedTargetAttrs.Has_stubs.SetValue(&hasStubs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sharedTargetAttrs.Suffix = compilerAttrs.suffix
|
||||||
|
|
||||||
for axis, configToProps := range m.GetArchVariantProperties(ctx, &LibraryProperties{}) {
|
for axis, configToProps := range m.GetArchVariantProperties(ctx, &LibraryProperties{}) {
|
||||||
for config, props := range configToProps {
|
for config, props := range configToProps {
|
||||||
if props, ok := props.(*LibraryProperties); ok {
|
if props, ok := props.(*LibraryProperties); ok {
|
||||||
@@ -2647,6 +2649,8 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||||||
},
|
},
|
||||||
|
|
||||||
Features: baseAttributes.features,
|
Features: baseAttributes.features,
|
||||||
|
|
||||||
|
Suffix: compilerAttrs.suffix,
|
||||||
}
|
}
|
||||||
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
|
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
|
||||||
hasStubs := true
|
hasStubs := true
|
||||||
@@ -2729,6 +2733,8 @@ type bazelCcLibrarySharedAttributes struct {
|
|||||||
Has_stubs bazel.BoolAttribute
|
Has_stubs bazel.BoolAttribute
|
||||||
|
|
||||||
Inject_bssl_hash bazel.BoolAttribute
|
Inject_bssl_hash bazel.BoolAttribute
|
||||||
|
|
||||||
|
Suffix bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type bazelCcStubSuiteAttributes struct {
|
type bazelCcStubSuiteAttributes struct {
|
||||||
|
Reference in New Issue
Block a user