aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/merge_zips
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-11-22 14:09:40 -0800
committerColin Cross <ccross@android.com>2017-11-22 16:08:35 -0800
commite909e1e0796ab87e4ad32ac12d848263186ef77b (patch)
tree1e71674b25039f406573ac6182a0bb66ab1516de /cmd/merge_zips
parentf3831d0e0831c201406a959f40196eaabf243569 (diff)
downloadbuild_soong-e909e1e0796ab87e4ad32ac12d848263186ef77b.tar.gz
build_soong-e909e1e0796ab87e4ad32ac12d848263186ef77b.tar.bz2
build_soong-e909e1e0796ab87e4ad32ac12d848263186ef77b.zip
Add support for --ignore_duplicates to merge_zips
Add a --ignore_duplicates option to cause merge_zips to silently take the first entry in the case of duplicate entries in the zips to be merged. This will be used for soong Jacoco support to combine the instrumented jar with the original jar to pick up any classes that were excluded. Bug: 69629238 Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true WITH_DEXPREOPT=false Change-Id: I49ede3f07ce0ed7701b4db7058da2e4f11b8043e
Diffstat (limited to 'cmd/merge_zips')
-rw-r--r--cmd/merge_zips/merge_zips.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go
index 207b161c..556dad07 100644
--- a/cmd/merge_zips/merge_zips.go
+++ b/cmd/merge_zips/merge_zips.go
@@ -54,13 +54,14 @@ func (s zipsToNotStripSet) Set(zip_path string) error {
}
var (
- sortEntries = flag.Bool("s", false, "sort entries (defaults to the order from the input zip files)")
- emulateJar = flag.Bool("j", false, "sort zip entries using jar ordering (META-INF first)")
- stripDirs fileList
- stripFiles fileList
- zipsToNotStrip = make(zipsToNotStripSet)
- stripDirEntries = flag.Bool("D", false, "strip directory entries from the output zip file")
- manifest = flag.String("m", "", "manifest file to insert in jar")
+ sortEntries = flag.Bool("s", false, "sort entries (defaults to the order from the input zip files)")
+ emulateJar = flag.Bool("j", false, "sort zip entries using jar ordering (META-INF first)")
+ stripDirs fileList
+ stripFiles fileList
+ zipsToNotStrip = make(zipsToNotStripSet)
+ stripDirEntries = flag.Bool("D", false, "strip directory entries from the output zip file")
+ manifest = flag.String("m", "", "manifest file to insert in jar")
+ ignoreDuplicates = flag.Bool("ignore-duplicates", false, "take each entry from the first zip it exists in and don't warn")
)
func init() {
@@ -118,7 +119,7 @@ func main() {
}
// do merge
- err = mergeZips(readers, writer, *manifest, *sortEntries, *emulateJar, *stripDirEntries)
+ err = mergeZips(readers, writer, *manifest, *sortEntries, *emulateJar, *stripDirEntries, *ignoreDuplicates)
if err != nil {
log.Fatal(err)
}
@@ -210,7 +211,7 @@ type fileMapping struct {
}
func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest string,
- sortEntries, emulateJar, stripDirEntries bool) error {
+ sortEntries, emulateJar, stripDirEntries, ignoreDuplicates bool) error {
sourceByDest := make(map[string]zipSource, 0)
orderedMappings := []fileMapping{}
@@ -266,6 +267,9 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest string,
return fmt.Errorf("Directory/file mismatch at %v from %v and %v\n",
dest, existingSource, source)
}
+ if ignoreDuplicates {
+ continue
+ }
if emulateJar &&
file.Name == jar.ManifestFile || file.Name == jar.ModuleInfoClass {
// Skip manifest and module info files that are not from the first input file