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

@@ -385,11 +385,9 @@ func (j *Module) compile(ctx android.ModuleContext) {
}
resourceJarSpecs := ResourceDirsToJarSpecs(ctx, j.properties.Resource_dirs, j.properties.Exclude_resource_dirs)
manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
if len(resourceJarSpecs) > 0 || manifest.Valid() {
if len(resourceJarSpecs) > 0 {
// Combine classes + resources into classes-full-debug.jar
resourceJar := TransformResourcesToJar(ctx, resourceJarSpecs, manifest, extraJarDeps)
resourceJar := TransformResourcesToJar(ctx, resourceJarSpecs, extraJarDeps)
if ctx.Failed() {
return
}
@@ -399,9 +397,11 @@ func (j *Module) compile(ctx android.ModuleContext) {
jars = append(jars, deps.staticJars...)
manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
// Combine the classes built from sources, any manifests, and any static libraries into
// classes-combined.jar. If there is only one input jar this step will be skipped.
outputFile := TransformJarsToJar(ctx, "classes-combined.jar", jars)
outputFile := TransformJarsToJar(ctx, "classes.jar", jars, manifest, false)
if j.properties.Jarjar_rules != nil {
jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
@@ -616,7 +616,7 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
j.combinedClasspathFile = TransformJarsToJar(ctx, "classes.jar", j.classpathFiles)
j.combinedClasspathFile = TransformJarsToJar(ctx, "classes.jar", j.classpathFiles, android.OptionalPath{}, false)
}
var _ Dependency = (*Import)(nil)