Replace ctx.ExpandSources with android.PathsForModuleSrc
Move the logic from ctx.ExpandSources into android.PathsForModuleSrc and ctx.ExpandSource into android.PathForModuleSrc, and deprecate them. When combined with the pathDepsMutator this will let all properties that take source paths also take filegroups or genrule outputs, as long as they are tagged with `android:"path"`. Test: All soong tests Change-Id: I01625e76b5da19240e9649bf26a014eeeafcab8f
This commit is contained in:
@@ -130,7 +130,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani
|
||||
// Find implicit or explicit asset and resource dirs
|
||||
assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets")
|
||||
resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res")
|
||||
resourceZips := ctx.ExpandSources(a.aaptProperties.Resource_zips, nil)
|
||||
resourceZips := android.PathsForModuleSrc(ctx, a.aaptProperties.Resource_zips)
|
||||
|
||||
var linkDeps android.Paths
|
||||
|
||||
|
@@ -470,7 +470,7 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
a.generateAndroidBuildActions(ctx)
|
||||
|
||||
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites)
|
||||
a.data = ctx.ExpandSources(a.testProperties.Data, nil)
|
||||
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
|
||||
}
|
||||
|
||||
func (a *AndroidTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
@@ -696,7 +696,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||
})
|
||||
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
|
||||
// may contain filegroup or genrule.
|
||||
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
|
||||
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
||||
flags := j.collectAidlFlags(ctx, deps)
|
||||
srcFiles = j.genSources(ctx, srcFiles, flags)
|
||||
|
||||
@@ -715,12 +715,12 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||
}
|
||||
j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
|
||||
|
||||
j.argFiles = ctx.ExpandSources(j.properties.Arg_files, nil)
|
||||
j.argFiles = android.PathsForModuleSrc(ctx, j.properties.Arg_files)
|
||||
argFilesMap := map[string]string{}
|
||||
argFileLabels := []string{}
|
||||
|
||||
for _, label := range j.properties.Arg_files {
|
||||
var paths = ctx.ExpandSources([]string{label}, nil)
|
||||
var paths = android.PathsForModuleSrc(ctx, []string{label})
|
||||
if _, exists := argFilesMap[label]; !exists {
|
||||
argFilesMap[label] = strings.Join(paths.Strings(), " ")
|
||||
argFileLabels = append(argFileLabels, label)
|
||||
@@ -936,13 +936,13 @@ func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits
|
||||
|
||||
if len(d.properties.Html_dirs) > 0 {
|
||||
htmlDir := d.properties.Html_dirs[0]
|
||||
*implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(d.properties.Html_dirs[0], "**/*")}, nil)...)
|
||||
*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(d.properties.Html_dirs[0], "**/*")})...)
|
||||
args = args + " -htmldir " + htmlDir
|
||||
}
|
||||
|
||||
if len(d.properties.Html_dirs) > 1 {
|
||||
htmlDir2 := d.properties.Html_dirs[1]
|
||||
*implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(htmlDir2, "**/*")}, nil)...)
|
||||
*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(htmlDir2, "**/*")})...)
|
||||
args = args + " -htmldir2 " + htmlDir2
|
||||
}
|
||||
|
||||
@@ -950,7 +950,7 @@ func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits
|
||||
ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs")
|
||||
}
|
||||
|
||||
knownTags := ctx.ExpandSources(d.properties.Knowntags, nil)
|
||||
knownTags := android.PathsForModuleSrc(ctx, d.properties.Knowntags)
|
||||
*implicits = append(*implicits, knownTags...)
|
||||
|
||||
for _, kt := range knownTags {
|
||||
@@ -1415,12 +1415,12 @@ func (d *Droidstubs) collectAnnotationsFlags(ctx android.ModuleContext,
|
||||
"has to be non-empty if annotations was enabled (unless validating nullability)")
|
||||
}
|
||||
if migratingNullability {
|
||||
previousApi := ctx.ExpandSource(String(d.properties.Previous_api), "previous_api")
|
||||
previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
|
||||
*implicits = append(*implicits, previousApi)
|
||||
flags += " --migrate-nullness " + previousApi.String()
|
||||
}
|
||||
if s := String(d.properties.Validate_nullability_from_list); s != "" {
|
||||
flags += " --validate-nullability-from-list " + ctx.ExpandSource(s, "validate_nullability_from_list").String()
|
||||
flags += " --validate-nullability-from-list " + android.PathForModuleSrc(ctx, s).String()
|
||||
}
|
||||
if validatingNullability {
|
||||
d.nullabilityWarningsFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_nullability_warnings.txt")
|
||||
@@ -1793,7 +1793,7 @@ func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {}
|
||||
func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
path := String(d.properties.Path)
|
||||
d.dir = android.PathForModuleSrc(ctx, path)
|
||||
d.deps = ctx.ExpandSources([]string{filepath.Join(path, "**/*")}, nil)
|
||||
d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
|
||||
}
|
||||
|
||||
//
|
||||
|
14
java/java.go
14
java/java.go
@@ -942,7 +942,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
||||
if flags.javaVersion == "1.9" {
|
||||
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
|
||||
}
|
||||
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
|
||||
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
||||
if hasSrcExt(srcFiles.Strings(), ".proto") {
|
||||
flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
|
||||
}
|
||||
@@ -958,7 +958,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
||||
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...)
|
||||
|
||||
if j.properties.Jarjar_rules != nil {
|
||||
j.expandJarjarRules = ctx.ExpandSource(*j.properties.Jarjar_rules, "jarjar_rules")
|
||||
j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||
}
|
||||
|
||||
jarName := ctx.ModuleName() + ".jar"
|
||||
@@ -1133,10 +1133,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
||||
|
||||
manifest := j.overrideManifest
|
||||
if !manifest.Valid() && j.properties.Manifest != nil {
|
||||
manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
|
||||
manifest = android.OptionalPathForPath(android.PathForModuleSrc(ctx, *j.properties.Manifest))
|
||||
}
|
||||
|
||||
services := ctx.ExpandSources(j.properties.Services, nil)
|
||||
services := android.PathsForModuleSrc(ctx, j.properties.Services)
|
||||
if len(services) > 0 {
|
||||
servicesJar := android.PathForModuleOut(ctx, "services", jarName)
|
||||
var zipargs []string
|
||||
@@ -1547,7 +1547,7 @@ type Test struct {
|
||||
|
||||
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites)
|
||||
j.data = ctx.ExpandSources(j.testProperties.Data, nil)
|
||||
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
|
||||
|
||||
j.Library.GenerateAndroidBuildActions(ctx)
|
||||
}
|
||||
@@ -1641,7 +1641,7 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.isWrapperVariant = true
|
||||
|
||||
if j.binaryProperties.Wrapper != nil {
|
||||
j.wrapperFile = ctx.ExpandSource(*j.binaryProperties.Wrapper, "wrapper")
|
||||
j.wrapperFile = android.PathForModuleSrc(ctx, *j.binaryProperties.Wrapper)
|
||||
} else {
|
||||
j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
|
||||
}
|
||||
@@ -1765,7 +1765,7 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
jars := ctx.ExpandSources(j.properties.Jars, nil)
|
||||
jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
|
||||
|
||||
jarName := ctx.ModuleName() + ".jar"
|
||||
outputFile := android.PathForModuleOut(ctx, "combined", jarName)
|
||||
|
@@ -46,7 +46,7 @@ func ResourceDirsToJarArgs(ctx android.ModuleContext,
|
||||
}
|
||||
}
|
||||
|
||||
excludeFiles = append(excludeFiles, ctx.ExpandSources(excludeResourceFiles, nil).Strings()...)
|
||||
excludeFiles = append(excludeFiles, android.PathsForModuleSrc(ctx, excludeResourceFiles).Strings()...)
|
||||
|
||||
excludeFiles = append(excludeFiles, resourceExcludes...)
|
||||
|
||||
@@ -96,7 +96,7 @@ func SourceFilesToJarArgs(ctx android.ModuleContext,
|
||||
func resourceFilesToJarArgs(ctx android.ModuleContext,
|
||||
res, exclude []string) (args []string, deps android.Paths) {
|
||||
|
||||
files := ctx.ExpandSources(res, exclude)
|
||||
files := android.PathsForModuleSrcExcludes(ctx, res, exclude)
|
||||
|
||||
lastDir := ""
|
||||
for i, f := range files {
|
||||
|
Reference in New Issue
Block a user