Handle include_build_directory prop in bp2build
Test: go test cc tests Test: generate bp2build, sync bp2build, bazel build //bionic/... Bug: 181794963 Change-Id: I8dcef585e3025ef6f44d22430ed67b1e0429dca0
This commit is contained in:
@@ -70,6 +70,7 @@ func TestCcObjectBp2Build(t *testing.T) {
|
|||||||
],
|
],
|
||||||
local_include_dirs = [
|
local_include_dirs = [
|
||||||
"include",
|
"include",
|
||||||
|
".",
|
||||||
],
|
],
|
||||||
srcs = [
|
srcs = [
|
||||||
"a/b/bar.h",
|
"a/b/bar.h",
|
||||||
@@ -120,6 +121,7 @@ cc_defaults {
|
|||||||
],
|
],
|
||||||
local_include_dirs = [
|
local_include_dirs = [
|
||||||
"include",
|
"include",
|
||||||
|
".",
|
||||||
],
|
],
|
||||||
srcs = [
|
srcs = [
|
||||||
"a/b/c.c",
|
"a/b/c.c",
|
||||||
@@ -156,6 +158,9 @@ cc_object {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
],
|
],
|
||||||
|
local_include_dirs = [
|
||||||
|
".",
|
||||||
|
],
|
||||||
srcs = [
|
srcs = [
|
||||||
"x/y/z.c",
|
"x/y/z.c",
|
||||||
],
|
],
|
||||||
@@ -167,6 +172,37 @@ cc_object {
|
|||||||
deps = [
|
deps = [
|
||||||
":bar",
|
":bar",
|
||||||
],
|
],
|
||||||
|
local_include_dirs = [
|
||||||
|
".",
|
||||||
|
],
|
||||||
|
srcs = [
|
||||||
|
"a/b/c.c",
|
||||||
|
],
|
||||||
|
)`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "cc_object with include_build_dir: false",
|
||||||
|
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"],
|
||||||
|
include_build_directory: false,
|
||||||
|
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`cc_object(
|
||||||
|
name = "foo",
|
||||||
|
copts = [
|
||||||
|
"-fno-addrsig",
|
||||||
|
],
|
||||||
srcs = [
|
srcs = [
|
||||||
"a/b/c.c",
|
"a/b/c.c",
|
||||||
],
|
],
|
||||||
@@ -262,6 +298,9 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
|
|||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
local_include_dirs = [
|
||||||
|
".",
|
||||||
|
],
|
||||||
)`,
|
)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -310,6 +349,9 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
|
|||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
local_include_dirs = [
|
||||||
|
".",
|
||||||
|
],
|
||||||
)`,
|
)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -256,6 +256,10 @@ func (compiler *baseCompiler) compilerProps() []interface{} {
|
|||||||
return []interface{}{&compiler.Properties, &compiler.Proto}
|
return []interface{}{&compiler.Properties, &compiler.Proto}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (compiler *baseCompiler) includeBuildDirectory() bool {
|
||||||
|
return proptools.BoolDefault(compiler.Properties.Include_build_directory, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {}
|
func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {}
|
||||||
|
|
||||||
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
@@ -332,8 +336,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
flags.Local.YasmFlags = append(flags.Local.YasmFlags, f)
|
flags.Local.YasmFlags = append(flags.Local.YasmFlags, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.Properties.Include_build_directory == nil ||
|
if compiler.includeBuildDirectory() {
|
||||||
*compiler.Properties.Include_build_directory {
|
|
||||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+modulePath)
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+modulePath)
|
||||||
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
|
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
|
||||||
}
|
}
|
||||||
|
@@ -160,6 +160,10 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c, ok := m.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
|
||||||
|
localIncludeDirs = append(localIncludeDirs, ".")
|
||||||
|
}
|
||||||
|
|
||||||
var deps bazel.LabelList
|
var deps bazel.LabelList
|
||||||
for _, props := range m.linker.linkerProps() {
|
for _, props := range m.linker.linkerProps() {
|
||||||
if objectLinkerProps, ok := props.(*ObjectLinkerProperties); ok {
|
if objectLinkerProps, ok := props.(*ObjectLinkerProperties); ok {
|
||||||
|
Reference in New Issue
Block a user