bp2build: arch-configurable selects for label list attrs. am: 0702791a99
am: ca0664d2fe
am: b1fb88681b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1635579 Change-Id: Ic633ddfe15248d31833d62f71b081512d31c06d7
This commit is contained in:
@@ -2029,7 +2029,7 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func Bp2BuildParseHeaderLibs(ctx android.TopDownMutatorContext, module *Module) bazel.LabelList {
|
||||
func Bp2BuildParseHeaderLibs(ctx android.TopDownMutatorContext, module *Module) bazel.LabelListAttribute {
|
||||
var headerLibs []string
|
||||
for _, linkerProps := range module.linker.linkerProps() {
|
||||
if baseLinkerProps, ok := linkerProps.(*BaseLinkerProperties); ok {
|
||||
@@ -2038,12 +2038,11 @@ func Bp2BuildParseHeaderLibs(ctx android.TopDownMutatorContext, module *Module)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
headerLibsLabels := android.BazelLabelForModuleDeps(ctx, headerLibs)
|
||||
headerLibsLabels := bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, headerLibs))
|
||||
return headerLibsLabels
|
||||
}
|
||||
|
||||
func Bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) (bazel.LabelList, bazel.LabelList) {
|
||||
func Bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) (bazel.LabelListAttribute, bazel.LabelListAttribute) {
|
||||
libraryDecorator := module.linker.(*libraryDecorator)
|
||||
|
||||
includeDirs := libraryDecorator.flagExporter.Properties.Export_system_include_dirs
|
||||
@@ -2059,17 +2058,16 @@ func Bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Mo
|
||||
}
|
||||
|
||||
headersLabels := android.BazelLabelForModuleSrc(ctx, includeDirGlobs)
|
||||
|
||||
return includeDirsLabels, headersLabels
|
||||
return bazel.MakeLabelListAttribute(includeDirsLabels), bazel.MakeLabelListAttribute(headersLabels)
|
||||
}
|
||||
|
||||
type bazelCcLibraryStaticAttributes struct {
|
||||
Copts []string
|
||||
Srcs bazel.LabelList
|
||||
Deps bazel.LabelList
|
||||
Srcs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Linkstatic bool
|
||||
Includes bazel.LabelList
|
||||
Hdrs bazel.LabelList
|
||||
Includes bazel.LabelListAttribute
|
||||
Hdrs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
type bazelCcLibraryStatic struct {
|
||||
@@ -2110,7 +2108,7 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
||||
break
|
||||
}
|
||||
}
|
||||
srcsLabels := android.BazelLabelForModuleSrc(ctx, srcs)
|
||||
srcsLabels := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, srcs))
|
||||
|
||||
var staticLibs []string
|
||||
var wholeStaticLibs []string
|
||||
@@ -2135,18 +2133,18 @@ func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
||||
includesLabels := android.BazelLabelForModuleSrc(ctx, allIncludes)
|
||||
|
||||
exportedIncludesLabels, exportedIncludesHeadersLabels := Bp2BuildParseExportedIncludes(ctx, module)
|
||||
includesLabels.Append(exportedIncludesLabels)
|
||||
includesLabels.Append(exportedIncludesLabels.Value)
|
||||
|
||||
headerLibsLabels := Bp2BuildParseHeaderLibs(ctx, module)
|
||||
depsLabels.Append(headerLibsLabels)
|
||||
depsLabels.Append(headerLibsLabels.Value)
|
||||
|
||||
attrs := &bazelCcLibraryStaticAttributes{
|
||||
Copts: copts,
|
||||
Srcs: bazel.UniqueBazelLabelList(srcsLabels),
|
||||
Deps: bazel.UniqueBazelLabelList(depsLabels),
|
||||
Srcs: srcsLabels,
|
||||
Deps: bazel.MakeLabelListAttribute(depsLabels),
|
||||
Linkstatic: true,
|
||||
Includes: bazel.UniqueBazelLabelList(includesLabels),
|
||||
Hdrs: bazel.UniqueBazelLabelList(exportedIncludesHeadersLabels),
|
||||
Includes: bazel.MakeLabelListAttribute(includesLabels),
|
||||
Hdrs: exportedIncludesHeadersLabels,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
|
@@ -62,9 +62,9 @@ func prebuiltLibraryHeaderFactory() android.Module {
|
||||
}
|
||||
|
||||
type bazelCcLibraryHeadersAttributes struct {
|
||||
Hdrs bazel.LabelList
|
||||
Includes bazel.LabelList
|
||||
Deps bazel.LabelList
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Includes bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
type bazelCcLibraryHeaders struct {
|
||||
|
23
cc/object.go
23
cc/object.go
@@ -103,8 +103,8 @@ func ObjectFactory() android.Module {
|
||||
|
||||
// For bp2build conversion.
|
||||
type bazelObjectAttributes struct {
|
||||
Srcs bazel.LabelList
|
||||
Deps bazel.LabelList
|
||||
Srcs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Copts bazel.StringListAttribute
|
||||
Local_include_dirs []string
|
||||
}
|
||||
@@ -147,14 +147,16 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
||||
|
||||
// Set arch-specific configurable attributes
|
||||
var copts bazel.StringListAttribute
|
||||
var srcs []string
|
||||
var excludeSrcs []string
|
||||
var srcs bazel.LabelListAttribute
|
||||
var localIncludeDirs []string
|
||||
for _, props := range m.compiler.compilerProps() {
|
||||
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
|
||||
copts.Value = baseCompilerProps.Cflags
|
||||
srcs = baseCompilerProps.Srcs
|
||||
excludeSrcs = baseCompilerProps.Exclude_srcs
|
||||
srcs = bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrcExcludes(
|
||||
ctx,
|
||||
baseCompilerProps.Srcs,
|
||||
baseCompilerProps.Exclude_srcs))
|
||||
localIncludeDirs = baseCompilerProps.Local_include_dirs
|
||||
break
|
||||
}
|
||||
@@ -164,22 +166,23 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
||||
localIncludeDirs = append(localIncludeDirs, ".")
|
||||
}
|
||||
|
||||
var deps bazel.LabelList
|
||||
var deps bazel.LabelListAttribute
|
||||
for _, props := range m.linker.linkerProps() {
|
||||
if objectLinkerProps, ok := props.(*ObjectLinkerProperties); ok {
|
||||
deps = android.BazelLabelForModuleDeps(ctx, objectLinkerProps.Objs)
|
||||
deps = bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleDeps(ctx, objectLinkerProps.Objs))
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
copts.SetValueForArch(arch.Name, cProps.Cflags)
|
||||
}
|
||||
}
|
||||
copts.SetValueForArch("default", []string{})
|
||||
|
||||
attrs := &bazelObjectAttributes{
|
||||
Srcs: android.BazelLabelForModuleSrcExcludes(ctx, srcs, excludeSrcs),
|
||||
Srcs: srcs,
|
||||
Deps: deps,
|
||||
Copts: copts,
|
||||
Local_include_dirs: localIncludeDirs,
|
||||
|
Reference in New Issue
Block a user