Rearrange manifest file handling in merge_zips and soong_zip

Jar always puts default MANIFEST.MF files in if none was specified.
Copying that behavior in soong_zip causes problems with merge_zips,
because it ends up taking the default manifest from the classes.jar
instead of the user's manifest from res.jar.  We don't want the
user's manifest in the classes.jar, otherwise a change to the
manifest will cause all the class files to rebuild.  Instead,
move the manifest insertion to the final merge_zips stage.

Test: m -j checkbuild
Change-Id: Id6376961dbaf743c2fb92843f9bdf2e44b963be0
This commit is contained in:
Colin Cross
2017-09-12 22:50:46 -07:00
parent 6eebec7414
commit 635acc9446
7 changed files with 246 additions and 105 deletions

View File

@@ -78,10 +78,10 @@ var (
combineJar = pctx.AndroidStaticRule("combineJar",
blueprint.RuleParams{
Command: `${config.MergeZipsCmd} -j $out $in`,
Command: `${config.MergeZipsCmd} -j $jarArgs $out $in`,
CommandDeps: []string{"${config.MergeZipsCmd}"},
},
"outDir")
"jarArgs")
dx = pctx.AndroidStaticRule("dx",
blueprint.RuleParams{
@@ -126,7 +126,7 @@ func TransformJavaToClasses(ctx android.ModuleContext, srcFiles, srcFileLists an
classDir := android.PathForModuleOut(ctx, "classes")
annoDir := android.PathForModuleOut(ctx, "anno")
classJar := android.PathForModuleOut(ctx, "classes.jar")
classJar := android.PathForModuleOut(ctx, "classes-compiled.jar")
javacFlags := flags.javacFlags + android.JoinWithPrefix(srcFileLists.Strings(), "@")
@@ -187,7 +187,7 @@ func RunErrorProne(ctx android.ModuleContext, srcFiles android.Paths, srcFileLis
}
func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
manifest android.OptionalPath, deps android.Paths) android.Path {
deps android.Paths) android.Path {
outputFile := android.PathForModuleOut(ctx, "res.jar")
@@ -198,11 +198,6 @@ func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
jarArgs = append(jarArgs, j.soongJarArgs())
}
if manifest.Valid() {
deps = append(deps, manifest.Path())
jarArgs = append(jarArgs, "-m "+manifest.String())
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: jar,
Description: "jar",
@@ -216,19 +211,36 @@ func TransformResourcesToJar(ctx android.ModuleContext, resources []jarSpec,
return outputFile
}
func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Paths) android.Path {
func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Paths,
manifest android.OptionalPath, stripDirs bool) android.Path {
outputFile := android.PathForModuleOut(ctx, stem)
if len(jars) == 1 {
if len(jars) == 1 && !manifest.Valid() {
return jars[0]
}
var deps android.Paths
var jarArgs []string
if manifest.Valid() {
jarArgs = append(jarArgs, "-m "+manifest.String())
deps = append(deps, manifest.Path())
}
if stripDirs {
jarArgs = append(jarArgs, "-D")
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: combineJar,
Description: "combine jars",
Output: outputFile,
Inputs: jars,
Implicits: deps,
Args: map[string]string{
"jarArgs": strings.Join(jarArgs, " "),
},
})
return outputFile