aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-04-10 17:44:24 -0700
committerColin Cross <ccross@android.com>2015-04-13 12:25:40 -0700
commit6d1e72d7c69d1787b6d7edf990925a65f43b48ea (patch)
treecef145ab5b2bf3a4f528845ca70c26bffab42e17 /java
parent2097830df79aa14ebe581f477406a34e6f5cb7e9 (diff)
downloadbuild_soong-6d1e72d7c69d1787b6d7edf990925a65f43b48ea.tar.gz
build_soong-6d1e72d7c69d1787b6d7edf990925a65f43b48ea.tar.bz2
build_soong-6d1e72d7c69d1787b6d7edf990925a65f43b48ea.zip
Fix multi-dex builds
Building with --multi-dex requires passing an output directory instead of an output file to dx. Change-Id: I9ffcfe8ff6b96dbdda3eec1076124cd38ae5077f
Diffstat (limited to 'java')
-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)