Loading cc/bp2build.go +26 −10 Original line number Diff line number Diff line Loading @@ -59,13 +59,17 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) { ctx.AddDependency(module, nil, android.SortedUniqueStrings(allDeps)...) } // Convenience struct to hold all attributes parsed from compiler properties. type compilerAttributes struct { copts bazel.StringListAttribute srcs bazel.LabelListAttribute hdrs bazel.LabelListAttribute } // bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes. func bp2BuildParseCompilerProps( ctx android.TopDownMutatorContext, module *Module) ( copts bazel.StringListAttribute, srcs bazel.LabelListAttribute, hdrs bazel.LabelListAttribute) { func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes { var hdrs, srcs bazel.LabelListAttribute var copts bazel.StringListAttribute hdrsAndSrcs := func(baseCompilerProps *BaseCompilerProperties) (bazel.LabelList, bazel.LabelList) { srcsList := android.BazelLabelForModuleSrcExcludes( Loading Loading @@ -100,13 +104,22 @@ func bp2BuildParseCompilerProps( } } return copts, srcs, hdrs return compilerAttributes{ hdrs: hdrs, srcs: srcs, copts: copts, } } // Convenience struct to hold all attributes parsed from linker properties. type linkerAttributes struct { deps bazel.LabelListAttribute linkopts bazel.StringListAttribute } // bp2BuildParseLinkerProps creates a label list attribute containing the header library deps of a module, including // configurable attribute values. func bp2BuildParseLinkerProps( ctx android.TopDownMutatorContext, module *Module) (bazel.LabelListAttribute, bazel.StringListAttribute) { func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes { var deps bazel.LabelListAttribute var linkopts bazel.StringListAttribute Loading Loading @@ -142,7 +155,10 @@ func bp2BuildParseLinkerProps( } } return deps, linkopts return linkerAttributes{ deps: deps, linkopts: linkopts, } } func bp2BuildListHeadersInDir(ctx android.TopDownMutatorContext, includeDir string) bazel.LabelList { Loading cc/library.go +19 −17 Original line number Diff line number Diff line Loading @@ -256,17 +256,17 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) { return } copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, m) deps, linkopts := bp2BuildParseLinkerProps(ctx, m) compilerAttrs := bp2BuildParseCompilerProps(ctx, m) linkerAttrs := bp2BuildParseLinkerProps(ctx, m) exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, m) hdrs.Append(exportedIncludesHeaders) compilerAttrs.hdrs.Append(exportedIncludesHeaders) attrs := &bazelCcLibraryAttributes{ Srcs: srcs, Hdrs: hdrs, Copts: copts, Linkopts: linkopts, Deps: deps, Srcs: compilerAttrs.srcs, Hdrs: compilerAttrs.hdrs, Copts: compilerAttrs.copts, Linkopts: linkerAttrs.linkopts, Deps: linkerAttrs.deps, Includes: exportedIncludes, } Loading Loading @@ -2154,12 +2154,13 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { return } copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, module) compilerAttrs := bp2BuildParseCompilerProps(ctx, module) var includeDirs []string var localIncludeDirs []string for _, props := range module.compiler.compilerProps() { if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok { // TODO: these should be arch and os specific. includeDirs = bp2BuildMakePathsRelativeToModule(ctx, baseCompilerProps.Include_dirs) localIncludeDirs = bp2BuildMakePathsRelativeToModule(ctx, baseCompilerProps.Local_include_dirs) break Loading @@ -2174,15 +2175,16 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { // For Bazel, be more explicit about headers - list all header files in include dirs as srcs for _, includeDir := range includeDirs { srcs.Value.Append(bp2BuildListHeadersInDir(ctx, includeDir)) compilerAttrs.srcs.Value.Append(bp2BuildListHeadersInDir(ctx, includeDir)) } for _, localIncludeDir := range localIncludeDirs { srcs.Value.Append(bp2BuildListHeadersInDir(ctx, localIncludeDir)) compilerAttrs.srcs.Value.Append(bp2BuildListHeadersInDir(ctx, localIncludeDir)) } var staticLibs []string var wholeStaticLibs []string for _, props := range module.linker.linkerProps() { // TODO: move this into bp2buildParseLinkerProps if baseLinkerProperties, ok := props.(*BaseLinkerProperties); ok { staticLibs = baseLinkerProperties.Static_libs wholeStaticLibs = baseLinkerProperties.Whole_static_libs Loading @@ -2204,18 +2206,18 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { allIncludes.Value = append(allIncludes.Value, includeDirs...) allIncludes.Value = append(allIncludes.Value, localIncludeDirs...) hdrs.Append(exportedIncludesHeaders) compilerAttrs.hdrs.Append(exportedIncludesHeaders) headerLibsLabels, _ := bp2BuildParseLinkerProps(ctx, module) depsLabels.Append(headerLibsLabels.Value) linkerAttrs := bp2BuildParseLinkerProps(ctx, module) depsLabels.Append(linkerAttrs.deps.Value) attrs := &bazelCcLibraryStaticAttributes{ Copts: copts, Srcs: srcs, Copts: compilerAttrs.copts, Srcs: compilerAttrs.srcs, Deps: bazel.MakeLabelListAttribute(depsLabels), Linkstatic: true, Includes: allIncludes, Hdrs: hdrs, Hdrs: compilerAttrs.hdrs, } props := bazel.BazelTargetModuleProperties{ Loading cc/library_headers.go +4 −4 Original line number Diff line number Diff line Loading @@ -96,14 +96,14 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) { } exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, module) copts, _, _ := bp2BuildParseCompilerProps(ctx, module) headerLibs, _ := bp2BuildParseLinkerProps(ctx, module) compilerAttrs := bp2BuildParseCompilerProps(ctx, module) linkerAttrs := bp2BuildParseLinkerProps(ctx, module) attrs := &bazelCcLibraryHeadersAttributes{ Copts: copts, Copts: compilerAttrs.copts, Includes: exportedIncludes, Hdrs: exportedIncludesHeaders, Deps: headerLibs, Deps: linkerAttrs.deps, } props := bazel.BazelTargetModuleProperties{ Loading cc/object.go +4 −10 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) { } // Set arch-specific configurable attributes copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, m) compilerAttrs := bp2BuildParseCompilerProps(ctx, m) var localIncludeDirs []string var asFlags []string for _, props := range m.compiler.compilerProps() { Loading Loading @@ -196,17 +196,11 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) { } // TODO(b/183595872) warn/error if we're not handling product variables for arch, p := range m.GetArchProperties(&BaseCompilerProperties{}) { if cProps, ok := p.(*BaseCompilerProperties); ok { srcs.SetValueForArch(arch.Name, android.BazelLabelForModuleSrcExcludes(ctx, cProps.Srcs, cProps.Exclude_srcs)) } } attrs := &bazelObjectAttributes{ Srcs: srcs, Hdrs: hdrs, Srcs: compilerAttrs.srcs, Hdrs: compilerAttrs.hdrs, Deps: deps, Copts: copts, Copts: compilerAttrs.copts, Asflags: asFlags, Local_include_dirs: localIncludeDirs, } Loading Loading
cc/bp2build.go +26 −10 Original line number Diff line number Diff line Loading @@ -59,13 +59,17 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) { ctx.AddDependency(module, nil, android.SortedUniqueStrings(allDeps)...) } // Convenience struct to hold all attributes parsed from compiler properties. type compilerAttributes struct { copts bazel.StringListAttribute srcs bazel.LabelListAttribute hdrs bazel.LabelListAttribute } // bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes. func bp2BuildParseCompilerProps( ctx android.TopDownMutatorContext, module *Module) ( copts bazel.StringListAttribute, srcs bazel.LabelListAttribute, hdrs bazel.LabelListAttribute) { func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes { var hdrs, srcs bazel.LabelListAttribute var copts bazel.StringListAttribute hdrsAndSrcs := func(baseCompilerProps *BaseCompilerProperties) (bazel.LabelList, bazel.LabelList) { srcsList := android.BazelLabelForModuleSrcExcludes( Loading Loading @@ -100,13 +104,22 @@ func bp2BuildParseCompilerProps( } } return copts, srcs, hdrs return compilerAttributes{ hdrs: hdrs, srcs: srcs, copts: copts, } } // Convenience struct to hold all attributes parsed from linker properties. type linkerAttributes struct { deps bazel.LabelListAttribute linkopts bazel.StringListAttribute } // bp2BuildParseLinkerProps creates a label list attribute containing the header library deps of a module, including // configurable attribute values. func bp2BuildParseLinkerProps( ctx android.TopDownMutatorContext, module *Module) (bazel.LabelListAttribute, bazel.StringListAttribute) { func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes { var deps bazel.LabelListAttribute var linkopts bazel.StringListAttribute Loading Loading @@ -142,7 +155,10 @@ func bp2BuildParseLinkerProps( } } return deps, linkopts return linkerAttributes{ deps: deps, linkopts: linkopts, } } func bp2BuildListHeadersInDir(ctx android.TopDownMutatorContext, includeDir string) bazel.LabelList { Loading
cc/library.go +19 −17 Original line number Diff line number Diff line Loading @@ -256,17 +256,17 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) { return } copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, m) deps, linkopts := bp2BuildParseLinkerProps(ctx, m) compilerAttrs := bp2BuildParseCompilerProps(ctx, m) linkerAttrs := bp2BuildParseLinkerProps(ctx, m) exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, m) hdrs.Append(exportedIncludesHeaders) compilerAttrs.hdrs.Append(exportedIncludesHeaders) attrs := &bazelCcLibraryAttributes{ Srcs: srcs, Hdrs: hdrs, Copts: copts, Linkopts: linkopts, Deps: deps, Srcs: compilerAttrs.srcs, Hdrs: compilerAttrs.hdrs, Copts: compilerAttrs.copts, Linkopts: linkerAttrs.linkopts, Deps: linkerAttrs.deps, Includes: exportedIncludes, } Loading Loading @@ -2154,12 +2154,13 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { return } copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, module) compilerAttrs := bp2BuildParseCompilerProps(ctx, module) var includeDirs []string var localIncludeDirs []string for _, props := range module.compiler.compilerProps() { if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok { // TODO: these should be arch and os specific. includeDirs = bp2BuildMakePathsRelativeToModule(ctx, baseCompilerProps.Include_dirs) localIncludeDirs = bp2BuildMakePathsRelativeToModule(ctx, baseCompilerProps.Local_include_dirs) break Loading @@ -2174,15 +2175,16 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { // For Bazel, be more explicit about headers - list all header files in include dirs as srcs for _, includeDir := range includeDirs { srcs.Value.Append(bp2BuildListHeadersInDir(ctx, includeDir)) compilerAttrs.srcs.Value.Append(bp2BuildListHeadersInDir(ctx, includeDir)) } for _, localIncludeDir := range localIncludeDirs { srcs.Value.Append(bp2BuildListHeadersInDir(ctx, localIncludeDir)) compilerAttrs.srcs.Value.Append(bp2BuildListHeadersInDir(ctx, localIncludeDir)) } var staticLibs []string var wholeStaticLibs []string for _, props := range module.linker.linkerProps() { // TODO: move this into bp2buildParseLinkerProps if baseLinkerProperties, ok := props.(*BaseLinkerProperties); ok { staticLibs = baseLinkerProperties.Static_libs wholeStaticLibs = baseLinkerProperties.Whole_static_libs Loading @@ -2204,18 +2206,18 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) { allIncludes.Value = append(allIncludes.Value, includeDirs...) allIncludes.Value = append(allIncludes.Value, localIncludeDirs...) hdrs.Append(exportedIncludesHeaders) compilerAttrs.hdrs.Append(exportedIncludesHeaders) headerLibsLabels, _ := bp2BuildParseLinkerProps(ctx, module) depsLabels.Append(headerLibsLabels.Value) linkerAttrs := bp2BuildParseLinkerProps(ctx, module) depsLabels.Append(linkerAttrs.deps.Value) attrs := &bazelCcLibraryStaticAttributes{ Copts: copts, Srcs: srcs, Copts: compilerAttrs.copts, Srcs: compilerAttrs.srcs, Deps: bazel.MakeLabelListAttribute(depsLabels), Linkstatic: true, Includes: allIncludes, Hdrs: hdrs, Hdrs: compilerAttrs.hdrs, } props := bazel.BazelTargetModuleProperties{ Loading
cc/library_headers.go +4 −4 Original line number Diff line number Diff line Loading @@ -96,14 +96,14 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) { } exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, module) copts, _, _ := bp2BuildParseCompilerProps(ctx, module) headerLibs, _ := bp2BuildParseLinkerProps(ctx, module) compilerAttrs := bp2BuildParseCompilerProps(ctx, module) linkerAttrs := bp2BuildParseLinkerProps(ctx, module) attrs := &bazelCcLibraryHeadersAttributes{ Copts: copts, Copts: compilerAttrs.copts, Includes: exportedIncludes, Hdrs: exportedIncludesHeaders, Deps: headerLibs, Deps: linkerAttrs.deps, } props := bazel.BazelTargetModuleProperties{ Loading
cc/object.go +4 −10 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) { } // Set arch-specific configurable attributes copts, srcs, hdrs := bp2BuildParseCompilerProps(ctx, m) compilerAttrs := bp2BuildParseCompilerProps(ctx, m) var localIncludeDirs []string var asFlags []string for _, props := range m.compiler.compilerProps() { Loading Loading @@ -196,17 +196,11 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) { } // TODO(b/183595872) warn/error if we're not handling product variables for arch, p := range m.GetArchProperties(&BaseCompilerProperties{}) { if cProps, ok := p.(*BaseCompilerProperties); ok { srcs.SetValueForArch(arch.Name, android.BazelLabelForModuleSrcExcludes(ctx, cProps.Srcs, cProps.Exclude_srcs)) } } attrs := &bazelObjectAttributes{ Srcs: srcs, Hdrs: hdrs, Srcs: compilerAttrs.srcs, Hdrs: compilerAttrs.hdrs, Deps: deps, Copts: copts, Copts: compilerAttrs.copts, Asflags: asFlags, Local_include_dirs: localIncludeDirs, } Loading