Make the cflags property configurable

So that you can use select statements on it. The current modivation
is to convert a module from make to bp with minimal soong config
variable boilerplate.

Bug: 342006386
Bug: 346922064
Test: m nothing --no-skip-soong-tests
Change-Id: I48d5a11ad3aa65c24cc199458634a5fdbeab2f64
This commit is contained in:
Cole Faust
2024-06-13 14:51:14 -07:00
parent a551b011d0
commit e96c16a806
5 changed files with 19 additions and 13 deletions

View File

@@ -149,7 +149,7 @@ type StaticOrSharedProperties struct {
Sanitized Sanitized `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
@@ -464,9 +464,9 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
}
if library.static() {
flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags...)
flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags.GetOrDefault(ctx, nil)...)
} else if library.shared() {
flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags...)
flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags.GetOrDefault(ctx, nil)...)
}
if library.shared() {
@@ -2081,8 +2081,8 @@ func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Mod
// Check libraries in addition to cflags, since libraries may be exporting different
// include directories.
if len(staticCompiler.StaticProperties.Static.Cflags) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Cflags) == 0 &&
if len(staticCompiler.StaticProperties.Static.Cflags.GetOrDefault(mctx, nil)) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Cflags.GetOrDefault(mctx, nil)) == 0 &&
len(staticCompiler.StaticProperties.Static.Whole_static_libs) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Whole_static_libs) == 0 &&
len(staticCompiler.StaticProperties.Static.Static_libs) == 0 &&