diff options
author | Colin Cross <ccross@android.com> | 2016-11-01 11:10:25 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-11-04 04:54:16 +0000 |
commit | 7f19f37443f35f2fdd50f31bcc9263c002dab424 (patch) | |
tree | 1d9d16434a7c8558970017e9f3d0cdf5df0da077 /android/paths.go | |
parent | 28f9094ee7d48a610c482bc5d20ceaf9a95cfaca (diff) | |
download | build_soong-7f19f37443f35f2fdd50f31bcc9263c002dab424.tar.gz build_soong-7f19f37443f35f2fdd50f31bcc9263c002dab424.tar.bz2 build_soong-7f19f37443f35f2fdd50f31bcc9263c002dab424.zip |
Move globbing to Blueprint
Move Soong's globbing-with-dependencies support into Blueprint so it can
be used for subdirs= lines in Android.bp files.
Blueprint has a slight change in behavior around subname= lines, it now
always uses the subname and doesn't fall back to Blueprints. To support
the Blueprints files in build/blueprint, use them directly with build=.
Test: build, add source file that matches glob, rebuild
Change-Id: Ifd0b0d3bc061aae0a16d6c7ca9a1cd8672656b4d
Diffstat (limited to 'android/paths.go')
-rw-r--r-- | android/paths.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/android/paths.go b/android/paths.go index 1202d6d4..1a6125a3 100644 --- a/android/paths.go +++ b/android/paths.go @@ -21,8 +21,6 @@ import ( "reflect" "strings" - "android/soong/glob" - "github.com/google/blueprint" "github.com/google/blueprint/pathtools" ) @@ -34,6 +32,10 @@ type PathContext interface { AddNinjaFileDeps(deps ...string) } +type PathGlobContext interface { + GlobWithDeps(globPattern string, excludes []string) ([]string, error) +} + var _ PathContext = blueprint.SingletonContext(nil) var _ PathContext = blueprint.ModuleContext(nil) @@ -248,7 +250,7 @@ func PathsWithOptionalDefaultForModuleSrc(ctx ModuleContext, input []string, def // Use Glob so that if the default doesn't exist, a dependency is added so that when it // is created, we're run again. path := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir(), def) - return ctx.Glob("default", path, []string{}) + return ctx.Glob(path, []string{}) } // Strings returns the Paths in string form @@ -382,15 +384,15 @@ func OptionalPathForSource(ctx PathContext, intermediates string, paths ...strin return OptionalPath{} } - if glob.IsGlob(path.String()) { + if pathtools.IsGlob(path.String()) { reportPathError(ctx, "path may not contain a glob: %s", path.String()) return OptionalPath{} } - if gctx, ok := ctx.(globContext); ok { + if gctx, ok := ctx.(PathGlobContext); ok { // Use glob to produce proper dependencies, even though we only want // a single file. - files, err := Glob(gctx, PathForIntermediates(ctx, intermediates).String(), path.String(), nil) + files, err := gctx.GlobWithDeps(path.String(), nil) if err != nil { reportPathError(ctx, "glob: %s", err.Error()) return OptionalPath{} @@ -444,10 +446,10 @@ func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath { } dir := filepath.Join(p.config.srcDir, p.path, relDir) // Use Glob so that we are run again if the directory is added. - if glob.IsGlob(dir) { + if pathtools.IsGlob(dir) { reportPathError(ctx, "Path may not contain a glob: %s", dir) } - paths, err := Glob(ctx, PathForModuleOut(ctx, "overlay").String(), dir, []string{}) + paths, err := ctx.GlobWithDeps(dir, []string{}) if err != nil { reportPathError(ctx, "glob: %s", err.Error()) return OptionalPath{} |