aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-02-23 02:38:58 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-02-23 02:38:58 +0000
commit945aebf48e4469f05c20dfe63a94c4a37ad790cf (patch)
tree439c9aae14934eda141996bf5843be26cc387137
parent230c992943c6362911f6e2eec619d3e2b5e6d8a4 (diff)
parentb3407069ee328b17f1e38d380003a26379b3cf7a (diff)
downloadbuild_soong-945aebf48e4469f05c20dfe63a94c4a37ad790cf.tar.gz
build_soong-945aebf48e4469f05c20dfe63a94c4a37ad790cf.tar.bz2
build_soong-945aebf48e4469f05c20dfe63a94c4a37ad790cf.zip
Merge changes If1894fd9,Id7925999,I4fe11c3f,Iea2b0781,Id2c0a503 am: 1b5599e462
am: b3407069ee Change-Id: Ib0f7f8e93842cea36b915c1e10929f96249c20e3
-rw-r--r--android/package_ctx.go2
-rw-r--r--android/paths.go255
-rw-r--r--android/paths_test.go25
-rw-r--r--cc/pgo.go2
-rw-r--r--java/droiddoc.go8
-rw-r--r--java/java.go6
6 files changed, 168 insertions, 130 deletions
diff --git a/android/package_ctx.go b/android/package_ctx.go
index 0dbcea52..849eb72a 100644
--- a/android/package_ctx.go
+++ b/android/package_ctx.go
@@ -240,7 +240,7 @@ func (p PackageContext) PrefixedExistentPathsForSourcesVariable(
return p.VariableFunc(name, func(config Config) (string, error) {
ctx := &configErrorWrapper{p, config, []error{}}
- paths := ExistentPathsForSources(ctx, "", paths)
+ paths := ExistentPathsForSources(ctx, paths)
if len(ctx.errors) > 0 {
return "", ctx.errors[0]
}
diff --git a/android/paths.go b/android/paths.go
index e941e964..3bb5d1b7 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -70,7 +70,14 @@ var _ moduleErrorf = blueprint.ModuleContext(nil)
// reportPathError will register an error with the attached context. It
// attempts ctx.ModuleErrorf for a better error message first, then falls
// back to ctx.Errorf.
-func reportPathError(ctx PathContext, format string, args ...interface{}) {
+func reportPathError(ctx PathContext, err error) {
+ reportPathErrorf(ctx, "%s", err.Error())
+}
+
+// reportPathErrorf will register an error with the attached context. It
+// attempts ctx.ModuleErrorf for a better error message first, then falls
+// back to ctx.Errorf.
+func reportPathErrorf(ctx PathContext, format string, args ...interface{}) {
if mctx, ok := ctx.(moduleErrorf); ok {
mctx.ModuleErrorf(format, args...)
} else if ectx, ok := ctx.(errorfContext); ok {
@@ -121,7 +128,7 @@ func GenPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) Module
if path, ok := p.(genPathProvider); ok {
return path.genPathWithExt(ctx, subdir, ext)
}
- reportPathError(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p)
+ reportPathErrorf(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p)
return PathForModuleGen(ctx)
}
@@ -131,7 +138,7 @@ func ObjPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) Module
if path, ok := p.(objPathProvider); ok {
return path.objPathWithExt(ctx, subdir, ext)
}
- reportPathError(ctx, "Tried to create object file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
+ reportPathErrorf(ctx, "Tried to create object file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
return PathForModuleObj(ctx)
}
@@ -142,7 +149,7 @@ func ResPathWithName(ctx ModuleContext, p Path, name string) ModuleResPath {
if path, ok := p.(resPathProvider); ok {
return path.resPathWithName(ctx, name)
}
- reportPathError(ctx, "Tried to create res file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
+ reportPathErrorf(ctx, "Tried to create res file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
return PathForModuleRes(ctx)
}
@@ -188,21 +195,6 @@ type Paths []Path
// PathsForSource returns Paths rooted from SrcDir
func PathsForSource(ctx PathContext, paths []string) Paths {
- if ctx.Config().AllowMissingDependencies() {
- if modCtx, ok := ctx.(ModuleContext); ok {
- ret := make(Paths, 0, len(paths))
- intermediates := pathForModule(modCtx).withRel("missing")
- for _, path := range paths {
- p := ExistentPathForSource(ctx, intermediates.String(), path)
- if p.Valid() {
- ret = append(ret, p.Path())
- } else {
- modCtx.AddMissingDependencies([]string{path})
- }
- }
- return ret
- }
- }
ret := make(Paths, len(paths))
for i, path := range paths {
ret[i] = PathForSource(ctx, path)
@@ -213,10 +205,10 @@ func PathsForSource(ctx PathContext, paths []string) Paths {
// ExistentPathsForSources returns a list of Paths rooted from SrcDir that are
// found in the tree. If any are not found, they are omitted from the list,
// and dependencies are added so that we're re-run when they are added.
-func ExistentPathsForSources(ctx PathContext, intermediates string, paths []string) Paths {
+func ExistentPathsForSources(ctx PathContext, paths []string) Paths {
ret := make(Paths, 0, len(paths))
for _, path := range paths {
- p := ExistentPathForSource(ctx, intermediates, path)
+ p := ExistentPathForSource(ctx, path)
if p.Valid() {
ret = append(ret, p.Path())
}
@@ -246,7 +238,7 @@ func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
for _, p := range paths {
path := filepath.Clean(p)
if !strings.HasPrefix(path, prefix) {
- reportPathError(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
+ reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
continue
}
ret = append(ret, PathForModuleSrc(ctx, path[len(prefix):]))
@@ -477,117 +469,123 @@ func (p SourcePath) withRel(rel string) SourcePath {
// safePathForSource is for paths that we expect are safe -- only for use by go
// code that is embedding ninja variables in paths
func safePathForSource(ctx PathContext, path string) SourcePath {
- p := validateSafePath(ctx, path)
+ p, err := validateSafePath(path)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
ret := SourcePath{basePath{p, ctx.Config(), ""}}
abs, err := filepath.Abs(ret.String())
if err != nil {
- reportPathError(ctx, "%s", err.Error())
+ reportPathError(ctx, err)
return ret
}
buildroot, err := filepath.Abs(ctx.Config().buildDir)
if err != nil {
- reportPathError(ctx, "%s", err.Error())
+ reportPathError(ctx, err)
return ret
}
if strings.HasPrefix(abs, buildroot) {
- reportPathError(ctx, "source path %s is in output", abs)
+ reportPathErrorf(ctx, "source path %s is in output", abs)
return ret
}
return ret
}
-// PathForSource joins the provided path components and validates that the result
-// neither escapes the source dir nor is in the out dir.
-// On error, it will return a usable, but invalid SourcePath, and report a ModuleError.
-func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
- p := validatePath(ctx, pathComponents...)
+// pathForSource creates a SourcePath from pathComponents, but does not check that it exists.
+func pathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error) {
+ p, err := validatePath(pathComponents...)
ret := SourcePath{basePath{p, ctx.Config(), ""}}
+ if err != nil {
+ return ret, err
+ }
abs, err := filepath.Abs(ret.String())
if err != nil {
- reportPathError(ctx, "%s", err.Error())
- return ret
+ return ret, err
}
buildroot, err := filepath.Abs(ctx.Config().buildDir)
if err != nil {
- reportPathError(ctx, "%s", err.Error())
- return ret
+ return ret, err
}
if strings.HasPrefix(abs, buildroot) {
- reportPathError(ctx, "source path %s is in output", abs)
- return ret
+ return ret, fmt.Errorf("source path %s is in output", abs)
}
- if exists, _, err := ctx.Fs().Exists(ret.String()); err != nil {
- reportPathError(ctx, "%s: %s", ret, err.Error())
- } else if !exists {
- reportPathError(ctx, "source path %s does not exist", ret)
+ if pathtools.IsGlob(ret.String()) {
+ return ret, fmt.Errorf("path may not contain a glob: %s", ret.String())
}
- return ret
-}
-// ExistentPathForSource returns an OptionalPath with the SourcePath if the
-// path exists, or an empty OptionalPath if it doesn't exist. Dependencies are added
-// so that the ninja file will be regenerated if the state of the path changes.
-func ExistentPathForSource(ctx PathContext, intermediates string, pathComponents ...string) OptionalPath {
- if len(pathComponents) == 0 {
- // For when someone forgets the 'intermediates' argument
- panic("Missing path(s)")
- }
+ return ret, nil
+}
- p := validatePath(ctx, pathComponents...)
- path := SourcePath{basePath{p, ctx.Config(), ""}}
+// existsWithDependencies returns true if the path exists, and adds appropriate dependencies to rerun if the
+// path does not exist.
+func existsWithDependencies(ctx PathContext, path SourcePath) (exists bool, err error) {
+ var files []string
- abs, err := filepath.Abs(path.String())
- if err != nil {
- reportPathError(ctx, "%s", err.Error())
- return OptionalPath{}
+ if gctx, ok := ctx.(PathGlobContext); ok {
+ // Use glob to produce proper dependencies, even though we only want
+ // a single file.
+ files, err = gctx.GlobWithDeps(path.String(), nil)
+ } else {
+ var deps []string
+ // We cannot add build statements in this context, so we fall back to
+ // AddNinjaFileDeps
+ files, deps, err = pathtools.Glob(path.String(), nil)
+ ctx.AddNinjaFileDeps(deps...)
}
- buildroot, err := filepath.Abs(ctx.Config().buildDir)
+
if err != nil {
- reportPathError(ctx, "%s", err.Error())
- return OptionalPath{}
- }
- if strings.HasPrefix(abs, buildroot) {
- reportPathError(ctx, "source path %s is in output", abs)
- return OptionalPath{}
+ return false, fmt.Errorf("glob: %s", err.Error())
}
- if pathtools.IsGlob(path.String()) {
- reportPathError(ctx, "path may not contain a glob: %s", path.String())
- return OptionalPath{}
+ return len(files) > 0, nil
+}
+
+// PathForSource joins the provided path components and validates that the result
+// neither escapes the source dir nor is in the out dir.
+// On error, it will return a usable, but invalid SourcePath, and report a ModuleError.
+func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
+ path, err := pathForSource(ctx, pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
}
- if gctx, ok := ctx.(PathGlobContext); ok {
- // Use glob to produce proper dependencies, even though we only want
- // a single file.
- files, err := gctx.GlobWithDeps(path.String(), nil)
+ if modCtx, ok := ctx.(ModuleContext); ok && ctx.Config().AllowMissingDependencies() {
+ exists, err := existsWithDependencies(ctx, path)
if err != nil {
- reportPathError(ctx, "glob: %s", err.Error())
- return OptionalPath{}
- }
-
- if len(files) == 0 {
- return OptionalPath{}
+ reportPathError(ctx, err)
}
- } else {
- // We cannot add build statements in this context, so we fall back to
- // AddNinjaFileDeps
- files, dirs, err := pathtools.Glob(path.String(), nil)
- if err != nil {
- reportPathError(ctx, "glob: %s", err.Error())
- return OptionalPath{}
+ if !exists {
+ modCtx.AddMissingDependencies([]string{path.String()})
}
+ } else if exists, _, err := ctx.Fs().Exists(path.String()); err != nil {
+ reportPathErrorf(ctx, "%s: %s", path, err.Error())
+ } else if !exists {
+ reportPathErrorf(ctx, "source path %s does not exist", path)
+ }
+ return path
+}
- ctx.AddNinjaFileDeps(dirs...)
-
- if len(files) == 0 {
- return OptionalPath{}
- }
+// ExistentPathForSource returns an OptionalPath with the SourcePath if the
+// path exists, or an empty OptionalPath if it doesn't exist. Dependencies are added
+// so that the ninja file will be regenerated if the state of the path changes.
+func ExistentPathForSource(ctx PathContext, pathComponents ...string) OptionalPath {
+ path, err := pathForSource(ctx, pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
+ return OptionalPath{}
+ }
- ctx.AddNinjaFileDeps(path.String())
+ exists, err := existsWithDependencies(ctx, path)
+ if err != nil {
+ reportPathError(ctx, err)
+ return OptionalPath{}
+ }
+ if !exists {
+ return OptionalPath{}
}
return OptionalPathForPath(path)
}
@@ -599,7 +597,10 @@ func (p SourcePath) String() string {
// Join creates a new SourcePath with paths... joined with the current path. The
// provided paths... may not use '..' to escape from the current path.
func (p SourcePath) Join(ctx PathContext, paths ...string) SourcePath {
- path := validatePath(ctx, paths...)
+ path, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return p.withRel(path)
}
@@ -612,17 +613,17 @@ func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath {
} else if srcPath, ok := path.(SourcePath); ok {
relDir = srcPath.path
} else {
- reportPathError(ctx, "Cannot find relative path for %s(%s)", reflect.TypeOf(path).Name(), path)
+ reportPathErrorf(ctx, "Cannot find relative path for %s(%s)", reflect.TypeOf(path).Name(), path)
return OptionalPath{}
}
dir := filepath.Join(p.config.srcDir, p.path, relDir)
// Use Glob so that we are run again if the directory is added.
if pathtools.IsGlob(dir) {
- reportPathError(ctx, "Path may not contain a glob: %s", dir)
+ reportPathErrorf(ctx, "Path may not contain a glob: %s", dir)
}
paths, err := ctx.GlobWithDeps(dir, []string{})
if err != nil {
- reportPathError(ctx, "glob: %s", err.Error())
+ reportPathErrorf(ctx, "glob: %s", err.Error())
return OptionalPath{}
}
if len(paths) == 0 {
@@ -630,7 +631,7 @@ func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath {
}
relPath, err := filepath.Rel(p.config.srcDir, paths[0])
if err != nil {
- reportPathError(ctx, "%s", err.Error())
+ reportPathError(ctx, err)
return OptionalPath{}
}
return OptionalPathForPath(PathForSource(ctx, relPath))
@@ -652,7 +653,10 @@ var _ Path = OutputPath{}
// validated to not escape the build dir.
// On error, it will return a usable, but invalid OutputPath, and report a ModuleError.
func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath {
- path := validatePath(ctx, pathComponents...)
+ path, err := validatePath(pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return OutputPath{basePath{path, ctx.Config(), ""}}
}
@@ -669,14 +673,20 @@ func (p OutputPath) RelPathString() string {
// Join creates a new OutputPath with paths... joined with the current path. The
// provided paths... may not use '..' to escape from the current path.
func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath {
- path := validatePath(ctx, paths...)
+ path, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return p.withRel(path)
}
// PathForIntermediates returns an OutputPath representing the top-level
// intermediates directory.
func PathForIntermediates(ctx PathContext, paths ...string) OutputPath {
- path := validatePath(ctx, paths...)
+ path, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return PathForOutput(ctx, ".intermediates", path)
}
@@ -693,7 +703,10 @@ var _ resPathProvider = ModuleSrcPath{}
// PathForModuleSrc returns a ModuleSrcPath representing the paths... under the
// module's local source directory.
func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath {
- p := validatePath(ctx, paths...)
+ p, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
path := ModuleSrcPath{PathForSource(ctx, ctx.ModuleDir(), p)}
path.basePath.rel = p
return path
@@ -765,13 +778,16 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNd
}
refDumpFileStr := "prebuilts/abi-dumps/" + vndkOrNdkDir + "/" + version + "/" +
archName + "/" + sourceOrBinaryDir + "/" + fileName + ext
- return ExistentPathForSource(ctx, "", refDumpFileStr)
+ return ExistentPathForSource(ctx, refDumpFileStr)
}
// PathForModuleOut returns a Path representing the paths... under the module's
// output directory.
func PathForModuleOut(ctx ModuleContext, paths ...string) ModuleOutPath {
- p := validatePath(ctx, paths...)
+ p, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return ModuleOutPath{
OutputPath: pathForModule(ctx).withRel(p),
}
@@ -790,7 +806,10 @@ var _ objPathProvider = ModuleGenPath{}
// PathForModuleGen returns a Path representing the paths... under the module's
// `gen' directory.
func PathForModuleGen(ctx ModuleContext, paths ...string) ModuleGenPath {
- p := validatePath(ctx, paths...)
+ p, err := validatePath(paths...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return ModuleGenPath{
ModuleOutPath: ModuleOutPath{
OutputPath: pathForModule(ctx).withRel("gen").withRel(p),
@@ -818,7 +837,10 @@ var _ Path = ModuleObjPath{}
// PathForModuleObj returns a Path representing the paths... under the module's
// 'obj' directory.
func PathForModuleObj(ctx ModuleContext, pathComponents ...string) ModuleObjPath {
- p := validatePath(ctx, pathComponents...)
+ p, err := validatePath(pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
return ModuleObjPath{PathForModuleOut(ctx, "obj", p)}
}
@@ -833,7 +855,11 @@ var _ Path = ModuleResPath{}
// PathForModuleRes returns a Path representing the paths... under the module's
// 'res' directory.
func PathForModuleRes(ctx ModuleContext, pathComponents ...string) ModuleResPath {
- p := validatePath(ctx, pathComponents...)
+ p, err := validatePath(pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
+
return ModuleResPath{PathForModuleOut(ctx, "res", p)}
}
@@ -879,36 +905,34 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
// validateSafePath validates a path that we trust (may contain ninja variables).
// Ensures that each path component does not attempt to leave its component.
-func validateSafePath(ctx PathContext, pathComponents ...string) string {
+func validateSafePath(pathComponents ...string) (string, error) {
for _, path := range pathComponents {
path := filepath.Clean(path)
if path == ".." || strings.HasPrefix(path, "../") || strings.HasPrefix(path, "/") {
- reportPathError(ctx, "Path is outside directory: %s", path)
- return ""
+ return "", fmt.Errorf("Path is outside directory: %s", path)
}
}
// TODO: filepath.Join isn't necessarily correct with embedded ninja
// variables. '..' may remove the entire ninja variable, even if it
// will be expanded to multiple nested directories.
- return filepath.Join(pathComponents...)
+ return filepath.Join(pathComponents...), nil
}
// validatePath validates that a path does not include ninja variables, and that
// each path component does not attempt to leave its component. Returns a joined
// version of each path component.
-func validatePath(ctx PathContext, pathComponents ...string) string {
+func validatePath(pathComponents ...string) (string, error) {
for _, path := range pathComponents {
if strings.Contains(path, "$") {
- reportPathError(ctx, "Path contains invalid character($): %s", path)
- return ""
+ return "", fmt.Errorf("Path contains invalid character($): %s", path)
}
}
- return validateSafePath(ctx, pathComponents...)
+ return validateSafePath(pathComponents...)
}
func PathForPhony(ctx PathContext, phony string) WritablePath {
if strings.ContainsAny(phony, "$/") {
- reportPathError(ctx, "Phony target contains invalid character ($ or /): %s", phony)
+ reportPathErrorf(ctx, "Phony target contains invalid character ($ or /): %s", phony)
}
return PhonyPath{basePath{phony, ctx.Config(), ""}}
}
@@ -931,7 +955,10 @@ func (p testPath) String() string {
}
func PathForTesting(paths ...string) Path {
- p := validateSafePath(nil, paths...)
+ p, err := validateSafePath(paths...)
+ if err != nil {
+ panic(err)
+ }
return testPath{basePath{path: p, rel: p}}
}
diff --git a/android/paths_test.go b/android/paths_test.go
index 61a172fa..00757985 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -110,17 +110,27 @@ var validatePathTestCases = append(commonValidatePathTestCases, []strsTestCase{
func TestValidateSafePath(t *testing.T) {
for _, testCase := range validateSafePathTestCases {
- ctx := &configErrorWrapper{}
- out := validateSafePath(ctx, testCase.in...)
- check(t, "validateSafePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
+ t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
+ ctx := &configErrorWrapper{}
+ out, err := validateSafePath(testCase.in...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
+ check(t, "validateSafePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
+ })
}
}
func TestValidatePath(t *testing.T) {
for _, testCase := range validatePathTestCases {
- ctx := &configErrorWrapper{}
- out := validatePath(ctx, testCase.in...)
- check(t, "validatePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
+ t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
+ ctx := &configErrorWrapper{}
+ out, err := validatePath(testCase.in...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
+ check(t, "validatePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
+ })
}
}
@@ -133,6 +143,7 @@ func TestOptionalPath(t *testing.T) {
}
func checkInvalidOptionalPath(t *testing.T, path OptionalPath) {
+ t.Helper()
if path.Valid() {
t.Errorf("Uninitialized OptionalPath should not be valid")
}
@@ -150,9 +161,11 @@ func checkInvalidOptionalPath(t *testing.T, path OptionalPath) {
func check(t *testing.T, testType, testString string,
got interface{}, err []error,
expected interface{}, expectedErr []error) {
+ t.Helper()
printedTestCase := false
e := func(s string, expected, got interface{}) {
+ t.Helper()
if !printedTestCase {
t.Errorf("test case %s: %s", testType, testString)
printedTestCase = true
diff --git a/cc/pgo.go b/cc/pgo.go
index 779ef39d..10c8daca 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -102,7 +102,7 @@ func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags
func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath {
// Test if the profile_file is present in any of the PGO profile projects
for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) {
- path := android.ExistentPathForSource(ctx, "", profileProject, *props.Pgo.Profile_file)
+ path := android.ExistentPathForSource(ctx, profileProject, *props.Pgo.Profile_file)
if path.Valid() {
return path
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index efd430ad..ac6bd338 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -374,10 +374,8 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
// templateDir (maybe missing) is relative to top of the source tree instead of current module.
- templateDir := android.PathsForSource(ctx, []string{String(d.properties.Custom_template_dir)})
- if len(templateDir) > 0 {
- implicits = append(implicits, ctx.GlobFiles(filepath.Join(templateDir[0].String(), "**/*"), nil)...)
- }
+ templateDir := android.PathForSource(ctx, String(d.properties.Custom_template_dir)).String()
+ implicits = append(implicits, ctx.GlobFiles(filepath.Join(templateDir, "**/*"), nil)...)
var htmlDirArgs string
if len(d.properties.Html_dirs) > 0 {
@@ -420,7 +418,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
opts := "-source 1.8 -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file " +
"-doclet com.google.doclava.Doclava -docletpath ${config.JsilverJar}:${config.DoclavaJar} " +
- "-templatedir " + String(d.properties.Custom_template_dir) + " " + htmlDirArgs + " " + htmlDir2Args + " " +
+ "-templatedir " + templateDir + " " + htmlDirArgs + " " + htmlDir2Args + " " +
"-hdf page.build " + ctx.Config().BuildId() + "-" + ctx.Config().BuildNumberFromFile() + " " +
"-hdf page.now " + `"$$(date -d @$$(cat ` + ctx.Config().Getenv("BUILD_DATETIME_FILE") + `) "+%d %b %Y %k:%M")"` + " " +
args + " -stubs " + android.PathForModuleOut(ctx, "docs", "stubsDir").String()
diff --git a/java/java.go b/java/java.go
index 4a7d7043..ae48bd65 100644
--- a/java/java.go
+++ b/java/java.go
@@ -371,8 +371,8 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
jar = filepath.Join(dir, "core.jar")
}
aidl := filepath.Join(dir, "framework.aidl")
- jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
- aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
+ jarPath := android.ExistentPathForSource(ctx, jar)
+ aidlPath := android.ExistentPathForSource(ctx, aidl)
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
return sdkDep{
@@ -530,7 +530,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
- if src := android.ExistentPathForSource(ctx, "", ctx.ModuleDir(), "src"); src.Valid() {
+ if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
flags = append(flags, "-I"+src.String())
}