bp2build: add support for cc_object's objs and exclude_srcs properties.

objs contains module references to other cc_objects that will be used
for linking later. This maps to cc_library deps.

Also support exclude_srcs, and added tests.

Test: bp2build generate, sync, bazel build //bionic/...

Change-Id: I21200ff73f24bcf5357d9df8dcb5519cde532a77
This commit is contained in:
Jingwen Chen
2021-02-23 00:46:47 -05:00
parent bbfd5ab606
commit db12024524
2 changed files with 64 additions and 5 deletions

View File

@@ -92,6 +92,7 @@ func ObjectFactory() android.Module {
// For bp2build conversion.
type bazelObjectAttributes struct {
Srcs bazel.LabelList
Deps bazel.LabelList
Copts []string
Local_include_dirs []string
}
@@ -134,18 +135,28 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
var copts []string
var srcs []string
var excludeSrcs []string
var localIncludeDirs []string
for _, props := range m.compiler.compilerProps() {
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
copts = baseCompilerProps.Cflags
srcs = baseCompilerProps.Srcs
excludeSrcs = baseCompilerProps.Exclude_srcs
localIncludeDirs = baseCompilerProps.Local_include_dirs
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{
Srcs: android.BazelLabelForModuleSrc(ctx, srcs),
Srcs: android.BazelLabelForModuleSrcExcludes(ctx, srcs, excludeSrcs),
Deps: deps,
Copts: copts,
Local_include_dirs: localIncludeDirs,
}