Merge "Refactor cc/bp2build.go to use parse helper" am: 4dc57a6d7b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2072288 Change-Id: Ib5980bf23cea4f8663da6c665c50dea288805d6c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
104
cc/bp2build.go
104
cc/bp2build.go
@@ -167,21 +167,17 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo
|
|||||||
attrs.System_dynamic_deps.ForceSpecifyEmptyList = true
|
attrs.System_dynamic_deps.ForceSpecifyEmptyList = true
|
||||||
|
|
||||||
if isStatic {
|
if isStatic {
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &StaticProperties{}) {
|
bp2BuildPropParseHelper(ctx, module, &StaticProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for config, props := range configToProps {
|
if staticOrSharedProps, ok := props.(*StaticProperties); ok {
|
||||||
if staticOrSharedProps, ok := props.(*StaticProperties); ok {
|
setAttrs(axis, config, staticOrSharedProps.Static)
|
||||||
setAttrs(axis, config, staticOrSharedProps.Static)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
} else {
|
} else {
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &SharedProperties{}) {
|
bp2BuildPropParseHelper(ctx, module, &SharedProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for config, props := range configToProps {
|
if staticOrSharedProps, ok := props.(*SharedProperties); ok {
|
||||||
if staticOrSharedProps, ok := props.(*SharedProperties); ok {
|
setAttrs(axis, config, staticOrSharedProps.Shared)
|
||||||
setAttrs(axis, config, staticOrSharedProps.Shared)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
partitionedSrcs := groupSrcsByExtension(ctx, attrs.Srcs)
|
partitionedSrcs := groupSrcsByExtension(ctx, attrs.Srcs)
|
||||||
@@ -359,21 +355,18 @@ func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ca *compilerAttributes) convertStlProps(ctx android.ArchVariantContext, module *Module) {
|
func (ca *compilerAttributes) convertStlProps(ctx android.ArchVariantContext, module *Module) {
|
||||||
stlPropsByArch := module.GetArchVariantProperties(ctx, &StlProperties{})
|
bp2BuildPropParseHelper(ctx, module, &StlProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for _, configToProps := range stlPropsByArch {
|
if stlProps, ok := props.(*StlProperties); ok {
|
||||||
for _, props := range configToProps {
|
if stlProps.Stl == nil {
|
||||||
if stlProps, ok := props.(*StlProperties); ok {
|
return
|
||||||
if stlProps.Stl == nil {
|
}
|
||||||
continue
|
if ca.stl == nil {
|
||||||
}
|
ca.stl = stlProps.Stl
|
||||||
if ca.stl == nil {
|
} else if ca.stl != stlProps.Stl {
|
||||||
ca.stl = stlProps.Stl
|
ctx.ModuleErrorf("Unsupported conversion: module with different stl for different variants: %s and %s", *ca.stl, stlProps.Stl)
|
||||||
} else if ca.stl != stlProps.Stl {
|
|
||||||
ctx.ModuleErrorf("Unsupported conversion: module with different stl for different variants: %s and %s", *ca.stl, stlProps.Stl)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ca *compilerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
func (ca *compilerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
||||||
@@ -713,17 +706,15 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (la *linkerAttributes) convertStripProps(ctx android.BazelConversionPathContext, module *Module) {
|
func (la *linkerAttributes) convertStripProps(ctx android.BazelConversionPathContext, module *Module) {
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &StripProperties{}) {
|
bp2BuildPropParseHelper(ctx, module, &StripProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for config, props := range configToProps {
|
if stripProperties, ok := props.(*StripProperties); ok {
|
||||||
if stripProperties, ok := props.(*StripProperties); ok {
|
la.stripKeepSymbols.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols)
|
||||||
la.stripKeepSymbols.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols)
|
la.stripKeepSymbolsList.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_list)
|
||||||
la.stripKeepSymbolsList.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_list)
|
la.stripKeepSymbolsAndDebugFrame.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_and_debug_frame)
|
||||||
la.stripKeepSymbolsAndDebugFrame.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_and_debug_frame)
|
la.stripAll.SetSelectValue(axis, config, stripProperties.Strip.All)
|
||||||
la.stripAll.SetSelectValue(axis, config, stripProperties.Strip.All)
|
la.stripNone.SetSelectValue(axis, config, stripProperties.Strip.None)
|
||||||
la.stripNone.SetSelectValue(axis, config, stripProperties.Strip.None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (la *linkerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
func (la *linkerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
||||||
@@ -859,18 +850,16 @@ func bp2BuildParseExportedIncludesHelper(ctx android.BazelConversionPathContext,
|
|||||||
} else {
|
} else {
|
||||||
exported = BazelIncludes{}
|
exported = BazelIncludes{}
|
||||||
}
|
}
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &FlagExporterProperties{}) {
|
bp2BuildPropParseHelper(ctx, module, &FlagExporterProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for config, props := range configToProps {
|
if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
|
||||||
if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
|
if len(flagExporterProperties.Export_include_dirs) > 0 {
|
||||||
if len(flagExporterProperties.Export_include_dirs) > 0 {
|
exported.Includes.SetSelectValue(axis, config, android.FirstUniqueStrings(append(exported.Includes.SelectValue(axis, config), flagExporterProperties.Export_include_dirs...)))
|
||||||
exported.Includes.SetSelectValue(axis, config, android.FirstUniqueStrings(append(exported.Includes.SelectValue(axis, config), flagExporterProperties.Export_include_dirs...)))
|
}
|
||||||
}
|
if len(flagExporterProperties.Export_system_include_dirs) > 0 {
|
||||||
if len(flagExporterProperties.Export_system_include_dirs) > 0 {
|
exported.SystemIncludes.SetSelectValue(axis, config, android.FirstUniqueStrings(append(exported.SystemIncludes.SelectValue(axis, config), flagExporterProperties.Export_system_include_dirs...)))
|
||||||
exported.SystemIncludes.SetSelectValue(axis, config, android.FirstUniqueStrings(append(exported.SystemIncludes.SelectValue(axis, config), flagExporterProperties.Export_system_include_dirs...)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
exported.AbsoluteIncludes.DeduplicateAxesFromBase()
|
exported.AbsoluteIncludes.DeduplicateAxesFromBase()
|
||||||
exported.Includes.DeduplicateAxesFromBase()
|
exported.Includes.DeduplicateAxesFromBase()
|
||||||
exported.SystemIncludes.DeduplicateAxesFromBase()
|
exported.SystemIncludes.DeduplicateAxesFromBase()
|
||||||
@@ -938,22 +927,19 @@ type binaryLinkerAttrs struct {
|
|||||||
|
|
||||||
func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module) binaryLinkerAttrs {
|
func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module) binaryLinkerAttrs {
|
||||||
attrs := binaryLinkerAttrs{}
|
attrs := binaryLinkerAttrs{}
|
||||||
archVariantProps := m.GetArchVariantProperties(ctx, &BinaryLinkerProperties{})
|
bp2BuildPropParseHelper(ctx, m, &BinaryLinkerProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||||
for axis, configToProps := range archVariantProps {
|
linkerProps := props.(*BinaryLinkerProperties)
|
||||||
for _, p := range configToProps {
|
staticExecutable := linkerProps.Static_executable
|
||||||
props := p.(*BinaryLinkerProperties)
|
if axis == bazel.NoConfigAxis {
|
||||||
staticExecutable := props.Static_executable
|
if linkBinaryShared := !proptools.Bool(staticExecutable); !linkBinaryShared {
|
||||||
if axis == bazel.NoConfigAxis {
|
attrs.Linkshared = &linkBinaryShared
|
||||||
if linkBinaryShared := !proptools.Bool(staticExecutable); !linkBinaryShared {
|
|
||||||
attrs.Linkshared = &linkBinaryShared
|
|
||||||
}
|
|
||||||
} else if staticExecutable != nil {
|
|
||||||
// TODO(b/202876379): Static_executable is arch-variant; however, linkshared is a
|
|
||||||
// nonconfigurable attribute. Only 4 AOSP modules use this feature, defer handling
|
|
||||||
ctx.ModuleErrorf("bp2build cannot migrate a module with arch/target-specific static_executable values")
|
|
||||||
}
|
}
|
||||||
|
} else if staticExecutable != nil {
|
||||||
|
// TODO(b/202876379): Static_executable is arch-variant; however, linkshared is a
|
||||||
|
// nonconfigurable attribute. Only 4 AOSP modules use this feature, defer handling
|
||||||
|
ctx.ModuleErrorf("bp2build cannot migrate a module with arch/target-specific static_executable values")
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user