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