Merge "bp2build: add support for cc_object's objs and exclude_srcs properties." am: 1251bb5775
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1600655 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ia52b0cbf118d1e51c5496b7d816df13c53602129
This commit is contained in:
commit
c1858d0f50
|
@ -38,9 +38,10 @@ func TestCcObjectBp2Build(t *testing.T) {
|
||||||
moduleTypeUnderTestFactory: cc.ObjectFactory,
|
moduleTypeUnderTestFactory: cc.ObjectFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
|
moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"a/b/foo.h": "",
|
"a/b/foo.h": "",
|
||||||
"a/b/bar.h": "",
|
"a/b/bar.h": "",
|
||||||
"a/b/c.c": "",
|
"a/b/exclude.c": "",
|
||||||
|
"a/b/c.c": "",
|
||||||
},
|
},
|
||||||
blueprint: `cc_object {
|
blueprint: `cc_object {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -52,8 +53,9 @@ func TestCcObjectBp2Build(t *testing.T) {
|
||||||
],
|
],
|
||||||
srcs: [
|
srcs: [
|
||||||
"a/b/*.h",
|
"a/b/*.h",
|
||||||
"a/b/c.c"
|
"a/b/*.c"
|
||||||
],
|
],
|
||||||
|
exclude_srcs: ["a/b/exclude.c"],
|
||||||
|
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}
|
}
|
||||||
|
@ -131,6 +133,52 @@ cc_defaults {
|
||||||
srcs = [
|
srcs = [
|
||||||
"a/b/c.c",
|
"a/b/c.c",
|
||||||
],
|
],
|
||||||
|
)`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "cc_object with cc_object deps in objs props",
|
||||||
|
moduleTypeUnderTest: "cc_object",
|
||||||
|
moduleTypeUnderTestFactory: cc.ObjectFactory,
|
||||||
|
moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
|
||||||
|
filesystem: map[string]string{
|
||||||
|
"a/b/c.c": "",
|
||||||
|
"x/y/z.c": "",
|
||||||
|
},
|
||||||
|
blueprint: `cc_object {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a/b/c.c"],
|
||||||
|
objs: ["bar"],
|
||||||
|
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_object {
|
||||||
|
name: "bar",
|
||||||
|
srcs: ["x/y/z.c"],
|
||||||
|
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`cc_object(
|
||||||
|
name = "bar",
|
||||||
|
copts = [
|
||||||
|
"-fno-addrsig",
|
||||||
|
],
|
||||||
|
srcs = [
|
||||||
|
"x/y/z.c",
|
||||||
|
],
|
||||||
|
)`, `cc_object(
|
||||||
|
name = "foo",
|
||||||
|
copts = [
|
||||||
|
"-fno-addrsig",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":bar",
|
||||||
|
],
|
||||||
|
srcs = [
|
||||||
|
"a/b/c.c",
|
||||||
|
],
|
||||||
)`,
|
)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
13
cc/object.go
13
cc/object.go
|
@ -92,6 +92,7 @@ func ObjectFactory() android.Module {
|
||||||
// For bp2build conversion.
|
// For bp2build conversion.
|
||||||
type bazelObjectAttributes struct {
|
type bazelObjectAttributes struct {
|
||||||
Srcs bazel.LabelList
|
Srcs bazel.LabelList
|
||||||
|
Deps bazel.LabelList
|
||||||
Copts []string
|
Copts []string
|
||||||
Local_include_dirs []string
|
Local_include_dirs []string
|
||||||
}
|
}
|
||||||
|
@ -134,18 +135,28 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
||||||
|
|
||||||
var copts []string
|
var copts []string
|
||||||
var srcs []string
|
var srcs []string
|
||||||
|
var excludeSrcs []string
|
||||||
var localIncludeDirs []string
|
var localIncludeDirs []string
|
||||||
for _, props := range m.compiler.compilerProps() {
|
for _, props := range m.compiler.compilerProps() {
|
||||||
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
|
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
|
||||||
copts = baseCompilerProps.Cflags
|
copts = baseCompilerProps.Cflags
|
||||||
srcs = baseCompilerProps.Srcs
|
srcs = baseCompilerProps.Srcs
|
||||||
|
excludeSrcs = baseCompilerProps.Exclude_srcs
|
||||||
localIncludeDirs = baseCompilerProps.Local_include_dirs
|
localIncludeDirs = baseCompilerProps.Local_include_dirs
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deps bazel.LabelList
|
||||||
|
for _, props := range m.linker.linkerProps() {
|
||||||
|
if objectLinkerProps, ok := props.(*ObjectLinkerProperties); ok {
|
||||||
|
deps = android.BazelLabelForModuleDeps(ctx, objectLinkerProps.Objs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
attrs := &bazelObjectAttributes{
|
attrs := &bazelObjectAttributes{
|
||||||
Srcs: android.BazelLabelForModuleSrc(ctx, srcs),
|
Srcs: android.BazelLabelForModuleSrcExcludes(ctx, srcs, excludeSrcs),
|
||||||
|
Deps: deps,
|
||||||
Copts: copts,
|
Copts: copts,
|
||||||
Local_include_dirs: localIncludeDirs,
|
Local_include_dirs: localIncludeDirs,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue