Compare commits

...

59 Commits
2.4.0 ... 2.4.5

Author SHA1 Message Date
Klaas Skelte van der Werf
15af034b34 Report why the sanity check for the cli target failed (#605) 2025-02-11 10:34:43 +08:00
Jerry Ma
1f281cd376 Fix gettext multithread segment fault bug (#603)
* Fix gettext included with multithreaded bug

* Change --enable-zts to BuildCommand
2025-02-10 20:28:00 +08:00
Jerry Ma
95d741496e Fix windows curl build (using cmake) (#600) 2025-02-06 22:59:02 +08:00
Alexander Over
21de1a2291 add opentelemetry extension support (#593)
* add opentelemetry extension support

* config sort

* cleanup build args

* Update docs

* Adjust custom extension overrides for opentelemetry

* Add tests

* Update README.md and remove windows limitation

* Fix windows static build for opentelemetry

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-02-06 12:27:43 +08:00
Jerry Ma
f19e90afd7 Add extension dio support (#590)
* Add extension dio support

* cs-fix
2025-01-25 17:43:12 +08:00
Jerry Ma
36b4ef306e Fix libtiff dependencies, avoid using system libraries (#588)
* Remove tmate debugger

* Bump version to 2.4.4

* Fix libtiff dependencies may wrongly added

* Add matrix tests

* Add tmate debug

* Disable libdeflate for libtiff

* Remove ssh debugger
2025-01-25 16:15:53 +08:00
crazywhalecc
4bd3a2ae25 Add ssh debug 2025-01-25 12:20:54 +08:00
crazywhalecc
dd647c53ec Add doctor for build-unix CI 2025-01-25 11:35:47 +08:00
crazywhalecc
0c0d16bbb3 Try new build CI 2025-01-25 11:30:59 +08:00
crazywhalecc
c665a18b79 Try new build CI 2025-01-25 11:29:18 +08:00
crazywhalecc
16d448b97c Try new build CI 2025-01-25 11:09:13 +08:00
crazywhalecc
27ccc1189f Try new build CI 2025-01-25 10:59:44 +08:00
Jerry Ma
eecebbcd4d Fix x86_64 macOS CI invalid options 2025-01-25 09:48:15 +08:00
Jerry Ma
2ca5ad075b Add legacy CentOS distro support (#585) 2025-01-13 20:42:09 +08:00
Jean-François Lépine
20dad4cdb3 Merge pull request #583 from Halleck45/support_ast_extension
Support AST extension
2025-01-13 11:11:32 +08:00
crazywhalecc
a3e0ad6b9f Add PHP 8.4 support for cli-generator 2025-01-13 09:33:25 +08:00
Jerry Ma
4b16631d45 Fix openssl missing cert bug for Linux & macOS (#581)
* Fix openssl missing cert bug for linux

* Fix openssl missing cert bug for macOS
2024-12-24 22:06:31 +08:00
Jerry Ma
944f4af914 Update FUNDING.yml 2024-12-23 11:05:21 +08:00
Jerry Ma
4865c1c124 Update README.md 2024-12-23 11:04:46 +08:00
Jerry Ma
78aea56de4 Add aom patch for alpine linux (#579) 2024-12-20 12:18:34 +08:00
Jerry Ma
adbe2e80f3 Update ConsoleApplication.php 2024-12-19 12:28:49 +08:00
Jerry Ma
192c8cde87 Add libaom, libde265, libheif support, for imagick AVIF format support (#575)
* Add libaom, libde265, libheif support, for imagick AVIF format support

* Fix aom optimization

* Fix aom build command

* Fix libheif build command

* Fix libheif build

* cs fix
2024-12-19 12:23:39 +08:00
Adam
d4ec366c5f Update SQLite to 3.45 (#574)
* Force SQLite 3.45 build from source.

* Update SQLite to 3.45.

* Sort config.

* Minimize changes.
2024-12-15 20:03:48 +08:00
Jerry Ma
bad28fa263 Merge pull request #256 from crazywhalecc/ext/rdkafka
Add extension rdkafka support
2024-12-13 16:23:21 +08:00
crazywhalecc
985cd6781e Add macOS x86_64 test 2024-12-13 15:36:51 +08:00
crazywhalecc
44dcc830f4 Add rdkafka tests 2024-12-13 15:23:55 +08:00
crazywhalecc
10ef4c0d3b Adjust config 2024-12-13 15:22:54 +08:00
crazywhalecc
d0fbc5ab2d Merge branch 'main' into ext/rdkafka
# Conflicts:
#	src/globals/test-extensions.php
2024-12-13 15:12:05 +08:00
crazywhalecc
1bc7bc3421 Addd embed docs 2024-12-13 15:05:44 +08:00
crazywhalecc
8b9b70704a Fix test 2024-12-13 15:05:44 +08:00
crazywhalecc
804020210d Fix test 2024-12-13 15:05:44 +08:00
crazywhalecc
5c51305978 Add embed build tests 2024-12-13 15:05:44 +08:00
crazywhalecc
43cc9d0ba3 Add command, bump version 2024-12-13 15:05:44 +08:00
crazywhalecc
52869218e0 Fix grpc redundant static lib 2024-12-13 15:05:44 +08:00
crazywhalecc
82e11e52dd Fix gettext build 2024-12-13 15:05:44 +08:00
crazywhalecc
955c367a47 Fix pgsql embed builds 2024-12-13 15:05:44 +08:00
crazywhalecc
a613e9a84f Add spc-config command 2024-12-13 15:05:44 +08:00
crazywhalecc
c4b9660cd7 Add embed sanity check 2024-12-13 15:05:44 +08:00
crazywhalecc
f433866671 Add embed spc-config output instead of php-config 2024-12-13 15:05:44 +08:00
crazywhalecc
fdc4a907c7 Fix pgsql missing symbol 2024-12-09 21:57:35 +08:00
Jerry Ma
cf37e16e38 Update build-macos-x86_64.yml 2024-12-06 13:13:50 +08:00
Jerry Ma
2aa42123f6 Update build-macos-x86_64.yml 2024-12-06 13:07:52 +08:00
crazywhalecc
bc7dba6125 Fix parallel config.m4 2024-12-05 18:51:57 +08:00
crazywhalecc
3ce24da15c Fix patch point tests 2024-12-05 18:51:57 +08:00
crazywhalecc
3659e20b0d Fix patch point tests 2024-12-05 18:51:57 +08:00
crazywhalecc
a90a57ffab Add extension configure tests 2024-12-05 18:51:57 +08:00
crazywhalecc
45bdb6a66b Add extension configure tests 2024-12-05 18:51:57 +08:00
crazywhalecc
64258e3513 Fix pgsql linux builds with PHP 8.4 2024-12-05 18:30:19 +08:00
crazywhalecc
fe72b800c6 Add pgsql tests 2024-12-05 13:48:27 +08:00
crazywhalecc
39bc44322e cs-fix 2024-12-05 13:48:27 +08:00
crazywhalecc
1a0e6ee717 cs-fix, add tests 2024-12-05 13:48:27 +08:00
crazywhalecc
cc088b6382 Let grpc use openssl 2024-12-05 13:48:27 +08:00
crazywhalecc
b9f709c23d Change ext.json for pgsql 2024-12-05 13:48:27 +08:00
crazywhalecc
05b602d38c Fix pgsql with PHP 8.4 embed missing libs bug 2024-12-05 13:48:27 +08:00
Simon Hamp
a8a071de1a Add missing step 2024-12-01 16:11:05 +08:00
crazywhalecc
c840165fa8 Add tests for rdkafka 2024-09-23 16:52:01 +08:00
crazywhalecc
4e95d969e3 Merge branch 'refs/heads/main' into ext/rdkafka
# Conflicts:
#	config/source.json
2024-09-23 16:25:59 +08:00
daddeffe
330dd2bfc6 Added optional zlib and disabled two extension (#545)
asd
2024-09-23 16:19:40 +08:00
crazywhalecc
c0b52fc2d1 Add extension rdkafka support 2023-11-05 17:09:48 +08:00
80 changed files with 1336 additions and 599 deletions

4
.github/FUNDING.yml vendored
View File

@@ -1,9 +1,9 @@
# These are supported funding model platforms # These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] github: [crazywhalecc]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username open_collective: # Replace with a single Open Collective username
ko_fi: crazywhalecc # Replace with a single Ko-fi username # ko_fi: crazywhalecc # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username liberapay: # Replace with a single Liberapay username

View File

@@ -1,131 +0,0 @@
name: CI on arm linux
on:
workflow_dispatch:
inputs:
operating-system:
required: true
description: Compile target arch (Linux only)
type: choice
options:
- aarch64
version:
required: true
description: php version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on ${{ inputs.operating-system }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,126 +0,0 @@
name: CI on x86_64 linux
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on Linux x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,140 +0,0 @@
name: CI on arm64 macOS
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on macOS arm64
runs-on: macos-14
steps:
- uses: actions/checkout@v4
# Install macOS missing packages and mark os suffix
- run: |
brew install automake gzip
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: pecl, composer
extensions: curl, openssl, mbstring, tokenizer
ini-values: memory_limit=-1
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,139 +0,0 @@
name: CI on x86_64 macOS
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on macOS x86_64
runs-on: macos-13
steps:
- uses: actions/checkout@v4
# Install macOS missing packages and mark os suffix
- run: |
brew install automake gzip
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: pecl, composer
extensions: curl, openssl, mbstring, tokenizer
ini-values: memory_limit=-1
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

190
.github/workflows/build-unix.yml vendored Normal file
View File

@@ -0,0 +1,190 @@
name: "CI on Unix"
on:
workflow_dispatch:
inputs:
os:
required: true
description: Build target OS
type: choice
options:
- 'linux-x86_64'
- 'linux-aarch64'
- 'macos-x86_64'
- 'macos-aarch64'
php-version:
required: true
description: PHP version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
extensions:
description: Extensions to build (comma separated)
required: true
type: string
extra-libs:
description: Extra libraries to build (optional, comma separated)
type: string
build-cli:
description: Build cli binary
default: true
type: boolean
build-micro:
description: Build phpmicro binary
type: boolean
build-fpm:
description: Build fpm binary
type: boolean
prefer-pre-built:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: Show full build logs
type: boolean
no-strip:
description: Keep debug symbols for debugging
type: boolean
default: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
define-build:
name: "Define Build Scripts"
runs-on: ubuntu-latest
outputs:
run: ${{ steps.gendef.outputs.run }}
download: ${{ steps.gendef.outputs.download }}
build: ${{ steps.gendef.outputs.build }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Define"
id: gendef
run: |
case "${{ inputs.os }}" in
linux-x86_64)
DOWN_CMD="./bin/spc-alpine-docker download"
BUILD_CMD="./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-latest"
;;
linux-aarch64)
DOWN_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker download"
BUILD_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-latest"
;;
macos-x86_64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-13"
;;
macos-aarch64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-14"
;;
esac
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
if [ -n "${{ inputs.extra-libs }}" ]; then
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
fi
if [ ${{ inputs.debug }} == true ]; then
DOWN_CMD="$DOWN_CMD --debug"
BUILD_CMD="$BUILD_CMD --debug"
fi
if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi
if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli"
fi
if [ ${{ inputs.build-micro }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-micro"
fi
if [ ${{ inputs.build-fpm }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-fpm"
fi
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
build:
name: "Build ${{ inputs.version }} on ${{ inputs.os }}"
runs-on: ${{ needs.define-build.outputs.run }}
needs: define-build
timeout-minutes: 240
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
env:
phpts: nts
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-dependencies-${{ inputs.os }}
- name: "Download sources"
run: ${{ needs.define-build.outputs.download }}
- name: "Build PHP"
run: ${{ needs.define-build.outputs.build }}
#- name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI"
uses: actions/upload-artifact@v4
with:
name: php-cli-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
name: "Upload PHP micro SAPI"
uses: actions/upload-artifact@v4
with:
name: php-micro-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
name: "Upload PHP fpm SAPI"
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
name: "Upload License Files"
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
name: "Upload Build Metadata"
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -14,7 +14,6 @@ on:
- '8.2' - '8.2'
- '8.1' - '8.1'
- '8.0' - '8.0'
- '7.4'
build-cli: build-cli:
description: build cli binary description: build cli binary
default: true default: true

View File

@@ -199,3 +199,7 @@ jobs:
- name: "Run Build Tests (build)" - name: "Run Build Tests (build)"
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }} run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Run Build Tests (build - embed for non-windows)"
if: matrix.os != 'windows-latest'
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}

View File

@@ -313,7 +313,7 @@ Now there is a [static-php](https://github.com/static-php) organization, which i
## Sponsor this project ## Sponsor this project
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). A portion of your donation will be used to maintain the **static-php.dev** server. You can sponsor me or my project from [GitHub Sponsor](https://github.com/crazywhalecc). A portion of your donation will be used to maintain the **static-php.dev** server.
## Open-Source License ## Open-Source License

28
composer.lock generated
View File

@@ -2529,16 +2529,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.64.0", "version": "v3.65.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "58dd9c931c785a79739310aef5178928305ffa67" "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/58dd9c931c785a79739310aef5178928305ffa67", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f",
"reference": "58dd9c931c785a79739310aef5178928305ffa67", "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2548,7 +2548,7 @@
"ext-filter": "*", "ext-filter": "*",
"ext-json": "*", "ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"fidry/cpu-core-counter": "^1.0", "fidry/cpu-core-counter": "^1.2",
"php": "^7.4 || ^8.0", "php": "^7.4 || ^8.0",
"react/child-process": "^0.6.5", "react/child-process": "^0.6.5",
"react/event-loop": "^1.0", "react/event-loop": "^1.0",
@@ -2568,18 +2568,18 @@
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
}, },
"require-dev": { "require-dev": {
"facile-it/paraunit": "^1.3 || ^2.3", "facile-it/paraunit": "^1.3.1 || ^2.4",
"infection/infection": "^0.29.5", "infection/infection": "^0.29.8",
"justinrainbow/json-schema": "^5.2", "justinrainbow/json-schema": "^5.3 || ^6.0",
"keradus/cli-executor": "^2.1", "keradus/cli-executor": "^2.1",
"mikey179/vfsstream": "^1.6.11", "mikey179/vfsstream": "^1.6.12",
"php-coveralls/php-coveralls": "^2.7", "php-coveralls/php-coveralls": "^2.7",
"php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5",
"phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2", "phpunit/phpunit": "^9.6.21 || ^10.5.38 || ^11.4.3",
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", "symfony/var-dumper": "^5.4.47 || ^6.4.15 || ^7.1.8",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0" "symfony/yaml": "^5.4.45 || ^6.4.13 || ^7.1.6"
}, },
"suggest": { "suggest": {
"ext-dom": "For handling output formats in XML", "ext-dom": "For handling output formats in XML",
@@ -2620,7 +2620,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.64.0" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0"
}, },
"funding": [ "funding": [
{ {
@@ -2628,7 +2628,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-08-30T23:09:38+00:00" "time": "2024-11-25T00:39:24+00:00"
}, },
{ {
"name": "humbug/box", "name": "humbug/box",

View File

@@ -17,6 +17,10 @@
"type": "external", "type": "external",
"source": "apcu" "source": "apcu"
}, },
"ast": {
"type": "external",
"source": "ast"
},
"bcmath": { "bcmath": {
"type": "builtin" "type": "builtin"
}, },
@@ -53,6 +57,13 @@
"qdbm" "qdbm"
] ]
}, },
"dio": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "dio"
},
"dom": { "dom": {
"support": { "support": {
"BSD": "wip" "BSD": "wip"
@@ -434,6 +445,13 @@
"zlib" "zlib"
] ]
}, },
"opentelemetry": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "opentelemetry"
},
"parallel": { "parallel": {
"support": { "support": {
"BSD": "wip" "BSD": "wip"
@@ -524,7 +542,7 @@
}, },
"notes": true, "notes": true,
"type": "builtin", "type": "builtin",
"arg-type": "with-prefix", "arg-type": "custom",
"lib-depends": [ "lib-depends": [
"postgresql" "postgresql"
] ]
@@ -560,6 +578,19 @@
"source": "rar", "source": "rar",
"cpp-extension": true "cpp-extension": true
}, },
"rdkafka": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "external",
"source": "ext-rdkafka",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"librdkafka"
]
},
"readline": { "readline": {
"support": { "support": {
"Windows": "wip", "Windows": "wip",

View File

@@ -34,7 +34,7 @@
"libcurl.a" "libcurl.a"
], ],
"static-libs-windows": [ "static-libs-windows": [
"libcurl_a.lib" "libcurl.lib"
], ],
"headers": [ "headers": [
"curl" "curl"
@@ -143,11 +143,11 @@
"source": "grpc", "source": "grpc",
"static-libs-unix": [ "static-libs-unix": [
"libgrpc.a", "libgrpc.a",
"libboringssl.a",
"libcares.a" "libcares.a"
], ],
"lib-depends": [ "lib-depends": [
"zlib" "zlib",
"openssl"
], ],
"frameworks": [ "frameworks": [
"CoreFoundation" "CoreFoundation"
@@ -176,7 +176,8 @@
"libjpeg", "libjpeg",
"libwebp", "libwebp",
"freetype", "freetype",
"libtiff" "libtiff",
"libheif"
], ],
"lib-suggests": [ "lib-suggests": [
"zstd", "zstd",
@@ -208,6 +209,13 @@
"libsodium" "libsodium"
] ]
}, },
"libaom": {
"source": "libaom",
"static-libs-unix": [
"libaom.a"
],
"cpp-library": true
},
"libargon2": { "libargon2": {
"source": "libargon2", "source": "libargon2",
"static-libs-unix": [ "static-libs-unix": [
@@ -235,6 +243,13 @@
"ares_rules.h" "ares_rules.h"
] ]
}, },
"libde265": {
"source": "libde265",
"static-libs-unix": [
"libde265.a"
],
"cpp-library": true
},
"libevent": { "libevent": {
"source": "libevent", "source": "libevent",
"static-libs-unix": [ "static-libs-unix": [
@@ -276,6 +291,19 @@
"fficonfig.h" "fficonfig.h"
] ]
}, },
"libheif": {
"source": "libheif",
"static-libs-unix": [
"libheif.a"
],
"lib-depends": [
"libde265",
"libwebp",
"libaom",
"zlib",
"brotli"
]
},
"libiconv": { "libiconv": {
"source": "libiconv", "source": "libiconv",
"static-libs-unix": [ "static-libs-unix": [
@@ -355,6 +383,18 @@
"openssl" "openssl"
] ]
}, },
"librdkafka": {
"source": "librdkafka",
"static-libs-unix": [
"librdkafka.a",
"librdkafka++.a",
"librdkafka-static.a"
],
"cpp-library": true,
"lib-suggests": [
"zstd"
]
},
"libsodium": { "libsodium": {
"source": "libsodium", "source": "libsodium",
"static-libs-unix": [ "static-libs-unix": [
@@ -385,6 +425,10 @@
"source": "libtiff", "source": "libtiff",
"static-libs-unix": [ "static-libs-unix": [
"libtiff.a" "libtiff.a"
],
"lib-depends": [
"zlib",
"libjpeg"
] ]
}, },
"libuuid": { "libuuid": {

View File

@@ -26,6 +26,16 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ast": {
"type": "url",
"url": "https://pecl.php.net/get/ast",
"path": "php-src/ext/ast",
"filename": "ast.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"brotli": { "brotli": {
"type": "ghtar", "type": "ghtar",
"repo": "google/brotli", "repo": "google/brotli",
@@ -36,9 +46,13 @@
} }
}, },
"bzip2": { "bzip2": {
"type": "filelist", "alt": {
"url": "https://sourceware.org/pub/bzip2/", "type": "filelist",
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/", "url": "https://sourceware.org/pub/bzip2/",
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/"
},
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/bzip2/bzip2-1.0.8.tar.gz",
"provide-pre-built": true, "provide-pre-built": true,
"license": { "license": {
"type": "text", "type": "text",
@@ -55,6 +69,16 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"dio": {
"type": "url",
"url": "https://pecl.php.net/get/dio",
"path": "php-src/ext/dio",
"filename": "dio.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-ds": { "ext-ds": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/ds", "url": "https://pecl.php.net/get/ds",
@@ -124,6 +148,15 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-rdkafka": {
"type": "ghtar",
"repo": "arnaud-lb/php-rdkafka",
"path": "php-src/ext/rdkafka",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-simdjson": { "ext-simdjson": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/simdjson", "url": "https://pecl.php.net/get/simdjson",
@@ -290,6 +323,16 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"libaom": {
"type": "git",
"rev": "main",
"url": "https://aomedia.googlesource.com/aom",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libargon2": { "libargon2": {
"type": "git", "type": "git",
"rev": "master", "rev": "master",
@@ -325,6 +368,17 @@
"path": "LICENSE.md" "path": "LICENSE.md"
} }
}, },
"libde265": {
"type": "ghrel",
"repo": "strukturag/libde265",
"match": "libde265-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libevent": { "libevent": {
"type": "ghrel", "type": "ghrel",
"repo": "libevent/libevent", "repo": "libevent/libevent",
@@ -355,6 +409,17 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"libheif": {
"type": "ghrel",
"repo": "strukturag/libheif",
"match": "libheif-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libiconv": { "libiconv": {
"type": "filelist", "type": "filelist",
"url": "https://ftp.gnu.org/gnu/libiconv/", "url": "https://ftp.gnu.org/gnu/libiconv/",
@@ -421,6 +486,14 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"librdkafka": {
"type": "ghtar",
"repo": "confluentinc/librdkafka",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libsodium": { "libsodium": {
"type": "ghrel", "type": "ghrel",
"repo": "jedisct1/libsodium", "repo": "jedisct1/libsodium",
@@ -610,6 +683,16 @@
"path": "LICENSE.txt" "path": "LICENSE.txt"
} }
}, },
"opentelemetry": {
"type": "url",
"url": "https://pecl.php.net/get/opentelemetry",
"path": "php-src/ext/opentelemetry",
"filename": "opentelemetry.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"parallel": { "parallel": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/parallel", "url": "https://pecl.php.net/get/parallel",
@@ -730,7 +813,7 @@
}, },
"sqlite": { "sqlite": {
"type": "url", "type": "url",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz", "url": "https://www.sqlite.org/2024/sqlite-autoconf-3450200.tar.gz",
"provide-pre-built": true, "provide-pre-built": true,
"license": { "license": {
"type": "text", "type": "text",

View File

@@ -225,11 +225,11 @@ const isSupported = (extName, os) => {
}; };
const availablePhpVersions = [ const availablePhpVersions = [
'7.4',
'8.0', '8.0',
'8.1', '8.1',
'8.2', '8.2',
'8.3', '8.3',
'8.4',
]; ];
const I18N = { const I18N = {

View File

@@ -74,6 +74,12 @@ bin/setup-runtime -action add-path
bin/setup-runtime -action remove-path bin/setup-runtime -action remove-path
``` ```
Finally, now that you have PHP and Composer installed, you need to install static-php-cli's Composer dependencies:
```shell
composer install
```
### Install other Tools (automatic) ### Install other Tools (automatic)
For `php-sdk-binary-tools`, `strawberry-perl`, and `nasm`, For `php-sdk-binary-tools`, `strawberry-perl`, and `nasm`,

View File

@@ -553,3 +553,76 @@ If you need to build multiple times locally, the following method can save you t
- If you want to rebuild once, but do not re-download the source code, you can first `rm -rf buildroot source` to delete the compilation directory and source code directory, and then rebuild. - If you want to rebuild once, but do not re-download the source code, you can first `rm -rf buildroot source` to delete the compilation directory and source code directory, and then rebuild.
- If you want to update a version of a dependency, you can use `bin/spc del-download <source-name>` to delete the specified source code, and then use `download <source-name>` to download it again. - If you want to update a version of a dependency, you can use `bin/spc del-download <source-name>` to delete the specified source code, and then use `download <source-name>` to download it again.
- If you want to update all dependent versions, you can use `bin/spc download --clean` to delete all downloaded sources, and then download them again. - If you want to update all dependent versions, you can use `bin/spc download --clean` to delete all downloaded sources, and then download them again.
## embed usage
If you want to embed static-php into other C language programs, you can use `--build-embed` to build an embed version of PHP.
```bash
bin/spc build {your extensions} --build-embed --debug
```
Under normal circumstances, PHP embed will generate `php-config` after compilation.
For static-php, we provide `spc-config` to obtain the parameters during compilation.
In addition, when using embed SAPI (libphp.a), you need to use the same compiler as libphp, otherwise there will be a link error.
Here is the basic usage of spc-config:
```bash
# output all flags and options
bin/spc spc-config curl,zlib,phar,openssl
# output libs
bin/spc spc-config curl,zlib,phar,openssl --libs
# output includes
bin/spc spc-config curl,zlib,phar,openssl --includes
```
By default, static-php uses the following compilers on different systems:
- macOS: `clang`
- Linux (Alpine Linux): `gcc`
- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc`
- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc`
- FreeBSD: `clang`
Here is an example of using embed SAPI:
```c
// embed.c
#include <sapi/embed/php_embed.h>
int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle;
zend_stream_init_filename(&file_handle,"embed.php");
if(php_execute_script(&file_handle) == FAILURE){
php_printf("Failed to execute PHP script.\n");
}
PHP_EMBED_END_BLOCK()
return 0;
}
```
```php
<?php
// embed.php
echo "Hello world!\n";
```
```bash
# compile in debian/ubuntu x86_64
/usr/local/musl/bin/x86_64-linux-musl-gcc embed.c $(bin/spc spc-config bcmath,zlib) -static -o embed
# compile in macOS/FreeBSD
clang embed.c $(bin/spc spc-config bcmath,zlib) -o embed
./embed
# out: Hello world!
```

View File

@@ -8,8 +8,15 @@ here will describe how to check the errors by yourself and report Issue.
Problems with downloading resources are one of the most common problems with spc. Problems with downloading resources are one of the most common problems with spc.
The main reason is that the addresses used for SPC download resources are generally the official website of the corresponding project or GitHub, etc., The main reason is that the addresses used for SPC download resources are generally the official website of the corresponding project or GitHub, etc.,
and these websites may occasionally go down and block IP addresses. and these websites may occasionally go down and block IP addresses.
Currently, version 2.0.0 has not added an automatic retry mechanism, so after encountering a download failure, After encountering a download failure,
you can try to call the download command multiple times. If you confirm that the address is indeed inaccessible, you can try to call the download command multiple times.
When downloading extensions, you may eventually see errors like `curl: (56) The requested URL returned error: 403` which are often caused by github rate limiting.
You can verify this by adding `--debug` to the command and will see something like `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"`.
To fix this, [create](https://github.com/settings/tokens) a personal access token on GitHub and set it as an environment variable `GITHUB_TOKEN=<XXX>`.
If you confirm that the address is indeed inaccessible,
you can submit an Issue or PR to update the url or download type. you can submit an Issue or PR to update the url or download type.
## Doctor Can't Fix Something ## Doctor Can't Fix Something

View File

@@ -493,3 +493,75 @@ static-php-cli 开放的方法非常多,文档中无法一一列举,但只
- 如果你想重新构建一次,但不重新下载源码,可以先 `rm -rf buildroot source` 删除编译目录和源码目录,然后重新构建。 - 如果你想重新构建一次,但不重新下载源码,可以先 `rm -rf buildroot source` 删除编译目录和源码目录,然后重新构建。
- 如果你想更新某个依赖的版本,可以使用 `bin/spc del-download <source-name>` 删除指定的源码,然后使用 `download <source-name>` 重新下载。 - 如果你想更新某个依赖的版本,可以使用 `bin/spc del-download <source-name>` 删除指定的源码,然后使用 `download <source-name>` 重新下载。
- 如果你想更新所有依赖的版本,可以使用 `bin/spc download --clean` 删除所有下载的源码,然后重新下载。 - 如果你想更新所有依赖的版本,可以使用 `bin/spc download --clean` 删除所有下载的源码,然后重新下载。
## embed 使用
如果你想将 static-php 嵌入到其他 C 语言程序中,可以使用 `--build-embed` 构建一个 embed 版本的 PHP。
```bash
bin/spc build {your extensions} --build-embed --debug
```
在通常的情况下PHP embed 编译后会生成 `php-config`。对于 static-php我们提供了 `spc-config`,用于获取编译时的参数。
另外,在使用 embed SAPIlibphp.a你需要使用和编译 libphp 相同的编译器,否则会出现链接错误。
下面是 spc-config 的基本用法:
```bash
# output all flags and options
bin/spc spc-config curl,zlib,phar,openssl
# output libs
bin/spc spc-config curl,zlib,phar,openssl --libs
# output includes
bin/spc spc-config curl,zlib,phar,openssl --includes
```
默认情况下static-php 在不同系统使用的编译器分别是:
- macOS: `clang`
- Linux (Alpine Linux): `gcc`
- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc`
- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc`
- FreeBSD: `clang`
下面是一个使用 embed SAPI 的例子:
```c
// embed.c
#include <sapi/embed/php_embed.h>
int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle;
zend_stream_init_filename(&file_handle,"embed.php");
if(php_execute_script(&file_handle) == FAILURE){
php_printf("Failed to execute PHP script.\n");
}
PHP_EMBED_END_BLOCK()
return 0;
}
```
```php
<?php
// embed.php
echo "Hello world!\n";
```
```bash
# compile in debian/ubuntu x86_64
/usr/local/musl/bin/x86_64-linux-musl-gcc embed.c $(bin/spc spc-config bcmath,zlib) -static -o embed
# compile in macOS/FreeBSD
clang embed.c $(bin/spc spc-config bcmath,zlib) -o embed
./embed
# out: Hello world!
```

View File

@@ -5,7 +5,14 @@
## 下载失败问题 ## 下载失败问题
下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。 下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。
目前 2.0.0 版本还没有加入自动重试机制,所以在遇到下载失败后,可以多次尝试调用下载命令。如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址 在遇到下载失败后,可以多次尝试调用下载命令
当下载资源时,你可能最终会看到类似 `curl: (56) The requested URL returned error: 403` 的错误,这通常是由于 GitHub 限制导致的。
你可以通过在命令中添加 `--debug` 来验证,会看到类似 `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"` 的输出。
要解决这个问题,可以在 GitHub 上 [创建](https://github.com/settings/token) 一个个人访问令牌,并将其设置为环境变量 `GITHUB_TOKEN=<XXX>`
如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。
## doctor 无法修复 ## doctor 无法修复

View File

@@ -22,6 +22,7 @@ use SPC\command\DumpLicenseCommand;
use SPC\command\ExtractCommand; use SPC\command\ExtractCommand;
use SPC\command\InstallPkgCommand; use SPC\command\InstallPkgCommand;
use SPC\command\MicroCombineCommand; use SPC\command\MicroCombineCommand;
use SPC\command\SPCConfigCommand;
use SPC\command\SwitchPhpVersionCommand; use SPC\command\SwitchPhpVersionCommand;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
@@ -30,7 +31,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const VERSION = '2.4.0'; public const VERSION = '2.4.5';
public function __construct() public function __construct()
{ {
@@ -52,6 +53,7 @@ final class ConsoleApplication extends Application
new ExtractCommand(), new ExtractCommand(),
new MicroCombineCommand(), new MicroCombineCommand(),
new SwitchPhpVersionCommand(), new SwitchPhpVersionCommand(),
new SPCConfigCommand(),
// Dev commands // Dev commands
new AllExtCommand(), new AllExtCommand(),

View File

@@ -6,6 +6,7 @@ namespace SPC\builder;
use SPC\exception\ExceptionHandler; use SPC\exception\ExceptionHandler;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\InterruptException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
@@ -24,6 +25,12 @@ abstract class BuilderBase
/** @var array<string, Extension> extensions */ /** @var array<string, Extension> extensions */
protected array $exts = []; protected array $exts = [];
/** @var array<int, string> extension names */
protected array $ext_list = [];
/** @var array<int, string> library names */
protected array $lib_list = [];
/** @var bool compile libs only (just mark it) */ /** @var bool compile libs only (just mark it) */
protected bool $libs_only = false; protected bool $libs_only = false;
@@ -160,7 +167,7 @@ abstract class BuilderBase
* @throws FileSystemException * @throws FileSystemException
* @throws RuntimeException * @throws RuntimeException
* @throws \ReflectionException * @throws \ReflectionException
* @throws WrongUsageException * @throws \Throwable|WrongUsageException
* @internal * @internal
*/ */
public function proveExts(array $extensions, bool $skip_check_deps = false): void public function proveExts(array $extensions, bool $skip_check_deps = false): void
@@ -190,6 +197,7 @@ abstract class BuilderBase
foreach ($this->exts as $ext) { foreach ($this->exts as $ext) {
$ext->checkDependency(); $ext->checkDependency();
} }
$this->ext_list = $extensions;
} }
/** /**
@@ -407,6 +415,13 @@ abstract class BuilderBase
} }
logger()->debug('Running additional patch script: ' . $patch); logger()->debug('Running additional patch script: ' . $patch);
require $patch; require $patch;
} catch (InterruptException $e) {
if ($e->getCode() === 0) {
logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
} else {
logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
}
exit($e->getCode());
} catch (\Throwable $e) { } catch (\Throwable $e) {
logger()->critical('Patch script ' . $patch . ' failed to run.'); logger()->critical('Patch script ' . $patch . ' failed to run.');
if ($this->getOption('debug')) { if ($this->getOption('debug')) {
@@ -414,6 +429,7 @@ abstract class BuilderBase
} else { } else {
logger()->critical('Please check with --debug option to see more details.'); logger()->critical('Please check with --debug option to see more details.');
} }
throw $e;
} }
} }
} }

View File

@@ -203,7 +203,7 @@ class Extension
// Run compile check if build target is cli // Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException // If check failed, throw RuntimeException
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false); [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
} }
@@ -216,7 +216,7 @@ class Extension
file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php')) file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))
); );
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"'); [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
} }

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('dio')]
class dio extends Extension
{
public function patchBeforeBuildconf(): bool
{
if (!file_exists(SOURCE_PATH . '/php-src/ext/dio/php_dio.h')) {
FileSystem::writeFile(SOURCE_PATH . '/php-src/ext/dio/php_dio.h', FileSystem::readFile(SOURCE_PATH . '/php-src/ext/dio/src/php_dio.h'));
return true;
}
return false;
}
}

View File

@@ -34,7 +34,7 @@ class mbregex extends Extension
public function runCliCheckWindows(): void public function runCliCheckWindows(): void
{ {
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false); [$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !'); throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
} }

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
#[CustomExt('opentelemetry')]
class opentelemetry extends Extension
{
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
}
}
public function patchBeforeBuildconf(): bool
{
if (PHP_OS_FAMILY === 'Windows') {
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/opentelemetry/config.w32',
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');",
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', PHP_OPENTELEMETRY_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
);
return true;
}
return false;
}
public function patchBeforeMake(): bool
{
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;
}
}

View File

@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('parallel')] #[CustomExt('parallel')]
@@ -17,4 +18,10 @@ class parallel extends Extension
throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!');
} }
} }
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/parallel/config.m4', '/PHP_VERSION=.*/m', '');
return true;
}
} }

View File

@@ -6,6 +6,8 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -14,6 +16,8 @@ class pgsql extends Extension
{ {
/** /**
* @throws FileSystemException * @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
@@ -24,4 +28,16 @@ class pgsql extends Extension
); );
return true; return true;
} }
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
return '--with-pgsql PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"';
}
return '--with-pgsql=' . BUILD_ROOT_PATH;
}
} }

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('rdkafka')]
class rdkafka extends Extension
{
public function patchBeforeMake(): bool
{
// when compiling rdkafka with inline builds, it shows some errors, I don't know why.
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/rdkafka/rdkafka.c',
"#ifdef HAS_RD_KAFKA_TRANSACTIONS\n#include \"kafka_error_exception.h\"\n#endif",
'#include "kafka_error_exception.h"'
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/rdkafka/kafka_error_exception.h',
['#ifdef HAS_RD_KAFKA_TRANSACTIONS', '#endif'],
''
);
return true;
}
public function getConfigureArg(): string
{
$pkgconf_libs = shell()->execWithResult('pkg-config --libs --static rdkafka')[1];
$pkgconf_libs = trim(implode('', $pkgconf_libs));
return '--with-rdkafka=' . BUILD_ROOT_PATH . ' LIBS="' . $pkgconf_libs . '"';
}
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -21,13 +21,16 @@ class SystemUtil
switch (true) { switch (true) {
case file_exists('/etc/centos-release'): case file_exists('/etc/centos-release'):
$lines = file('/etc/centos-release'); $lines = file('/etc/centos-release');
$centos = true;
goto rh; goto rh;
case file_exists('/etc/redhat-release'): case file_exists('/etc/redhat-release'):
$lines = file('/etc/redhat-release'); $lines = file('/etc/redhat-release');
$centos = false;
rh: rh:
foreach ($lines as $line) { foreach ($lines as $line) {
if (preg_match('/release\s+(\d*(\.\d+)*)/', $line, $matches)) { if (preg_match('/release\s+(\d*(\.\d+)*)/', $line, $matches)) {
$ret['dist'] = 'redhat'; /* @phpstan-ignore-next-line */
$ret['dist'] = $centos ? 'centos' : 'redhat';
$ret['ver'] = $matches[1]; $ret['ver'] = $matches[1];
} }
} }
@@ -171,6 +174,8 @@ class SystemUtil
'debian', 'ubuntu', 'Deepin', 'debian', 'ubuntu', 'Deepin',
// rhel-like // rhel-like
'redhat', 'redhat',
// centos
'centos',
// alpine // alpine
'alpine', 'alpine',
// arch // arch

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libaom extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libaom;
public const NAME = 'libaom';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libde265 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libde265;
public const NAME = 'libde265';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libheif extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libheif;
public const NAME = 'libheif';
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class librdkafka extends LinuxLibraryBase
{
// TODO: Linux is buggy, see https://github.com/confluentinc/librdkafka/discussions/4495
use \SPC\builder\unix\library\librdkafka;
public const NAME = 'librdkafka';
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *
@@ -68,6 +69,7 @@ class openssl extends LinuxLibraryBase
"{$env} ./Configure no-shared {$extra} " . "{$env} ./Configure no-shared {$extra} " .
'--prefix=/ ' . '--prefix=/ ' .
'--libdir=lib ' . '--libdir=lib ' .
'--openssldir=/etc/ssl ' .
'-static ' . '-static ' .
"{$zlib_extra}" . "{$zlib_extra}" .
'no-legacy ' . 'no-legacy ' .

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class libaom extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libaom;
public const NAME = 'libaom';
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class libde265 extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libde265;
public const NAME = 'libde265';
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
use SPC\store\FileSystem;
class libheif extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libheif;
public const NAME = 'libheif';
public function patchBeforeBuild(): bool
{
if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) {
FileSystem::replaceFileStr(
$this->source_dir . '/CMakeLists.txt',
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")',
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")'
);
return true;
}
return false;
}
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class librdkafka extends MacOSLibraryBase
{
use \SPC\builder\unix\library\librdkafka;
public const NAME = 'librdkafka';
}

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *
@@ -53,7 +54,7 @@ class openssl extends MacOSLibraryBase
"./Configure no-shared {$extra} " . "./Configure no-shared {$extra} " .
'--prefix=/ ' . // use prefix=/ '--prefix=/ ' . // use prefix=/
"--libdir={$lib} " . "--libdir={$lib} " .
'--openssldir=/System/Library/OpenSSL ' . '--openssldir=/etc/ssl ' .
"darwin64-{$this->builder->getOption('arch')}-cc" "darwin64-{$this->builder->getOption('arch')}-cc"
) )
->exec('make clean') ->exec('make clean')

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com> * Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
* *

View File

@@ -12,6 +12,7 @@ use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\DependencyUtil; use SPC\util\DependencyUtil;
use SPC\util\SPCConfigUtil;
abstract class UnixBuilderBase extends BuilderBase abstract class UnixBuilderBase extends BuilderBase
{ {
@@ -128,6 +129,7 @@ abstract class UnixBuilderBase extends BuilderBase
foreach ($this->libs as $lib) { foreach ($this->libs as $lib) {
$lib->calcDependency(); $lib->calcDependency();
} }
$this->lib_list = $sorted_libraries;
} }
/** /**
@@ -141,8 +143,9 @@ abstract class UnixBuilderBase extends BuilderBase
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
logger()->info('running cli sanity check'); logger()->info('running cli sanity check');
[$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "echo \"hello\";"'); [$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "echo \"hello\";"');
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { $raw_output = implode('', $output);
throw new RuntimeException('cli failed sanity check'); if ($ret !== 0 || trim($raw_output) !== 'hello') {
throw new RuntimeException("cli failed sanity check: ret[{$ret}]. out[{$raw_output}]");
} }
foreach ($this->exts as $ext) { foreach ($this->exts as $ext) {
@@ -170,6 +173,32 @@ abstract class UnixBuilderBase extends BuilderBase
} }
} }
} }
// sanity check for embed
if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
logger()->info('running embed sanity check');
$sample_file_path = SOURCE_PATH . '/embed-test';
if (!is_dir($sample_file_path)) {
@mkdir($sample_file_path);
}
// copy embed test files
copy(ROOT_DIR . '/src/globals/common-tests/embed.c', $sample_file_path . '/embed.c');
copy(ROOT_DIR . '/src/globals/common-tests/embed.php', $sample_file_path . '/embed.php');
$util = new SPCConfigUtil($this);
$config = $util->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
$lens = "{$config['cflags']} {$config['ldflags']} {$config['libs']}";
if (PHP_OS_FAMILY === 'Linux') {
$lens .= ' -static';
}
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
if ($ret !== 0) {
throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out));
}
[$ret, $output] = shell()->cd($sample_file_path)->execWithResult('./embed');
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
throw new RuntimeException('embed failed sanity check: run failed. Error message: ' . implode("\n", $output));
}
}
} }
/** /**

View File

@@ -10,15 +10,23 @@ trait gettext
{ {
$extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : ''; $extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : '';
$extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : ''; $extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : '';
$zts = $this->builder->getOption('enable-zts') ? '--enable-threads=isoc+posix ' : '--disable-threads ';
$cflags = $this->builder->getOption('enable-zts') ? '-lpthread -D_REENTRANT' : '';
$ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : '';
shell()->cd($this->source_dir) shell()->cd($this->source_dir)
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
->execWithEnv( ->execWithEnv(
'./configure ' . './configure ' .
'--enable-static ' . '--enable-static ' .
'--disable-shared ' . '--disable-shared ' .
'--disable-java ' . '--disable-java ' .
'--disable-c+ ' . '--disable-c+ ' .
$zts .
$extra . $extra .
'--with-included-gettext ' .
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
'--prefix=' . BUILD_ROOT_PATH '--prefix=' . BUILD_ROOT_PATH
) )

View File

@@ -11,7 +11,7 @@ trait grpc
protected function build(): void protected function build(): void
{ {
shell()->cd($this->source_dir) shell()->cd($this->source_dir)
->exec('EXTRA_DEFINES=GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK CXXFLAGS="-L' . BUILD_LIB_PATH . ' -I' . BUILD_INCLUDE_PATH . '" make static -j' . $this->builder->concurrency); ->exec('EXTRA_DEFINES=GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK EMBED_OPENSSL=false CXXFLAGS="-L' . BUILD_LIB_PATH . ' -I' . BUILD_INCLUDE_PATH . '" make static -j' . $this->builder->concurrency);
copy($this->source_dir . '/libs/opt/libgrpc.a', BUILD_LIB_PATH . '/libgrpc.a'); copy($this->source_dir . '/libs/opt/libgrpc.a', BUILD_LIB_PATH . '/libgrpc.a');
copy($this->source_dir . '/libs/opt/libboringssl.a', BUILD_LIB_PATH . '/libboringssl.a'); copy($this->source_dir . '/libs/opt/libboringssl.a', BUILD_LIB_PATH . '/libboringssl.a');
if (!file_exists(BUILD_LIB_PATH . '/libcares.a')) { if (!file_exists(BUILD_LIB_PATH . '/libcares.a')) {

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait libaom
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/builddir');
// Start build
shell()->cd($this->source_dir . '/builddir')
->exec(
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DAOM_TARGET_CPU=generic ' .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['aom.pc']);
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait libde265
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DENABLE_SDL=OFF ' . // Disable SDL, currently not supported
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['libde265.pc']);
}
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait libheif
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'--preset=release ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DWITH_EXAMPLES=OFF ' .
'-DWITH_GDK_PIXBUF=OFF ' .
'-DBUILD_TESTING=OFF ' .
'-DWITH_LIBSHARPYUV=ON ' . // optional: libwebp
'-DENABLE_PLUGIN_LOADING=OFF ' .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['libheif.pc']);
}
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
trait librdkafka
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
$builddir = BUILD_ROOT_PATH;
$zstd_option = $this->builder->getLib('zstd') ? ("STATIC_LIB_libzstd={$builddir}/lib/libzstd.a ") : '';
shell()->cd($this->source_dir)
->exec(
$zstd_option .
'./configure ' .
'--enable-static --disable-shared --disable-curl --disable-sasl --disable-valgrind --disable-zlib --disable-ssl ' .
($zstd_option == '' ? '--disable-zstd ' : '') .
'--prefix='
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$builddir}");
$this->patchPkgconfPrefix(['rdkafka.pc', 'rdkafka-static.pc', 'rdkafka++.pc', 'rdkafka++-static.pc']);
// remove dynamic libs
shell()
->exec("rm -rf {$builddir}/lib/*.so.*")
->exec("rm -rf {$builddir}/lib/*.so")
->exec("rm -rf {$builddir}/lib/*.dylib");
}
}

View File

@@ -15,10 +15,18 @@ trait libtiff
*/ */
protected function build(): void protected function build(): void
{ {
// zlib
$extra_libs = '--enable-zlib --with-zlib-include-dir=' . BUILD_ROOT_PATH . '/include --with-zlib-lib-dir=' . BUILD_ROOT_PATH . '/lib';
// libjpeg
$extra_libs .= ' --enable-jpeg --disable-old-jpeg --disable-jpeg12 --with-jpeg-include-dir=' . BUILD_ROOT_PATH . '/include --with-jpeg-lib-dir=' . BUILD_ROOT_PATH . '/lib';
// We disabled lzma, zstd, webp, libdeflate by default to reduce the size of the binary
$extra_libs .= ' --disable-lzma --disable-zstd --disable-webp --disable-libdeflate';
$shell = shell()->cd($this->source_dir) $shell = shell()->cd($this->source_dir)
->exec( ->exec(
'./configure ' . './configure ' .
'--enable-static --disable-shared ' . '--enable-static --disable-shared ' .
"{$extra_libs} " .
'--disable-cxx ' . '--disable-cxx ' .
'--prefix=' '--prefix='
); );

View File

@@ -248,6 +248,7 @@ class WindowsBuilder extends BuilderBase
foreach ($this->libs as $lib) { foreach ($this->libs as $lib) {
$lib->calcDependency(); $lib->calcDependency();
} }
$this->lib_list = $sorted_libraries;
} }
/** /**
@@ -276,7 +277,7 @@ class WindowsBuilder extends BuilderBase
// sanity check for php-cli // sanity check for php-cli
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
logger()->info('running cli sanity check'); logger()->info('running cli sanity check');
[$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -r "echo \"hello\";"'); [$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -n -r "echo \"hello\";"');
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
throw new RuntimeException('cli failed sanity check'); throw new RuntimeException('cli failed sanity check');
} }

View File

@@ -12,14 +12,41 @@ class curl extends WindowsLibraryBase
protected function build(): void protected function build(): void
{ {
FileSystem::createDir(BUILD_BIN_PATH); // reset cmake
cmd()->cd($this->source_dir . '\winbuild') FileSystem::resetDir($this->source_dir . '\cmakebuild');
// lib:zstd
$alt = $this->builder->getLib('zstd') ? '' : '-DCURL_ZSTD=OFF';
// lib:brotli
$alt .= $this->builder->getLib('brotli') ? '' : ' -DCURL_BROTLI=OFF';
// start build
cmd()->cd($this->source_dir)
->execWithWrapper( ->execWithWrapper(
$this->builder->makeSimpleWrapper('nmake'), $this->builder->makeSimpleWrapper('cmake'),
'/f Makefile.vc WITH_DEVEL=' . BUILD_ROOT_PATH . ' ' . '-B cmakebuild ' .
'WITH_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-A x64 ' .
'mode=static RTLIBCFG=static WITH_SSL=static WITH_NGHTTP2=static WITH_SSH2=static ENABLE_IPV6=yes WITH_ZLIB=static MACHINE=x64 DEBUG=no' "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DBUILD_STATIC_LIBS=ON ' .
'-DCURL_STATICLIB=ON ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
'-DBUILD_CURL_EXE=OFF ' . // disable curl.exe
'-DBUILD_TESTING=OFF ' . // disable tests
'-DBUILD_EXAMPLES=OFF ' . // disable examples
'-DUSE_LIBIDN2=OFF ' . // disable libidn2
'-DCURL_USE_LIBPSL=OFF ' . // disable libpsl
'-DCURL_ENABLE_SSL=ON ' .
'-DUSE_NGHTTP2=ON ' . // enable nghttp2
'-DCURL_USE_LIBSSH2=ON ' . // enable libssh2
'-DENABLE_IPV6=ON ' . // enable ipv6
'-DNGHTTP2_CFLAGS="/DNGHTTP2_STATICLIB" ' .
$alt
)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
"--build cmakebuild --config Release --target install -j{$this->builder->concurrency}"
); );
FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl');
} }
} }

View File

@@ -32,7 +32,6 @@ class BuildCliCommand extends BuildCommand
$this->addOption('build-embed', null, null, 'Build embed SAPI'); $this->addOption('build-embed', null, null, 'Build embed SAPI');
$this->addOption('build-all', null, null, 'Build all SAPI'); $this->addOption('build-all', null, null, 'Build all SAPI');
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
$this->addOption('enable-zts', null, null, 'enable ZTS support');
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
$this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', $isWindows ? null : '/usr/local/etc/php'); $this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', $isWindows ? null : '/usr/local/etc/php');
$this->addOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', $isWindows ? null : '/usr/local/etc/php/conf.d'); $this->addOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', $isWindows ? null : '/usr/local/etc/php/conf.d');
@@ -181,7 +180,9 @@ class BuildCliCommand extends BuildCommand
// compile stopwatch :P // compile stopwatch :P
$time = round(microtime(true) - START_TIME, 3); $time = round(microtime(true) - START_TIME, 3);
logger()->info('Build complete, used ' . $time . ' s !'); logger()->info('');
logger()->info(' Build complete, used ' . $time . ' s !');
logger()->info('');
// ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ---------- // ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ----------
$build_root_path = BUILD_ROOT_PATH; $build_root_path = BUILD_ROOT_PATH;

View File

@@ -31,5 +31,6 @@ abstract class BuildCommand extends BaseCommand
$this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`'); $this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`');
$this->addOption('bloat', null, null, 'add all libraries into binary'); $this->addOption('bloat', null, null, 'add all libraries into binary');
$this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild');
$this->addOption('enable-zts', null, null, 'enable ZTS support');
} }
} }

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace SPC\command;
use SPC\exception\RuntimeException;
use SPC\util\SPCConfigUtil;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
#[AsCommand('spc-config', 'Build dependencies')]
class SPCConfigCommand extends BuildCommand
{
protected bool $no_motd = true;
public function configure(): void
{
$this->addArgument('extensions', InputArgument::OPTIONAL, 'The extensions will be compiled, comma separated');
$this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', '');
$this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs');
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
$this->addOption('includes', null, null, 'Add additional include path');
$this->addOption('libs', null, null, 'Add additional libs path');
}
/**
* @throws RuntimeException
*/
public function handle(): int
{
// transform string to array
$libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs'))));
// transform string to array
$extensions = $this->getArgument('extensions') ? $this->parseExtensionList($this->getArgument('extensions')) : [];
$include_suggest_ext = $this->getOption('with-suggested-exts');
$include_suggest_lib = $this->getOption('with-suggested-libs');
$util = new SPCConfigUtil(null, $this->input);
$config = $util->config($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
if ($this->getOption('includes')) {
$this->output->writeln($config['cflags']);
} elseif ($this->getOption('libs')) {
$this->output->writeln("{$config['ldflags']} {$config['libs']}");
} else {
$this->output->writeln("{$config['cflags']} {$config['ldflags']} {$config['libs']}");
}
return 0;
}
}

View File

@@ -57,7 +57,7 @@ class LinuxToolCheckList
$required = match ($distro['dist']) { $required = match ($distro['dist']) {
'alpine' => self::TOOLS_ALPINE, 'alpine' => self::TOOLS_ALPINE,
'redhat' => self::TOOLS_RHEL, 'redhat', 'centos' => self::TOOLS_RHEL,
'arch' => self::TOOLS_ARCH, 'arch' => self::TOOLS_ARCH,
default => self::TOOLS_DEBIAN, default => self::TOOLS_DEBIAN,
}; };
@@ -72,6 +72,7 @@ class LinuxToolCheckList
'ubuntu', 'ubuntu',
'alpine', 'alpine',
'redhat', 'redhat',
'centos',
'Deepin', 'Deepin',
'arch', 'arch',
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
@@ -121,13 +122,14 @@ class LinuxToolCheckList
'ubuntu', 'debian', 'Deepin' => 'apt-get install -y', 'ubuntu', 'debian', 'Deepin' => 'apt-get install -y',
'alpine' => 'apk add', 'alpine' => 'apk add',
'redhat' => 'dnf install -y', 'redhat' => 'dnf install -y',
'centos' => 'yum install -y',
'arch' => 'pacman -S --noconfirm', 'arch' => 'pacman -S --noconfirm',
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
}; };
$prefix = ''; $prefix = '';
if (get_current_user() !== 'root') { if (($user = exec('whoami')) !== 'root') {
$prefix = 'sudo '; $prefix = 'sudo ';
logger()->warning('Current user is not root, using sudo for running command'); logger()->warning('Current user (' . $user . ') is not root, using sudo for running command');
} }
try { try {
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']); $is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']);

View File

@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);
namespace SPC\exception;
class InterruptException extends \Exception {}

View File

@@ -6,6 +6,7 @@ namespace SPC\store;
use SPC\builder\BuilderBase; use SPC\builder\BuilderBase;
use SPC\builder\linux\LinuxBuilder; use SPC\builder\linux\LinuxBuilder;
use SPC\builder\linux\SystemUtil;
use SPC\builder\unix\UnixBuilderBase; use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
@@ -27,6 +28,7 @@ class SourcePatcher
FileSystem::addSourceExtractHook('libyaml', [SourcePatcher::class, 'patchLibYaml']); FileSystem::addSourceExtractHook('libyaml', [SourcePatcher::class, 'patchLibYaml']);
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchImapLicense']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchImapLicense']);
FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']); FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']);
FileSystem::addSourceExtractHook('libaom', [SourcePatcher::class, 'patchLibaomForAlpine']);
} }
/** /**
@@ -393,6 +395,15 @@ class SourcePatcher
return true; return true;
} }
public static function patchLibaomForAlpine(): bool
{
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist()) {
SourcePatcher::patchFile('libaom_posix_implict.patch', SOURCE_PATH . '/libaom');
return true;
}
return false;
}
/** /**
* Patch cli SAPI Makefile for Windows. * Patch cli SAPI Makefile for Windows.
* *

View File

@@ -0,0 +1,104 @@
<?php
declare(strict_types=1);
namespace SPC\util;
use SPC\builder\BuilderBase;
use SPC\builder\BuilderProvider;
use SPC\builder\macos\MacOSBuilder;
use SPC\store\Config;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
class SPCConfigUtil
{
public function __construct(private ?BuilderBase $builder = null, ?InputInterface $input = null)
{
if ($builder === null) {
$this->builder = BuilderProvider::makeBuilderByInput($input ?? new ArgvInput());
}
}
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
{
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
ob_start();
$this->builder->proveLibs($libraries);
$this->builder->proveExts($extensions);
ob_get_clean();
$ldflags = $this->getLdflagsString();
$libs = $this->getLibsString($libraries);
$cflags = $this->getIncludesString();
// embed
$libs = '-lphp -lc ' . $libs;
$extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS');
if (is_string($extra_env)) {
$libs .= ' ' . $extra_env;
}
// c++
if ($this->builder->hasCpp()) {
$libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++';
}
return [
'cflags' => $cflags,
'ldflags' => $ldflags,
'libs' => $libs,
];
}
private function getIncludesString(): string
{
$base = BUILD_INCLUDE_PATH;
$php_embed_includes = [
"-I{$base}",
"-I{$base}/php",
"-I{$base}/php/main",
"-I{$base}/php/TSRM",
"-I{$base}/php/Zend",
"-I{$base}/php/ext",
];
return implode(' ', $php_embed_includes);
}
private function getLdflagsString(): string
{
return '-L' . BUILD_LIB_PATH;
}
private function getLibsString(array $libraries): string
{
$short_name = [];
foreach (array_reverse($libraries) as $library) {
$libs = Config::getLib($library, 'static-libs', []);
foreach ($libs as $lib) {
$short_name[] = $this->getShortLibName($lib);
}
if (PHP_OS_FAMILY !== 'Darwin') {
continue;
}
foreach (Config::getLib($library, 'frameworks', []) as $fw) {
$ks = '-framework ' . $fw;
if (!in_array($ks, $short_name)) {
$short_name[] = $ks;
}
}
}
// patch: imagick (imagemagick wrapper) for linux needs -lgomp
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') {
$short_name[] = '-lgomp';
}
return implode(' ', $short_name);
}
private function getShortLibName(string $lib): string
{
if (!str_starts_with($lib, 'lib') || !str_ends_with($lib, '.a')) {
return BUILD_LIB_PATH . '/' . $lib;
}
// get short name
return '-l' . substr($lib, 3, -2);
}
}

View File

@@ -62,6 +62,9 @@ class UnixShell
logger()->debug(ConsoleColor::blue('[EXEC] ') . ConsoleColor::gray($cmd)); logger()->debug(ConsoleColor::blue('[EXEC] ') . ConsoleColor::gray($cmd));
} }
logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']);
if ($this->cd !== null) {
$cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd;
}
exec($cmd, $out, $code); exec($cmd, $out, $code);
return [$code, $out]; return [$code, $out];
} }

View File

@@ -0,0 +1,17 @@
#include <sapi/embed/php_embed.h>
int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle;
zend_stream_init_filename(&file_handle,"embed.php");
if(php_execute_script(&file_handle) == FAILURE){
php_printf("Failed to execute PHP script.\n");
}
PHP_EMBED_END_BLOCK()
return 0;
}

View File

@@ -0,0 +1,4 @@
<?php
declare(strict_types=1);
echo 'hello' . PHP_EOL;

View File

@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
assert(function_exists('ast\parse_code'));

View File

@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
assert(function_exists('dio_open'));

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
assert(class_exists('Imagick'));
assert(Imagick::queryFormats('AVIF') !== []);
assert(Imagick::queryFormats('HEIF') !== []);
assert(Imagick::queryFormats('HEIC') !== []);
assert(Imagick::queryFormats('WEBP') !== []);
assert(Imagick::queryFormats('JPEG') !== []);
assert(Imagick::queryFormats('PNG') !== []);
assert(Imagick::queryFormats('TIFF') !== []);

View File

@@ -4,3 +4,4 @@ declare(strict_types=1);
assert(function_exists('openssl_digest')); assert(function_exists('openssl_digest'));
assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e'); assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e');
assert(file_get_contents('https://example.com/') !== false);

View File

@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
assert(function_exists('OpenTelemetry\Instrumentation\hook'));

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use SPC\builder\BuilderBase; use SPC\builder\BuilderBase;
use SPC\builder\BuilderProvider; use SPC\builder\BuilderProvider;
use SPC\exception\InterruptException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\util\UnixShell; use SPC\util\UnixShell;
@@ -125,6 +126,11 @@ function patch_point(): string
return BuilderProvider::getBuilder()->getPatchPoint(); return BuilderProvider::getBuilder()->getPatchPoint();
} }
function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException
{
return new InterruptException(message: $msg, code: $retcode);
}
// ------- function f_* part ------- // ------- function f_* part -------
// f_ means standard function wrapper // f_ means standard function wrapper

View File

@@ -0,0 +1,13 @@
https://bugs.gentoo.org/869419
POSIX_C_SOURCE is needed for ftello.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,6 +269,7 @@ add_library(aom_rtcd OBJECT ${AOM_RTCD_SOURCES})
add_dependencies(aom_rtcd aom_version)
if(ENABLE_EXAMPLES)
+ add_definitions(-D_POSIX_C_SOURCE=200112L)
add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_encoder_stats)
endif()

View File

@@ -21,12 +21,14 @@ $test_php_version = [
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) // test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
$test_os = [ $test_os = [
// 'macos-13',
'macos-14', 'macos-14',
'ubuntu-latest', 'ubuntu-latest',
// 'windows-latest',
]; ];
// whether enable thread safe // whether enable thread safe
$zts = false; $zts = true;
$no_strip = false; $no_strip = false;
@@ -38,8 +40,8 @@ $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'grpc', 'Linux', 'Darwin' => 'gettext',
'Windows' => 'amqp,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,swow,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib', 'Windows' => 'gettext',
}; };
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
@@ -52,7 +54,7 @@ $with_libs = match (PHP_OS_FAMILY) {
// You can use `common`, `bulk`, `minimal` or `none`. // You can use `common`, `bulk`, `minimal` or `none`.
// note: combination is only available for *nix platform. Windows must use `none` combination // note: combination is only available for *nix platform. Windows must use `none` combination
$base_combination = match (PHP_OS_FAMILY) { $base_combination = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'minimal', 'Linux', 'Darwin' => 'none',
'Windows' => 'none', 'Windows' => 'none',
}; };
@@ -114,14 +116,13 @@ if ($argv[1] === 'download_cmd') {
} }
// generate build command // generate build command
if ($argv[1] === 'build_cmd') { if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') {
$build_cmd = 'build '; $build_cmd = 'build ';
$build_cmd .= quote2($final_extensions) . ' '; $build_cmd .= quote2($final_extensions) . ' ';
$build_cmd .= $zts ? '--enable-zts ' : ''; $build_cmd .= $zts ? '--enable-zts ' : '';
$build_cmd .= $no_strip ? '--no-strip ' : ''; $build_cmd .= $no_strip ? '--no-strip ' : '';
$build_cmd .= $upx ? '--with-upx-pack ' : ''; $build_cmd .= $upx ? '--with-upx-pack ' : '';
$build_cmd .= $final_libs === '' ? '' : ('--with-libs=' . quote2($final_libs) . ' '); $build_cmd .= $final_libs === '' ? '' : ('--with-libs=' . quote2($final_libs) . ' ');
$build_cmd .= '--build-cli --build-micro ';
$build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm '; $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm ';
$build_cmd .= '--debug '; $build_cmd .= '--debug ';
} }
@@ -139,6 +140,7 @@ echo match ($argv[1]) {
'prefer_pre_built' => $prefer_pre_built ? '--prefer-pre-built' : '', 'prefer_pre_built' => $prefer_pre_built ? '--prefer-pre-built' : '',
'download_cmd' => $down_cmd, 'download_cmd' => $down_cmd,
'build_cmd' => $build_cmd, 'build_cmd' => $build_cmd,
'build_embed_cmd' => $build_cmd,
default => '', default => '',
}; };
@@ -150,9 +152,16 @@ if ($argv[1] === 'download_cmd') {
} }
} elseif ($argv[1] === 'build_cmd') { } elseif ($argv[1] === 'build_cmd') {
if (str_starts_with($argv[2], 'windows-')) { if (str_starts_with($argv[2], 'windows-')) {
passthru('powershell.exe -file .\bin\spc.ps1 ' . $build_cmd, $retcode); passthru('powershell.exe -file .\bin\spc.ps1 ' . $build_cmd . ' --build-cli --build-micro', $retcode);
} else { } else {
passthru('./bin/spc ' . $build_cmd, $retcode); passthru('./bin/spc ' . $build_cmd . ' --build-cli --build-micro', $retcode);
}
} elseif ($argv[1] === 'build_embed_cmd') {
if (str_starts_with($argv[2], 'windows-')) {
// windows does not accept embed SAPI
passthru('powershell.exe -file .\bin\spc.ps1 ' . $build_cmd . ' --build-cli', $retcode);
} else {
passthru('./bin/spc ' . $build_cmd . ' --build-embed', $retcode);
} }
} }

View File

@@ -246,6 +246,7 @@ class BuilderTest extends TestCase
public function testEmitPatchPointNotExists() public function testEmitPatchPointNotExists()
{ {
$this->expectOutputRegex('/failed to run/'); $this->expectOutputRegex('/failed to run/');
$this->expectException(RuntimeException::class);
$this->builder->setOption('with-added-patch', ['/tmp/patch-point.not_exsssists.php']); $this->builder->setOption('with-added-patch', ['/tmp/patch-point.not_exsssists.php']);
$this->builder->emitPatchPoint('not-exists'); $this->builder->emitPatchPoint('not-exists');
} }