POS: brotli
authorMichael Wallner <mike@php.net>
Tue, 27 Feb 2018 10:04:52 +0000 (11:04 +0100)
committerMichael Wallner <mike@php.net>
Tue, 27 Feb 2018 10:04:52 +0000 (11:04 +0100)
autoconf/pecl/libbrotli.m4
src/php_http_encoding_brotli.c
travis/brotli.sh

index 8ea8b1f8c3d14fd7744fcb7799a520a400529d8a..6d9a80edf73e24b7d84cd42d7078a5f9d03f5d18 100644 (file)
@@ -1,15 +1,30 @@
 
 AC_DEFUN([PECL_CHECK_LIBBROTLI], [
+       PECL_CHECK_LIBBROTLI_COMMON([$1], [$2])
+       PECL_CHECK_DONE(libbrotlicommon, [$PECL_VAR([HAVE_LIBBROTLI_COMMON])])
        PECL_CHECK_LIBBROTLI_DEC([$1], [$2])
        PECL_CHECK_DONE(libbrotlidec, [$PECL_VAR([HAVE_LIBBROTLI_DEC])])
        PECL_CHECK_LIBBROTLI_ENC([$1], [$2])
        PECL_CHECK_DONE(libbrotlienc, [$PECL_VAR([HAVE_LIBBROTLI_ENC])])
        
-       if $PECL_VAR([HAVE_LIBBROTLI_DEC]) && $PECL_VAR([HAVE_LIBBROTLI_ENC]); then
+       if $PECL_VAR([HAVE_LIBBROTLI_COMMON]) \
+       && $PECL_VAR([HAVE_LIBBROTLI_DEC]) \
+       && $PECL_VAR([HAVE_LIBBROTLI_ENC]); then
                PECL_VAR([HAVE_LIBBROTLI])=true
        fi
 ])
 
+AC_DEFUN([PECL_CHECK_LIBBROTLI_COMMON], [
+       PECL_CHECK_PKGCONFIG(libbrotlicommon, [$1])
+       
+       PECL_HAVE_VERSION(libbrotlicommon, ifelse($2,,1.0,$2), [
+               PECL_VAR([HAVE_LIBBROTLI_COMMON])=true
+       ], [
+               AC_MSG_WARN([skipping libbrotli])
+               PECL_VAR([HAVE_LIBBROTLI_COMMON])=false
+       ])
+])
+
 AC_DEFUN([PECL_CHECK_LIBBROTLI_DEC], [
        PECL_CHECK_PKGCONFIG(libbrotlidec, [$1])
        
index a46a2f6af6f987e9dc3d77fb6496390e3e522980..dbea978db988d3f2944e10d2580a317b874e2a0f 100644 (file)
@@ -397,10 +397,17 @@ static zend_function_entry php_http_debrotli_stream_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
+/* POS */
+const void *BrotliGetDictionary();
+const void *(*php_http_brotli_get_dictionary)();
+
 PHP_MINIT_FUNCTION(http_encoding_brotli)
 {
        zend_class_entry ce;
 
+       /* force link to libbrotlicommon, because their libraries don't */
+       php_http_brotli_get_dictionary = BrotliGetDictionary();
+
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Enbrotli", php_http_enbrotli_stream_methods);
        php_http_enbrotli_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_get_encoding_stream_class_entry());
index 1a9f6cd93670fcd08457f73bdae5907e60a1ed7a..4fec33ea4fd7999c3e65fad55138ecba60070c89 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-git clone https://github.com/google/brotli.git
-cd brotli
+git clone https://github.com/google/brotli.git /home/travis/brotli.git
+cd /home/travis/brotli.git
 git checkout v1.0.2
 ./bootstrap
 ./configure --prefix=/home/travis/brotli