bp2build: refactor/standardize cc_* bp2build converters
This CL refactors the cc* bp2build converters to use the common
attribute extractors in cc/bp2build.go.
This also adds include_build_directory to be handled by the compiler
attr extractor to generate recursive headers as inputs.
This also turns include_dirs and local_include_dirs into the
execroot-relative -I flags.
e.g. if a module in bionic/libc has "private" in local_include_dirs,
the "-Ibionic/libc/private" copt is generated for it.
Fixes: 185139955
Test: TH
Test: Forrest for mixed_clean-droid
Change-Id: Ib67056482227e62068fbbea0455035bdf5d56319
diff --git a/cc/object.go b/cc/object.go
index 9bb279a..d8f1aba 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -112,12 +112,11 @@
// For bp2build conversion.
type bazelObjectAttributes struct {
- Srcs bazel.LabelListAttribute
- Hdrs bazel.LabelListAttribute
- Deps bazel.LabelListAttribute
- Copts bazel.StringListAttribute
- Asflags []string
- Local_include_dirs []string
+ Srcs bazel.LabelListAttribute
+ Hdrs bazel.LabelListAttribute
+ Deps bazel.LabelListAttribute
+ Copts bazel.StringListAttribute
+ Asflags []string
}
type bazelObject struct {
@@ -158,18 +157,7 @@
// Set arch-specific configurable attributes
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
- var localIncludeDirs []string
var asFlags []string
- for _, props := range m.compiler.compilerProps() {
- if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
- localIncludeDirs = baseCompilerProps.Local_include_dirs
- break
- }
- }
-
- if c, ok := m.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
- localIncludeDirs = append(localIncludeDirs, ".")
- }
var deps bazel.LabelListAttribute
for _, props := range m.linker.linkerProps() {
@@ -197,12 +185,10 @@
// TODO(b/183595872) warn/error if we're not handling product variables
attrs := &bazelObjectAttributes{
- Srcs: compilerAttrs.srcs,
- Hdrs: compilerAttrs.hdrs,
- Deps: deps,
- Copts: compilerAttrs.copts,
- Asflags: asFlags,
- Local_include_dirs: localIncludeDirs,
+ Srcs: compilerAttrs.srcs,
+ Deps: deps,
+ Copts: compilerAttrs.copts,
+ Asflags: asFlags,
}
props := bazel.BazelTargetModuleProperties{