Bug 1355671 - Build the brotli command line tool as a host program. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 07 Apr 2017 17:02:54 +0900
changeset 353707 55cb8ab2f8466b99cf88d6c59d2ab151b89065e9
parent 353706 666f87b2d58fab1d0feed62f695635129239f8d5
child 353708 6b410448e079878a8414a6718efc6f4c2bfad001
push id31675
push usercbook@mozilla.com
push dateWed, 19 Apr 2017 08:28:05 +0000
treeherdermozilla-central@245811243903 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1355671
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1355671 - Build the brotli command line tool as a host program. r=gps
modules/brotli/clang-cl-exceptions.patch
modules/brotli/moz.build
modules/brotli/tools/bro.cc
modules/brotli/update.sh
new file mode 100644
--- /dev/null
+++ b/modules/brotli/clang-cl-exceptions.patch
@@ -0,0 +1,39 @@
+diff --git a/tools/bro.cc b/tools/bro.cc
+index b254f0ffdb08..30d9858a95b3 100644
+--- a/tools/bro.cc
++++ b/tools/bro.cc
+@@ -282,29 +282,34 @@ int main(int argc, char** argv) {
+     FILE* fin = OpenInputFile(input_path);
+     FILE* fout = OpenOutputFile(output_path, force);
+     if (decompress) {
+       Decompresss(fin, fout);
+     } else {
+       brotli::BrotliParams params;
+       params.lgwin = lgwin;
+       params.quality = quality;
++/* clang-cl doesn't like exceptions */
++#if !defined(_MSC_VER) || !defined(__clang__)
+       try {
++#endif
+         brotli::BrotliFileIn in(fin, 1 << 16);
+         brotli::BrotliFileOut out(fout);
+         if (!BrotliCompress(params, &in, &out)) {
+           fprintf(stderr, "compression failed\n");
+           unlink(output_path);
+           exit(1);
+         }
++#if !defined(_MSC_VER) || !defined(__clang__)
+       } catch (std::bad_alloc&) {
+         fprintf(stderr, "not enough memory\n");
+         unlink(output_path);
+         exit(1);
+       }
++#endif
+     }
+     if (fclose(fin) != 0) {
+       perror("fclose");
+       exit(1);
+     }
+     if (fclose(fout) != 0) {
+       perror("fclose");
+       exit(1);
--- a/modules/brotli/moz.build
+++ b/modules/brotli/moz.build
@@ -16,8 +16,29 @@ UNIFIED_SOURCES += [
 ]
 
 # We allow warnings for third-party code that can be updated from upstream.
 ALLOW_COMPILER_WARNINGS = True
 
 CFLAGS += ['-DBROTLI_BUILD_PORTABLE']
 
 Library('brotli')
+
+HostProgram('bro')
+
+HOST_SOURCES += UNIFIED_SOURCES
+
+HOST_SOURCES += [
+    'enc/backward_references.cc',
+    'enc/block_splitter.cc',
+    'enc/brotli_bit_stream.cc',
+    'enc/compress_fragment.cc',
+    'enc/compress_fragment_two_pass.cc',
+    'enc/encode.cc',
+    'enc/entropy_encode.cc',
+    'enc/histogram.cc',
+    'enc/literal_cost.cc',
+    'enc/metablock.cc',
+    'enc/static_dict.cc',
+    'enc/streams.cc',
+    'enc/utf8_util.cc',
+    'tools/bro.cc',
+]
--- a/modules/brotli/tools/bro.cc
+++ b/modules/brotli/tools/bro.cc
@@ -282,29 +282,34 @@ int main(int argc, char** argv) {
     FILE* fin = OpenInputFile(input_path);
     FILE* fout = OpenOutputFile(output_path, force);
     if (decompress) {
       Decompresss(fin, fout);
     } else {
       brotli::BrotliParams params;
       params.lgwin = lgwin;
       params.quality = quality;
+/* clang-cl doesn't like exceptions */
+#if !defined(_MSC_VER) || !defined(__clang__)
       try {
+#endif
         brotli::BrotliFileIn in(fin, 1 << 16);
         brotli::BrotliFileOut out(fout);
         if (!BrotliCompress(params, &in, &out)) {
           fprintf(stderr, "compression failed\n");
           unlink(output_path);
           exit(1);
         }
+#if !defined(_MSC_VER) || !defined(__clang__)
       } catch (std::bad_alloc&) {
         fprintf(stderr, "not enough memory\n");
         unlink(output_path);
         exit(1);
       }
+#endif
     }
     if (fclose(fin) != 0) {
       perror("fclose");
       exit(1);
     }
     if (fclose(fout) != 0) {
       perror("fclose");
       exit(1);
--- a/modules/brotli/update.sh
+++ b/modules/brotli/update.sh
@@ -13,14 +13,17 @@ perl -p -i -e "s/\[commit [0-9a-f]{40}\]
 
 DIRS="dec enc tools"
 
 for d in $DIRS; do
 	rm -rf $d
 	mv ${MY_TEMP_DIR}/brotli/$d $d
 done
 rm -rf ${MY_TEMP_DIR}
+
+patch -p1 < clang-cl-exceptions.patch
+
 hg addremove $DIRS
 
 echo "###"
 echo "### Updated brotli/dec to $COMMIT."
 echo "### Remember to verify and commit the changes to source control!"
 echo "###"