Loading android/config.go +1 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,7 @@ func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath { if defaultCert == "" || filepath.Dir(defaultCert) == "build/target/product/security" { // When defaultCert is unset or is set to the testkeys path, use the APEX keys // that is under the module dir return PathForModuleSrc(ctx).SourcePath return pathForModuleSrc(ctx) } else { // If not, APEX keys are under the specified directory return PathForSource(ctx, filepath.Dir(defaultCert)) Loading android/paths.go +25 −33 Original line number Diff line number Diff line Loading @@ -254,10 +254,9 @@ func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bo continue } moduleSrcPath := ModuleSrcPath{srcPath} moduleSrcPath.basePath.rel = srcPath.path srcPath.basePath.rel = srcPath.path ret = append(ret, moduleSrcPath) ret = append(ret, srcPath) } return ret } Loading Loading @@ -633,9 +632,7 @@ func (p SourcePath) join(ctx PathContext, paths ...string) SourcePath { // SourcePath is the path to a resource overlay directory. func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath { var relDir string if moduleSrcPath, ok := path.(ModuleSrcPath); ok { relDir = moduleSrcPath.path } else if srcPath, ok := path.(SourcePath); ok { if srcPath, ok := path.(SourcePath); ok { relDir = srcPath.path } else { reportPathErrorf(ctx, "Cannot find relative path for %s(%s)", reflect.TypeOf(path).Name(), path) Loading Loading @@ -747,41 +744,36 @@ func PathForIntermediates(ctx PathContext, paths ...string) OutputPath { return PathForOutput(ctx, ".intermediates", path) } // ModuleSrcPath is a Path representing a file rooted from a module's local source dir type ModuleSrcPath struct { SourcePath } var _ Path = ModuleSrcPath{} var _ genPathProvider = ModuleSrcPath{} var _ objPathProvider = ModuleSrcPath{} var _ resPathProvider = ModuleSrcPath{} var _ genPathProvider = SourcePath{} var _ objPathProvider = SourcePath{} var _ resPathProvider = SourcePath{} // PathForModuleSrc returns a ModuleSrcPath representing the paths... under the // PathForModuleSrc returns a Path representing the paths... under the // module's local source directory. func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath { func PathForModuleSrc(ctx ModuleContext, paths ...string) Path { path := pathForModuleSrc(ctx, paths...) if exists, _, err := ctx.Fs().Exists(path.String()); err != nil { reportPathErrorf(ctx, "%s: %s", path, err.Error()) } else if !exists { reportPathErrorf(ctx, "module source path %q does not exist", path) } return path } func pathForModuleSrc(ctx ModuleContext, paths ...string) SourcePath { p, err := validatePath(paths...) if err != nil { reportPathError(ctx, err) } srcPath, err := pathForSource(ctx, ctx.ModuleDir(), p) path, err := pathForSource(ctx, ctx.ModuleDir(), p) if err != nil { reportPathError(ctx, err) } if pathtools.IsGlob(srcPath.String()) { reportPathErrorf(ctx, "path may not contain a glob: %s", srcPath.String()) } path := ModuleSrcPath{srcPath} path.basePath.rel = p if exists, _, err := ctx.Fs().Exists(path.String()); err != nil { reportPathErrorf(ctx, "%s: %s", path, err.Error()) } else if !exists { reportPathErrorf(ctx, "module source path %q does not exist", path) } return path } Loading @@ -790,7 +782,7 @@ func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath { // inside subDir then a path error will be reported. func PathsWithModuleSrcSubDir(ctx ModuleContext, paths Paths, subDir string) Paths { paths = append(Paths(nil), paths...) subDirFullPath := PathForModuleSrc(ctx, subDir) subDirFullPath := pathForModuleSrc(ctx, subDir) for i, path := range paths { rel := Rel(ctx, subDirFullPath.String(), path.String()) paths[i] = subDirFullPath.join(ctx, rel) Loading @@ -801,7 +793,7 @@ func PathsWithModuleSrcSubDir(ctx ModuleContext, paths Paths, subDir string) Pat // PathWithModuleSrcSubDir takes a Path and returns a Path where Rel() will return the path relative to subDir in the // module's source directory. If the input path is not located inside subDir then a path error will be reported. func PathWithModuleSrcSubDir(ctx ModuleContext, path Path, subDir string) Path { subDirFullPath := PathForModuleSrc(ctx, subDir) subDirFullPath := pathForModuleSrc(ctx, subDir) rel := Rel(ctx, subDirFullPath.String(), path.String()) return subDirFullPath.Join(ctx, rel) } Loading @@ -815,15 +807,15 @@ func OptionalPathForModuleSrc(ctx ModuleContext, p *string) OptionalPath { return OptionalPathForPath(PathForModuleSrc(ctx, *p)) } func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath { func (p SourcePath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath { return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } func (p ModuleSrcPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath { func (p SourcePath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } func (p ModuleSrcPath) resPathWithName(ctx ModuleContext, name string) ModuleResPath { func (p SourcePath) resPathWithName(ctx ModuleContext, name string) ModuleResPath { // TODO: Use full directory if the new ctx is not the current ctx? return PathForModuleRes(ctx, p.path, name) } Loading android/paths_test.go +19 −7 Original line number Diff line number Diff line Loading @@ -508,15 +508,27 @@ func TestPathForModuleInstall(t *testing.T) { } func TestDirectorySortedPaths(t *testing.T) { config := TestConfig("out", nil) ctx := PathContextForTesting(config, map[string][]byte{ "a.txt": nil, "a/txt": nil, "a/b/c": nil, "a/b/d": nil, "b": nil, "b/b.txt": nil, "a/a.txt": nil, }) makePaths := func() Paths { return Paths{ PathForTesting("a.txt"), PathForTesting("a/txt"), PathForTesting("a/b/c"), PathForTesting("a/b/d"), PathForTesting("b"), PathForTesting("b/b.txt"), PathForTesting("a/a.txt"), PathForSource(ctx, "a.txt"), PathForSource(ctx, "a/txt"), PathForSource(ctx, "a/b/c"), PathForSource(ctx, "a/b/d"), PathForSource(ctx, "b"), PathForSource(ctx, "b/b.txt"), PathForSource(ctx, "a/a.txt"), } } Loading cc/ndk_headers.go +5 −4 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ type headerModule struct { properties headerProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string, Loading Loading @@ -204,7 +204,7 @@ type versionedHeaderModule struct { properties versionedHeaderProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading Loading @@ -232,7 +232,8 @@ func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleCo processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, srcFiles, installPaths) } func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path, srcFiles android.Paths, installPaths []android.WritablePath) android.Path { func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path, srcFiles android.Paths, installPaths []android.WritablePath) android.Path { // The versioner depends on a dependencies directory to simplify determining include paths // when parsing headers. This directory contains architecture specific directories as well // as a common directory, each of which contains symlinks to the actually directories to Loading Loading @@ -326,7 +327,7 @@ type preprocessedHeadersModule struct { properties preprocessedHeadersProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading java/droiddoc.go +9 −9 Original line number Diff line number Diff line Loading @@ -935,15 +935,15 @@ func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits }) if len(d.properties.Html_dirs) > 0 { htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0]) *implicits = append(*implicits, ctx.Glob(htmlDir.Join(ctx, "**/*").String(), nil)...) args = args + " -htmldir " + htmlDir.String() htmlDir := d.properties.Html_dirs[0] *implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(d.properties.Html_dirs[0], "**/*")}, nil)...) args = args + " -htmldir " + htmlDir } if len(d.properties.Html_dirs) > 1 { htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1]) *implicits = append(*implicits, ctx.Glob(htmlDir2.Join(ctx, "**/*").String(), nil)...) args = args + " -htmldir2 " + htmlDir2.String() htmlDir2 := d.properties.Html_dirs[1] *implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(htmlDir2, "**/*")}, nil)...) args = args + " -htmldir2 " + htmlDir2 } if len(d.properties.Html_dirs) > 2 { Loading Loading @@ -1791,9 +1791,9 @@ func ExportedDroiddocDirFactory() android.Module { func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {} func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) { path := android.PathForModuleSrc(ctx, String(d.properties.Path)) d.dir = path d.deps = ctx.Glob(path.Join(ctx, "**/*").String(), nil) path := String(d.properties.Path) d.dir = android.PathForModuleSrc(ctx, path) d.deps = ctx.ExpandSources([]string{filepath.Join(path, "**/*")}, nil) } // Loading Loading
android/config.go +1 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,7 @@ func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath { if defaultCert == "" || filepath.Dir(defaultCert) == "build/target/product/security" { // When defaultCert is unset or is set to the testkeys path, use the APEX keys // that is under the module dir return PathForModuleSrc(ctx).SourcePath return pathForModuleSrc(ctx) } else { // If not, APEX keys are under the specified directory return PathForSource(ctx, filepath.Dir(defaultCert)) Loading
android/paths.go +25 −33 Original line number Diff line number Diff line Loading @@ -254,10 +254,9 @@ func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bo continue } moduleSrcPath := ModuleSrcPath{srcPath} moduleSrcPath.basePath.rel = srcPath.path srcPath.basePath.rel = srcPath.path ret = append(ret, moduleSrcPath) ret = append(ret, srcPath) } return ret } Loading Loading @@ -633,9 +632,7 @@ func (p SourcePath) join(ctx PathContext, paths ...string) SourcePath { // SourcePath is the path to a resource overlay directory. func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath { var relDir string if moduleSrcPath, ok := path.(ModuleSrcPath); ok { relDir = moduleSrcPath.path } else if srcPath, ok := path.(SourcePath); ok { if srcPath, ok := path.(SourcePath); ok { relDir = srcPath.path } else { reportPathErrorf(ctx, "Cannot find relative path for %s(%s)", reflect.TypeOf(path).Name(), path) Loading Loading @@ -747,41 +744,36 @@ func PathForIntermediates(ctx PathContext, paths ...string) OutputPath { return PathForOutput(ctx, ".intermediates", path) } // ModuleSrcPath is a Path representing a file rooted from a module's local source dir type ModuleSrcPath struct { SourcePath } var _ Path = ModuleSrcPath{} var _ genPathProvider = ModuleSrcPath{} var _ objPathProvider = ModuleSrcPath{} var _ resPathProvider = ModuleSrcPath{} var _ genPathProvider = SourcePath{} var _ objPathProvider = SourcePath{} var _ resPathProvider = SourcePath{} // PathForModuleSrc returns a ModuleSrcPath representing the paths... under the // PathForModuleSrc returns a Path representing the paths... under the // module's local source directory. func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath { func PathForModuleSrc(ctx ModuleContext, paths ...string) Path { path := pathForModuleSrc(ctx, paths...) if exists, _, err := ctx.Fs().Exists(path.String()); err != nil { reportPathErrorf(ctx, "%s: %s", path, err.Error()) } else if !exists { reportPathErrorf(ctx, "module source path %q does not exist", path) } return path } func pathForModuleSrc(ctx ModuleContext, paths ...string) SourcePath { p, err := validatePath(paths...) if err != nil { reportPathError(ctx, err) } srcPath, err := pathForSource(ctx, ctx.ModuleDir(), p) path, err := pathForSource(ctx, ctx.ModuleDir(), p) if err != nil { reportPathError(ctx, err) } if pathtools.IsGlob(srcPath.String()) { reportPathErrorf(ctx, "path may not contain a glob: %s", srcPath.String()) } path := ModuleSrcPath{srcPath} path.basePath.rel = p if exists, _, err := ctx.Fs().Exists(path.String()); err != nil { reportPathErrorf(ctx, "%s: %s", path, err.Error()) } else if !exists { reportPathErrorf(ctx, "module source path %q does not exist", path) } return path } Loading @@ -790,7 +782,7 @@ func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath { // inside subDir then a path error will be reported. func PathsWithModuleSrcSubDir(ctx ModuleContext, paths Paths, subDir string) Paths { paths = append(Paths(nil), paths...) subDirFullPath := PathForModuleSrc(ctx, subDir) subDirFullPath := pathForModuleSrc(ctx, subDir) for i, path := range paths { rel := Rel(ctx, subDirFullPath.String(), path.String()) paths[i] = subDirFullPath.join(ctx, rel) Loading @@ -801,7 +793,7 @@ func PathsWithModuleSrcSubDir(ctx ModuleContext, paths Paths, subDir string) Pat // PathWithModuleSrcSubDir takes a Path and returns a Path where Rel() will return the path relative to subDir in the // module's source directory. If the input path is not located inside subDir then a path error will be reported. func PathWithModuleSrcSubDir(ctx ModuleContext, path Path, subDir string) Path { subDirFullPath := PathForModuleSrc(ctx, subDir) subDirFullPath := pathForModuleSrc(ctx, subDir) rel := Rel(ctx, subDirFullPath.String(), path.String()) return subDirFullPath.Join(ctx, rel) } Loading @@ -815,15 +807,15 @@ func OptionalPathForModuleSrc(ctx ModuleContext, p *string) OptionalPath { return OptionalPathForPath(PathForModuleSrc(ctx, *p)) } func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath { func (p SourcePath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath { return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } func (p ModuleSrcPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath { func (p SourcePath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } func (p ModuleSrcPath) resPathWithName(ctx ModuleContext, name string) ModuleResPath { func (p SourcePath) resPathWithName(ctx ModuleContext, name string) ModuleResPath { // TODO: Use full directory if the new ctx is not the current ctx? return PathForModuleRes(ctx, p.path, name) } Loading
android/paths_test.go +19 −7 Original line number Diff line number Diff line Loading @@ -508,15 +508,27 @@ func TestPathForModuleInstall(t *testing.T) { } func TestDirectorySortedPaths(t *testing.T) { config := TestConfig("out", nil) ctx := PathContextForTesting(config, map[string][]byte{ "a.txt": nil, "a/txt": nil, "a/b/c": nil, "a/b/d": nil, "b": nil, "b/b.txt": nil, "a/a.txt": nil, }) makePaths := func() Paths { return Paths{ PathForTesting("a.txt"), PathForTesting("a/txt"), PathForTesting("a/b/c"), PathForTesting("a/b/d"), PathForTesting("b"), PathForTesting("b/b.txt"), PathForTesting("a/a.txt"), PathForSource(ctx, "a.txt"), PathForSource(ctx, "a/txt"), PathForSource(ctx, "a/b/c"), PathForSource(ctx, "a/b/d"), PathForSource(ctx, "b"), PathForSource(ctx, "b/b.txt"), PathForSource(ctx, "a/a.txt"), } } Loading
cc/ndk_headers.go +5 −4 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ type headerModule struct { properties headerProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string, Loading Loading @@ -204,7 +204,7 @@ type versionedHeaderModule struct { properties versionedHeaderProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading Loading @@ -232,7 +232,8 @@ func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleCo processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, srcFiles, installPaths) } func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path, srcFiles android.Paths, installPaths []android.WritablePath) android.Path { func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path, srcFiles android.Paths, installPaths []android.WritablePath) android.Path { // The versioner depends on a dependencies directory to simplify determining include paths // when parsing headers. This directory contains architecture specific directories as well // as a common directory, each of which contains symlinks to the actually directories to Loading Loading @@ -326,7 +327,7 @@ type preprocessedHeadersModule struct { properties preprocessedHeadersProperties installPaths android.Paths licensePath android.ModuleSrcPath licensePath android.Path } func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading
java/droiddoc.go +9 −9 Original line number Diff line number Diff line Loading @@ -935,15 +935,15 @@ func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits }) if len(d.properties.Html_dirs) > 0 { htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0]) *implicits = append(*implicits, ctx.Glob(htmlDir.Join(ctx, "**/*").String(), nil)...) args = args + " -htmldir " + htmlDir.String() htmlDir := d.properties.Html_dirs[0] *implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(d.properties.Html_dirs[0], "**/*")}, nil)...) args = args + " -htmldir " + htmlDir } if len(d.properties.Html_dirs) > 1 { htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1]) *implicits = append(*implicits, ctx.Glob(htmlDir2.Join(ctx, "**/*").String(), nil)...) args = args + " -htmldir2 " + htmlDir2.String() htmlDir2 := d.properties.Html_dirs[1] *implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(htmlDir2, "**/*")}, nil)...) args = args + " -htmldir2 " + htmlDir2 } if len(d.properties.Html_dirs) > 2 { Loading Loading @@ -1791,9 +1791,9 @@ func ExportedDroiddocDirFactory() android.Module { func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {} func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) { path := android.PathForModuleSrc(ctx, String(d.properties.Path)) d.dir = path d.deps = ctx.Glob(path.Join(ctx, "**/*").String(), nil) path := String(d.properties.Path) d.dir = android.PathForModuleSrc(ctx, path) d.deps = ctx.ExpandSources([]string{filepath.Join(path, "**/*")}, nil) } // Loading