Add support for variant_prepend properties in bp2build for cc library

Some properties in soong are marked "variant_prepend", which means
in bp2build output, variant properties(select ...) should come before
general properties.
Prepend property is added in StringListAttribute
stuct so that bp2build can handlle variant_prepend properly, if
Prepend is properly set in different module logics.
This change also coordinates cc library with Prepend.
Coordination with other module types will be in separate CLs.

Bug: 261644490
Test: TestCcLibraryHeadersSimple,
TestCcLibraryHeadersArchAndTargetExportSystemIncludes and TH

Change-Id: I3b61c491c54bbe91ba9aa2af9b4c84193c91ae7f
This commit is contained in:
Zi Wang
2022-12-09 16:08:54 -08:00
parent c0f432edfd
commit 1cb11800f7
4 changed files with 45 additions and 22 deletions

View File

@@ -1257,6 +1257,13 @@ func bp2BuildParseExportedIncludes(ctx android.BazelConversionPathContext, modul
} else {
exported = BazelIncludes{}
}
// cc library Export_include_dirs and Export_system_include_dirs are marked
// "variant_prepend" in struct tag, set their prepend property to true to make
// sure bp2build generates correct result.
exported.Includes.Prepend = true
exported.SystemIncludes.Prepend = true
bp2BuildPropParseHelper(ctx, module, &FlagExporterProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
if len(flagExporterProperties.Export_include_dirs) > 0 {