aboutsummaryrefslogtreecommitdiffstats
path: root/java/app_builder.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-09-23 15:26:20 -0700
committerDan Willemsen <dwillemsen@google.com>2015-12-09 14:29:12 -0800
commit34cc69e4bf36cb65bb181b42ccb0f8c792a32cfb (patch)
treeecaff919037e29033fa9b3bbfb33baa8e93196cf /java/app_builder.go
parentfafa3dc7e267675610a34b0c335be350eb30936d (diff)
downloadbuild_soong-34cc69e4bf36cb65bb181b42ccb0f8c792a32cfb.tar.gz
build_soong-34cc69e4bf36cb65bb181b42ccb0f8c792a32cfb.tar.bz2
build_soong-34cc69e4bf36cb65bb181b42ccb0f8c792a32cfb.zip
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
Diffstat (limited to 'java/app_builder.go')
-rw-r--r--java/app_builder.go65
1 files changed, 30 insertions, 35 deletions
diff --git a/java/app_builder.go b/java/app_builder.go
index 849abfd3..2a475196 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -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, " "),
},