Enable bp2build for cc modules relying on sysprop
Bug: 244439349 Test: m bp2build Test: Inspect BUILD.bazel files Test: Unit tests Change-Id: I85bfb9fa69cb3f96b15bdbeb797dba86b3349804
This commit is contained in:
@@ -28,14 +28,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
cSrcPartition = "c"
|
||||
asSrcPartition = "as"
|
||||
asmSrcPartition = "asm"
|
||||
lSrcPartition = "l"
|
||||
llSrcPartition = "ll"
|
||||
cppSrcPartition = "cpp"
|
||||
protoSrcPartition = "proto"
|
||||
aidlSrcPartition = "aidl"
|
||||
cSrcPartition = "c"
|
||||
asSrcPartition = "as"
|
||||
asmSrcPartition = "asm"
|
||||
lSrcPartition = "l"
|
||||
llSrcPartition = "ll"
|
||||
cppSrcPartition = "cpp"
|
||||
protoSrcPartition = "proto"
|
||||
aidlSrcPartition = "aidl"
|
||||
syspropSrcPartition = "sysprop"
|
||||
|
||||
stubsSuffix = "_stub_libs_current"
|
||||
)
|
||||
@@ -104,7 +105,8 @@ func groupSrcsByExtension(ctx android.BazelConversionPathContext, srcs bazel.Lab
|
||||
llSrcPartition: bazel.LabelPartition{Extensions: []string{".ll"}},
|
||||
// C++ is the "catch-all" group, and comprises generated sources because we don't
|
||||
// know the language of these sources until the genrule is executed.
|
||||
cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
|
||||
cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
|
||||
syspropSrcPartition: bazel.LabelPartition{Extensions: []string{".sysprop"}},
|
||||
}
|
||||
|
||||
return bazel.PartitionLabelListAttribute(ctx, &srcs, labels)
|
||||
@@ -320,6 +322,9 @@ type compilerAttributes struct {
|
||||
llSrcs bazel.LabelListAttribute
|
||||
lexopts bazel.StringListAttribute
|
||||
|
||||
// Sysprop sources
|
||||
syspropSrcs bazel.LabelListAttribute
|
||||
|
||||
hdrs bazel.LabelListAttribute
|
||||
|
||||
rtti bazel.BoolAttribute
|
||||
@@ -482,6 +487,7 @@ func (ca *compilerAttributes) finalize(ctx android.BazelConversionPathContext, i
|
||||
ca.asmSrcs = partitionedSrcs[asmSrcPartition]
|
||||
ca.lSrcs = partitionedSrcs[lSrcPartition]
|
||||
ca.llSrcs = partitionedSrcs[llSrcPartition]
|
||||
ca.syspropSrcs = partitionedSrcs[syspropSrcPartition]
|
||||
|
||||
ca.absoluteIncludes.DeduplicateAxesFromBase()
|
||||
ca.localIncludes.DeduplicateAxesFromBase()
|
||||
@@ -734,6 +740,10 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
||||
(&compilerAttrs).srcs.Add(&convertedLSrcs.srcName)
|
||||
(&compilerAttrs).cSrcs.Add(&convertedLSrcs.cSrcName)
|
||||
|
||||
if !compilerAttrs.syspropSrcs.IsEmpty() {
|
||||
(&linkerAttrs).wholeArchiveDeps.Add(bp2buildCcSysprop(ctx, module.Name(), module.Properties.Min_sdk_version, compilerAttrs.syspropSrcs))
|
||||
}
|
||||
|
||||
features := compilerAttrs.features.Clone().Append(linkerAttrs.features)
|
||||
features.DeduplicateAxesFromBase()
|
||||
|
||||
@@ -1208,10 +1218,14 @@ func bp2BuildParseExportedIncludes(ctx android.BazelConversionPathContext, modul
|
||||
return exported
|
||||
}
|
||||
|
||||
func BazelLabelNameForStaticModule(baseLabel string) string {
|
||||
return baseLabel + "_bp2build_cc_library_static"
|
||||
}
|
||||
|
||||
func bazelLabelForStaticModule(ctx android.BazelConversionPathContext, m blueprint.Module) string {
|
||||
label := android.BazelModuleLabel(ctx, m)
|
||||
if ccModule, ok := m.(*Module); ok && ccModule.typ() == fullLibrary && !android.GetBp2BuildAllowList().GenerateCcLibraryStaticOnly(m.Name()) {
|
||||
label += "_bp2build_cc_library_static"
|
||||
return BazelLabelNameForStaticModule(label)
|
||||
}
|
||||
return label
|
||||
}
|
||||
|
Reference in New Issue
Block a user