Use `Path` instead of string for file paths
This centralizes verification and common operations, like converting the
path to a source file to the path for a built object.
It also embeds the configuration knowledge into the path, so that we can
remove "${SrcDir}/path" from the ninja file. When SrcDir is '.', that
leads to paths like './path' instead of just 'path' like make is doing,
causing differences in compiled binaries.
Change-Id: Ib4e8910a6e867ce1b7b420d927c04f1142a7589e
diff --git a/java/resources.go b/java/resources.go
index 405d8b0..4f734f2 100644
--- a/java/resources.go
+++ b/java/resources.go
@@ -42,7 +42,7 @@
var excludes []string
for _, exclude := range excludeDirs {
- excludes = append(excludes, filepath.Join(common.ModuleSrcDir(ctx), exclude, "**/*"))
+ excludes = append(excludes, common.PathForModuleSrc(ctx, exclude, "**/*").String())
}
excludes = append(excludes, resourceExcludes...)
@@ -53,15 +53,14 @@
if isStringInSlice(resourceDir, excludeDirs) {
continue
}
- resourceDir := filepath.Join(common.ModuleSrcDir(ctx), resourceDir)
- dirs := ctx.Glob("java_resources", resourceDir, nil)
+ resourceDir := common.PathForModuleSrc(ctx, resourceDir)
+ dirs := ctx.Glob("java_resources", resourceDir.String(), nil)
for _, dir := range dirs {
- relDir := common.SrcDirRelPath(ctx, dir)
- fileListFile := filepath.Join(common.ModuleOutDir(ctx), "res", relDir, "resources.list")
- depFile := fileListFile + ".d"
+ fileListFile := common.ResPathWithName(ctx, dir, "resources.list")
+ depFile := fileListFile.String() + ".d"
- glob := filepath.Join(dir, "**/*")
- common.GlobRule(ctx, glob, excludes, fileListFile, depFile)
+ glob := filepath.Join(dir.String(), "**/*")
+ common.GlobRule(ctx, glob, excludes, fileListFile.String(), depFile)
jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir})
}
}