Skip to content

Commit

Permalink
fixes and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Dec 2, 2023
1 parent 4dc62f2 commit d598959
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
14 changes: 8 additions & 6 deletions build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ if [ "$CLEAN" ]; then
fi

# Build libphp if ncessary
if [ ! -f "dist/static-php-cli/buildroot/lib/libphp.a" ]; then
if [ -f "dist/static-php-cli/buildroot/lib/libphp.a" ]; then
cd dist/static-php-cli
else
mkdir -p dist/
cd dist/

Expand Down Expand Up @@ -84,23 +86,23 @@ if [ ! -f "dist/static-php-cli/buildroot/lib/libphp.a" ]; then
./bin/spc fetch --with-php="$PHP_VERSION" --for-extensions="$PHP_EXTENSIONS"
# shellcheck disable=SC2086
./bin/spc build --enable-zts --build-embed $extraOpts "$PHP_EXTENSIONS" --with-libs="$PHP_EXTENSION_LIBS"

cd ../..
fi

CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $(dist/static-php-cli/buildroot/bin/php-config --includes | sed s#-I/#-I"$PWD"/buildroot/#g)"
CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $(./buildroot/bin/php-config --includes | sed s#-I/#-I"$PWD"/buildroot/#g)"
export CGO_CFLAGS
if [ "$os" = "mac" ]; then
export CGO_LDFLAGS="-framework CoreFoundation -framework SystemConfiguration"
fi
CGO_LDFLAGS="$CGO_LDFLAGS $(dist/static-php-cli/buildroot/bin/php-config --ldflags) $(dist/static-php-cli/buildroot/bin/php-config --libs)"
CGO_LDFLAGS="$CGO_LDFLAGS $(./buildroot/bin/php-config --ldflags) $(./buildroot/bin/php-config --libs)"
export CGO_LDFLAGS
LIBPHP_VERSION="$(dist/static-php-cli/buildroot/bin/php-config --version)"
LIBPHP_VERSION="$(./buildroot/bin/php-config --version)"
export LIBPHP_VERSION
cd ../..
# Embed PHP app, if any
if [ -d "$EMBED" ]; then
mv embed embed.bak
Expand Down
17 changes: 14 additions & 3 deletions docs/static.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ docker buildx bake --load --set static-builder.args.PHP_EXTENSIONS=opcache,pdo_s
# ...
```

See [the list of supported extensions](https://static-php.dev/en/guide/extensions.html).

To add libraries enabling additional functionality to the extensions you've enabled, you can pass use the `PHP_EXTENSION_LIBS` Docker ARG:

```console
Expand All @@ -43,6 +41,8 @@ docker buildx bake \
static-builder
```

See also: [customizing the build](#customizing-the-build)

### GitHub Token

If you hit the GitHub API rate limit, set a GitHub Personal Access Token in an environment variable named `GITHUB_TOKEN`:
Expand All @@ -64,4 +64,15 @@ cd frankenphp

Note: this script also works on Linux (and probably on other Unixes), and is used internally by the Docker based static builder we provide.

See [the list of supported extensions](https://static-php.dev/en/guide/extensions.html).
## Customizing The Build

The following environment variables can be passed to `docker build` and to the `build-static.sh`
script to customize the static build:

* `FRANKENPHP_VERSION`: the version of FrankenPHP to use
* `PHP_VERSION`: the version of PHP to use
* `PHP_EXTENSIONS`: the PHP extensions to build ([list of supported extensions](https://static-php.dev/en/guide/extensions.html))
* `PHP_EXTENSION_LIBS`: extra libraries to build that add extra features to the extensions
* `EMBED`: path of the PHP application to embed in the binary
* `CLEAN`: when set, libphp and all its dependencies are built from scratch (no cache)
* `RELEASE`: (maintainers only) when set, the resulting binary will be uploaded on GitHub
2 changes: 2 additions & 0 deletions static-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ARG FRANKENPHP_VERSION=''
ARG PHP_VERSION=''
ARG PHP_EXTENSIONS=''
ARG PHP_EXTENSION_LIBS=''
ARG CLEAN=''
ARG EMBED=''
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk update; \
Expand Down

0 comments on commit d598959

Please sign in to comment.