Handle no generated headers and exporting for xsd
Test: new bp2build unit tests Test: build libvintf Change-Id: I2c7bf409b30d78fcf6762d69139e3249a2b0d368
This commit is contained in:
@@ -940,12 +940,8 @@ var (
|
|||||||
|
|
||||||
//system/libvintf
|
//system/libvintf
|
||||||
// depends on apex-info-list-tinyxml, unconverted xsd_config Soong module type.
|
// depends on apex-info-list-tinyxml, unconverted xsd_config Soong module type.
|
||||||
"libvintf",
|
|
||||||
"vintf",
|
|
||||||
"libassemblevintf",
|
"libassemblevintf",
|
||||||
"assemble_vintf",
|
"assemble_vintf",
|
||||||
"libvintffm",
|
|
||||||
"vintffm",
|
|
||||||
"checkvintf",
|
"checkvintf",
|
||||||
|
|
||||||
// depends on audio_policy_configuration_aidl_default, xsd_config module.
|
// depends on audio_policy_configuration_aidl_default, xsd_config module.
|
||||||
|
@@ -398,6 +398,9 @@ type compilerAttributes struct {
|
|||||||
cppFlags bazel.StringListAttribute
|
cppFlags bazel.StringListAttribute
|
||||||
srcs bazel.LabelListAttribute
|
srcs bazel.LabelListAttribute
|
||||||
|
|
||||||
|
// xsd config sources
|
||||||
|
xsdInSrcs bazel.StringListAttribute
|
||||||
|
|
||||||
// Lex sources and options
|
// Lex sources and options
|
||||||
lSrcs bazel.LabelListAttribute
|
lSrcs bazel.LabelListAttribute
|
||||||
llSrcs bazel.LabelListAttribute
|
llSrcs bazel.LabelListAttribute
|
||||||
@@ -484,9 +487,14 @@ func parseCommandLineFlags(soongFlags []string, filterOut ...filterOutFn) []stri
|
|||||||
func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis, config string, props *BaseCompilerProperties) {
|
func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis, config string, props *BaseCompilerProperties) {
|
||||||
// If there's arch specific srcs or exclude_srcs, generate a select entry for it.
|
// If there's arch specific srcs or exclude_srcs, generate a select entry for it.
|
||||||
// TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
|
// TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
|
||||||
if srcsList, ok := parseSrcs(ctx, props); ok {
|
srcsList, xsdList, ok := parseSrcs(ctx, props)
|
||||||
|
|
||||||
|
if ok {
|
||||||
ca.srcs.SetSelectValue(axis, config, srcsList)
|
ca.srcs.SetSelectValue(axis, config, srcsList)
|
||||||
}
|
}
|
||||||
|
if len(xsdList) > 0 {
|
||||||
|
ca.xsdInSrcs.SetSelectValue(axis, config, xsdList)
|
||||||
|
}
|
||||||
|
|
||||||
localIncludeDirs := props.Local_include_dirs
|
localIncludeDirs := props.Local_include_dirs
|
||||||
if axis == bazel.NoConfigAxis {
|
if axis == bazel.NoConfigAxis {
|
||||||
@@ -588,11 +596,11 @@ func (ca *compilerAttributes) finalize(ctx android.BazelConversionPathContext, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse srcs from an arch or OS's props value.
|
// Parse srcs from an arch or OS's props value.
|
||||||
func parseSrcs(ctx android.BazelConversionPathContext, props *BaseCompilerProperties) (bazel.LabelList, bool) {
|
func parseSrcs(ctx android.BazelConversionPathContext, props *BaseCompilerProperties) (bazel.LabelList, []string, bool) {
|
||||||
anySrcs := false
|
anySrcs := false
|
||||||
// Add srcs-like dependencies such as generated files.
|
// Add srcs-like dependencies such as generated files.
|
||||||
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
||||||
genSrcs, _ := android.PartitionXsdSrcs(ctx, props.Generated_sources)
|
genSrcs, xsd := android.PartitionXsdSrcs(ctx, props.Generated_sources)
|
||||||
generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, genSrcs, props.Exclude_generated_sources)
|
generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, genSrcs, props.Exclude_generated_sources)
|
||||||
if len(props.Generated_sources) > 0 || len(props.Exclude_generated_sources) > 0 {
|
if len(props.Generated_sources) > 0 || len(props.Exclude_generated_sources) > 0 {
|
||||||
anySrcs = true
|
anySrcs = true
|
||||||
@@ -604,7 +612,7 @@ func parseSrcs(ctx android.BazelConversionPathContext, props *BaseCompilerProper
|
|||||||
anySrcs = true
|
anySrcs = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), anySrcs
|
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), xsd, anySrcs
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildStdVal(std *string, prefix string, useGnu bool) *string {
|
func bp2buildStdVal(std *string, prefix string, useGnu bool) *string {
|
||||||
@@ -718,14 +726,6 @@ func bp2BuildYasm(ctx android.Bp2buildMutatorContext, m *Module, ca compilerAttr
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-cpp
|
|
||||||
func xsdConfigCppTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
|
|
||||||
callback := func(xsd android.XsdConfigBp2buildTargets) string {
|
|
||||||
return xsd.CppBp2buildTargetName()
|
|
||||||
}
|
|
||||||
return android.XsdConfigBp2buildTarget(ctx, mod, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
// bp2BuildParseBaseProps returns all compiler, linker, library attributes of a cc module..
|
// bp2BuildParseBaseProps returns all compiler, linker, library attributes of a cc module..
|
||||||
func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) baseAttributes {
|
func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) baseAttributes {
|
||||||
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
||||||
@@ -762,15 +762,9 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
for _, axis := range bazel.SortedConfigurationAxes(axisToConfigs) {
|
for _, axis := range bazel.SortedConfigurationAxes(axisToConfigs) {
|
||||||
configs := axisToConfigs[axis]
|
configs := axisToConfigs[axis]
|
||||||
for cfg := range configs {
|
for cfg := range configs {
|
||||||
var allHdrs []string
|
var allHdrs, allHdrsXsd []string
|
||||||
if baseCompilerProps, ok := archVariantCompilerProps[axis][cfg].(*BaseCompilerProperties); ok {
|
if baseCompilerProps, ok := archVariantCompilerProps[axis][cfg].(*BaseCompilerProperties); ok {
|
||||||
ah, allHdrsXsd := android.PartitionXsdSrcs(ctx, baseCompilerProps.Generated_headers)
|
allHdrs, allHdrsXsd = android.PartitionXsdSrcs(ctx, baseCompilerProps.Generated_headers)
|
||||||
allHdrs = ah
|
|
||||||
// in the synthetic bp2build workspace, xsd sources are compiled to a static library
|
|
||||||
xsdCppConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, allHdrsXsd, xsdConfigCppTarget)
|
|
||||||
iwad := linkerAttrs.implementationWholeArchiveDeps.SelectValue(axis, cfg)
|
|
||||||
(&iwad).Append(xsdCppConfigLibraryLabels)
|
|
||||||
linkerAttrs.implementationWholeArchiveDeps.SetSelectValue(axis, cfg, bazel.FirstUniqueBazelLabelList(iwad))
|
|
||||||
|
|
||||||
if baseCompilerProps.Lex != nil {
|
if baseCompilerProps.Lex != nil {
|
||||||
compilerAttrs.lexopts.SetSelectValue(axis, cfg, baseCompilerProps.Lex.Flags)
|
compilerAttrs.lexopts.SetSelectValue(axis, cfg, baseCompilerProps.Lex.Flags)
|
||||||
@@ -784,14 +778,19 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
aidlLibs.Append(android.BazelLabelForModuleDeps(ctx, baseCompilerProps.Aidl.Libs))
|
aidlLibs.Append(android.BazelLabelForModuleDeps(ctx, baseCompilerProps.Aidl.Libs))
|
||||||
}
|
}
|
||||||
|
|
||||||
var exportHdrs []string
|
var exportHdrs, exportHdrsXsd []string
|
||||||
|
|
||||||
if baseLinkerProps, ok := archVariantLinkerProps[axis][cfg].(*BaseLinkerProperties); ok {
|
if baseLinkerProps, ok := archVariantLinkerProps[axis][cfg].(*BaseLinkerProperties); ok {
|
||||||
exportHdrs = baseLinkerProps.Export_generated_headers
|
exportHdrs, exportHdrsXsd = android.PartitionXsdSrcs(ctx, baseLinkerProps.Export_generated_headers)
|
||||||
|
|
||||||
(&linkerAttrs).bp2buildForAxisAndConfig(ctx, module, axis, cfg, baseLinkerProps)
|
(&linkerAttrs).bp2buildForAxisAndConfig(ctx, module, axis, cfg, baseLinkerProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in the synthetic bp2build workspace, xsd sources are compiled to a static library
|
||||||
|
xsdList := compilerAttrs.xsdInSrcs.SelectValue(axis, cfg)
|
||||||
|
allHdrsXsd = android.FirstUniqueStrings(append(xsdList, allHdrsXsd...))
|
||||||
headers := maybePartitionExportedAndImplementationsDeps(ctx, !module.Binary(), allHdrs, exportHdrs, android.BazelLabelForModuleDeps)
|
headers := maybePartitionExportedAndImplementationsDeps(ctx, !module.Binary(), allHdrs, exportHdrs, android.BazelLabelForModuleDeps)
|
||||||
|
xsdConfigLibs := maybePartitionExportedAndImplementationsDeps(ctx, !module.Binary(), allHdrsXsd, exportHdrsXsd, bazelLabelForXsdConfig)
|
||||||
|
|
||||||
implementationHdrs.SetSelectValue(axis, cfg, headers.implementation)
|
implementationHdrs.SetSelectValue(axis, cfg, headers.implementation)
|
||||||
compilerAttrs.hdrs.SetSelectValue(axis, cfg, headers.export)
|
compilerAttrs.hdrs.SetSelectValue(axis, cfg, headers.export)
|
||||||
|
|
||||||
@@ -827,6 +826,15 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
compilerAttrs.suffix.SetSelectValue(axis, cfg, suffix)
|
compilerAttrs.suffix.SetSelectValue(axis, cfg, suffix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(allHdrsXsd) > 0 {
|
||||||
|
wholeStaticLibs := linkerAttrs.implementationWholeArchiveDeps.SelectValue(axis, cfg)
|
||||||
|
(&wholeStaticLibs).Append(xsdConfigLibs.implementation)
|
||||||
|
linkerAttrs.implementationWholeArchiveDeps.SetSelectValue(axis, cfg, wholeStaticLibs)
|
||||||
|
wholeStaticLibs = linkerAttrs.wholeArchiveDeps.SelectValue(axis, cfg)
|
||||||
|
(&wholeStaticLibs).Append(xsdConfigLibs.export)
|
||||||
|
linkerAttrs.wholeArchiveDeps.SetSelectValue(axis, cfg, wholeStaticLibs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1703,6 +1711,18 @@ func bazelLabelForStaticWholeModuleDeps(ctx android.BazelConversionPathContext,
|
|||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-cpp
|
||||||
|
func xsdConfigCppTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
|
||||||
|
callback := func(xsd android.XsdConfigBp2buildTargets) string {
|
||||||
|
return xsd.CppBp2buildTargetName()
|
||||||
|
}
|
||||||
|
return android.XsdConfigBp2buildTarget(ctx, mod, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bazelLabelForXsdConfig(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||||
|
return android.BazelLabelForModuleDepsWithFn(ctx, modules, xsdConfigCppTarget)
|
||||||
|
}
|
||||||
|
|
||||||
func bazelLabelForWholeDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
func bazelLabelForWholeDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||||
return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticWholeModuleDeps)
|
return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticWholeModuleDeps)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user