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