Merge changes I5400e4b0,Ia6760b01,I8a076c99
* changes: Add test for java generated sources Fix doubled generated source files Fix mixing genrule dependencies with globs
This commit is contained in:
commit
2675f5648b
4 changed files with 41 additions and 14 deletions
|
@ -882,10 +882,10 @@ func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string
|
|||
}
|
||||
} else if pathtools.IsGlob(s) {
|
||||
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), excludes)
|
||||
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
|
||||
for i, s := range expandedSrcFiles {
|
||||
expandedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
||||
for i, s := range globbedSrcFiles {
|
||||
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
||||
}
|
||||
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
|
||||
} else {
|
||||
s := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
|
||||
expandedSrcFiles = append(expandedSrcFiles, s)
|
||||
|
|
|
@ -28,8 +28,8 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
android.RegisterModuleType("gensrcs", genSrcsFactory)
|
||||
android.RegisterModuleType("genrule", genRuleFactory)
|
||||
android.RegisterModuleType("gensrcs", GenSrcsFactory)
|
||||
android.RegisterModuleType("genrule", GenRuleFactory)
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -331,7 +331,7 @@ func NewGenSrcs() *Module {
|
|||
return generatorFactory(tasks, properties)
|
||||
}
|
||||
|
||||
func genSrcsFactory() android.Module {
|
||||
func GenSrcsFactory() android.Module {
|
||||
m := NewGenSrcs()
|
||||
android.InitAndroidModule(m)
|
||||
return m
|
||||
|
@ -361,7 +361,7 @@ func NewGenRule() *Module {
|
|||
return generatorFactory(tasks, properties)
|
||||
}
|
||||
|
||||
func genRuleFactory() android.Module {
|
||||
func GenRuleFactory() android.Module {
|
||||
m := NewGenRule()
|
||||
android.InitAndroidModule(m)
|
||||
return m
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/genrule"
|
||||
"android/soong/java/config"
|
||||
)
|
||||
|
||||
|
@ -437,12 +436,6 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
|||
|
||||
srcFileLists = append(srcFileLists, deps.srcFileLists...)
|
||||
|
||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if gen, ok := module.(genrule.SourceFileGenerator); ok {
|
||||
srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
|
||||
}
|
||||
})
|
||||
|
||||
srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
|
||||
|
||||
var jars android.Paths
|
||||
|
|
|
@ -61,6 +61,7 @@ func testJava(t *testing.T, bp string) *android.TestContext {
|
|||
ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(ImportFactory))
|
||||
ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
|
||||
ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(genrule.FileGroupFactory))
|
||||
ctx.RegisterModuleType("genrule", android.ModuleFactoryAdaptor(genrule.GenRuleFactory))
|
||||
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
|
||||
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
|
@ -506,6 +507,39 @@ func TestExcludeResources(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGeneratedSources(t *testing.T) {
|
||||
ctx := testJava(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: [
|
||||
"a*.java",
|
||||
":gen",
|
||||
"b*.java",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "gen",
|
||||
tool_files: ["res/a"],
|
||||
out: ["gen.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||
genrule := ctx.ModuleForTests("gen", "").Rule("generator")
|
||||
|
||||
if len(genrule.Outputs) != 1 || filepath.Base(genrule.Outputs[0].String()) != "gen.java" {
|
||||
t.Fatalf(`gen output file %v is not [".../gen.java"]`, genrule.Outputs.Strings())
|
||||
}
|
||||
|
||||
if len(javac.Inputs) != 3 ||
|
||||
javac.Inputs[0].String() != "a.java" ||
|
||||
javac.Inputs[1].String() != genrule.Outputs[0].String() ||
|
||||
javac.Inputs[2].String() != "b.java" {
|
||||
t.Errorf(`foo inputs %v != ["a.java", ".../gen.java", "b.java"]`, javac.Inputs)
|
||||
}
|
||||
}
|
||||
|
||||
func fail(t *testing.T, errs []error) {
|
||||
if len(errs) > 0 {
|
||||
for _, err := range errs {
|
||||
|
|
Loading…
Reference in a new issue