diff options
author | 2015-06-01 14:45:21 +0000 | |
---|---|---|
committer | 2015-06-01 15:50:49 +0000 | |
commit | eb6e90397eff1083f0574b6cbd94eb9f42d2d239 (patch) | |
tree | 7eac158033f6db031ea5ac167f75fd3ff800c4a1 /third_party/ijar | |
parent | 14b437bf749baf0488cfc7e4ed7589dc4af9bec3 (diff) |
Use the ijar ZIP implementation in Blaze instead of libarchive
This ZIP implementation is lightweight and rely on zlib for
compression. libarchive was a bit tricky to set-up so it's
better to use that one.
--
Change-Id: I607b492998572e834e095a4606eeb77c0b574542
Reviewed-on: https://bazel-review.googlesource.com/#/c/1410/
MOS_MIGRATED_REVID=94910072
Diffstat (limited to 'third_party/ijar')
-rw-r--r-- | third_party/ijar/BUILD | 4 | ||||
-rwxr-xr-x | third_party/ijar/test/zip_test.sh | 2 | ||||
-rw-r--r-- | third_party/ijar/zip.cc | 11 | ||||
-rw-r--r-- | third_party/ijar/zip.h | 5 | ||||
-rw-r--r-- | third_party/ijar/zip_main.cc | 1 |
5 files changed, 17 insertions, 6 deletions
diff --git a/third_party/ijar/BUILD b/third_party/ijar/BUILD index 1ab0975c02..2224dd6c93 100644 --- a/third_party/ijar/BUILD +++ b/third_party/ijar/BUILD @@ -14,7 +14,9 @@ cc_library( "common.h", "zip.h", ], - # TODO(bazel-team): we should replace the -lz flag. + # TODO(bazel-team): we should replace the -lz flag, it is non-hermetic. + # We should instead use a new_local_repository once the autoconf + # mechanism is ready. linkopts = ["-lz"], ) diff --git a/third_party/ijar/test/zip_test.sh b/third_party/ijar/test/zip_test.sh index 3cecd9527c..b3247fd60b 100755 --- a/third_party/ijar/test/zip_test.sh +++ b/third_party/ijar/test/zip_test.sh @@ -18,7 +18,7 @@ DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ## Inputs -ZIPPER=$TEST_SRCDIR/$1 +ZIPPER=${PWD}/$1 shift UNZIP=$1 shift diff --git a/third_party/ijar/zip.cc b/third_party/ijar/zip.cc index 989f50b826..604c2f1467 100644 --- a/third_party/ijar/zip.cc +++ b/third_party/ijar/zip.cc @@ -54,11 +54,13 @@ #define GENERAL_PURPOSE_BIT_FLAG_COMPRESSED (1 << 3) #define GENERAL_PURPOSE_BIT_FLAG_UTF8_ENCODED (1 << 11) +#define GENERAL_PURPOSE_BIT_FLAG_COMPRESSION_SPEED ((1 << 2) | (1 << 1)) #define GENERAL_PURPOSE_BIT_FLAG_SUPPORTED \ - (GENERAL_PURPOSE_BIT_FLAG_COMPRESSED | GENERAL_PURPOSE_BIT_FLAG_UTF8_ENCODED) + (GENERAL_PURPOSE_BIT_FLAG_COMPRESSED \ + | GENERAL_PURPOSE_BIT_FLAG_UTF8_ENCODED \ + | GENERAL_PURPOSE_BIT_FLAG_COMPRESSION_SPEED) namespace devtools_ijar { - // In the absence of ZIP64 support, zip files are limited to 4GB. // http://www.info-zip.org/FAQ.html#limits static const u8 kMaximumOutputSize = std::numeric_limits<uint32_t>::max(); @@ -119,8 +121,11 @@ class InputZipFile : public ZipExtractor { // time it is found too small, until it reaches MAX_BUFFER_SIZE. If that is // not enough, we bail out. We only decompress class files, so they should // be smaller than 64K anyway, but we give a little leeway. + // MAX_BUFFER_SIZE must be bigger than the size of the biggest file in the + // ZIP. It is set to 128M here so we can uncompress the Bazel server with + // this library. static const size_t INITIAL_BUFFER_SIZE = 256 * 1024; // 256K - static const size_t MAX_BUFFER_SIZE = 16 * 1024 * 1024; + static const size_t MAX_BUFFER_SIZE = 128 * 1024 * 1024; static const size_t MAX_MAPPED_REGION = 32 * 1024 * 1024; // These metadata fields are the fields of the ZIP header of the file being diff --git a/third_party/ijar/zip.h b/third_party/ijar/zip.h index 97a8e28af2..046072d25a 100644 --- a/third_party/ijar/zip.h +++ b/third_party/ijar/zip.h @@ -26,6 +26,11 @@ namespace devtools_ijar { +// Tells if this is a directory entry from the mode. This method +// is safer than zipattr_to_mode(attr) & S_IFDIR because the unix +// mode might not be set in DOS zip files. +inline bool zipattr_is_dir(u4 attr) { return (attr & 0x10) != 0; } + // Convert a Unix file mode to a ZIP file attribute inline u4 mode_to_zipattr(mode_t m) { return (((u4) m) << 16) + ((m & S_IFDIR) != 0 ? 0x10 : 0); diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc index 096662368c..11b0c06f58 100644 --- a/third_party/ijar/zip_main.cc +++ b/third_party/ijar/zip_main.cc @@ -72,7 +72,6 @@ class UnzipProcessor : public ZipExtractorProcessor { void concat_path(char* out, const size_t size, const char *path1, const char *path2) { int len1 = strlen(path1); - int len2 = strlen(path2); int l = len1; strncpy(out, path1, size-1); out[size-1] = 0; |