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
This commit is contained in:
@@ -74,11 +74,11 @@ var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterP
|
||||
type prebuiltEtcProperties struct {
|
||||
// Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
|
||||
// Mutually exclusive with srcs.
|
||||
Src *string `android:"path,arch_variant"`
|
||||
Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
|
||||
|
||||
// Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
|
||||
// Mutually exclusive with src. When used, filename_from_src is set to true.
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
|
||||
|
||||
// Optional name for the installed file. If unspecified, name of the module is used as the file
|
||||
// name. Only available when using a single source (src).
|
||||
@@ -158,6 +158,8 @@ type PrebuiltEtc struct {
|
||||
installDirPath android.InstallPath
|
||||
additionalDependencies *android.Paths
|
||||
|
||||
usedSrcsProperty bool
|
||||
|
||||
makeClass string
|
||||
}
|
||||
|
||||
@@ -247,10 +249,10 @@ func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation
|
||||
}
|
||||
|
||||
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
|
||||
if len(p.properties.Srcs) > 0 {
|
||||
if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
|
||||
panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
|
||||
}
|
||||
return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
|
||||
return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
|
||||
}
|
||||
|
||||
func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
|
||||
@@ -264,7 +266,7 @@ func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
|
||||
}
|
||||
|
||||
func (p *PrebuiltEtc) OutputFile() android.OutputPath {
|
||||
if len(p.properties.Srcs) > 0 {
|
||||
if p.usedSrcsProperty {
|
||||
panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
|
||||
}
|
||||
return p.outputFilePaths[0]
|
||||
@@ -319,7 +321,9 @@ func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
|
||||
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
var installs []installProperties
|
||||
|
||||
if p.properties.Src != nil && len(p.properties.Srcs) > 0 {
|
||||
srcProperty := p.properties.Src.Get(ctx)
|
||||
srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
|
||||
if srcProperty.IsPresent() && len(srcsProperty) > 0 {
|
||||
ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
|
||||
}
|
||||
|
||||
@@ -331,8 +335,8 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
filename := proptools.String(p.properties.Filename)
|
||||
filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
|
||||
if p.properties.Src != nil {
|
||||
p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{proptools.String(p.properties.Src)})
|
||||
if srcProperty.IsPresent() {
|
||||
p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
|
||||
// If the source was not found, set a fake source path to
|
||||
// support AllowMissingDependencies executions.
|
||||
if len(p.sourceFilePaths) == 0 {
|
||||
@@ -367,7 +371,8 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
symlinks: p.properties.Symlinks,
|
||||
}
|
||||
installs = append(installs, ip)
|
||||
} else if len(p.properties.Srcs) > 0 {
|
||||
} else if len(srcsProperty) > 0 {
|
||||
p.usedSrcsProperty = true
|
||||
if filename != "" {
|
||||
ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
|
||||
}
|
||||
@@ -377,7 +382,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if p.properties.Filename_from_src != nil {
|
||||
ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
|
||||
}
|
||||
p.sourceFilePaths = android.PathsForModuleSrc(ctx, p.properties.Srcs)
|
||||
p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
|
||||
for _, src := range p.sourceFilePaths {
|
||||
filename := src.Base()
|
||||
output := android.PathForModuleOut(ctx, filename).OutputPath
|
||||
|
Reference in New Issue
Block a user