Fix multi-dex builds
Building with --multi-dex requires passing an output directory instead of an output file to dx. Change-Id: I9ffcfe8ff6b96dbdda3eec1076124cd38ae5077f
This commit is contained in:
parent
2097830df7
commit
6d1e72d7c6
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue