aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/builder.go20
-rw-r--r--java/java.go4
2 files changed, 13 insertions, 11 deletions
diff --git a/java/builder.go b/java/builder.go
index d939e6a6..94f67ebc 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -58,7 +58,9 @@ var (
dx = pctx.StaticRule("dx",
blueprint.RuleParams{
- Command: "$dxCmd --dex --output=$out $dxFlags $in",
+ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
+ `$dxCmd --dex --output=$outDir $dxFlags $in || ( rm -rf "$outDir"; exit 41 ) && ` +
+ `find "$outDir" -name "classes*.dex" > $out`,
Description: "dex $out",
},
"outDir", "dxFlags")
@@ -164,9 +166,10 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
}
func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar string,
- flags javaBuilderFlags) string {
+ flags javaBuilderFlags) jarSpec {
- outputFile := filepath.Join(common.ModuleOutDir(ctx), "classes.dex")
+ outDir := filepath.Join(common.ModuleOutDir(ctx), "dex")
+ outputFile := filepath.Join(common.ModuleOutDir(ctx), "dex.filelist")
ctx.Build(pctx, blueprint.BuildParams{
Rule: dx,
@@ -175,14 +178,15 @@ func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar string
Implicits: []string{"$dxCmd"},
Args: map[string]string{
"dxFlags": flags.dxFlags,
+ "outDir": outDir,
},
})
- return outputFile
+ return jarSpec{outputFile, outDir}
}
func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
- dexFile string) string {
+ dexJarSpec jarSpec) string {
outputFile := filepath.Join(common.ModuleOutDir(ctx), "javalib.jar")
var deps []string
@@ -193,10 +197,8 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
jarArgs = append(jarArgs, j.soongJarArgs())
}
- dexDir, _ := filepath.Split(dexFile)
- jarArgs = append(jarArgs, "-C "+dexDir+" -f "+dexFile)
-
- deps = append(deps, "$jarCmd", dexFile)
+ deps = append(deps, dexJarSpec.fileList)
+ jarArgs = append(jarArgs, dexJarSpec.soongJarArgs())
ctx.Build(pctx, blueprint.BuildParams{
Rule: jar,
diff --git a/java/java.go b/java/java.go
index 2d1aaa53..7f6b1346 100644
--- a/java/java.go
+++ b/java/java.go
@@ -326,13 +326,13 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
flags.dxFlags = strings.Join(dxFlags, " ")
// Compile classes.jar into classes.dex
- dexFile := TransformClassesJarToDex(ctx, outputFile, flags)
+ dexJarSpec := TransformClassesJarToDex(ctx, outputFile, flags)
if ctx.Failed() {
return
}
// Combine classes.dex + resources into javalib.jar
- outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexFile)
+ outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec)
}
j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", outputFile)