Skip to content

Commit 88e757d

Browse files
committed
Merge remote-tracking branch 'origin/main' into workers
2 parents 66aa975 + c1a4576 commit 88e757d

1 file changed

Lines changed: 63 additions & 63 deletions

File tree

build-static.sh

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -117,82 +117,82 @@ if [ -n "${CLEAN}" ]; then
117117
go clean -cache
118118
fi
119119

120-
cache_key="${PHP_VERSION}-${PHP_EXTENSIONS}-${PHP_EXTENSION_LIBS}"
120+
mkdir -p dist/
121+
cd dist/
121122

122-
# Build libphp if necessary
123-
if [ -f dist/cache_key ] && [ "$(cat dist/cache_key)" = "${cache_key}" ] && [ -f "dist/static-php-cli/buildroot/lib/libphp.a" ]; then
124-
cd dist/static-php-cli
125-
else
126-
mkdir -p dist/
127-
cd dist/
128-
echo -n "${cache_key}" >cache_key
129-
130-
if type "brew" >/dev/null 2>&1; then
131-
if ! type "composer" >/dev/null; then
132-
packages="composer"
133-
fi
134-
if ! type "go" >/dev/null 2>&1; then
135-
packages="${packages} go"
136-
fi
137-
if [ -n "${RELEASE}" ] && ! type "gh" >/dev/null 2>&1; then
138-
packages="${packages} gh"
139-
fi
140-
141-
if [ -n "${packages}" ]; then
142-
# shellcheck disable=SC2086
143-
brew install --formula --quiet ${packages}
144-
fi
123+
if type "brew" >/dev/null 2>&1; then
124+
if ! type "composer" >/dev/null; then
125+
packages="composer"
145126
fi
146-
147-
if [ "${SPC_REL_TYPE}" = "binary" ]; then
148-
mkdir static-php-cli/
149-
cd static-php-cli/
150-
curl -o spc -fsSL "https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-$(uname -m)"
151-
chmod +x spc
152-
spcCommand="./spc"
153-
elif [ -d "static-php-cli/src" ]; then
154-
cd static-php-cli/
155-
git pull
156-
composer install --no-dev -a
157-
spcCommand="./bin/spc"
158-
else
159-
git clone --depth 1 https://github.com/crazywhalecc/static-php-cli --branch main
160-
cd static-php-cli/
161-
composer install --no-dev -a
162-
spcCommand="./bin/spc"
127+
if ! type "go" >/dev/null 2>&1; then
128+
packages="${packages} go"
163129
fi
164-
165-
# extensions to build
166-
if [ -z "${PHP_EXTENSIONS}" ]; then
167-
# enable EMBED mode, first check if project has dumped extensions
168-
if [ -n "${EMBED}" ] && [ -f "${EMBED}/composer.json" ] && [ -f "${EMBED}/composer.lock" ] && [ -f "${EMBED}/vendor/installed.json" ]; then
169-
cd "${EMBED}"
170-
# read the extensions using spc dump-extensions
171-
PHP_EXTENSIONS=$(${spcCommand} dump-extensions "${EMBED}" --format=text --no-dev --no-ext-output="${defaultExtensions}")
172-
else
173-
PHP_EXTENSIONS="${defaultExtensions}"
174-
fi
130+
if [ -n "${RELEASE}" ] && ! type "gh" >/dev/null 2>&1; then
131+
packages="${packages} gh"
175132
fi
176-
# additional libs to build
177-
if [ -z "${PHP_EXTENSION_LIBS}" ]; then
178-
PHP_EXTENSION_LIBS="${defaultExtensionLibs}"
133+
134+
if [ -n "${packages}" ]; then
135+
# shellcheck disable=SC2086
136+
brew install --formula --quiet ${packages}
179137
fi
180-
# The Brotli library must always be built as it is required by http://github.com/dunglas/caddy-cbrotli
181-
if ! echo "${PHP_EXTENSION_LIBS}" | grep -q "\bbrotli\b"; then
182-
PHP_EXTENSION_LIBS="${PHP_EXTENSION_LIBS},brotli"
138+
fi
139+
140+
if [ "${SPC_REL_TYPE}" = "binary" ]; then
141+
mkdir static-php-cli/
142+
cd static-php-cli/
143+
curl -o spc -fsSL "https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-$(uname -m)"
144+
chmod +x spc
145+
spcCommand="./spc"
146+
elif [ -d "static-php-cli/src" ]; then
147+
cd static-php-cli/
148+
git pull
149+
composer install --no-dev -a --no-interaction
150+
spcCommand="./bin/spc"
151+
else
152+
git clone --depth 1 https://github.com/crazywhalecc/static-php-cli --branch main
153+
cd static-php-cli/
154+
composer install --no-dev -a --no-interaction
155+
spcCommand="./bin/spc"
156+
fi
157+
158+
# extensions to build
159+
if [ -z "${PHP_EXTENSIONS}" ]; then
160+
# enable EMBED mode, first check if project has dumped extensions
161+
if [ -n "${EMBED}" ] && [ -f "${EMBED}/composer.json" ] && [ -f "${EMBED}/composer.lock" ] && [ -f "${EMBED}/vendor/installed.json" ]; then
162+
cd "${EMBED}"
163+
# read the extensions using spc dump-extensions
164+
PHP_EXTENSIONS=$(${spcCommand} dump-extensions "${EMBED}" --format=text --no-dev --no-ext-output="${defaultExtensions}")
165+
else
166+
PHP_EXTENSIONS="${defaultExtensions}"
183167
fi
184-
# The mimalloc library must be built if MIMALLOC is true
185-
if [ -n "${MIMALLOC}" ]; then
186-
if ! echo "${PHP_EXTENSION_LIBS}" | grep -q "\bmimalloc\b"; then
187-
PHP_EXTENSION_LIBS="${PHP_EXTENSION_LIBS},mimalloc"
188-
fi
168+
fi
169+
# additional libs to build
170+
if [ -z "${PHP_EXTENSION_LIBS}" ]; then
171+
PHP_EXTENSION_LIBS="${defaultExtensionLibs}"
172+
fi
173+
# The Brotli library must always be built as it is required by http://github.com/dunglas/caddy-cbrotli
174+
if ! echo "${PHP_EXTENSION_LIBS}" | grep -q "\bbrotli\b"; then
175+
PHP_EXTENSION_LIBS="${PHP_EXTENSION_LIBS},brotli"
176+
fi
177+
# The mimalloc library must be built if MIMALLOC is true
178+
if [ -n "${MIMALLOC}" ]; then
179+
if ! echo "${PHP_EXTENSION_LIBS}" | grep -q "\bmimalloc\b"; then
180+
PHP_EXTENSION_LIBS="${PHP_EXTENSION_LIBS},mimalloc"
189181
fi
182+
fi
190183

184+
# Build libphp if necessary
185+
cache_key="${PHP_VERSION}-${PHP_EXTENSIONS}-${PHP_EXTENSION_LIBS}"
186+
if [ -f ../cache_key ] && [ "$(cat ../cache_key)" = "${cache_key}" ] && [ -f "buildroot/lib/libphp.a" ]; then
187+
echo "Hit cache, skipping libphp build."
188+
else
191189
${spcCommand} doctor --auto-fix
192190
# shellcheck disable=SC2086
193191
${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS}
194192
# shellcheck disable=SC2086
195193
${spcCommand} build --enable-zts --build-embed ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"
194+
195+
echo -n "${cache_key}" >../cache_key
196196
fi
197197

198198
if ! type "go" >/dev/null 2>&1; then

0 commit comments

Comments
 (0)