Convert some properties to Configurable properties
Focusing on the properties needed to remove soong config modules from
packages/modules/Virtualization.
- prebuilt_etc's src and srcs
- filegroup's srcs and exclude_srcs
- rust's cfgs
Bug: 342006386
Test: m nothing --no-skip-soong-tests
Change-Id: I6971da744a17955f98104948e6f9614776955782
diff --git a/rust/compiler.go b/rust/compiler.go
index efc3dee..a2546a1 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -197,7 +197,7 @@
Features []string `android:"arch_variant"`
// list of configuration options to enable for this crate. To enable features, use the "features" property.
- Cfgs []string `android:"arch_variant"`
+ Cfgs proptools.Configurable[[]string] `android:"arch_variant"`
// specific rust edition that should be used if the default version is not desired
Edition *string `android:"arch_variant"`
@@ -338,7 +338,7 @@
}
func cfgsToFlags(cfgs []string) []string {
- flags := []string{}
+ flags := make([]string, 0, len(cfgs))
for _, cfg := range cfgs {
flags = append(flags, "--cfg '"+cfg+"'")
}
@@ -385,8 +385,9 @@
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
flags = CommonDefaultCfgFlags(flags, ctx.RustModule().InVendor(), ctx.RustModule().InProduct())
- flags.RustFlags = append(flags.RustFlags, cfgsToFlags(compiler.Properties.Cfgs)...)
- flags.RustdocFlags = append(flags.RustdocFlags, cfgsToFlags(compiler.Properties.Cfgs)...)
+ cfgFlags := cfgsToFlags(compiler.Properties.Cfgs.GetOrDefault(ctx, nil))
+ flags.RustFlags = append(flags.RustFlags, cfgFlags...)
+ flags.RustdocFlags = append(flags.RustdocFlags, cfgFlags...)
return flags
}
diff --git a/rust/library.go b/rust/library.go
index 1eb0c5e..2a21263 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -504,15 +504,19 @@
flags = library.baseCompiler.cfgFlags(ctx, flags)
flags = CommonLibraryCfgFlags(ctx, flags)
+ cfgs := library.baseCompiler.Properties.Cfgs.GetOrDefault(ctx, nil)
+
if library.dylib() {
// We need to add a dependency on std in order to link crates as dylibs.
// The hack to add this dependency is guarded by the following cfg so
// that we don't force a dependency when it isn't needed.
- library.baseCompiler.Properties.Cfgs = append(library.baseCompiler.Properties.Cfgs, "android_dylib")
+ cfgs = append(cfgs, "android_dylib")
}
- flags.RustFlags = append(flags.RustFlags, cfgsToFlags(library.baseCompiler.Properties.Cfgs)...)
- flags.RustdocFlags = append(flags.RustdocFlags, cfgsToFlags(library.baseCompiler.Properties.Cfgs)...)
+ cfgFlags := cfgsToFlags(cfgs)
+
+ flags.RustFlags = append(flags.RustFlags, cfgFlags...)
+ flags.RustdocFlags = append(flags.RustdocFlags, cfgFlags...)
return flags
}