Merge "Revert "root.bp: Add vendor/*/*""
diff --git a/Android.bp b/Android.bp
index a941ca4..23cbad8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -159,6 +159,7 @@
"soong-android",
],
srcs: [
+ "genrule/filegroup.go",
"genrule/genrule.go",
],
pluginFor: ["soong_build"],
diff --git a/README.md b/README.md
index 9d3dde6..8b086df 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,9 @@
By design, Android.bp files are very simple. There are no conditionals or
control flow statements - any complexity is handled in build logic written in
-Go.
+Go. The syntax and semantics of Android.bp files are intentionally similar
+to [Bazel BUILD files](https://www.bazel.io/versions/master/docs/be/overview.html)
+when possible.
### Modules
diff --git a/android/module.go b/android/module.go
index c0b9c47..7156e8c 100644
--- a/android/module.go
+++ b/android/module.go
@@ -711,6 +711,38 @@
return -1
}
+func SrcIsModule(s string) string {
+ if len(s) > 1 && s[0] == ':' {
+ return s[1:]
+ }
+ return ""
+}
+
+type sourceDependencyTag struct {
+ blueprint.BaseDependencyTag
+}
+
+var SourceDepTag sourceDependencyTag
+
+// Returns a list of modules that must be depended on to satisfy filegroup or generated sources
+// modules listed in srcFiles using ":module" syntax
+func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
+ var deps []string
+ for _, s := range srcFiles {
+ if m := SrcIsModule(s); m != "" {
+ deps = append(deps, m)
+ }
+ }
+
+ ctx.AddDependency(ctx.Module(), SourceDepTag, deps...)
+}
+
+type SourceFileProducer interface {
+ Srcs() Paths
+}
+
+// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.
+// ExpandSourceDeps must have already been called during the dependency resolution phase.
func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
prefix := PathForModuleSrc(ctx).String()
for i, e := range excludes {
@@ -724,7 +756,14 @@
globbedSrcFiles := make(Paths, 0, len(srcFiles))
for _, s := range srcFiles {
- if pathtools.IsGlob(s) {
+ if m := SrcIsModule(s); m != "" {
+ module := ctx.GetDirectDepWithTag(m, SourceDepTag)
+ if srcProducer, ok := module.(SourceFileProducer); ok {
+ globbedSrcFiles = append(globbedSrcFiles, srcProducer.Srcs()...)
+ } else {
+ ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
+ }
+ } else if pathtools.IsGlob(s) {
globbedSrcFiles = append(globbedSrcFiles, ctx.Glob(filepath.Join(prefix, s), excludes)...)
} else {
globbedSrcFiles = append(globbedSrcFiles, PathForModuleSrc(ctx, s))
diff --git a/cc/cc.go b/cc/cc.go
index 74d3d3d..8bf1467 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -227,7 +227,8 @@
staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
lateStaticDepTag = dependencyTag{name: "late static", library: true}
wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true}
- headerDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
+ headerDepTag = dependencyTag{name: "header", library: true}
+ headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
genSourceDepTag = dependencyTag{name: "gen source"}
genHeaderDepTag = dependencyTag{name: "gen header"}
genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
@@ -663,7 +664,13 @@
deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
}
- actx.AddVariationDependencies(nil, headerDepTag, deps.HeaderLibs...)
+ for _, lib := range deps.HeaderLibs {
+ depTag := headerDepTag
+ if inList(lib, deps.ReexportHeaderLibHeaders) {
+ depTag = headerExportDepTag
+ }
+ actx.AddVariationDependencies(nil, depTag, lib)
+ }
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
deps.WholeStaticLibs...)
@@ -826,7 +833,7 @@
cc, _ := m.(*Module)
if cc == nil {
switch tag {
- case android.DefaultsDepTag:
+ case android.DefaultsDepTag, android.SourceDepTag:
case genSourceDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
diff --git a/cc/compiler.go b/cc/compiler.go
index e6f432c..d53e799 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -29,6 +29,8 @@
type BaseCompilerProperties struct {
// list of source files used to compile the C/C++ module. May be .c, .cpp, or .S files.
+ // srcs may reference the outputs of other modules that produce source files like genrule
+ // or filegroup using the syntax ":module".
Srcs []string `android:"arch_variant"`
// list of source files that should not be used to build the C/C++ module.
@@ -133,6 +135,8 @@
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
+ android.ExtractSourcesDeps(ctx, compiler.Properties.Srcs)
+
if compiler.hasSrcExt(".proto") {
deps = protoDeps(ctx, deps, &compiler.Proto)
}
diff --git a/cc/config/global.go b/cc/config/global.go
index c8b803b..6f14486 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -113,7 +113,6 @@
pctx.PrefixedPathsForOptionalSourceVariable("CommonGlobalSystemIncludes", "-isystem ",
[]string{
"frameworks/av/include",
- "frameworks/base/include",
})
// This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help
// with this, since there is no associated library.
diff --git a/genrule/filegroup.go b/genrule/filegroup.go
new file mode 100644
index 0000000..9b53c9f
--- /dev/null
+++ b/genrule/filegroup.go
@@ -0,0 +1,61 @@
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package genrule
+
+import (
+ "github.com/google/blueprint"
+
+ "android/soong/android"
+)
+
+func init() {
+ android.RegisterModuleType("filegroup", fileGroupFactory)
+}
+
+type fileGroupProperties struct {
+ // srcs lists files that will be included in this filegroup
+ Srcs []string
+
+ Exclude_srcs []string
+}
+
+type fileGroup struct {
+ android.ModuleBase
+ properties fileGroupProperties
+ srcs android.Paths
+}
+
+var _ android.SourceFileProducer = (*fileGroup)(nil)
+
+// filegroup modules contain a list of files, and can be used to export files across package
+// boundaries. filegroups (and genrules) can be referenced from srcs properties of other modules
+// using the syntax ":module".
+func fileGroupFactory() (blueprint.Module, []interface{}) {
+ module := &fileGroup{}
+
+ return android.InitAndroidModule(module, &module.properties)
+}
+
+func (fg *fileGroup) DepsMutator(ctx android.BottomUpMutatorContext) {
+ android.ExtractSourcesDeps(ctx, fg.properties.Srcs)
+}
+
+func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ fg.srcs = ctx.ExpandSources(fg.properties.Srcs, fg.properties.Exclude_srcs)
+}
+
+func (fg *fileGroup) Srcs() android.Paths {
+ return fg.srcs
+}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index bb78b1f..5a2ac84 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -96,6 +96,10 @@
return g.outputFiles
}
+func (g *generator) Srcs() android.Paths {
+ return g.outputFiles
+}
+
func (g *generator) GeneratedHeaderDirs() android.Paths {
return g.exportedIncludeDirs
}