compile_extension.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname $0)/..
  4. # utf8_range has to live in the base third_party directory.
  5. # We copy it into the ext/google/protobuf directory for the build
  6. # (and for the release to PECL).
  7. rm -rf ext/google/protobuf/third_party
  8. mkdir -p ext/google/protobuf/third_party/utf8_range
  9. cp ../third_party/utf8_range/* ext/google/protobuf/third_party/utf8_range
  10. echo "Copied utf8_range from ../third_party -> ext/google/protobuf/third_party"
  11. pushd ext/google/protobuf > /dev/null
  12. CONFIGURE_OPTIONS=("./configure" "--with-php-config=$(which php-config)")
  13. if [ "$1" != "--release" ]; then
  14. CONFIGURE_OPTIONS+=("CFLAGS=-g -O0 -Wall -DPBPHP_ENABLE_ASSERTS")
  15. fi
  16. FINGERPRINT="$(sha256sum $(which php)) ${CONFIGURE_OPTIONS[@]}"
  17. # If the PHP interpreter we are building against or the arguments
  18. # have changed, we must regenerated the Makefile.
  19. if [[ ! -f BUILD_STAMP ]] || [[ "$(cat BUILD_STAMP)" != "$FINGERPRINT" ]]; then
  20. phpize --clean
  21. rm -f configure.in configure.ac
  22. phpize
  23. "${CONFIGURE_OPTIONS[@]}"
  24. echo "$FINGERPRINT" > BUILD_STAMP
  25. fi
  26. make
  27. TEST_PHP_ARGS="-q" make test
  28. popd > /dev/null