Merge "Convert some properties to Configurable properties" into main am: c6b5fdbc5c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3095915 Change-Id: I9d13a27541e62e82b0e23708740473d40cb15c30 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
655c526ec2
4 changed files with 31 additions and 20 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -36,9 +37,9 @@ func RegisterFilegroupBuildComponents(ctx RegistrationContext) {
|
||||||
|
|
||||||
type fileGroupProperties struct {
|
type fileGroupProperties struct {
|
||||||
// srcs lists files that will be included in this filegroup
|
// srcs lists files that will be included in this filegroup
|
||||||
Srcs []string `android:"path"`
|
Srcs proptools.Configurable[[]string] `android:"path"`
|
||||||
|
|
||||||
Exclude_srcs []string `android:"path"`
|
Exclude_srcs proptools.Configurable[[]string] `android:"path"`
|
||||||
|
|
||||||
// The base path to the files. May be used by other modules to determine which portion
|
// The base path to the files. May be used by other modules to determine which portion
|
||||||
// of the path to use. For example, when a filegroup is used as data in a cc_test rule,
|
// of the path to use. For example, when a filegroup is used as data in a cc_test rule,
|
||||||
|
@ -89,7 +90,7 @@ func (fg *fileGroup) JSONActions() []blueprint.JSONAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
|
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
fg.srcs = PathsForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs)
|
fg.srcs = PathsForModuleSrcExcludes(ctx, fg.properties.Srcs.GetOrDefault(ctx, nil), fg.properties.Exclude_srcs.GetOrDefault(ctx, nil))
|
||||||
if fg.properties.Path != nil {
|
if fg.properties.Path != nil {
|
||||||
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
|
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,11 @@ var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterP
|
||||||
type prebuiltEtcProperties struct {
|
type prebuiltEtcProperties struct {
|
||||||
// Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
|
// Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
|
||||||
// Mutually exclusive with srcs.
|
// 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.
|
// 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.
|
// 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
|
// 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).
|
// name. Only available when using a single source (src).
|
||||||
|
@ -158,6 +158,8 @@ type PrebuiltEtc struct {
|
||||||
installDirPath android.InstallPath
|
installDirPath android.InstallPath
|
||||||
additionalDependencies *android.Paths
|
additionalDependencies *android.Paths
|
||||||
|
|
||||||
|
usedSrcsProperty bool
|
||||||
|
|
||||||
makeClass string
|
makeClass string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +249,10 @@ func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
|
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()))
|
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 {
|
func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
|
||||||
|
@ -264,7 +266,7 @@ func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltEtc) OutputFile() android.OutputPath {
|
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()))
|
panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
|
||||||
}
|
}
|
||||||
return p.outputFilePaths[0]
|
return p.outputFilePaths[0]
|
||||||
|
@ -319,7 +321,9 @@ func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
|
||||||
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var installs []installProperties
|
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")
|
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)
|
filename := proptools.String(p.properties.Filename)
|
||||||
filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
|
filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
|
||||||
if p.properties.Src != nil {
|
if srcProperty.IsPresent() {
|
||||||
p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{proptools.String(p.properties.Src)})
|
p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
|
||||||
// If the source was not found, set a fake source path to
|
// If the source was not found, set a fake source path to
|
||||||
// support AllowMissingDependencies executions.
|
// support AllowMissingDependencies executions.
|
||||||
if len(p.sourceFilePaths) == 0 {
|
if len(p.sourceFilePaths) == 0 {
|
||||||
|
@ -367,7 +371,8 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
symlinks: p.properties.Symlinks,
|
symlinks: p.properties.Symlinks,
|
||||||
}
|
}
|
||||||
installs = append(installs, ip)
|
installs = append(installs, ip)
|
||||||
} else if len(p.properties.Srcs) > 0 {
|
} else if len(srcsProperty) > 0 {
|
||||||
|
p.usedSrcsProperty = true
|
||||||
if filename != "" {
|
if filename != "" {
|
||||||
ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
|
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 {
|
if p.properties.Filename_from_src != nil {
|
||||||
ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
|
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 {
|
for _, src := range p.sourceFilePaths {
|
||||||
filename := src.Base()
|
filename := src.Base()
|
||||||
output := android.PathForModuleOut(ctx, filename).OutputPath
|
output := android.PathForModuleOut(ctx, filename).OutputPath
|
||||||
|
|
|
@ -197,7 +197,7 @@ type BaseCompilerProperties struct {
|
||||||
Features []string `android:"arch_variant"`
|
Features []string `android:"arch_variant"`
|
||||||
|
|
||||||
// list of configuration options to enable for this crate. To enable features, use the "features" property.
|
// 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
|
// specific rust edition that should be used if the default version is not desired
|
||||||
Edition *string `android:"arch_variant"`
|
Edition *string `android:"arch_variant"`
|
||||||
|
@ -338,7 +338,7 @@ func (compiler *baseCompiler) compilerProps() []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func cfgsToFlags(cfgs []string) []string {
|
func cfgsToFlags(cfgs []string) []string {
|
||||||
flags := []string{}
|
flags := make([]string, 0, len(cfgs))
|
||||||
for _, cfg := range cfgs {
|
for _, cfg := range cfgs {
|
||||||
flags = append(flags, "--cfg '"+cfg+"'")
|
flags = append(flags, "--cfg '"+cfg+"'")
|
||||||
}
|
}
|
||||||
|
@ -385,8 +385,9 @@ func CommonDefaultCfgFlags(flags Flags, vendor bool, product bool) Flags {
|
||||||
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
|
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
flags = CommonDefaultCfgFlags(flags, ctx.RustModule().InVendor(), ctx.RustModule().InProduct())
|
flags = CommonDefaultCfgFlags(flags, ctx.RustModule().InVendor(), ctx.RustModule().InProduct())
|
||||||
|
|
||||||
flags.RustFlags = append(flags.RustFlags, cfgsToFlags(compiler.Properties.Cfgs)...)
|
cfgFlags := cfgsToFlags(compiler.Properties.Cfgs.GetOrDefault(ctx, nil))
|
||||||
flags.RustdocFlags = append(flags.RustdocFlags, cfgsToFlags(compiler.Properties.Cfgs)...)
|
flags.RustFlags = append(flags.RustFlags, cfgFlags...)
|
||||||
|
flags.RustdocFlags = append(flags.RustdocFlags, cfgFlags...)
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,15 +504,19 @@ func (library *libraryDecorator) cfgFlags(ctx ModuleContext, flags Flags) Flags
|
||||||
flags = library.baseCompiler.cfgFlags(ctx, flags)
|
flags = library.baseCompiler.cfgFlags(ctx, flags)
|
||||||
flags = CommonLibraryCfgFlags(ctx, flags)
|
flags = CommonLibraryCfgFlags(ctx, flags)
|
||||||
|
|
||||||
|
cfgs := library.baseCompiler.Properties.Cfgs.GetOrDefault(ctx, nil)
|
||||||
|
|
||||||
if library.dylib() {
|
if library.dylib() {
|
||||||
// We need to add a dependency on std in order to link crates as dylibs.
|
// 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
|
// 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.
|
// 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)...)
|
cfgFlags := cfgsToFlags(cfgs)
|
||||||
flags.RustdocFlags = append(flags.RustdocFlags, cfgsToFlags(library.baseCompiler.Properties.Cfgs)...)
|
|
||||||
|
flags.RustFlags = append(flags.RustFlags, cfgFlags...)
|
||||||
|
flags.RustdocFlags = append(flags.RustdocFlags, cfgFlags...)
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue