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
This commit is contained in:
@@ -19,7 +19,6 @@ package java
|
||||
// functions.
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
@@ -75,44 +74,40 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
pctx.StaticVariable("androidManifestMergerCmd", "${srcDir}/prebuilts/devtools/tools/lib/manifest-merger.jar")
|
||||
pctx.VariableFunc("aaptCmd", func(c interface{}) (string, error) {
|
||||
return c.(common.Config).HostBinTool("aapt")
|
||||
})
|
||||
pctx.VariableFunc("signapkCmd", func(c interface{}) (string, error) {
|
||||
return c.(common.Config).HostJavaTool("signapk.jar")
|
||||
})
|
||||
pctx.SourcePathVariable("androidManifestMergerCmd", "prebuilts/devtools/tools/lib/manifest-merger.jar")
|
||||
pctx.HostBinToolVariable("aaptCmd", "aapt")
|
||||
pctx.HostJavaToolVariable("signapkCmd", "signapk.jar")
|
||||
}
|
||||
|
||||
func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
|
||||
deps []string) (string, string, string) {
|
||||
javaDir := filepath.Join(common.ModuleGenDir(ctx), "R")
|
||||
javaFileList := filepath.Join(common.ModuleOutDir(ctx), "R.filelist")
|
||||
publicResourcesFile := filepath.Join(common.ModuleOutDir(ctx), "public_resources.xml")
|
||||
proguardOptionsFile := filepath.Join(common.ModuleOutDir(ctx), "proguard.options")
|
||||
deps common.Paths) (common.Path, common.Path, common.Path) {
|
||||
javaDir := common.PathForModuleGen(ctx, "R")
|
||||
javaFileList := common.PathForModuleOut(ctx, "R.filelist")
|
||||
publicResourcesFile := common.PathForModuleOut(ctx, "public_resources.xml")
|
||||
proguardOptionsFile := common.PathForModuleOut(ctx, "proguard.options")
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
Rule: aaptCreateResourceJavaFile,
|
||||
Outputs: []string{publicResourcesFile, proguardOptionsFile, javaFileList},
|
||||
Outputs: common.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"aaptFlags": strings.Join(flags, " "),
|
||||
"publicResourcesFile": publicResourcesFile,
|
||||
"proguardOptionsFile": proguardOptionsFile,
|
||||
"javaDir": javaDir,
|
||||
"javaFileList": javaFileList,
|
||||
"publicResourcesFile": publicResourcesFile.String(),
|
||||
"proguardOptionsFile": proguardOptionsFile.String(),
|
||||
"javaDir": javaDir.String(),
|
||||
"javaFileList": javaFileList.String(),
|
||||
},
|
||||
})
|
||||
|
||||
return publicResourcesFile, proguardOptionsFile, javaFileList
|
||||
}
|
||||
|
||||
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps []string) string {
|
||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package-export.apk")
|
||||
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps common.Paths) common.ModuleOutPath {
|
||||
outputFile := common.PathForModuleOut(ctx, "package-export.apk")
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
Rule: aaptCreateAssetsPackage,
|
||||
Outputs: []string{outputFile},
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"aaptFlags": strings.Join(flags, " "),
|
||||
@@ -122,31 +117,31 @@ func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps [
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile string,
|
||||
certificates []string) string {
|
||||
func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile common.Path,
|
||||
certificates []string) common.Path {
|
||||
|
||||
resourceApk := filepath.Join(common.ModuleOutDir(ctx), "resources.apk")
|
||||
resourceApk := common.PathForModuleOut(ctx, "resources.apk")
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: aaptAddResources,
|
||||
Outputs: []string{resourceApk},
|
||||
Inputs: []string{jarFile},
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
Rule: aaptAddResources,
|
||||
Output: resourceApk,
|
||||
Input: jarFile,
|
||||
Args: map[string]string{
|
||||
"aaptFlags": strings.Join(flags, " "),
|
||||
},
|
||||
})
|
||||
|
||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package.apk")
|
||||
outputFile := common.PathForModuleOut(ctx, "package.apk")
|
||||
|
||||
var certificateArgs []string
|
||||
for _, c := range certificates {
|
||||
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
|
||||
}
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: signapk,
|
||||
Outputs: []string{outputFile},
|
||||
Inputs: []string{resourceApk},
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
Rule: signapk,
|
||||
Output: outputFile,
|
||||
Input: resourceApk,
|
||||
Args: map[string]string{
|
||||
"certificates": strings.Join(certificateArgs, " "),
|
||||
},
|
||||
|
Reference in New Issue
Block a user