Merge "Revert "Support filegroup in exclude_srcs""
am: f5801db4cc
Change-Id: I180101b7d1a0eeef10a1ca4bfc4198262b80c001
This commit is contained in:
@@ -1176,24 +1176,15 @@ func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop stri
|
|||||||
func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
|
func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
|
||||||
prefix := PathForModuleSrc(ctx).String()
|
prefix := PathForModuleSrc(ctx).String()
|
||||||
|
|
||||||
expandedExcludes := make([]string, 0, len(excludes))
|
for i, e := range excludes {
|
||||||
|
j := findStringInSlice(e, srcFiles)
|
||||||
for _, e := range excludes {
|
if j != -1 {
|
||||||
if m := SrcIsModule(e); m != "" {
|
srcFiles = append(srcFiles[:j], srcFiles[j+1:]...)
|
||||||
module := ctx.GetDirectDepWithTag(m, SourceDepTag)
|
|
||||||
if module == nil {
|
|
||||||
// Error will have been handled by ExtractSourcesDeps
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if srcProducer, ok := module.(SourceFileProducer); ok {
|
|
||||||
expandedExcludes = append(expandedExcludes, srcProducer.Srcs().Strings()...)
|
|
||||||
} else {
|
|
||||||
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
expandedExcludes = append(expandedExcludes, filepath.Join(prefix, e))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
excludes[i] = filepath.Join(prefix, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
expandedSrcFiles := make(Paths, 0, len(srcFiles))
|
expandedSrcFiles := make(Paths, 0, len(srcFiles))
|
||||||
for _, s := range srcFiles {
|
for _, s := range srcFiles {
|
||||||
if m := SrcIsModule(s); m != "" {
|
if m := SrcIsModule(s); m != "" {
|
||||||
@@ -1203,33 +1194,22 @@ func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if srcProducer, ok := module.(SourceFileProducer); ok {
|
if srcProducer, ok := module.(SourceFileProducer); ok {
|
||||||
moduleSrcs := srcProducer.Srcs()
|
expandedSrcFiles = append(expandedSrcFiles, srcProducer.Srcs()...)
|
||||||
for _, e := range expandedExcludes {
|
|
||||||
for j, ms := range moduleSrcs {
|
|
||||||
if ms.String() == e {
|
|
||||||
moduleSrcs = append(moduleSrcs[:j], moduleSrcs[j+1:]...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expandedSrcFiles = append(expandedSrcFiles, moduleSrcs...)
|
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
||||||
}
|
}
|
||||||
} else if pathtools.IsGlob(s) {
|
} else if pathtools.IsGlob(s) {
|
||||||
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), expandedExcludes)
|
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), excludes)
|
||||||
for i, s := range globbedSrcFiles {
|
for i, s := range globbedSrcFiles {
|
||||||
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
||||||
}
|
}
|
||||||
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
|
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
|
||||||
} else {
|
} else {
|
||||||
p := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
|
s := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
|
||||||
j := findStringInSlice(p.String(), expandedExcludes)
|
expandedSrcFiles = append(expandedSrcFiles, s)
|
||||||
if j == -1 {
|
|
||||||
expandedSrcFiles = append(expandedSrcFiles, p)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return expandedSrcFiles
|
return expandedSrcFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -202,7 +202,6 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
|
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
|
||||||
|
|
||||||
android.ExtractSourcesDeps(ctx, compiler.Properties.Srcs)
|
android.ExtractSourcesDeps(ctx, compiler.Properties.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, compiler.Properties.Exclude_srcs)
|
|
||||||
|
|
||||||
if compiler.hasSrcExt(".proto") {
|
if compiler.hasSrcExt(".proto") {
|
||||||
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
|
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
|
||||||
|
@@ -62,7 +62,6 @@ func FileGroupFactory() android.Module {
|
|||||||
|
|
||||||
func (fg *fileGroup) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (fg *fileGroup) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
android.ExtractSourcesDeps(ctx, fg.properties.Srcs)
|
android.ExtractSourcesDeps(ctx, fg.properties.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, fg.properties.Exclude_srcs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
@@ -466,7 +466,6 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...)
|
ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...)
|
||||||
|
|
||||||
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs)
|
|
||||||
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
|
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
|
||||||
android.ExtractSourceDeps(ctx, j.properties.Manifest)
|
android.ExtractSourceDeps(ctx, j.properties.Manifest)
|
||||||
|
|
||||||
|
@@ -131,19 +131,16 @@ func testContext(config android.Config, bp string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mockFS := map[string][]byte{
|
mockFS := map[string][]byte{
|
||||||
"Android.bp": []byte(bp),
|
"Android.bp": []byte(bp),
|
||||||
"a.java": nil,
|
"a.java": nil,
|
||||||
"b.java": nil,
|
"b.java": nil,
|
||||||
"c.java": nil,
|
"c.java": nil,
|
||||||
"b.kt": nil,
|
"b.kt": nil,
|
||||||
"a.jar": nil,
|
"a.jar": nil,
|
||||||
"b.jar": nil,
|
"b.jar": nil,
|
||||||
"java-res/a": nil,
|
"java-res/a": nil,
|
||||||
"java-res/b": nil,
|
"java-res/b": nil,
|
||||||
"java-res2/a": nil,
|
"java-res2/a": nil,
|
||||||
"java-fg/a.java": nil,
|
|
||||||
"java-fg/b.java": nil,
|
|
||||||
"java-fg/c.java": nil,
|
|
||||||
|
|
||||||
"prebuilts/sdk/14/android.jar": nil,
|
"prebuilts/sdk/14/android.jar": nil,
|
||||||
"prebuilts/sdk/14/framework.aidl": nil,
|
"prebuilts/sdk/14/framework.aidl": nil,
|
||||||
@@ -910,32 +907,6 @@ func TestJarGenrules(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExcludeFileGroupInSrcs(t *testing.T) {
|
|
||||||
ctx := testJava(t, `
|
|
||||||
java_library {
|
|
||||||
name: "foo",
|
|
||||||
srcs: ["a.java", ":foo-srcs"],
|
|
||||||
exclude_srcs: ["a.java", ":foo-excludes"],
|
|
||||||
}
|
|
||||||
|
|
||||||
filegroup {
|
|
||||||
name: "foo-srcs",
|
|
||||||
srcs: ["java-fg/a.java", "java-fg/b.java", "java-fg/c.java"],
|
|
||||||
}
|
|
||||||
|
|
||||||
filegroup {
|
|
||||||
name: "foo-excludes",
|
|
||||||
srcs: ["java-fg/a.java", "java-fg/b.java"],
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
|
||||||
|
|
||||||
if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "java-fg/c.java" {
|
|
||||||
t.Errorf(`foo inputs %v != ["java-fg/c.java"]`, javac.Inputs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fail(t *testing.T, errs []error) {
|
func fail(t *testing.T, errs []error) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
@@ -266,13 +266,11 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
android.ExtractSourcesDeps(ctx, p.properties.Data)
|
android.ExtractSourcesDeps(ctx, p.properties.Data)
|
||||||
// deps from "srcs".
|
// deps from "srcs".
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Srcs)
|
android.ExtractSourcesDeps(ctx, p.properties.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Exclude_srcs)
|
|
||||||
|
|
||||||
switch p.properties.Actual_version {
|
switch p.properties.Actual_version {
|
||||||
case pyVersion2:
|
case pyVersion2:
|
||||||
// deps from "version.py2.srcs" property.
|
// deps from "version.py2.srcs" property.
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Version.Py2.Srcs)
|
android.ExtractSourcesDeps(ctx, p.properties.Version.Py2.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Version.Py2.Exclude_srcs)
|
|
||||||
|
|
||||||
ctx.AddVariationDependencies(nil, pythonLibTag,
|
ctx.AddVariationDependencies(nil, pythonLibTag,
|
||||||
uniqueLibs(ctx, p.properties.Libs, "version.py2.libs",
|
uniqueLibs(ctx, p.properties.Libs, "version.py2.libs",
|
||||||
@@ -288,7 +286,6 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
case pyVersion3:
|
case pyVersion3:
|
||||||
// deps from "version.py3.srcs" property.
|
// deps from "version.py3.srcs" property.
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Version.Py3.Srcs)
|
android.ExtractSourcesDeps(ctx, p.properties.Version.Py3.Srcs)
|
||||||
android.ExtractSourcesDeps(ctx, p.properties.Version.Py3.Exclude_srcs)
|
|
||||||
|
|
||||||
ctx.AddVariationDependencies(nil, pythonLibTag,
|
ctx.AddVariationDependencies(nil, pythonLibTag,
|
||||||
uniqueLibs(ctx, p.properties.Libs, "version.py3.libs",
|
uniqueLibs(ctx, p.properties.Libs, "version.py3.libs",
|
||||||
|
Reference in New Issue
Block a user