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:
Colin Cross
2019-03-05 22:25:09 -08:00
parent 07e51619a2
commit 8a49795df1
22 changed files with 368 additions and 193 deletions

View File

@@ -256,7 +256,7 @@ func addToModuleList(ctx ModuleContext, key android.OnceKey, module string) {
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
tc := ctx.toolchain()
compiler.srcsBeforeGen = ctx.ExpandSources(compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
CheckBadCompilerFlags(ctx, "cflags", compiler.Properties.Cflags)

View File

@@ -450,11 +450,11 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
buildFlags := flagsToBuilderFlags(flags)
if library.static() {
srcs := ctx.ExpandSources(library.Properties.Static.Srcs, nil)
srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
} else if library.shared() {
srcs := ctx.ExpandSources(library.Properties.Shared.Srcs, nil)
srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
}

View File

@@ -140,7 +140,7 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return
}
srcFiles := ctx.ExpandSources(m.properties.Srcs, m.properties.Exclude_srcs)
srcFiles := android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
for _, header := range srcFiles {
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
String(m.properties.To))
@@ -338,7 +338,7 @@ func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.Modu
preprocessor := android.PathForModuleSrc(ctx, String(m.properties.Preprocessor))
m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License))
srcFiles := ctx.ExpandSources(m.properties.Srcs, m.properties.Exclude_srcs)
srcFiles := android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
installDir := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
for _, src := range srcFiles {
installPath := installDir.Join(ctx, src.Base())

View File

@@ -253,7 +253,7 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
}
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
test.data = ctx.ExpandSources(test.Properties.Data, nil)
test.data = android.PathsForModuleSrc(ctx, test.Properties.Data)
optionsMap := map[string]string{}
if Bool(test.testDecorator.Properties.Isolated) {
optionsMap["not-shardable"] = "true"
@@ -378,7 +378,7 @@ func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps
}
func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
benchmark.data = ctx.ExpandSources(benchmark.Properties.Data, nil)
benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data)
benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config,
benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites)

View File

@@ -178,5 +178,5 @@ func newTest() android.Module {
}
func (test *testDataTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
test.data = ctx.ExpandSources(test.Properties.Data, nil)
test.data = android.PathsForModuleSrc(ctx, test.Properties.Data)
}