diff --git a/.github/workflows/build-unix.yml b/.github/workflows/build-unix.yml index 9a40960e5..083b464c9 100644 --- a/.github/workflows/build-unix.yml +++ b/.github/workflows/build-unix.yml @@ -29,6 +29,9 @@ on: description: Extensions to build (comma separated) required: true type: string + shared-extensions: + description: Shared extensions to build (optional, comma separated) + type: string extra-libs: description: Extra libraries to build (optional, comma separated) type: string @@ -42,6 +45,14 @@ on: build-fpm: description: Build fpm binary type: boolean + build-frankenphp: + description: Build frankenphp binary (requires ZTS) + type: boolean + default: false + enable-zts: + description: Enable ZTS + type: boolean + default: false prefer-pre-built: description: Prefer pre-built binaries (reduce build time) type: boolean @@ -73,6 +84,9 @@ on: description: Extensions to build (comma separated) required: true type: string + shared-extensions: + description: Shared extensions to build (optional, comma separated) + type: string extra-libs: description: Extra libraries to build (optional, comma separated) type: string @@ -86,6 +100,14 @@ on: build-fpm: description: Build fpm binary type: boolean + build-frankenphp: + description: Build frankenphp binary (requires ZTS) + type: boolean + default: false + enable-zts: + description: Enable ZTS + type: boolean + default: false prefer-pre-built: description: Prefer pre-built binaries (reduce build time) type: boolean @@ -152,8 +174,19 @@ jobs: RUNS_ON="macos-15" ;; 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 }}" + STATIC_EXTS="${{ inputs.extensions }}" + SHARED_EXTS="${{ inputs['shared-extensions'] }}" + BUILD_FRANKENPHP="${{ inputs['build-frankenphp'] }}" + ENABLE_ZTS="${{ inputs['enable-zts'] }}" + ALL_EXTS="$STATIC_EXTS" + if [ -n "$SHARED_EXTS" ]; then + ALL_EXTS="$ALL_EXTS,$SHARED_EXTS" + fi + DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=$ALL_EXTS --ignore-cache-sources=php-src" + BUILD_CMD="$BUILD_CMD $STATIC_EXTS" + if [ -n "$SHARED_EXTS" ]; then + BUILD_CMD="$BUILD_CMD --build-shared=$SHARED_EXTS" + fi if [ -n "${{ inputs.extra-libs }}" ]; then DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}" BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}" @@ -177,6 +210,12 @@ jobs: if [ ${{ inputs.build-fpm }} == true ]; then BUILD_CMD="$BUILD_CMD --build-fpm" fi + if [ "$BUILD_FRANKENPHP" = "true" ]; then + BUILD_CMD="$BUILD_CMD --build-frankenphp" + fi + if [ "$ENABLE_ZTS" = "true" ]; then + BUILD_CMD="$BUILD_CMD --enable-zts" + fi echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT" echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT" echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT" @@ -199,6 +238,27 @@ jobs: env: phpts: nts + - if: ${{ inputs['build-frankenphp'] == true }} + name: "Install go-xcaddy for FrankenPHP" + run: | + case "${{ inputs.os }}" in + linux-x86_64|linux-aarch64) + ./bin/spc-alpine-docker install-pkg go-xcaddy + ;; + linux-x86_64-glibc|linux-aarch64-glibc) + ./bin/spc-gnu-docker install-pkg go-xcaddy + ;; + macos-x86_64|macos-aarch64) + composer update --no-dev --classmap-authoritative + ./bin/spc doctor --auto-fix + ./bin/spc install-pkg go-xcaddy + ;; + *) + echo "Unsupported OS for go-xcaddy install: ${{ inputs.os }}" + exit 1 + ;; + esac + # Cache downloaded source - id: cache-download uses: actions/cache@v4 @@ -245,7 +305,22 @@ jobs: name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }} path: buildroot/bin/php-fpm + # Upload frankenphp executable + - if: ${{ inputs['build-frankenphp'] == true }} + name: "Upload FrankenPHP SAPI" + uses: actions/upload-artifact@v4 + with: + name: php-frankenphp-${{ inputs.php-version }}-${{ inputs.os }} + path: buildroot/bin/frankenphp + # Upload extensions metadata + - if: ${{ inputs['shared-extensions'] != '' }} + name: "Upload shared extensions" + uses: actions/upload-artifact@v4 + with: + name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }} + path: | + buildroot/modules/*.so - uses: actions/upload-artifact@v4 name: "Upload License Files" with: diff --git a/.gitignore b/.gitignore index 21bae186b..810af82ce 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,6 @@ spc.exe # dumped files from StaticPHP v3 /dump-*.json + +# config parse cache +/.spc.cache.php diff --git a/TODO.md b/TODO.md new file mode 100644 index 000000000..52d6133a9 --- /dev/null +++ b/TODO.md @@ -0,0 +1,57 @@ +# v3 TODO List + +Tracking items identified during the v2 → v3 migration audit. + +--- + +## Commands + +- [ ] Implement `craft` command (drives full build from `craft.yml`; should be easier with v3 vendor/registry mode) +- [x] Migrate `micro:combine` command (combine `micro.sfx` with PHP code + INI injection) +- [ ] Implement `dump-extensions` command (extract required extensions from `composer.json` / `composer.lock`) +- [ ] Design and implement v3 dev toolchain commands (WIP — needs design decision): + - [ ] `dev:extensions` / equivalent listing command + - [ ] `dev:php-version`, `dev:ext-version`, `dev:lib-version` + - [ ] Doc generation commands (`dev:gen-ext-docs`, `dev:gen-ext-dep-docs`, `dev:gen-lib-dep-docs`) — pending v3 doc design + +--- + +## Source Patches (SourcePatcher → Artifact migration) + +The following v2 `SourcePatcher` hooks are not yet migrated to v3 `src/Package/Artifact/` classes: + +- [ ] Migrate `patchSQLSRVWin32` — removes `/sdl` compile flag to prevent Zend build failure on Windows +- [ ] Migrate `patchSQLSRVPhp85` — fixes `pdo_sqlsrv` directory layout for PHP 8.5 +- [ ] Migrate `patchYamlWin32` — patches `config.w32` `_a.lib` detection logic for the `yaml` extension +- [ ] Migrate `patchImagickWith84` — applies PHP 8.4 compatibility patch for `imagick` based on version detection + +--- + +## Extension Package Classes (Unix) + +Extensions that had non-trivial v2 build logic and are missing a v3 `src/Package/Extension/` class: + +- [x] `gettext` — macOS: fix `config.m4` bracket syntax for cross-version compatibility + append frameworks to linker flags (critical for macOS linking; this is a Unix-side gap, not Windows-only) + +--- + +## Windows Extensions (Early Stage) + +Windows extension support is still in early stage. The following extensions had Windows-specific configure args or patches in v2 and are pending v3 Windows implementation: + +- [ ] `amqp` — Windows configure args +- [ ] `com_dotnet` — Windows-only extension +- [ ] `dom` — remove `dllmain.c` from `config.w32` +- [ ] `ev` — fix `PHP_EV_SHARED` in `config.w32` +- [ ] `gmssl` — add `CHECK_LIB("gmssl.lib")` to `config.w32` +- [ ] `intl` — fix `PHP_INTL_SHARED` in `config.w32` +- [ ] `lz4` — Windows configure args +- [ ] `mbregex` — Windows configure args +- [ ] `sqlsrv` / `pdo_sqlsrv` — complex conditional build logic (independent `sqlsrv` without `pdo_sqlsrv`) +- [ ] `xml` — remove `dllmain.c` from `config.w32`; handles `soap`, `xmlreader`, `xmlwriter`, `simplexml` + +--- + +## Documentation + +- [ ] Write v3 user documentation (currently zero v3 docs) diff --git a/bin/spc-debug b/bin/spc-debug index d5a18c837..2c5360037 100755 --- a/bin/spc-debug +++ b/bin/spc-debug @@ -1,4 +1,12 @@ #!/usr/bin/env bash +# Use SPC_XDEBUG=profile to enable Xdebug profiling mode, which will generate profiling files in /tmp. +# Otherwise, it will enable Xdebug debugging mode, which allows you to connect a debugger to port 9003. +if [ "$SPC_XDEBUG" = "profile" ]; then + XDEBUG_PREFIX="-d xdebug.mode=profile -d xdebug.start_with_request=yes -d xdebug.output_dir=/tmp -d xdebug.output_name=spc-profile.%t.%p.%r" +else + XDEBUG_PREFIX="-d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes" +fi + # This script runs the 'spc' command with Xdebug enabled for debugging purposes. -php -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes "$(dirname "$0")/../bin/spc" "$@" +php $XDEBUG_PREFIX "$(dirname "$0")/../bin/spc" "$@" diff --git a/composer.json b/composer.json index 0d4fde4e8..d006fbbfd 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "scripts": { "analyse": "phpstan analyse --memory-limit 300M", "cs-fix": "php-cs-fixer fix", - "lint-config": "bin/spc dev:lint-config", + "lint-config": "php bin/spc dev:lint-config", "test": "vendor/bin/phpunit tests/ --no-coverage", "build:phar": "vendor/bin/box compile" }, @@ -63,6 +63,9 @@ "optimize-autoloader": true, "sort-packages": true }, + "suggest": { + "ext-yaml": "Speeds up YAML config file parsing" + }, "funding": [ { "type": "other", diff --git a/composer.lock b/composer.lock index eded86efb..69cc2e278 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f30595c9c60e55083112410cd1ffb203", + "content-hash": "1d5518bdf7730190aead0e953abff538", "packages": [ { "name": "laravel/prompts", - "version": "v0.3.12", + "version": "v0.3.15", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "4861ded9003b7f8a158176a0b7666f74ee761be8" + "reference": "4bb8107ec97651fd3f17f897d6489dbc4d8fb999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/4861ded9003b7f8a158176a0b7666f74ee761be8", - "reference": "4861ded9003b7f8a158176a0b7666f74ee761be8", + "url": "https://api.github.com/repos/laravel/prompts/zipball/4bb8107ec97651fd3f17f897d6489dbc4d8fb999", + "reference": "4bb8107ec97651fd3f17f897d6489dbc4d8fb999", "shasum": "" }, "require": { @@ -61,22 +61,22 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.12" + "source": "https://github.com/laravel/prompts/tree/v0.3.15" }, - "time": "2026-02-03T06:57:26+00:00" + "time": "2026-03-17T13:45:17+00:00" }, { "name": "laravel/serializable-closure", - "version": "v2.0.9", + "version": "v2.0.10", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "8f631589ab07b7b52fead814965f5a800459cb3e" + "reference": "870fc81d2f879903dfc5b60bf8a0f94a1609e669" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/8f631589ab07b7b52fead814965f5a800459cb3e", - "reference": "8f631589ab07b7b52fead814965f5a800459cb3e", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/870fc81d2f879903dfc5b60bf8a0f94a1609e669", + "reference": "870fc81d2f879903dfc5b60bf8a0f94a1609e669", "shasum": "" }, "require": { @@ -124,168 +124,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2026-02-03T06:55:34+00:00" - }, - { - "name": "nette/php-generator", - "version": "v4.2.1", - "source": { - "type": "git", - "url": "https://github.com/nette/php-generator.git", - "reference": "52aff4d9b12f20ca9f3e31a559b646d2fd21dd61" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/52aff4d9b12f20ca9f3e31a559b646d2fd21dd61", - "reference": "52aff4d9b12f20ca9f3e31a559b646d2fd21dd61", - "shasum": "" - }, - "require": { - "nette/utils": "^4.0.6", - "php": "8.1 - 8.5" - }, - "require-dev": { - "jetbrains/phpstorm-attributes": "^1.2", - "nette/tester": "^2.6", - "nikic/php-parser": "^5.0", - "phpstan/phpstan": "^2.0@stable", - "tracy/tracy": "^2.8" - }, - "suggest": { - "nikic/php-parser": "to use ClassType::from(withBodies: true) & ClassType::fromCode()" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "psr-4": { - "Nette\\": "src" - }, - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.", - "homepage": "https://nette.org", - "keywords": [ - "code", - "nette", - "php", - "scaffolding" - ], - "support": { - "issues": "https://github.com/nette/php-generator/issues", - "source": "https://github.com/nette/php-generator/tree/v4.2.1" - }, - "time": "2026-02-09T05:43:31+00:00" - }, - { - "name": "nette/utils", - "version": "v4.1.2", - "source": { - "type": "git", - "url": "https://github.com/nette/utils.git", - "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", - "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", - "shasum": "" - }, - "require": { - "php": "8.2 - 8.5" - }, - "conflict": { - "nette/finder": "<3", - "nette/schema": "<1.2.2" - }, - "require-dev": { - "jetbrains/phpstorm-attributes": "^1.2", - "nette/tester": "^2.5", - "phpstan/phpstan": "^2.0@stable", - "tracy/tracy": "^2.9" - }, - "suggest": { - "ext-gd": "to use Image", - "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", - "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", - "ext-json": "to use Nette\\Utils\\Json", - "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Nette\\": "src" - }, - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", - "homepage": "https://nette.org", - "keywords": [ - "array", - "core", - "datetime", - "images", - "json", - "nette", - "paginator", - "password", - "slugify", - "string", - "unicode", - "utf-8", - "utility", - "validation" - ], - "support": { - "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.1.2" - }, - "time": "2026-02-03T17:21:09+00:00" + "time": "2026-02-20T19:59:49+00:00" }, { "name": "php-di/invoker", @@ -520,16 +359,16 @@ }, { "name": "symfony/console", - "version": "v7.4.4", + "version": "v7.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894" + "reference": "e1e6770440fb9c9b0cf725f81d1361ad1835329d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/41e38717ac1dd7a46b6bda7d6a82af2d98a78894", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894", + "url": "https://api.github.com/repos/symfony/console/zipball/e1e6770440fb9c9b0cf725f81d1361ad1835329d", + "reference": "e1e6770440fb9c9b0cf725f81d1361ad1835329d", "shasum": "" }, "require": { @@ -594,7 +433,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.4.4" + "source": "https://github.com/symfony/console/tree/v7.4.7" }, "funding": [ { @@ -614,7 +453,7 @@ "type": "tidelift" } ], - "time": "2026-01-13T11:36:38+00:00" + "time": "2026-03-06T14:06:20+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1172,16 +1011,16 @@ }, { "name": "symfony/string", - "version": "v8.0.4", + "version": "v8.0.6", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "758b372d6882506821ed666032e43020c4f57194" + "reference": "6c9e1108041b5dce21a9a4984b531c4923aa9ec4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/758b372d6882506821ed666032e43020c4f57194", - "reference": "758b372d6882506821ed666032e43020c4f57194", + "url": "https://api.github.com/repos/symfony/string/zipball/6c9e1108041b5dce21a9a4984b531c4923aa9ec4", + "reference": "6c9e1108041b5dce21a9a4984b531c4923aa9ec4", "shasum": "" }, "require": { @@ -1238,7 +1077,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v8.0.4" + "source": "https://github.com/symfony/string/tree/v8.0.6" }, "funding": [ { @@ -1258,20 +1097,20 @@ "type": "tidelift" } ], - "time": "2026-01-12T12:37:40+00:00" + "time": "2026-02-09T10:14:57+00:00" }, { "name": "symfony/yaml", - "version": "v7.4.1", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "24dd4de28d2e3988b311751ac49e684d783e2345" + "reference": "58751048de17bae71c5aa0d13cb19d79bca26391" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/24dd4de28d2e3988b311751ac49e684d783e2345", - "reference": "24dd4de28d2e3988b311751ac49e684d783e2345", + "url": "https://api.github.com/repos/symfony/yaml/zipball/58751048de17bae71c5aa0d13cb19d79bca26391", + "reference": "58751048de17bae71c5aa0d13cb19d79bca26391", "shasum": "" }, "require": { @@ -1314,7 +1153,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.4.1" + "source": "https://github.com/symfony/yaml/tree/v7.4.6" }, "funding": [ { @@ -1334,7 +1173,7 @@ "type": "tidelift" } ], - "time": "2025-12-04T18:11:45+00:00" + "time": "2026-02-09T09:33:46+00:00" }, { "name": "zhamao/logger", @@ -2217,7 +2056,7 @@ }, { "name": "captainhook/captainhook-phar", - "version": "5.28.0", + "version": "5.29.0", "source": { "type": "git", "url": "https://github.com/captainhook-git/captainhook-phar.git", @@ -2271,7 +2110,7 @@ ], "support": { "issues": "https://github.com/captainhook-git/captainhook/issues", - "source": "https://github.com/captainhook-git/captainhook-phar/tree/5.28.0" + "source": "https://github.com/captainhook-git/captainhook-phar/tree/5.29.0" }, "funding": [ { @@ -2968,16 +2807,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.93.1", + "version": "v3.94.2", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "b3546ab487c0762c39f308dc1ec0ea2c461fc21a" + "reference": "7787ceff91365ba7d623ec410b8f429cdebb4f63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/b3546ab487c0762c39f308dc1ec0ea2c461fc21a", - "reference": "b3546ab487c0762c39f308dc1ec0ea2c461fc21a", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7787ceff91365ba7d623ec410b8f429cdebb4f63", + "reference": "7787ceff91365ba7d623ec410b8f429cdebb4f63", "shasum": "" }, "require": { @@ -2994,7 +2833,7 @@ "react/event-loop": "^1.5", "react/socket": "^1.16", "react/stream": "^1.4", - "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0", + "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0 || ^8.0", "symfony/console": "^5.4.47 || ^6.4.24 || ^7.0 || ^8.0", "symfony/event-dispatcher": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", "symfony/filesystem": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", @@ -3008,18 +2847,18 @@ "symfony/stopwatch": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0" }, "require-dev": { - "facile-it/paraunit": "^1.3.1 || ^2.7", - "infection/infection": "^0.32", - "justinrainbow/json-schema": "^6.6", + "facile-it/paraunit": "^1.3.1 || ^2.7.1", + "infection/infection": "^0.32.3", + "justinrainbow/json-schema": "^6.6.4", "keradus/cli-executor": "^2.3", "mikey179/vfsstream": "^1.6.12", - "php-coveralls/php-coveralls": "^2.9", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6", - "phpunit/phpunit": "^9.6.31 || ^10.5.60 || ^11.5.48", + "php-coveralls/php-coveralls": "^2.9.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.7", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.7", + "phpunit/phpunit": "^9.6.34 || ^10.5.63 || ^11.5.51", "symfony/polyfill-php85": "^1.33", - "symfony/var-dumper": "^5.4.48 || ^6.4.26 || ^7.4.0 || ^8.0", - "symfony/yaml": "^5.4.45 || ^6.4.30 || ^7.4.1 || ^8.0" + "symfony/var-dumper": "^5.4.48 || ^6.4.32 || ^7.4.4 || ^8.0.4", + "symfony/yaml": "^5.4.45 || ^6.4.30 || ^7.4.1 || ^8.0.1" }, "suggest": { "ext-dom": "For handling output formats in XML", @@ -3060,7 +2899,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.93.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.94.2" }, "funding": [ { @@ -3068,20 +2907,20 @@ "type": "github" } ], - "time": "2026-01-28T23:50:50+00:00" + "time": "2026-02-20T16:13:53+00:00" }, { "name": "humbug/box", - "version": "4.6.10", + "version": "4.7.0", "source": { "type": "git", "url": "https://github.com/box-project/box.git", - "reference": "6dc6a1314d63e9d75c8195c996e1081e68514c36" + "reference": "9c2a430118f61ba4a20bc4969931494503f5da6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/box-project/box/zipball/6dc6a1314d63e9d75c8195c996e1081e68514c36", - "reference": "6dc6a1314d63e9d75c8195c996e1081e68514c36", + "url": "https://api.github.com/repos/box-project/box/zipball/9c2a430118f61ba4a20bc4969931494503f5da6a", + "reference": "9c2a430118f61ba4a20bc4969931494503f5da6a", "shasum": "" }, "require": { @@ -3180,9 +3019,9 @@ ], "support": { "issues": "https://github.com/box-project/box/issues", - "source": "https://github.com/box-project/box/tree/4.6.10" + "source": "https://github.com/box-project/box/tree/4.7.0" }, - "time": "2025-10-31T18:38:02+00:00" + "time": "2026-03-18T09:34:43+00:00" }, { "name": "humbug/php-scoper", @@ -3317,16 +3156,16 @@ }, { "name": "justinrainbow/json-schema", - "version": "6.6.4", + "version": "v6.7.2", "source": { "type": "git", "url": "https://github.com/jsonrainbow/json-schema.git", - "reference": "2eeb75d21cf73211335888e7f5e6fd7440723ec7" + "reference": "6fea66c7204683af437864e7c4e7abf383d14bc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/2eeb75d21cf73211335888e7f5e6fd7440723ec7", - "reference": "2eeb75d21cf73211335888e7f5e6fd7440723ec7", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/6fea66c7204683af437864e7c4e7abf383d14bc0", + "reference": "6fea66c7204683af437864e7c4e7abf383d14bc0", "shasum": "" }, "require": { @@ -3386,9 +3225,9 @@ ], "support": { "issues": "https://github.com/jsonrainbow/json-schema/issues", - "source": "https://github.com/jsonrainbow/json-schema/tree/6.6.4" + "source": "https://github.com/jsonrainbow/json-schema/tree/v6.7.2" }, - "time": "2025-12-19T15:01:32+00:00" + "time": "2026-02-15T15:06:22+00:00" }, { "name": "kelunik/certificate", @@ -3450,20 +3289,20 @@ }, { "name": "league/uri", - "version": "7.8.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri.git", - "reference": "4436c6ec8d458e4244448b069cc572d088230b76" + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/4436c6ec8d458e4244448b069cc572d088230b76", - "reference": "4436c6ec8d458e4244448b069cc572d088230b76", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/08cf38e3924d4f56238125547b5720496fac8fd4", + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4", "shasum": "" }, "require": { - "league/uri-interfaces": "^7.8", + "league/uri-interfaces": "^7.8.1", "php": "^8.1", "psr/http-factory": "^1" }, @@ -3536,7 +3375,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.8.0" + "source": "https://github.com/thephpleague/uri/tree/7.8.1" }, "funding": [ { @@ -3544,20 +3383,20 @@ "type": "github" } ], - "time": "2026-01-14T17:24:56+00:00" + "time": "2026-03-15T20:22:25+00:00" }, { "name": "league/uri-interfaces", - "version": "7.8.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "c5c5cd056110fc8afaba29fa6b72a43ced42acd4" + "reference": "85d5c77c5d6d3af6c54db4a78246364908f3c928" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/c5c5cd056110fc8afaba29fa6b72a43ced42acd4", - "reference": "c5c5cd056110fc8afaba29fa6b72a43ced42acd4", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/85d5c77c5d6d3af6c54db4a78246364908f3c928", + "reference": "85d5c77c5d6d3af6c54db4a78246364908f3c928", "shasum": "" }, "require": { @@ -3620,7 +3459,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.8.0" + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.8.1" }, "funding": [ { @@ -3628,7 +3467,7 @@ "type": "github" } ], - "time": "2026-01-15T06:54:53+00:00" + "time": "2026-03-08T20:05:35+00:00" }, { "name": "marc-mabe/php-enum", @@ -4260,16 +4099,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.6", + "version": "5.6.7", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8" + "reference": "31a105931bc8ffa3a123383829772e832fd8d903" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/5cee1d3dfc2d2aa6599834520911d246f656bcb8", - "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/31a105931bc8ffa3a123383829772e832fd8d903", + "reference": "31a105931bc8ffa3a123383829772e832fd8d903", "shasum": "" }, "require": { @@ -4318,9 +4157,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.6" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.7" }, - "time": "2025-12-22T21:13:58+00:00" + "time": "2026-03-18T20:47:46+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -4429,11 +4268,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.38", + "version": "2.1.42", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dfaf1f530e1663aa167bc3e52197adb221582629", - "reference": "dfaf1f530e1663aa167bc3e52197adb221582629", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1279e1ce86ba768f0780c9d889852b4e02ff40d0", + "reference": "1279e1ce86ba768f0780c9d889852b4e02ff40d0", "shasum": "" }, "require": { @@ -4478,7 +4317,7 @@ "type": "github" } ], - "time": "2026-01-30T17:12:46+00:00" + "time": "2026-03-17T14:58:32+00:00" }, { "name": "phpunit/php-code-coverage", @@ -6894,16 +6733,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.4.0", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a" + "reference": "3ebc794fa5315e59fd122561623c2e2e4280538e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/3ebc794fa5315e59fd122561623c2e2e4280538e", + "reference": "3ebc794fa5315e59fd122561623c2e2e4280538e", "shasum": "" }, "require": { @@ -6940,7 +6779,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.4.0" + "source": "https://github.com/symfony/filesystem/tree/v7.4.6" }, "funding": [ { @@ -6960,20 +6799,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-02-25T16:50:00+00:00" }, { "name": "symfony/finder", - "version": "v7.4.5", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb" + "reference": "8655bf1076b7a3a346cb11413ffdabff50c7ffcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", + "url": "https://api.github.com/repos/symfony/finder/zipball/8655bf1076b7a3a346cb11413ffdabff50c7ffcf", + "reference": "8655bf1076b7a3a346cb11413ffdabff50c7ffcf", "shasum": "" }, "require": { @@ -7008,7 +6847,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.4.5" + "source": "https://github.com/symfony/finder/tree/v7.4.6" }, "funding": [ { @@ -7028,7 +6867,7 @@ "type": "tidelift" } ], - "time": "2026-01-26T15:07:59+00:00" + "time": "2026-01-29T09:40:50+00:00" }, { "name": "symfony/options-resolver", @@ -7333,16 +7172,16 @@ }, { "name": "symfony/var-dumper", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "0e4769b46a0c3c62390d124635ce59f66874b282" + "reference": "045321c440ac18347b136c63d2e9bf28a2dc0291" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0e4769b46a0c3c62390d124635ce59f66874b282", - "reference": "0e4769b46a0c3c62390d124635ce59f66874b282", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/045321c440ac18347b136c63d2e9bf28a2dc0291", + "reference": "045321c440ac18347b136c63d2e9bf28a2dc0291", "shasum": "" }, "require": { @@ -7396,7 +7235,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.4.4" + "source": "https://github.com/symfony/var-dumper/tree/v7.4.6" }, "funding": [ { @@ -7416,20 +7255,20 @@ "type": "tidelift" } ], - "time": "2026-01-01T22:13:48+00:00" + "time": "2026-02-15T10:53:20+00:00" }, { "name": "thecodingmachine/safe", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/thecodingmachine/safe.git", - "reference": "2cdd579eeaa2e78e51c7509b50cc9fb89a956236" + "reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/2cdd579eeaa2e78e51c7509b50cc9fb89a956236", - "reference": "2cdd579eeaa2e78e51c7509b50cc9fb89a956236", + "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/705683a25bacf0d4860c7dea4d7947bfd09eea19", + "reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19", "shasum": "" }, "require": { @@ -7539,7 +7378,7 @@ "description": "PHP core functions that throw exceptions instead of returning FALSE on error", "support": { "issues": "https://github.com/thecodingmachine/safe/issues", - "source": "https://github.com/thecodingmachine/safe/tree/v3.3.0" + "source": "https://github.com/thecodingmachine/safe/tree/v3.4.0" }, "funding": [ { @@ -7550,12 +7389,16 @@ "url": "https://github.com/shish", "type": "github" }, + { + "url": "https://github.com/silasjoisten", + "type": "github" + }, { "url": "https://github.com/staabm", "type": "github" } ], - "time": "2025-05-14T06:15:44+00:00" + "time": "2026-02-04T18:08:13+00:00" }, { "name": "theseer/tokenizer", diff --git a/config/ext.json b/config/ext.json index 4352f2e2c..16a71c212 100644 --- a/config/ext.json +++ b/config/ext.json @@ -63,7 +63,8 @@ ], "ext-depends-windows": [ "zlib", - "openssl" + "openssl", + "brotli" ] }, "dba": { @@ -252,6 +253,7 @@ "arg-type-unix": "enable-path", "cpp-extension": true, "lib-depends": [ + "grpc", "zlib", "openssl", "libcares" diff --git a/config/lib.json b/config/lib.json index ebbf4b87b..4792a9329 100644 --- a/config/lib.json +++ b/config/lib.json @@ -109,8 +109,7 @@ "krb5" ], "lib-suggests-windows": [ - "brotli", - "zstd" + "brotli" ], "frameworks": [ "CoreFoundation", @@ -143,9 +142,7 @@ "zlib" ], "lib-suggests": [ - "libpng", - "bzip2", - "brotli" + "libpng" ] }, "gettext": { @@ -355,6 +352,9 @@ "static-libs-unix": [ "libaom.a" ], + "static-libs-windows": [ + "aom.lib" + ], "cpp-library": true }, "libargon2": { @@ -493,7 +493,7 @@ "static-libs-windows": [ "libjpeg_a.lib" ], - "lib-suggests-windows": [ + "lib-depends": [ "zlib" ] }, @@ -762,7 +762,6 @@ "xz" ], "lib-suggests-windows": [ - "zstd", "openssl" ] }, @@ -862,6 +861,9 @@ }, "openssl": { "source": "openssl", + "pkg-configs": [ + "openssl" + ], "static-libs-unix": [ "libssl.a", "libcrypto.a" @@ -974,6 +976,11 @@ }, "unixodbc": { "source": "unixodbc", + "pkg-configs": [ + "odbc", + "odbccr", + "odbcinst" + ], "static-libs-unix": [ "libodbc.a", "libodbccr.a", @@ -991,6 +998,9 @@ ], "headers": [ "wtr/watcher-c.h" + ], + "frameworks": [ + "CoreServices" ] }, "xz": { @@ -1015,6 +1025,9 @@ }, "zlib": { "source": "zlib", + "pkg-configs": [ + "zlib" + ], "static-libs-unix": [ "libz.a" ], @@ -1028,6 +1041,9 @@ }, "zstd": { "source": "zstd", + "pkg-configs": [ + "libzstd" + ], "static-libs-unix": [ "libzstd.a" ], diff --git a/config/pkg/ext/builtin-extensions.yml b/config/pkg/ext/builtin-extensions.yml index b938182c0..52478e2c3 100644 --- a/config/pkg/ext/builtin-extensions.yml +++ b/config/pkg/ext/builtin-extensions.yml @@ -9,6 +9,12 @@ ext-bz2: arg-type@windows: with ext-calendar: type: php-extension +ext-com_dotnet: + type: php-extension + php-extension: + os: + - Windows + arg-type@windows: '--enable-com-dotnet=yes' ext-ctype: type: php-extension ext-curl: @@ -16,6 +22,7 @@ ext-curl: depends: - curl depends@windows: + - curl - ext-zlib - ext-openssl php-extension: @@ -29,17 +36,20 @@ ext-dba: ext-dom: type: php-extension depends: - - libxml2 - ext-xml php-extension: - arg-type: '--enable-dom@shared_suffix@ --with-libxml=@build_root_path@' + arg-type: enable arg-type@windows: with ext-exif: type: php-extension + depends@windows: + - ext-mbstring ext-ffi: type: php-extension depends@unix: - libffi + depends@windows: + - libffi-win php-extension: arg-type@unix: '--with-ffi=@shared_suffix@ --enable-zend-signals' arg-type@windows: with @@ -64,28 +74,37 @@ ext-gd: - freetype php-extension: arg-type: custom + arg-type@windows: with ext-gettext: type: php-extension - depends: + depends@unix: - gettext + depends@windows: + - gettext-win php-extension: arg-type: with-path + arg-type@windows: with ext-gmp: type: php-extension - depends: + depends@unix: - gmp + depends@windows: + - mpir php-extension: arg-type: with-path + arg-type@windows: with ext-iconv: type: php-extension depends@unix: - libiconv + depends@windows: + - libiconv-win php-extension: arg-type@unix: with-path arg-type@windows: with ext-intl: type: php-extension - depends@unix: + depends: - icu ext-ldap: type: php-extension @@ -96,15 +115,20 @@ ext-ldap: - libsodium - ext-openssl php-extension: + os: + - Linux + - Darwin arg-type: with-path + arg-type@windows: with ext-libxml: type: php-extension depends: - - ext-xml + - libxml2 php-extension: build-with-php: true build-shared: false - arg-type: none + arg-type@unix: with-path + arg-type@windows: with ext-mbregex: type: php-extension depends: @@ -140,6 +164,7 @@ ext-odbc: - unixodbc php-extension: arg-type@unix: '--with-unixODBC@shared_path_suffix@' + arg-type@windows: enable ext-opcache: type: php-extension php-extension: @@ -163,10 +188,17 @@ ext-password-argon2: - libargon2 - ext-openssl php-extension: + os: + - Linux + - Darwin arg-type: custom display-name: '' ext-pcntl: type: php-extension + php-extension: + os: + - Linux + - Darwin ext-pdo: type: php-extension ext-pdo_mysql: @@ -180,7 +212,6 @@ ext-pdo_odbc: type: php-extension depends: - ext-pdo - - ext-odbc depends@unix: - unixodbc - ext-pdo @@ -189,7 +220,7 @@ ext-pdo_odbc: arg-type: custom ext-pdo_pgsql: type: php-extension - depends@unix: + depends: - ext-pdo - ext-pgsql - postgresql @@ -206,7 +237,7 @@ ext-pdo_sqlite: arg-type: with ext-pgsql: type: php-extension - depends@unix: + depends: - postgresql php-extension: arg-type: custom @@ -216,15 +247,19 @@ ext-phar: - zlib ext-posix: type: php-extension + php-extension: + os: + - Linux + - Darwin ext-readline: type: php-extension - depends: + depends@unix: - libedit + depends@windows: + - wineditline php-extension: - support: - Windows: wip - BSD: wip arg-type: '--with-libedit --without-readline' + arg-type@windows: with build-shared: false build-static: true ext-session: @@ -238,7 +273,7 @@ ext-simplexml: depends: - ext-xml php-extension: - arg-type@unix: '--enable-simplexml@shared_suffix@ --with-libxml=@build_root_path@' + arg-type@unix: enable arg-type@windows: with build-with-php: true ext-snmp: @@ -246,6 +281,9 @@ ext-snmp: depends: - net-snmp php-extension: + os: + - Linux + - Darwin arg-type: with ext-soap: type: php-extension @@ -253,8 +291,7 @@ ext-soap: - ext-xml - ext-session php-extension: - arg-type@unix: '--enable-soap@shared_suffix@ --with-libxml=@build_root_path@' - arg-type@windows: with + arg-type: enable build-with-php: true ext-sockets: type: php-extension @@ -275,28 +312,22 @@ ext-sqlite3: ext-sysvmsg: type: php-extension php-extension: - support: - Windows: 'no' - BSD: wip + os: + - Linux + - Darwin ext-sysvsem: type: php-extension php-extension: - support: - Windows: 'no' - BSD: wip + os: + - Linux + - Darwin ext-sysvshm: type: php-extension - php-extension: - support: - BSD: wip ext-tidy: type: php-extension depends: - tidy php-extension: - support: - Windows: wip - BSD: wip arg-type: with-path ext-tokenizer: type: php-extension @@ -305,27 +336,27 @@ ext-tokenizer: ext-xml: type: php-extension depends: - - libxml2 + - ext-libxml depends@windows: - - libxml2 - ext-iconv + - ext-libxml php-extension: - arg-type: '--enable-xml@shared_suffix@ --with-libxml=@build_root_path@' + arg-type@unix: enable arg-type@windows: with build-with-php: true ext-xmlreader: type: php-extension depends: - - libxml2 + - ext-xml php-extension: - arg-type: '--enable-xmlreader@shared_suffix@ --with-libxml=@build_root_path@' + arg-type: enable build-with-php: true ext-xmlwriter: type: php-extension depends: - - libxml2 + - ext-xml php-extension: - arg-type: '--enable-xmlwriter@shared_suffix@ --with-libxml=@build_root_path@' + arg-type: enable build-with-php: true ext-xsl: type: php-extension @@ -342,6 +373,6 @@ ext-zlib: - zlib php-extension: arg-type: custom - arg-type@windows: with + arg-type@windows: enable build-with-php: true build-shared: false diff --git a/config/pkg/ext/ext-amqp.yml b/config/pkg/ext/ext-amqp.yml index 1c8023602..6c73bf203 100644 --- a/config/pkg/ext/ext-amqp.yml +++ b/config/pkg/ext/ext-amqp.yml @@ -10,6 +10,7 @@ ext-amqp: depends: - librabbitmq depends@windows: + - librabbitmq - ext-openssl php-extension: arg-type: '--with-amqp@shared_suffix@ --with-librabbitmq-dir=@build_root_path@' diff --git a/config/pkg/ext/ext-event.yml b/config/pkg/ext/ext-event.yml index dd9c1c8ec..537af066b 100644 --- a/config/pkg/ext/ext-event.yml +++ b/config/pkg/ext/ext-event.yml @@ -14,6 +14,7 @@ ext-event: suggests: - ext-sockets php-extension: - support: - Windows: wip + os: + - Linux + - Darwin arg-type: custom diff --git a/config/pkg/ext/ext-excimer.yml b/config/pkg/ext/ext-excimer.yml index 3d0858882..a896fe0bd 100644 --- a/config/pkg/ext/ext-excimer.yml +++ b/config/pkg/ext/ext-excimer.yml @@ -7,3 +7,7 @@ ext-excimer: metadata: license-files: [LICENSE] license: PHP-3.01 + php-extension: + os: + - Linux + - Darwin diff --git a/config/pkg/ext/ext-grpc.yml b/config/pkg/ext/ext-grpc.yml index ff5bae7b8..ae63cad2b 100644 --- a/config/pkg/ext/ext-grpc.yml +++ b/config/pkg/ext/ext-grpc.yml @@ -11,4 +11,7 @@ ext-grpc: - grpc lang: cpp php-extension: + os: + - Linux + - Darwin arg-type@unix: enable-path diff --git a/config/pkg/ext/ext-imagick.yml b/config/pkg/ext/ext-imagick.yml index e6f9843eb..2a1c221c3 100644 --- a/config/pkg/ext/ext-imagick.yml +++ b/config/pkg/ext/ext-imagick.yml @@ -10,4 +10,7 @@ ext-imagick: depends: - imagemagick php-extension: + os: + - Linux + - Darwin arg-type: custom diff --git a/config/pkg/ext/ext-imap.yml b/config/pkg/ext/ext-imap.yml index a6c18daca..3abcebb8b 100644 --- a/config/pkg/ext/ext-imap.yml +++ b/config/pkg/ext/ext-imap.yml @@ -12,4 +12,7 @@ ext-imap: suggests: - ext-openssl php-extension: + os: + - Linux + - Darwin arg-type: custom diff --git a/config/pkg/ext/ext-inotify.yml b/config/pkg/ext/ext-inotify.yml index 0956f9e40..d69847ee4 100644 --- a/config/pkg/ext/ext-inotify.yml +++ b/config/pkg/ext/ext-inotify.yml @@ -7,3 +7,6 @@ ext-inotify: metadata: license-files: [LICENSE] license: PHP-3.01 + php-extension: + os: + - Linux diff --git a/config/pkg/ext/ext-lz4.yml b/config/pkg/ext/ext-lz4.yml index 8a3bb4dba..8e16d54e4 100644 --- a/config/pkg/ext/ext-lz4.yml +++ b/config/pkg/ext/ext-lz4.yml @@ -2,8 +2,9 @@ ext-lz4: type: php-extension artifact: source: - type: ghtagtar - repo: kjdev/php-ext-lz4 + type: git + url: 'https://github.com/kjdev/php-ext-lz4.git' + rev: master extract: php-src/ext/lz4 metadata: license-files: [LICENSE] diff --git a/config/pkg/ext/ext-mongodb.yml b/config/pkg/ext/ext-mongodb.yml index 7cbdbb140..97f9f0a0d 100644 --- a/config/pkg/ext/ext-mongodb.yml +++ b/config/pkg/ext/ext-mongodb.yml @@ -9,7 +9,9 @@ ext-mongodb: metadata: license-files: [LICENSE] license: PHP-3.01 - suggests: + depends@windows: + - ext-openssl + suggests@unix: - icu - openssl - zstd @@ -18,4 +20,5 @@ ext-mongodb: - CoreFoundation - Security php-extension: - arg-type: custom + arg-type@unix: custom + arg-type@windows: '--enable-mongodb --with-mongodb-client-side-encryption' diff --git a/config/pkg/ext/ext-parallel.yml b/config/pkg/ext/ext-parallel.yml index a3e91efe5..94103f578 100644 --- a/config/pkg/ext/ext-parallel.yml +++ b/config/pkg/ext/ext-parallel.yml @@ -7,3 +7,7 @@ ext-parallel: metadata: license-files: [LICENSE] license: PHP-3.01 + depends@windows: + - pthreads4w + php-extension: + arg-type@windows: with diff --git a/config/pkg/ext/ext-protobuf.yml b/config/pkg/ext/ext-protobuf.yml index 020059d39..f9d6b2080 100644 --- a/config/pkg/ext/ext-protobuf.yml +++ b/config/pkg/ext/ext-protobuf.yml @@ -7,3 +7,7 @@ ext-protobuf: metadata: license-files: [LICENSE] license: BSD-3-Clause + php-extension: + os: + - Linux + - Darwin diff --git a/config/pkg/ext/ext-rdkafka.yml b/config/pkg/ext/ext-rdkafka.yml index 1f26e49cb..1c7b55e3a 100644 --- a/config/pkg/ext/ext-rdkafka.yml +++ b/config/pkg/ext/ext-rdkafka.yml @@ -12,4 +12,7 @@ ext-rdkafka: - librdkafka lang: cpp php-extension: + os: + - Linux + - Darwin arg-type: custom diff --git a/config/pkg/ext/ext-snappy.yml b/config/pkg/ext/ext-snappy.yml index 7ddec2618..394527779 100644 --- a/config/pkg/ext/ext-snappy.yml +++ b/config/pkg/ext/ext-snappy.yml @@ -16,3 +16,4 @@ ext-snappy: lang: cpp php-extension: arg-type@unix: '--enable-snappy --with-snappy-includedir=@build_root_path@' + arg-type@windows: '--enable-snappy' diff --git a/config/pkg/ext/ext-spx.yml b/config/pkg/ext/ext-spx.yml index a379cdd4d..edf41f514 100644 --- a/config/pkg/ext/ext-spx.yml +++ b/config/pkg/ext/ext-spx.yml @@ -11,4 +11,7 @@ ext-spx: depends: - ext-zlib php-extension: + os: + - Linux + - Darwin arg-type: '--enable-SPX@shared_suffix@' diff --git a/config/pkg/ext/ext-swoole.yml b/config/pkg/ext/ext-swoole.yml index b6499e85e..31bbb1dc0 100644 --- a/config/pkg/ext/ext-swoole.yml +++ b/config/pkg/ext/ext-swoole.yml @@ -34,6 +34,9 @@ ext-swoole: - ext-swoole-hook-odbc lang: cpp php-extension: + os: + - Linux + - Darwin arg-type: custom ext-swoole-hook-mysql: type: php-extension @@ -44,6 +47,9 @@ ext-swoole-hook-mysql: suggests: - ext-mysqli php-extension: + os: + - Linux + - Darwin arg-type: none display-name: swoole ext-swoole-hook-odbc: @@ -52,6 +58,9 @@ ext-swoole-hook-odbc: - ext-pdo - unixodbc php-extension: + os: + - Linux + - Darwin arg-type: none display-name: swoole ext-swoole-hook-pgsql: @@ -60,6 +69,9 @@ ext-swoole-hook-pgsql: - ext-pgsql - ext-pdo php-extension: + os: + - Linux + - Darwin arg-type: none display-name: swoole ext-swoole-hook-sqlite: @@ -68,5 +80,8 @@ ext-swoole-hook-sqlite: - ext-sqlite3 - ext-pdo php-extension: + os: + - Linux + - Darwin arg-type: none display-name: swoole diff --git a/config/pkg/ext/ext-trader.yml b/config/pkg/ext/ext-trader.yml index 8e16afbbe..03dcadc60 100644 --- a/config/pkg/ext/ext-trader.yml +++ b/config/pkg/ext/ext-trader.yml @@ -8,7 +8,4 @@ ext-trader: license-files: [LICENSE] license: BSD-2-Clause php-extension: - support: - BSD: wip - Windows: wip arg-type: enable diff --git a/config/pkg/ext/ext-uuid.yml b/config/pkg/ext/ext-uuid.yml index 68080531d..3d71aa8b4 100644 --- a/config/pkg/ext/ext-uuid.yml +++ b/config/pkg/ext/ext-uuid.yml @@ -10,7 +10,7 @@ ext-uuid: depends: - libuuid php-extension: - support: - Windows: wip - BSD: wip + os: + - Linux + - Darwin arg-type: with-path diff --git a/config/pkg/ext/ext-uv.yml b/config/pkg/ext/ext-uv.yml index f1a3031bf..59d4a8c90 100644 --- a/config/pkg/ext/ext-uv.yml +++ b/config/pkg/ext/ext-uv.yml @@ -12,7 +12,4 @@ ext-uv: - libuv - ext-sockets php-extension: - support: - Windows: wip - BSD: wip arg-type: with-path diff --git a/config/pkg/ext/ext-xdebug.yml b/config/pkg/ext/ext-xdebug.yml index 0374e573b..20c6b4600 100644 --- a/config/pkg/ext/ext-xdebug.yml +++ b/config/pkg/ext/ext-xdebug.yml @@ -8,6 +8,9 @@ ext-xdebug: license-files: [LICENSE] license: Xdebug-1.03 php-extension: + os: + - Linux + - Darwin zend-extension: true build-static: false build-shared: true diff --git a/config/pkg/ext/ext-xhprof.yml b/config/pkg/ext/ext-xhprof.yml index b075f65bd..a554d8375 100644 --- a/config/pkg/ext/ext-xhprof.yml +++ b/config/pkg/ext/ext-xhprof.yml @@ -11,8 +11,8 @@ ext-xhprof: depends: - ext-ctype php-extension: - support: - Windows: wip - BSD: wip + os: + - Linux + - Darwin arg-type: enable build-with-php: true diff --git a/config/pkg/ext/ext-xlswriter.yml b/config/pkg/ext/ext-xlswriter.yml index 24d2fa3ce..01b99ed90 100644 --- a/config/pkg/ext/ext-xlswriter.yml +++ b/config/pkg/ext/ext-xlswriter.yml @@ -13,6 +13,5 @@ ext-xlswriter: suggests: - openssl php-extension: - support: - BSD: wip arg-type: custom + arg-type@windows: '--with-xlswriter' diff --git a/config/pkg/ext/ext-xz.yml b/config/pkg/ext/ext-xz.yml index 0d625ad29..1551eaec4 100644 --- a/config/pkg/ext/ext-xz.yml +++ b/config/pkg/ext/ext-xz.yml @@ -13,3 +13,4 @@ ext-xz: - xz php-extension: arg-type: with-path + arg-type@windows: enable diff --git a/config/pkg/ext/ext-zip.yml b/config/pkg/ext/ext-zip.yml index a5a9e4b54..9a4b0282b 100644 --- a/config/pkg/ext/ext-zip.yml +++ b/config/pkg/ext/ext-zip.yml @@ -8,10 +8,8 @@ ext-zip: metadata: license-files: [LICENSE] license: PHP-3.01 - depends@unix: + depends: - libzip php-extension: - support: - BSD: wip arg-type: custom arg-type@windows: enable diff --git a/config/pkg/ext/ext-zstd.yml b/config/pkg/ext/ext-zstd.yml index 1f004f131..9b01422be 100644 --- a/config/pkg/ext/ext-zstd.yml +++ b/config/pkg/ext/ext-zstd.yml @@ -11,5 +11,8 @@ ext-zstd: license: MIT depends: - zstd + suggests: + - ext-apcu php-extension: arg-type: '--enable-zstd --with-libzstd=@build_root_path@' + arg-type@windows: '--enable-zstd' diff --git a/config/pkg/lib/gettext-win.yml b/config/pkg/lib/gettext-win.yml new file mode 100644 index 000000000..142383077 --- /dev/null +++ b/config/pkg/lib/gettext-win.yml @@ -0,0 +1,9 @@ +gettext-win: + type: library + artifact: + source: + type: git + url: 'https://github.com/winlibs/gettext.git' + rev: master + static-libs@windows: + - libintl_a.lib diff --git a/config/pkg/lib/glfw.yml b/config/pkg/lib/glfw.yml index 13fba596e..f7d015492 100644 --- a/config/pkg/lib/glfw.yml +++ b/config/pkg/lib/glfw.yml @@ -1,6 +1,11 @@ glfw: type: library artifact: glfw + headers: + - GLFW/glfw3.h + - GLFW/glfw3native.h lang: cpp static-libs@unix: - libglfw3.a + static-libs@windows: + - glfw3.lib diff --git a/config/pkg/lib/krb5.yml b/config/pkg/lib/krb5.yml index 07fa3327f..e3234ade5 100644 --- a/config/pkg/lib/krb5.yml +++ b/config/pkg/lib/krb5.yml @@ -2,9 +2,8 @@ krb5: type: library artifact: source: - type: ghtagtar - repo: krb5/krb5 - match: krb5.+-final + type: url + url: 'https://web.mit.edu/kerberos/dist/krb5/1.22/krb5-1.22.2.tar.gz' metadata: license-files: [NOTICE] license: BSD-3-Clause diff --git a/config/pkg/lib/liblz4.yml b/config/pkg/lib/liblz4.yml index 298b3abf3..bb7a74aef 100644 --- a/config/pkg/lib/liblz4.yml +++ b/config/pkg/lib/liblz4.yml @@ -11,3 +11,5 @@ liblz4: license: BSD-2-Clause static-libs@unix: - liblz4.a + static-libs@windows: + - lz4.lib diff --git a/config/pkg/lib/libmaxminddb.yml b/config/pkg/lib/libmaxminddb.yml index a0c3a307f..1f67800e2 100644 --- a/config/pkg/lib/libmaxminddb.yml +++ b/config/pkg/lib/libmaxminddb.yml @@ -14,3 +14,5 @@ libmaxminddb: - maxminddb_config.h static-libs@unix: - libmaxminddb.a + static-libs@windows: + - libmaxminddb.lib diff --git a/config/pkg/lib/libuv.yml b/config/pkg/lib/libuv.yml index 3c41906dc..1548ebcd8 100644 --- a/config/pkg/lib/libuv.yml +++ b/config/pkg/lib/libuv.yml @@ -9,3 +9,5 @@ libuv: license: MIT static-libs@unix: - libuv.a + static-libs@windows: + - libuv.lib diff --git a/config/pkg/lib/libxslt.yml b/config/pkg/lib/libxslt.yml index 07955333a..a9898648a 100644 --- a/config/pkg/lib/libxslt.yml +++ b/config/pkg/lib/libxslt.yml @@ -13,3 +13,6 @@ libxslt: static-libs@unix: - libxslt.a - libexslt.a + static-libs@windows: + - libxslt_a.lib + - libexslt_a.lib diff --git a/config/pkg/lib/mpir.yml b/config/pkg/lib/mpir.yml new file mode 100644 index 000000000..6fc8012f0 --- /dev/null +++ b/config/pkg/lib/mpir.yml @@ -0,0 +1,9 @@ +mpir: + type: library + artifact: + source: + type: git + url: 'https://github.com/winlibs/mpir.git' + rev: master + static-libs@windows: + - mpir_a.lib diff --git a/config/pkg/lib/snappy.yml b/config/pkg/lib/snappy.yml index a369fa339..9875e784f 100644 --- a/config/pkg/lib/snappy.yml +++ b/config/pkg/lib/snappy.yml @@ -15,6 +15,13 @@ snappy: - snappy-c.h - snappy-sinksource.h - snappy-stubs-public.h + headers@windows: + - snappy.h + - snappy-c.h + - snappy-sinksource.h + - snappy-stubs-public.h lang: cpp static-libs@unix: - libsnappy.a + static-libs@windows: + - snappy.lib diff --git a/config/pkg/lib/tidy.yml b/config/pkg/lib/tidy.yml index 41487c1d3..a58a60d66 100644 --- a/config/pkg/lib/tidy.yml +++ b/config/pkg/lib/tidy.yml @@ -10,3 +10,5 @@ tidy: license: W3C static-libs@unix: - libtidy.a + static-libs@windows: + - tidy_a.lib diff --git a/config/pkg/lib/watcher.yml b/config/pkg/lib/watcher.yml index 6cf376f69..82911ec41 100644 --- a/config/pkg/lib/watcher.yml +++ b/config/pkg/lib/watcher.yml @@ -8,6 +8,8 @@ watcher: metadata: license-files: [license] license: MIT + frameworks: + - CoreServices headers: - wtr/watcher-c.h lang: cpp diff --git a/config/pkg/lib/wineditline.yml b/config/pkg/lib/wineditline.yml new file mode 100644 index 000000000..92f80ba2a --- /dev/null +++ b/config/pkg/lib/wineditline.yml @@ -0,0 +1,14 @@ +wineditline: + type: library + artifact: + source: + type: git + url: 'https://github.com/winlibs/wineditline.git' + rev: master + metadata: + license-files: [COPYING] + license: GPL-2.0-or-later + headers: + - editline + static-libs@windows: + - edit_a.lib diff --git a/config/pkg/lib/zstd.yml b/config/pkg/lib/zstd.yml index 875380d1f..c1d15cf6e 100644 --- a/config/pkg/lib/zstd.yml +++ b/config/pkg/lib/zstd.yml @@ -18,4 +18,4 @@ zstd: static-libs@unix: - libzstd.a static-libs@windows: - - zstd_static.lib + - zstd.lib diff --git a/config/source.json b/config/source.json index 040197cb1..18bca217b 100644 --- a/config/source.json +++ b/config/source.json @@ -462,10 +462,8 @@ } }, "krb5": { - "type": "ghtagtar", - "repo": "krb5/krb5", - "match": "krb5.+-final", - "prefer-stable": true, + "type": "url", + "url": "https://web.mit.edu/kerberos/dist/krb5/1.22/krb5-1.22.2.tar.gz", "license": { "type": "file", "path": "NOTICE" @@ -641,6 +639,7 @@ "libjpeg": { "type": "ghtar", "repo": "libjpeg-turbo/libjpeg-turbo", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE.md" @@ -1054,7 +1053,7 @@ }, "protobuf": { "type": "url", - "url": "https://pecl.php.net/get/protobuf", + "url": "https://pecl.php.net/get/protobuf-5.34.1.tgz", "path": "php-src/ext/protobuf", "filename": "protobuf.tgz", "license": { diff --git a/docs/en/guide/action-build.md b/docs/en/guide/action-build.md index 7d4bba327..b22549569 100644 --- a/docs/en/guide/action-build.md +++ b/docs/en/guide/action-build.md @@ -16,8 +16,10 @@ while also defining the extensions to compile. 1. Fork project. 2. Go to the Actions of the project and select `CI`. -3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`) -4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`. +3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of static extensions. (comma separated, e.g. `bcmath,curl,mbstring`) +4. If you need shared extensions (for example `xdebug`), set `shared-extensions` (comma separated, e.g. `xdebug`). +5. If you need FrankenPHP, enable `build-frankenphp` and also enable `enable-zts`. +6. After waiting for about a period of time, enter the corresponding task and get `Artifacts`. If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting. diff --git a/docs/zh/guide/action-build.md b/docs/zh/guide/action-build.md index 11f382d5e..7adcc456b 100644 --- a/docs/zh/guide/action-build.md +++ b/docs/zh/guide/action-build.md @@ -14,7 +14,9 @@ Action 构建指的是直接使用 GitHub Action 进行编译。 1. Fork 本项目。 2. 进入项目的 Actions,选择 CI 开头的 Workflow(根据你需要的操作系统选择)。 3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`) -4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`。 +4. 如果需要共享扩展(例如 `xdebug`),请设置 `shared-extensions`(使用英文逗号分割,例如 `xdebug`)。 +5. 如果需要 FrankenPHP,请启用 `build-frankenphp`,同时也需要启用 `enable-zts`。 +6. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`。 如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 diff --git a/src/Package/Artifact/imagick.php b/src/Package/Artifact/imagick.php new file mode 100644 index 000000000..568729e18 --- /dev/null +++ b/src/Package/Artifact/imagick.php @@ -0,0 +1,31 @@ += 80100 ? file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32') : file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32'); + if ($ver_id >= 80500) { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_85.w32'); + } elseif ($ver_id >= 80100) { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32'); + } else { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32'); + } file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32')); file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin); } diff --git a/src/Package/Extension/curl.php b/src/Package/Extension/curl.php new file mode 100644 index 000000000..eef43a566 --- /dev/null +++ b/src/Package/Extension/curl.php @@ -0,0 +1,26 @@ +getSourceDir()}\\config.w32", + 'EXTENSION(\'ev\'', + " EXTENSION('ev', php_ev_sources, PHP_EV_SHARED, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');" + ); + return true; + } +} diff --git a/src/Package/Extension/glfw.php b/src/Package/Extension/glfw.php index 2a9c7ee51..8c73cb483 100644 --- a/src/Package/Extension/glfw.php +++ b/src/Package/Extension/glfw.php @@ -16,6 +16,7 @@ class glfw extends PhpExtensionPackage { #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-glfw')] + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-glfw')] #[PatchDescription('Patch glfw extension before buildconf')] public function patchBeforeBuildconf(): void { diff --git a/src/Package/Extension/grpc.php b/src/Package/Extension/grpc.php index c3b08f161..d1ce1511e 100644 --- a/src/Package/Extension/grpc.php +++ b/src/Package/Extension/grpc.php @@ -29,6 +29,15 @@ public function patchBeforeBuildconf(): void 'zend_ce_exception,', ); + // Fix include path conflict with pdo_sqlsrv: grpc's PHP ext dir is added to the global include path via + $grpc_php_dir = "{$this->getSourceDir()}/src/php/ext/grpc"; + if (file_exists("{$grpc_php_dir}/version.h")) { + copy("{$grpc_php_dir}/version.h", "{$grpc_php_dir}/php_grpc_version.h"); + unlink("{$grpc_php_dir}/version.h"); + FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.h", '#include "version.h"', '#include "php_grpc_version.h"'); + FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.c", '#include "version.h"', '#include "php_grpc_version.h"'); + } + // custom config.m4 content for grpc extension, to prevent building libgrpc.a again $config_m4 = <<<'M4' PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])]) diff --git a/src/Package/Extension/intl.php b/src/Package/Extension/intl.php new file mode 100644 index 000000000..f5e17c1fe --- /dev/null +++ b/src/Package/Extension/intl.php @@ -0,0 +1,29 @@ +getTargetPackage('php')->getSourceDir(); + FileSystem::replaceFileStr( + "{$php_src}/ext/intl/config.w32", + 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,', + 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", PHP_INTL_SHARED,' + ); + } +} diff --git a/src/Package/Extension/maxminddb.php b/src/Package/Extension/maxminddb.php index bda8d34c7..9d04fcb94 100644 --- a/src/Package/Extension/maxminddb.php +++ b/src/Package/Extension/maxminddb.php @@ -15,6 +15,7 @@ class maxminddb extends PhpExtensionPackage { #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-maxminddb')] + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-maxminddb')] #[PatchDescription('Patch maxminddb extension for buildconf to support new source structure')] public function patchBeforeBuildconf(): void { diff --git a/src/Package/Extension/mbregex.php b/src/Package/Extension/mbregex.php index f01c7c787..20b025467 100644 --- a/src/Package/Extension/mbregex.php +++ b/src/Package/Extension/mbregex.php @@ -12,6 +12,7 @@ class mbregex { #[CustomPhpConfigureArg('Linux')] #[CustomPhpConfigureArg('Darwin')] + #[CustomPhpConfigureArg('Windows')] public function getUnixConfigureArg(): string { return ''; diff --git a/src/Package/Extension/mbstring.php b/src/Package/Extension/mbstring.php index 5c3c31d13..b6d818f16 100644 --- a/src/Package/Extension/mbstring.php +++ b/src/Package/Extension/mbstring.php @@ -19,4 +19,10 @@ public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): $arg .= $installer->isPackageResolved('ext-mbregex') === false ? ' --disable-mbregex' : ' --enable-mbregex'; return $arg; } + + #[CustomPhpConfigureArg('Windows')] + public function getWinConfigureArg(PackageInstaller $installer): string + { + return '--enable-mbstring ' . ($installer->isPackageResolved('ext-mbregex') ? '--enable-mbregex' : ' --disable-mbregex'); + } } diff --git a/src/Package/Extension/mongodb.php b/src/Package/Extension/mongodb.php index 3434491d6..944ce86af 100644 --- a/src/Package/Extension/mongodb.php +++ b/src/Package/Extension/mongodb.php @@ -4,14 +4,27 @@ namespace Package\Extension; +use Package\Target\php; +use StaticPHP\Attribute\Package\BeforeStage; use StaticPHP\Attribute\Package\CustomPhpConfigureArg; use StaticPHP\Attribute\Package\Extension; use StaticPHP\Package\PackageInstaller; use StaticPHP\Package\PhpExtensionPackage; +use StaticPHP\Util\FileSystem; #[Extension('mongodb')] class mongodb extends PhpExtensionPackage { + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-mongodb')] + public function patchBeforeBuild(): void + { + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/config.w32", + 'ADD_FLAG("CFLAGS_MONGODB", "/D KMS_MESSAGE_LITTLE_ENDIAN=1 /D MONGOCRYPT_LITTLE_ENDIAN=1 /D MLIB_USER=1");', + 'ADD_FLAG("CFLAGS_MONGODB", "/D KMS_MESSAGE_LITTLE_ENDIAN=1 /D MONGOCRYPT_LITTLE_ENDIAN=1 /D MLIB_USER=1");' . "\n ADD_FLAG(\"CFLAGS_MONGODB\", \"/utf-8\");", + ); + } + #[CustomPhpConfigureArg('Darwin')] #[CustomPhpConfigureArg('Linux')] public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string diff --git a/src/Package/Extension/opcache.php b/src/Package/Extension/opcache.php index 93cb0a9ff..07758de26 100644 --- a/src/Package/Extension/opcache.php +++ b/src/Package/Extension/opcache.php @@ -29,6 +29,7 @@ public function validate(): void } #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-opcache')] + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-opcache')] #[PatchDescription('Fix static opcache build for PHP 8.2.0 to 8.4.x')] public function patchBeforeBuildconf(PackageInstaller $installer): bool { diff --git a/src/Package/Extension/pdo_sqlsrv.php b/src/Package/Extension/pdo_sqlsrv.php new file mode 100644 index 000000000..00134db14 --- /dev/null +++ b/src/Package/Extension/pdo_sqlsrv.php @@ -0,0 +1,39 @@ +getTargetPackage('php')->getSourceDir() . '\Makefile'; + $makeContent = file_get_contents($makefile); + $makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/sdl\b/m', '$1', $makeContent); + $makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/W4\b/m', '$1', $makeContent); + $makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/WX\b/m', '$1', $makeContent); + file_put_contents($makefile, $makeContent); + return true; + } +} diff --git a/src/Package/Extension/swow.php b/src/Package/Extension/swow.php index 333a3ed7b..884f0217a 100644 --- a/src/Package/Extension/swow.php +++ b/src/Package/Extension/swow.php @@ -17,6 +17,7 @@ class swow extends PhpExtensionPackage { #[CustomPhpConfigureArg('Darwin')] #[CustomPhpConfigureArg('Linux')] + #[CustomPhpConfigureArg('Windows')] public function configureArg(PackageInstaller $installer): string { $arg = '--enable-swow'; diff --git a/src/Package/Extension/uv.php b/src/Package/Extension/uv.php index 869f4ad99..68a796ada 100644 --- a/src/Package/Extension/uv.php +++ b/src/Package/Extension/uv.php @@ -24,6 +24,21 @@ public function validate(): void } } + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-uv')] + public function patchBeforeBuild(): void + { + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/php_uv.c", + '#if !defined(PHP_WIN32) || defined(HAVE_SOCKET)', + '#if !defined(PHP_WIN32) || (defined(HAVE_SOCKETS) && !defined(COMPILE_DL_SOCKETS))', + ); + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/config.w32", + 'CHECK_LIB("Ws2_32.lib","uv", PHP_UV);', + "CHECK_LIB(\"Ws2_32.lib\",\"uv\" , PHP_UV);\n\tCHECK_LIB(\"dbghelp.lib\",\"uv\", PHP_UV);", + ); + } + #[BeforeStage('ext-uv', [PhpExtensionPackage::class, 'makeForUnix'])] public function patchBeforeSharedMake(PhpExtensionPackage $pkg): bool { diff --git a/src/Package/Extension/xlswriter.php b/src/Package/Extension/xlswriter.php index b2f25716e..f4d155302 100644 --- a/src/Package/Extension/xlswriter.php +++ b/src/Package/Extension/xlswriter.php @@ -4,10 +4,15 @@ namespace Package\Extension; +use Package\Target\php; +use StaticPHP\Attribute\Package\BeforeStage; use StaticPHP\Attribute\Package\CustomPhpConfigureArg; use StaticPHP\Attribute\Package\Extension; +use StaticPHP\Attribute\PatchDescription; use StaticPHP\Package\PackageInstaller; use StaticPHP\Package\PhpExtensionPackage; +use StaticPHP\Util\GlobalEnvManager; +use StaticPHP\Util\SourcePatcher; #[Extension('xlswriter')] class xlswriter extends PhpExtensionPackage @@ -22,4 +27,31 @@ public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): } return $arg; } + + #[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-xlswriter')] + #[PatchDescription('Fix Unix build: add -std=gnu17 to CFLAGS to fix build errors on older GCC versions')] + public function patchBeforeUnixMake(): void + { + GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -std=gnu17'); + } + + #[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-xlswriter')] + #[PatchDescription('Fix Windows build: apply win32 patch and add UTF-8 BOM to theme.c')] + public function patchBeforeMakeForWindows(): void + { + // fix windows build with openssl extension duplicate symbol bug + SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->getSourceDir()); + $content = file_get_contents($this->getSourceDir() . '/library/libxlsxwriter/src/theme.c'); + $bom = pack('CCC', 0xEF, 0xBB, 0xBF); + if (!str_starts_with($content, $bom)) { + file_put_contents($this->getSourceDir() . '/library/libxlsxwriter/src/theme.c', $bom . $content); + } + } + + public function getSharedExtensionEnv(): array + { + $parent = parent::getSharedExtensionEnv(); + $parent['CFLAGS'] .= ' -std=gnu17'; + return $parent; + } } diff --git a/src/Package/Extension/xz.php b/src/Package/Extension/xz.php new file mode 100644 index 000000000..a1f0d88d3 --- /dev/null +++ b/src/Package/Extension/xz.php @@ -0,0 +1,21 @@ +getSourceDir() . '/config.w32', 'true', 'PHP_XZ_SHARED'); + } +} diff --git a/src/Package/Extension/yaml.php b/src/Package/Extension/yaml.php new file mode 100644 index 000000000..035a8741a --- /dev/null +++ b/src/Package/Extension/yaml.php @@ -0,0 +1,28 @@ + '\MSVC17', + '16' => '\MSVC16', + default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), + }; + ApplicationContext::set('gettext_win_vs_ver_dir', $vs_ver_dir); + } + + #[PatchBeforeBuild] + public function patchBeforeBuild(LibraryPackage $lib): void + { + $vs_ver_dir = ApplicationContext::get('gettext_win_vs_ver_dir'); + $vcxproj = "{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static\\libintl_static.vcxproj"; + // libintl_static uses /MD (MultiThreadedDLL) in Release configs, which causes unresolved __imp_* symbols + // when linking into PHP statically. Patch to /MT (MultiThreaded) for static CRT compatibility. + FileSystem::replaceFileStr($vcxproj, 'MultiThreadedDLL', 'MultiThreaded'); + } + + #[BuildFor('Windows')] + public function build(LibraryPackage $lib): void + { + $vs_ver_dir = ApplicationContext::get('gettext_win_vs_ver_dir'); + cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static") + ->exec('msbuild libintl_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0'); + FileSystem::createDir($lib->getLibDir()); + FileSystem::createDir($lib->getIncludeDir()); + // libintl_a.lib is the static library output; copy as libintl.lib for linker compatibility + FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static\\x64\\Release\\libintl_a.lib", "{$lib->getLibDir()}\\libintl_a.lib"); + // libgnuintl.h is the public API header, installed as libintl.h + FileSystem::copy("{$lib->getSourceDir()}\\source\\gettext-runtime\\intl\\libgnuintl.h", "{$lib->getIncludeDir()}\\libintl.h"); + } +} diff --git a/src/Package/Library/glfw.php b/src/Package/Library/glfw.php index 9348489cd..f4a261493 100644 --- a/src/Package/Library/glfw.php +++ b/src/Package/Library/glfw.php @@ -11,6 +11,7 @@ use StaticPHP\Exception\ValidationException; use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; use StaticPHP\Runtime\SystemTarget; use StaticPHP\Toolchain\Interface\ToolchainInterface; @@ -97,4 +98,19 @@ public function buildForMac(LibraryPackage $lib): void // patch pkgconf $lib->patchPkgconfPrefix(['glfw3.pc']); } + + #[BuildFor('Windows')] + public function buildForWin(LibraryPackage $lib): void + { + WindowsCMakeExecutor::create($lib) + ->setWorkingDir("{$lib->getSourceDir()}/vendor/glfw") + ->setBuildDir("{$lib->getSourceDir()}/vendor/glfw") + ->setReset(false) + ->addConfigureArgs( + '-DGLFW_BUILD_EXAMPLES=OFF', + '-DGLFW_BUILD_TESTS=OFF', + '-DGLFW_BUILD_DOCS=OFF', + ) + ->build(); + } } diff --git a/src/Package/Library/krb5.php b/src/Package/Library/krb5.php index 303c3b63e..ad6ca1370 100644 --- a/src/Package/Library/krb5.php +++ b/src/Package/Library/krb5.php @@ -19,7 +19,9 @@ class krb5 #[BuildFor('Darwin')] public function build(LibraryPackage $lib, PackageInstaller $installer): void { - shell()->cd($lib->getSourceRoot())->exec('autoreconf -if'); + if (!file_exists($lib->getSourceRoot() . '/configure')) { + shell()->cd($lib->getSourceRoot())->exec('autoreconf -if'); + } $resolved = array_keys($installer->getResolvedPackages()); $spc = new SPCConfigUtil(['no_php' => true, 'libs_only_deps' => true]); diff --git a/src/Package/Library/libjpeg.php b/src/Package/Library/libjpeg.php index 6e06bfb70..06512aaca 100644 --- a/src/Package/Library/libjpeg.php +++ b/src/Package/Library/libjpeg.php @@ -22,6 +22,10 @@ public function buildUnix(LibraryPackage $lib): void ->addConfigureArgs( '-DENABLE_STATIC=ON', '-DENABLE_SHARED=OFF', + '-DWITH_SYSTEM_ZLIB=ON', + '-DWITH_TOOLS=OFF', + '-DWITH_TESTS=OFF', + '-DWITH_SIMD=OFF', ) ->build(); // patch pkgconfig @@ -37,6 +41,7 @@ public function buildWin(LibraryPackage $lib): void '-DENABLE_STATIC=ON', '-DBUILD_TESTING=OFF', '-DWITH_JAVA=OFF', + '-DWITH_SIMD=OFF', '-DWITH_CRT_DLL=OFF', ) ->optionalPackage('zlib', '-DENABLE_ZLIB_COMPRESSION=ON', '-DENABLE_ZLIB_COMPRESSION=OFF') diff --git a/src/Package/Library/liblz4.php b/src/Package/Library/liblz4.php index fb52a4fba..5dfbc9956 100644 --- a/src/Package/Library/liblz4.php +++ b/src/Package/Library/liblz4.php @@ -10,6 +10,7 @@ use StaticPHP\Attribute\PatchDescription; use StaticPHP\Package\LibraryPackage; use StaticPHP\Package\PackageBuilder; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; use StaticPHP\Util\FileSystem; #[Library('liblz4')] @@ -22,6 +23,16 @@ public function patchBeforeBuild(LibraryPackage $lib): void FileSystem::replaceFileStr($lib->getSourceDir() . '/programs/Makefile', 'install: lz4', "install: lz4\n\ninstallewfwef: lz4"); } + #[BuildFor('Windows')] + public function buildWin(LibraryPackage $lib): void + { + WindowsCMakeExecutor::create($lib) + ->setWorkingDir("{$lib->getSourceDir()}/build/cmake") + ->setBuildDir("{$lib->getSourceDir()}/_win_build") + ->addConfigureArgs('-DLZ4_BUILD_CLI=OFF') + ->build(); + } + #[BuildFor('Darwin')] #[BuildFor('Linux')] public function buildUnix(LibraryPackage $lib, PackageBuilder $builder): void diff --git a/src/Package/Library/libmaxminddb.php b/src/Package/Library/libmaxminddb.php index a045e4f12..54c045189 100644 --- a/src/Package/Library/libmaxminddb.php +++ b/src/Package/Library/libmaxminddb.php @@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\Library; use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; +use StaticPHP\Util\FileSystem; #[Library('libmaxminddb')] class libmaxminddb @@ -23,4 +25,18 @@ public function buildUnix(LibraryPackage $lib): void ) ->build(); } + + #[BuildFor('Windows')] + public function buildWindows(LibraryPackage $lib): void + { + WindowsCMakeExecutor::create($lib) + ->addConfigureArgs( + '-DBUILD_TESTING=OFF', + '-DMAXMINDDB_BUILD_BINARIES=OFF', + ) + ->build(); + if (!file_exists($lib->getLibDir() . '\libmaxminddb.lib')) { + FileSystem::copy("{$lib->getLibDir()}\\maxminddb.lib", "{$lib->getLibDir()}\\libmaxminddb.lib"); + } + } } diff --git a/src/Package/Library/libuv.php b/src/Package/Library/libuv.php index ed8c58381..c27b499c9 100644 --- a/src/Package/Library/libuv.php +++ b/src/Package/Library/libuv.php @@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\Library; use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; #[Library('libuv')] class libuv @@ -22,4 +23,12 @@ public function buildUnix(LibraryPackage $lib): void // patch pkgconfig $lib->patchPkgconfPrefix(['libuv-static.pc']); } + + #[BuildFor('Windows')] + public function buildWindows(LibraryPackage $lib): void + { + WindowsCMakeExecutor::create($lib) + ->addConfigureArgs('-DLIBUV_BUILD_SHARED=OFF') + ->build(); + } } diff --git a/src/Package/Library/libxslt.php b/src/Package/Library/libxslt.php index 11ba2bf84..7513d1468 100644 --- a/src/Package/Library/libxslt.php +++ b/src/Package/Library/libxslt.php @@ -9,7 +9,9 @@ use StaticPHP\Package\LibraryPackage; use StaticPHP\Package\PackageInstaller; use StaticPHP\Runtime\Executor\UnixAutoconfExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; use StaticPHP\Runtime\SystemTarget; +use StaticPHP\Util\FileSystem; use StaticPHP\Util\SPCConfigUtil; #[Library('libxslt')] @@ -49,4 +51,20 @@ public function buildUnix(LibraryPackage $lib, PackageInstaller $installer): voi ->exec("{$AR} -t libxslt.a | grep '\\.a$' | xargs -n1 {$AR} d libxslt.a") ->exec("{$AR} -t libexslt.a | grep '\\.a$' | xargs -n1 {$AR} d libexslt.a"); } + + #[BuildFor('Windows')] + public function buildWin(LibraryPackage $lib, PackageInstaller $installer): void + { + WindowsCMakeExecutor::create($lib) + ->addConfigureArgs( + '-DBUILD_SHARED_LIBS=OFF', + '-DLIBXSLT_WITH_PROFILER=OFF', + '-DLIBXSLT_WITH_PROGRAMS=OFF', + '-DLIBXSLT_WITH_PYTHON=OFF', + '-DLIBXSLT_WITH_TESTS=OFF', + ) + ->build(); + FileSystem::copy($lib->getLibDir() . '\libxslts.lib', $lib->getLibDir() . '\libxslt_a.lib'); + FileSystem::copy($lib->getLibDir() . '\libexslts.lib', $lib->getLibDir() . '\libexslt_a.lib'); + } } diff --git a/src/Package/Library/mpir.php b/src/Package/Library/mpir.php new file mode 100644 index 000000000..951d218ad --- /dev/null +++ b/src/Package/Library/mpir.php @@ -0,0 +1,44 @@ + '\build.vc17', + '16' => '\build.vc16', + default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), + }; + ApplicationContext::set('mpir_vs_ver_dir', $vs_ver_dir); + } + + #[BuildFor('Windows')] + public function build(LibraryPackage $lib): void + { + $vs_ver_dir = ApplicationContext::get('mpir_vs_ver_dir'); + cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc") + ->exec('msbuild lib_mpir_gc.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64'); + FileSystem::createDir($lib->getLibDir()); + FileSystem::createDir($lib->getIncludeDir()); + FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc\\x64\\Release\\mpir_a.lib", "{$lib->getLibDir()}\\mpir_a.lib"); + // mpir.h and gmp.h are generated by the prebuild step into the source root + FileSystem::copy("{$lib->getSourceDir()}\\mpir.h", "{$lib->getIncludeDir()}\\mpir.h"); + FileSystem::copy("{$lib->getSourceDir()}\\gmp.h", "{$lib->getIncludeDir()}\\gmp.h"); + } +} diff --git a/src/Package/Library/nghttp2.php b/src/Package/Library/nghttp2.php index f09659470..7ebc85694 100644 --- a/src/Package/Library/nghttp2.php +++ b/src/Package/Library/nghttp2.php @@ -9,6 +9,7 @@ use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixAutoconfExecutor; use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; +use StaticPHP\Util\FileSystem; #[Library('nghttp2')] class nghttp2 @@ -26,6 +27,8 @@ public function buildWin(LibraryPackage $lib): void '-DBUILD_TESTING=OFF', ) ->build(); + + FileSystem::replaceFileStr($lib->getIncludeDir() . '\nghttp2\nghttp2.h', '#ifdef NGHTTP2_STATICLIB', '#if 1'); } #[BuildFor('Linux')] diff --git a/src/Package/Library/ngtcp2.php b/src/Package/Library/ngtcp2.php index c88b643bf..0a5ca8f5a 100644 --- a/src/Package/Library/ngtcp2.php +++ b/src/Package/Library/ngtcp2.php @@ -24,7 +24,7 @@ public function buildWin(LibraryPackage $lib): void '-DBUILD_SHARED_LIBS=OFF', '-DENABLE_STATIC_CRT=ON', '-DENABLE_LIB_ONLY=ON', - '-DENABLE_OPENSSL=ON', + '-DENABLE_OPENSSL=OFF', ) ->build(); } diff --git a/src/Package/Library/snappy.php b/src/Package/Library/snappy.php index d822c3cfd..ca5a230af 100644 --- a/src/Package/Library/snappy.php +++ b/src/Package/Library/snappy.php @@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\Library; use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; #[Library('snappy')] class snappy @@ -24,4 +25,15 @@ public function buildUnix(LibraryPackage $lib): void ) ->build('../..'); } + + #[BuildFor('Windows')] + public function buildWin(LibraryPackage $lib): void + { + WindowsCMakeExecutor::create($lib) + ->addConfigureArgs( + '-DSNAPPY_BUILD_TESTS=OFF', + '-DSNAPPY_BUILD_BENCHMARKS=OFF', + ) + ->build(); + } } diff --git a/src/Package/Library/tidy.php b/src/Package/Library/tidy.php index b59160262..5e16b2d18 100644 --- a/src/Package/Library/tidy.php +++ b/src/Package/Library/tidy.php @@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\Library; use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; +use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; +use StaticPHP\Util\FileSystem; #[Library('tidy')] class tidy @@ -28,4 +30,18 @@ public function buildUnix(LibraryPackage $lib): void $cmake->build(); $lib->patchPkgconfPrefix(['tidy.pc']); } + + #[BuildFor('Windows')] + public function buildWindows(LibraryPackage $lib): void + { + $cmake = WindowsCMakeExecutor::create($lib) + ->setBuildDir("{$lib->getSourceDir()}/build-dir") + ->addConfigureArgs( + '-DSUPPORT_CONSOLE_APP=OFF', + '-DBUILD_SHARED_LIB=OFF' + )->build(); + + // rename tidy_static.lib to tidy_a.lib + FileSystem::moveFileOrDir($lib->getLibDir() . '\tidy_static.lib', $lib->getLibDir() . '\tidy_a.lib'); + } } diff --git a/src/Package/Library/wineditline.php b/src/Package/Library/wineditline.php new file mode 100644 index 000000000..f8ea67675 --- /dev/null +++ b/src/Package/Library/wineditline.php @@ -0,0 +1,23 @@ +build(); + FileSystem::copy($lib->getSourceDir() . '\lib64\edit_a.lib', $lib->getLibDir() . '\edit_a.lib'); + FileSystem::copyDir($lib->getSourceDir() . '\include\editline', $lib->getIncludeDir() . '\editline'); + } +} diff --git a/src/Package/Library/zstd.php b/src/Package/Library/zstd.php index f12bf3e02..4b4a490f1 100644 --- a/src/Package/Library/zstd.php +++ b/src/Package/Library/zstd.php @@ -9,6 +9,7 @@ use StaticPHP\Package\LibraryPackage; use StaticPHP\Runtime\Executor\UnixCMakeExecutor; use StaticPHP\Runtime\Executor\WindowsCMakeExecutor; +use StaticPHP\Util\FileSystem; #[Library('zstd')] class zstd @@ -24,6 +25,7 @@ public function buildWin(LibraryPackage $package): void '-DZSTD_BUILD_SHARED=OFF', ) ->build(); + FileSystem::copy($package->getLibDir() . '\zstd_static.lib', $package->getLibDir() . '/zstd.lib'); } #[BuildFor('Linux')] diff --git a/src/Package/Target/php.php b/src/Package/Target/php.php index 38e2ad91b..29b6848a9 100644 --- a/src/Package/Target/php.php +++ b/src/Package/Target/php.php @@ -12,6 +12,7 @@ use StaticPHP\Attribute\Package\Info; use StaticPHP\Attribute\Package\InitPackage; use StaticPHP\Attribute\Package\ResolveBuild; +use StaticPHP\Attribute\Package\Stage; use StaticPHP\Attribute\Package\Target; use StaticPHP\Attribute\Package\Validate; use StaticPHP\Config\PackageConfig; @@ -29,6 +30,7 @@ use StaticPHP\Toolchain\ToolchainManager; use StaticPHP\Util\DependencyResolver; use StaticPHP\Util\FileSystem; +use StaticPHP\Util\InteractiveTerm; use StaticPHP\Util\SourcePatcher; use StaticPHP\Util\V2CompatLayer; use Symfony\Component\Console\Input\InputArgument; @@ -339,6 +341,35 @@ public function beforeBuild(PackageBuilder $builder, Package $package): void FileSystem::removeDir(BUILD_MODULES_PATH); } + #[Stage('postInstall')] + public function postInstall(TargetPackage $package, PackageInstaller $installer): void + { + if ($package->getName() === 'frankenphp') { + $package->runStage([$this, 'smokeTestFrankenphpForUnix']); + return; + } + if ($package->getName() !== 'php') { + return; + } + if (SystemTarget::isUnix()) { + if ($installer->interactive) { + InteractiveTerm::indicateProgress('Running PHP smoke tests'); + } + $package->runStage([$this, 'smokeTestForUnix']); + if ($installer->interactive) { + InteractiveTerm::finish('PHP smoke tests passed'); + } + } elseif (SystemTarget::getTargetOS() === 'Windows') { + if ($installer->interactive) { + InteractiveTerm::indicateProgress('Running PHP smoke tests'); + } + $package->runStage([$this, 'smokeTestForWindows']); + if ($installer->interactive) { + InteractiveTerm::finish('PHP smoke tests passed'); + } + } + } + private function makeStaticExtensionString(PackageInstaller $installer): string { $arg = []; diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index f16d879f6..2b81402df 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -469,27 +469,6 @@ public function build(TargetPackage $package): void $package->runStage([$this, 'unixBuildSharedExt']); } - #[Stage('postInstall')] - public function postInstall(TargetPackage $package, PackageInstaller $installer): void - { - if ($package->getName() === 'frankenphp') { - $package->runStage([$this, 'smokeTestFrankenphpForUnix']); - return; - } - if ($package->getName() !== 'php') { - return; - } - if (SystemTarget::isUnix()) { - if ($installer->interactive) { - InteractiveTerm::indicateProgress('Running PHP smoke tests'); - } - $package->runStage([$this, 'smokeTestForUnix']); - if ($installer->interactive) { - InteractiveTerm::finish('PHP smoke tests passed'); - } - } - } - /** * Patch phpize and php-config if needed */ @@ -598,7 +577,7 @@ public function smokeTestEmbedForUnix(PackageInstaller $installer, ToolchainInte 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'); - $config = new SPCConfigUtil()->config(array_map(fn ($x) => $x->getName(), $installer->getResolvedPackages())); + $config = new SPCConfigUtil()->config($installer->getAvailableResolvedPackageNames()); $lens = "{$config['cflags']} {$config['ldflags']} {$config['libs']}"; if ($toolchain->isStatic()) { $lens .= ' -static'; @@ -662,7 +641,7 @@ protected function seekPhpSrcLogFileOnException(callable $callback, string $sour /** * Generate micro extension test php code. */ - private function generateMicroExtTests(PackageInstaller $installer): string + protected function generateMicroExtTests(PackageInstaller $installer): string { $php = "getResolvedPackages(PhpExtensionPackage::class) as $ext) { @@ -756,7 +735,7 @@ private function processLibphpSoFile(string $libphpSo, PackageInstaller $install */ private function makeVars(PackageInstaller $installer): array { - $config = new SPCConfigUtil(['libs_only_deps' => true])->config(array_map(fn ($x) => $x->getName(), $installer->getResolvedPackages())); + $config = new SPCConfigUtil(['libs_only_deps' => true])->config($installer->getAvailableResolvedPackageNames()); $static = ApplicationContext::get(ToolchainInterface::class)->isStatic() ? '-all-static' : ''; $pie = SystemTarget::getTargetOS() === 'Linux' ? '-pie' : ''; diff --git a/src/Package/Target/php/windows.php b/src/Package/Target/php/windows.php index 74e746e2b..47eb3c9f5 100644 --- a/src/Package/Target/php/windows.php +++ b/src/Package/Target/php/windows.php @@ -8,10 +8,15 @@ use StaticPHP\Attribute\Package\BuildFor; use StaticPHP\Attribute\Package\Stage; use StaticPHP\Attribute\PatchDescription; +use StaticPHP\Config\PackageConfig; use StaticPHP\Exception\PatchException; use StaticPHP\Exception\SPCInternalException; +use StaticPHP\Exception\ValidationException; +use StaticPHP\Exception\WrongUsageException; +use StaticPHP\Package\LibraryPackage; use StaticPHP\Package\PackageBuilder; use StaticPHP\Package\PackageInstaller; +use StaticPHP\Package\PhpExtensionPackage; use StaticPHP\Package\TargetPackage; use StaticPHP\Util\FileSystem; use StaticPHP\Util\InteractiveTerm; @@ -30,11 +35,17 @@ public function beforeBuildconfWin(TargetPackage $package): void } #[Stage] - public function buildconfForWindows(TargetPackage $package): void + public function buildconfForWindows(TargetPackage $package, PackageInstaller $installer): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat')); V2CompatLayer::emitPatchPoint('before-php-buildconf'); cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat'); + + if ($package->getBuildOption('enable-micro-win32') && $installer->isPackageResolved('php-micro')) { + SourcePatcher::patchMicroWin32(); + } else { + SourcePatcher::unpatchMicroWin32(); + } } #[Stage] @@ -52,9 +63,11 @@ public function configureForWindows(TargetPackage $package, PackageInstaller $in $cli = $installer->isPackageResolved('php-cli'); $cgi = $installer->isPackageResolved('php-cgi'); $micro = $installer->isPackageResolved('php-micro'); + $embed = $installer->isPackageResolved('php-embed'); $args[] = $cli ? '--enable-cli=yes' : '--enable-cli=no'; $args[] = $cgi ? '--enable-cgi=yes' : '--enable-cgi=no'; $args[] = $micro ? '--enable-micro=yes' : '--enable-micro=no'; + $args[] = $embed ? '--enable-embed=yes' : '--enable-embed=no'; // zts $args[] = $package->getBuildOption('enable-zts', false) ? '--enable-zts=yes' : '--enable-zts=no'; @@ -103,13 +116,26 @@ public function patchCLITarget(TargetPackage $package): void } #[Stage] - public function makeCliForWindows(TargetPackage $package, PackageBuilder $builder): void + public function makeCliForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('php.exe')); - // extra lib - $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; + // Collect static-libs@windows from all resolved library packages. + // PHP's configure.bat only adds libs declared by enabled extensions via config.w32; + // transitive library-only deps (e.g. zlibstatic.lib needed by libcrypto.lib) are + // not covered. Inject them here so the final link step has all required symbols. + $resolved_libs = []; + foreach ($installer->getResolvedPackages(LibraryPackage::class) as $lib) { + foreach (PackageConfig::get($lib->getName(), 'static-libs', []) as $lib_file) { + if (file_exists("{$package->getLibDir()}\\{$lib_file}")) { + $resolved_libs[] = $lib_file; + } + } + } + $resolved_libs = array_unique($resolved_libs); + // extra lib + $extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' ' . implode(' ', $resolved_libs)); // Add debug symbols for release build if --no-strip is specified // We need to modify CFLAGS to replace /Ox with /Zi and add /DEBUG to LDFLAGS $debug_overrides = ''; @@ -131,6 +157,68 @@ public function makeCliForWindows(TargetPackage $package, PackageBuilder $builde $this->deployWindowsBinary($builder, $package, 'php-cli'); } + #[BeforeStage('php', [self::class, 'makeCgiForWindows'])] + #[PatchDescription('Patch Windows Makefile for CGI target')] + public function patchCGITarget(TargetPackage $package): void + { + // search Makefile code line contains "$(BUILD_DIR)\php-cgi.exe:" + $content = FileSystem::readFile("{$package->getSourceDir()}\\Makefile"); + $lines = explode("\r\n", $content); + $line_num = 0; + $found = false; + foreach ($lines as $v) { + if (str_contains($v, '$(BUILD_DIR)\php-cgi.exe:')) { + $found = $line_num; + break; + } + ++$line_num; + } + if ($found === false) { + throw new PatchException('Windows Makefile patching for php-cgi.exe target', 'Cannot patch windows CGI Makefile, Makefile does not contain "$(BUILD_DIR)\php-cgi.exe:" line'); + } + $lines[$line_num] = '$(BUILD_DIR)\php-cgi.exe: $(DEPS_CGI) $(CGI_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php-cgi.exe.res $(BUILD_DIR)\php-cgi.exe.manifest'; + $lines[$line_num + 1] = "\t" . '@"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CGI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CGI) $(BUILD_DIR)\php-cgi.exe.res /out:$(BUILD_DIR)\php-cgi.exe $(LDFLAGS) $(LDFLAGS_CGI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286'; + FileSystem::writeFile("{$package->getSourceDir()}\\Makefile", implode("\r\n", $lines)); + + // Patch cgi-static, comment ZEND_TSRMLS_CACHE_DEFINE() + FileSystem::replaceFileRegex("{$package->getSourceDir()}\\sapi\\cgi\\cgi_main.c", '/^ZEND_TSRMLS_CACHE_DEFINE\(\)/m', '// ZEND_TSRMLS_CACHE_DEFINE()'); + } + + #[Stage] + public function makeCgiForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void + { + InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('php-cgi.exe')); + + // Collect static-libs@windows from all resolved library packages. + $resolved_libs = []; + foreach ($installer->getResolvedPackages(LibraryPackage::class) as $lib) { + foreach (PackageConfig::get($lib->getName(), 'static-libs', []) as $lib_file) { + if (file_exists("{$package->getLibDir()}\\{$lib_file}")) { + $resolved_libs[] = $lib_file; + } + } + } + $resolved_libs = array_unique($resolved_libs); + + // extra lib + $extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' ' . implode(' ', $resolved_libs)); + // Add debug symbols for release build if --no-strip is specified + $debug_overrides = ''; + if ($package->getBuildOption('no-strip', false)) { + $makefile_content = file_get_contents("{$package->getSourceDir()}\\Makefile"); + if (preg_match('/^CFLAGS=(.+?)$/m', $makefile_content, $matches)) { + $cflags = $matches[1]; + $cflags = str_replace('/Ox ', '/O2 /Zi ', $cflags); + $debug_overrides = '"CFLAGS=' . $cflags . '" "LDFLAGS=/DEBUG /LTCG /INCREMENTAL:NO" "LDFLAGS_CGI=/DEBUG" '; + } + } + + cmd()->cd($package->getSourceDir()) + ->exec("nmake /nologo {$debug_overrides}LIBS_CGI=\"ws2_32.lib kernel32.lib advapi32.lib {$extra_libs}\" EXTRA_LD_FLAGS_PROGRAM= php-cgi.exe"); + + $this->deployWindowsBinary($builder, $package, 'php-cgi'); + } + #[Stage] public function makeForWindows(TargetPackage $package, PackageInstaller $installer): void { @@ -147,6 +235,193 @@ public function makeForWindows(TargetPackage $package, PackageInstaller $install if ($installer->isPackageResolved('php-micro')) { $package->runStage([$this, 'makeMicroForWindows']); } + if ($installer->isPackageResolved('php-embed')) { + $package->runStage([$this, 'makeEmbedForWindows']); + } + } + + #[Stage] + public function makeMicroForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void + { + InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('micro.sfx')); + + // workaround for fiber (originally from https://github.com/dixyes/lwmbs/blob/master/windows/MicroBuild.php) + $makefile = FileSystem::readFile("{$package->getSourceDir()}\\Makefile"); + if ($this->getPHPVersionID() >= 80200 && str_contains($makefile, 'FIBER_ASM_ARCH')) { + $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ARCH)_ms_pe_masm.obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ARCH)_ms_pe_masm.obj' . "\r\n\r\n"; + } elseif ($this->getPHPVersionID() >= 80400 && str_contains($makefile, 'FIBER_ASM_ABI')) { + $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ABI).obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ABI).obj' . "\r\n\r\n"; + } + FileSystem::writeFile("{$package->getSourceDir()}\\Makefile", $makefile); + + // Collect static-libs@windows from all resolved library packages. + $resolved_libs = []; + foreach ($installer->getResolvedPackages(LibraryPackage::class) as $lib) { + foreach (PackageConfig::get($lib->getName(), 'static-libs', []) as $lib_file) { + if (file_exists("{$package->getLibDir()}\\{$lib_file}")) { + $resolved_libs[] = $lib_file; + } + } + } + $resolved_libs = array_unique($resolved_libs); + + // extra lib + $extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' ' . implode(' ', $resolved_libs)); + // Add debug symbols for release build if --no-strip is specified + $debug_overrides = ''; + if ($package->getBuildOption('no-strip', false)) { + $makefile_content = file_get_contents("{$package->getSourceDir()}\\Makefile"); + if (preg_match('/^CFLAGS=(.+?)$/m', $makefile_content, $matches)) { + $cflags = $matches[1]; + $cflags = str_replace('/Ox ', '/O2 /Zi ', $cflags); + $debug_overrides = '"CFLAGS=' . $cflags . '" "LDFLAGS=/DEBUG /LTCG /INCREMENTAL:NO" "LDFLAGS_MICRO=/DEBUG" '; + } + } + + $fake_cli = $package->getBuildOption('with-micro-fake-cli', false) ? ' /DPHP_MICRO_FAKE_CLI' : ''; + + // phar patch for micro + $phar_patched = false; + if ($installer->isPackageResolved('ext-phar')) { + $phar_patched = true; + SourcePatcher::patchMicroPhar(self::getPHPVersionID()); + } + + try { + cmd()->cd($package->getSourceDir()) + ->exec("nmake /nologo {$debug_overrides}LIBS_MICRO=\"ws2_32.lib shell32.lib {$extra_libs}\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" EXTRA_LD_FLAGS_PROGRAM= micro"); + } finally { + if ($phar_patched) { + SourcePatcher::unpatchMicroPhar(); + } + } + + $this->deployWindowsBinary($builder, $package, 'php-micro'); + } + + #[BeforeStage('php', [self::class, 'makeEmbedForWindows'])] + #[PatchDescription('Patch Windows Makefile for embed static library target')] + public function patchEmbedTarget(TargetPackage $package): void + { + $makefile_path = "{$package->getSourceDir()}\\Makefile"; + $content = FileSystem::readFile($makefile_path); + + // PHP's configure.bat generates PHP_LDFLAGS with /nodefaultlib:libcmt to avoid CRT + // duplication in a normal /MD build. But our static build compiles everything with /MT, + // so every .obj file has DEFAULTLIB:LIBCMT embedded. Removing /nodefaultlib:libcmt lets + // the linker pick up libcmt.lib. We also exclude the dynamic CRT (/nodefaultlib:msvcrt + // /nodefaultlib:msvcrtd) to keep the DLL dependency-free, consistent with CLI/CGI/micro. + $content = str_replace( + 'PHP_LDFLAGS=$(DLL_LDFLAGS) /nodefaultlib:libcmt /def:$(PHPDEF)', + 'PHP_LDFLAGS=$(DLL_LDFLAGS) /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /def:$(PHPDEF) /ltcg /ignore:4286', + $content + ); + + // Patch embed lib target to build a REAL static library instead of just an import lib. + // The default embed target only includes embed SAPI objects and links against php8.lib (import lib). + // We need to include PHP core objects (PHP_GLOBAL_OBJS) and static extension objects (STATIC_EXT_OBJS) + // to create a self-contained static library that doesn't require php8.dll at runtime. + $major = intdiv($this->getPHPVersionID(), 10000); + $embed_lib = "php{$major}embed.lib"; + + // Find and replace the embed lib build rule + // Actual Makefile format (note the backslash before $(PHPLIB)): + // $(BUILD_DIR)\php8embed.lib: $(DEPS_EMBED) $(EMBED_GLOBAL_OBJS) $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR)\php8embed.lib.res $(BUILD_DIR)\php8embed.lib.manifest + // @$(MAKE_LIB) /nologo /out:$(BUILD_DIR)\php8embed.lib $(ARFLAGS) $(EMBED_GLOBAL_OBJS_RESP) $(BUILD_DIR)\$(PHPLIB) $(ARFLAGS_EMBED) $(LIBS_EMBED) $(BUILD_DIR)\php8embed.lib.res + $lines = explode("\r\n", $content); + $new_lines = []; + $i = 0; + while ($i < count($lines)) { + $line = $lines[$i]; + // Check if this is the embed lib target dependency line (contains the lib name and $(BUILD_DIR)\$(PHPLIB)) + if (str_contains($line, "\$(BUILD_DIR)\\{$embed_lib}:") && str_contains($line, '$(BUILD_DIR)\$(PHPLIB)')) { + // Replace the dependency line + // Original: $(BUILD_DIR)\php8embed.lib: $(DEPS_EMBED) $(EMBED_GLOBAL_OBJS) $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR)\php8embed.lib.res $(BUILD_DIR)\php8embed.lib.manifest + // New: $(BUILD_DIR)\php8embed.lib: $(DEPS_EMBED) $(EMBED_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php8embed.lib.res $(BUILD_DIR)\php8embed.lib.manifest + $new_deps = "\$(BUILD_DIR)\\{$embed_lib}: \$(DEPS_EMBED) \$(EMBED_GLOBAL_OBJS) \$(PHP_GLOBAL_OBJS) \$(STATIC_EXT_OBJS) \$(ASM_OBJS) \$(BUILD_DIR)\\{$embed_lib}.res \$(BUILD_DIR)\\{$embed_lib}.manifest"; + $new_lines[] = $new_deps; + // Skip the original line (we replaced it) + ++$i; + // Now look for the lib.exe command line (should be the next non-empty line starting with tab) + while ($i < count($lines) && trim($lines[$i]) === '') { + $new_lines[] = $lines[$i]; + ++$i; + } + // Replace the lib.exe command to include PHP_GLOBAL_OBJS_RESP and STATIC_EXT_OBJS_RESP + // Original: @$(MAKE_LIB) /nologo /out:$(BUILD_DIR)\php8embed.lib $(ARFLAGS) $(EMBED_GLOBAL_OBJS_RESP) $(BUILD_DIR)\$(PHPLIB) $(ARFLAGS_EMBED) $(LIBS_EMBED) $(BUILD_DIR)\php8embed.lib.res + // New: @$(MAKE_LIB) /nologo /out:$(BUILD_DIR)\php8embed.lib $(ARFLAGS) $(EMBED_GLOBAL_OBJS_RESP) $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(ASM_OBJS) $(STATIC_EXT_LIBS) $(ARFLAGS_EMBED) $(LIBS_EMBED) $(BUILD_DIR)\php8embed.lib.res + if ($i < count($lines) && str_contains($lines[$i], '$(MAKE_LIB)')) { + $cmd_line = $lines[$i]; + // Remove $(BUILD_DIR)\$(PHPLIB) from the command (note the backslash) + $cmd_line = str_replace(' $(BUILD_DIR)\$(PHPLIB)', '', $cmd_line); + // Add PHP_GLOBAL_OBJS_RESP and STATIC_EXT_OBJS_RESP after EMBED_GLOBAL_OBJS_RESP + $cmd_line = str_replace( + '$(EMBED_GLOBAL_OBJS_RESP)', + '$(EMBED_GLOBAL_OBJS_RESP) $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(ASM_OBJS) $(STATIC_EXT_LIBS)', + $cmd_line + ); + $new_lines[] = $cmd_line; + ++$i; + } + } else { + $new_lines[] = $line; + ++$i; + } + } + $content = implode("\r\n", $new_lines); + + FileSystem::writeFile($makefile_path, $content); + } + + #[Stage] + public function makeEmbedForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void + { + $major = intdiv($this->getPHPVersionID(), 10000); + $embed_lib = "php{$major}embed.lib"; + InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow($embed_lib)); + + // Add debug symbols for release build if --no-strip is specified + $debug_overrides = ''; + if ($package->getBuildOption('no-strip', false)) { + $makefile_content = file_get_contents("{$package->getSourceDir()}\\Makefile"); + if (preg_match('/^CFLAGS=(.+?)$/m', $makefile_content, $matches)) { + $cflags = $matches[1]; + $cflags = str_replace('/Ox ', '/O2 /Zi ', $cflags); + $debug_overrides = '"CFLAGS=' . $cflags . '" "LDFLAGS=/DEBUG /LTCG /INCREMENTAL:NO" '; + } + } + + // Build the embed static library (patched to include PHP core and extension objects) + cmd()->cd($package->getSourceDir()) + ->exec("nmake /nologo {$debug_overrides}{$embed_lib}"); + + // Deploy: php8embed.lib is now a REAL static library containing all PHP code + $rel_type = 'Release'; // TODO: Debug build support + $ts = $builder->getOption('enable-zts') ? '_TS' : ''; + $build_dir = "{$package->getSourceDir()}\\x64\\{$rel_type}{$ts}"; + + // copy static embed lib to buildroot/lib + $embed_lib_src = "{$build_dir}\\{$embed_lib}"; + if (file_exists($embed_lib_src)) { + FileSystem::copy($embed_lib_src, "{$package->getLibDir()}\\{$embed_lib}"); + $package->setOutput('Static library path for embed SAPI', "{$package->getLibDir()}\\{$embed_lib}"); + } + + // Note: We no longer deploy php8.dll because the embed static library is self-contained. + // All PHP core code, extensions, and embed SAPI are statically linked into php8embed.lib. + + // copy .pdb debug info if --no-strip + $debug_dir = BUILD_ROOT_PATH . '\debug'; + if ($builder->getOption('no-strip', false)) { + $pdb = "{$build_dir}\\php{$major}embed.pdb"; + if (file_exists($pdb)) { + FileSystem::createDir($debug_dir); + FileSystem::copy($pdb, "{$debug_dir}\\php{$major}embed.pdb"); + } + } + + // Install PHP headers for embed SAPI development + $this->installPhpHeadersForWindows($package, $installer); } #[BuildFor('Windows')] @@ -215,6 +490,195 @@ public function patchBeforeBuildconfForWindows(TargetPackage $package): void } } + #[Stage] + public function smokeTestForWindows(PackageBuilder $builder, TargetPackage $package, PackageInstaller $installer): void + { + // analyse --no-smoke-test option + $no_smoke_test = $builder->getOption('no-smoke-test'); + $option = match ($no_smoke_test) { + false => false, + null => 'all', + default => parse_comma_list($no_smoke_test), + }; + $valid_tests = ['cli', 'cgi', 'micro', 'micro-exts', 'embed']; + // compat: --without-micro-ext-test is equivalent to --no-smoke-test=micro-exts + if ($builder->getOption('without-micro-ext-test', false)) { + $valid_tests = array_diff($valid_tests, ['micro-exts']); + } + if (is_array($option)) { + foreach ($option as $test) { + if (!in_array($test, $valid_tests, true)) { + throw new WrongUsageException("Invalid value for --no-smoke-test: {$test}. Valid values are: " . implode(', ', $valid_tests)); + } + $valid_tests = array_diff($valid_tests, [$test]); + } + } elseif ($option === 'all') { + $valid_tests = []; + } + + // remove all .dll from buildroot/bin/ + $dlls = glob(BUILD_BIN_PATH . '\*.dll') ?: []; + foreach ($dlls as $dll) { + @unlink($dll); + } + + if (in_array('cli', $valid_tests, true) && $installer->isPackageResolved('php-cli')) { + $package->runStage([$this, 'smokeTestCliForWindows']); + } + if (in_array('cgi', $valid_tests, true) && $installer->isPackageResolved('php-cgi')) { + $package->runStage([$this, 'smokeTestCgiForWindows']); + } + if (in_array('micro', $valid_tests, true) && $installer->isPackageResolved('php-micro')) { + $skipExtTest = !in_array('micro-exts', $valid_tests, true); + $package->runStage([$this, 'smokeTestMicroForWindows'], ['skipExtTest' => $skipExtTest]); + } + if (in_array('embed', $valid_tests, true) && $installer->isPackageResolved('php-embed')) { + $package->runStage([$this, 'smokeTestEmbedForWindows'], ['installer' => $installer]); + } + } + + #[Stage] + public function smokeTestCliForWindows(PackageInstaller $installer): void + { + InteractiveTerm::setMessage('Running basic php-cli smoke test'); + [$ret, $output] = cmd()->execWithResult(BUILD_BIN_PATH . '\php.exe -n -r "echo \"hello\";"'); + $raw_output = implode('', $output); + if ($ret !== 0 || trim($raw_output) !== 'hello') { + throw new ValidationException("cli failed smoke test. code: {$ret}, output: {$raw_output}", validation_module: 'php-cli smoke test'); + } + + $exts = $installer->getResolvedPackages(PhpExtensionPackage::class); + foreach ($exts as $ext) { + InteractiveTerm::setMessage('Running php-cli smoke test for ' . ConsoleColor::yellow($ext->getExtensionName()) . ' extension'); + $ext->runSmokeTestCliWindows(); + } + } + + #[Stage] + public function smokeTestCgiForWindows(): void + { + InteractiveTerm::setMessage('Running basic php-cgi smoke test'); + FileSystem::writeFile(SOURCE_PATH . '\php-cgi-test.php', 'Hello, World!"; ?>'); + [$ret, $output] = cmd()->execWithResult(BUILD_BIN_PATH . '\php-cgi.exe -n -f ' . SOURCE_PATH . '\php-cgi-test.php'); + $raw_output = implode("\n", $output); + if ($ret !== 0 || !str_contains($raw_output, 'Hello, World!')) { + throw new ValidationException("cgi failed smoke test. code: {$ret}, output: {$raw_output}", validation_module: 'php-cgi smoke test'); + } + } + + #[Stage] + public function smokeTestMicroForWindows(PackageInstaller $installer, bool $skipExtTest = false): void + { + $micro_sfx = BUILD_BIN_PATH . '\micro.sfx'; + + InteractiveTerm::setMessage('Running php-micro smoke test'); + $content = $skipExtTest + ? 'generateMicroExtTests($installer); + $test_file = SOURCE_PATH . '\micro_ext_test.exe'; + if (file_exists($test_file)) { + @unlink($test_file); + } + file_put_contents($test_file, file_get_contents($micro_sfx) . $content); + [$ret, $out] = cmd()->execWithResult($test_file); + $raw_out = trim(implode('', $out)); + if ($ret !== 0 || !str_starts_with($raw_out, '[micro-test-start]') || !str_ends_with($raw_out, '[micro-test-end]')) { + throw new ValidationException( + "micro_ext_test failed. code: {$ret}, output: {$raw_out}", + validation_module: 'phpmicro sanity check item [micro_ext_test]' + ); + } + } + + #[Stage] + public function smokeTestEmbedForWindows(PackageInstaller $installer, TargetPackage $package): void + { + $test_dir = SOURCE_PATH . '\embed-test'; + FileSystem::createDir($test_dir); + + // Create embed.c test file (Windows version) + $embed_c = <<<'C_CODE' +#include + +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)) { + php_printf("Failed to execute PHP script.\n"); + } + + PHP_EMBED_END_BLOCK() + return 0; +} +C_CODE; + FileSystem::writeFile($test_dir . '\embed.c', $embed_c); + + // Create embed.php test file + FileSystem::writeFile($test_dir . '\embed.php', "config(array_map(fn ($x) => $x->getName(), $installer->getResolvedPackages())); + + // Build the embed test executable using cl.exe + // Note: MSVCToolchain already initialized the VC environment, no need for vcvarsall + InteractiveTerm::setMessage('Running php-embed build smoke test'); + + // For Windows, we need to use PHP source directory headers directly + // because Windows PHP doesn't use php_config.h like Unix + $source_dir = $package->getSourceDir(); + $rel_type = 'Release'; + $ts = $package->getBuildOption('enable-zts', false) ? '_TS' : ''; + $build_dir = "{$source_dir}\\x64\\{$rel_type}{$ts}"; + + // Build include flags pointing to source dirs (like PHP Windows build does) + // Note: embed.c uses #include , so we need $source_dir itself + $include_flags = sprintf( + '/I"%s" /I"%s\main" /I"%s\Zend" /I"%s\TSRM" /I"%s" ' . + '/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _WINDOWS /D WINDOWS=1 /D _MBCS /D _USE_MATH_DEFINES', + $build_dir, + $source_dir, + $source_dir, + $source_dir, + $source_dir + ); + + // MSVC cl.exe format: compiler flags must come before /link, linker flags after + // ldflags contains /LIBPATH which must be after /link + $compile_cmd = sprintf( + 'cl.exe /nologo /O2 /MT /Z7 %s embed.c /Fe:embed.exe /link /LIBPATH:"%s\lib" %s %s', + $include_flags, + BUILD_ROOT_PATH, + $config['libs'], + 'kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib dnsapi.lib psapi.lib bcrypt.lib' // Windows system libs (match Makefile LIBS) + ); + + // Log command explicitly (workaround for cmd() not logging complex commands properly) + logger()->debug('Embed smoke test compile command: ' . $compile_cmd); + + [$ret, $out] = cmd()->cd($test_dir)->execWithResult($compile_cmd); + if ($ret !== 0) { + throw new ValidationException( + 'embed failed to build. Error message: ' . implode("\n", $out), + validation_module: 'php-embed build smoke test' + ); + } + + // Run the embed test + InteractiveTerm::setMessage('Running php-embed run smoke test'); + [$ret, $output] = cmd()->cd($test_dir)->execWithResult('embed.exe'); + $raw_output = implode('', $output); + if ($ret !== 0 || trim($raw_output) !== 'hello') { + throw new ValidationException( + 'embed failed to run. Error message: ' . $raw_output, + validation_module: 'php-embed run smoke test' + ); + } + } + protected function deployWindowsBinary(PackageBuilder $builder, TargetPackage $package, string $sapi): void { $rel_type = 'Release'; // TODO: Debug build support @@ -231,9 +695,98 @@ protected function deployWindowsBinary(PackageBuilder $builder, TargetPackage $p $builder->deployBinary($src_file, $dst_file); - // make debug info file path + $output_label = match ($sapi) { + 'php-cli' => 'Binary path for cli SAPI', + 'php-cgi' => 'Binary path for cgi SAPI', + 'php-micro' => 'Binary path for micro SAPI', + default => null, + }; + if ($output_label) { + $package->setOutput($output_label, $dst_file); + } + + // copy .pdb debug info file if ($builder->getOption('no-strip', false) && file_exists("{$src[0]}\\{$src[2]}")) { + FileSystem::createDir($debug_dir); FileSystem::copy("{$src[0]}\\{$src[2]}", "{$debug_dir}\\{$src[2]}"); } } + + /** + * Install PHP headers to buildroot/include for embed SAPI development. + * This mirrors the 'make install-headers' behavior on Unix. + */ + private function installPhpHeadersForWindows(TargetPackage $package, PackageInstaller $installer): void + { + InteractiveTerm::setMessage('Installing PHP headers for embed SAPI'); + + $source_dir = $package->getSourceDir(); + $include_dir = $package->getIncludeDir(); + $php_include_dir = "{$include_dir}\\php"; + + // Create directory structure + FileSystem::createDir("{$php_include_dir}\\main"); + FileSystem::createDir("{$php_include_dir}\\Zend"); + FileSystem::createDir("{$php_include_dir}\\TSRM"); + FileSystem::createDir("{$php_include_dir}\\sapi\\embed"); + + // Copy main/*.h + foreach (glob("{$source_dir}\\main\\*.h") as $h) { + FileSystem::copy($h, "{$php_include_dir}\\main\\" . basename($h)); + } + + // Copy Zend/*.h + foreach (glob("{$source_dir}\\Zend\\*.h") as $h) { + $target = "{$php_include_dir}\\Zend\\" . basename($h); + FileSystem::copy($h, $target); + // Fix GCC-specific #warning directive not supported by MSVC + if (basename($h) === 'zend_atomic.h') { + FileSystem::replaceFileStr($target, '#warning No atomics support detected. Please open an issue with platform details.', '#pragma message("No atomics support detected. Please open an issue with platform details.")'); + } + } + + // Copy TSRM/*.h + foreach (glob("{$source_dir}\\TSRM\\*.h") as $h) { + FileSystem::copy($h, "{$php_include_dir}\\TSRM\\" . basename($h)); + } + + // Copy embed SAPI header + FileSystem::copy("{$source_dir}\\sapi\\embed\\php_embed.h", "{$php_include_dir}\\sapi\\embed\\php_embed.h"); + + // Copy generated config.h (config.w32.h on Windows) to php_config.h + $rel_type = 'Release'; + $ts = $package->getBuildOption('enable-zts', false) ? '_TS' : ''; + $build_dir = "{$source_dir}\\x64\\{$rel_type}{$ts}"; + + // Always copy config.w32.h from source (it's used for both build and headers) + if (file_exists("{$source_dir}\\main\\config.w32.h")) { + FileSystem::copy("{$source_dir}\\main\\config.w32.h", "{$php_include_dir}\\main\\php_config.h"); + } + + // Windows: zend_config.w32.h must be copied as zend_config.h for Zend headers to work + if (file_exists("{$source_dir}\\Zend\\zend_config.w32.h")) { + FileSystem::copy("{$source_dir}\\Zend\\zend_config.w32.h", "{$php_include_dir}\\Zend\\zend_config.h"); + } + + // Copy extension headers for enabled extensions + foreach ($installer->getResolvedPackages(PhpExtensionPackage::class) as $ext) { + $ext_name = $ext->getExtensionName(); + $ext_dir = "{$source_dir}\\ext\\{$ext_name}"; + if (is_dir($ext_dir)) { + $target_ext_dir = "{$php_include_dir}\\ext\\{$ext_name}"; + FileSystem::createDir($target_ext_dir); + foreach (glob("{$ext_dir}\\*.h") as $h) { + FileSystem::copy($h, "{$target_ext_dir}\\" . basename($h)); + } + // Also copy any arginfo headers + foreach (glob("{$ext_dir}\\*_arginfo.h") as $h) { + if (!file_exists("{$target_ext_dir}\\" . basename($h))) { + FileSystem::copy($h, "{$target_ext_dir}\\" . basename($h)); + } + } + } + } + + $package->setOutput('PHP headers path for embed SAPI', $php_include_dir); + } } diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 750c49e4b..9685a1d88 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -34,7 +34,7 @@ */ final class ConsoleApplication extends Application { - public const string VERSION = '2.8.3'; + public const string VERSION = '2.8.5'; public function __construct() { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f5a5d9561..9077269e5 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -96,7 +96,8 @@ public function getLibFilesString(): string fn ($x) => $x->getStaticLibFiles(), $this->getLibraryDependencies(recursive: true) ); - return implode(' ', $ret); + $libs = implode(' ', $ret); + return deduplicate_flags($libs); } /** diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 383faa41a..73b1f9ed9 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -365,6 +365,27 @@ protected function installLicense(): void protected function isLibraryInstalled(): bool { + if ($pkg_configs = Config::getLib(static::NAME, 'pkg-configs', [])) { + $pkg_config_path = getenv('PKG_CONFIG_PATH') ?: ''; + $search_paths = array_unique(array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path))); + + foreach ($pkg_configs as $name) { + $found = false; + foreach ($search_paths as $path) { + if (file_exists($path . "/{$name}.pc")) { + $found = true; + break; + } + } + if (!$found) { + return false; + } + } + // allow using system dependencies if pkg_config_path is explicitly defined + if (count($search_paths) > 1) { + return true; + } + } foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { return false; diff --git a/src/SPC/builder/extension/grpc.php b/src/SPC/builder/extension/grpc.php index 42dcdd5b8..732f7cbe5 100644 --- a/src/SPC/builder/extension/grpc.php +++ b/src/SPC/builder/extension/grpc.php @@ -11,7 +11,6 @@ use SPC\util\CustomExt; use SPC\util\GlobalEnvManager; use SPC\util\SPCConfigUtil; -use SPC\util\SPCTarget; #[CustomExt('grpc')] class grpc extends Extension @@ -21,18 +20,59 @@ public function patchBeforeBuildconf(): bool if ($this->builder instanceof WindowsBuilder) { throw new ValidationException('grpc extension does not support windows yet'); } + + // Fix deprecated PHP API usage in call.c FileSystem::replaceFileStr( - $this->source_dir . '/src/php/ext/grpc/call.c', + "{$this->source_dir}/src/php/ext/grpc/call.c", 'zend_exception_get_default(TSRMLS_C),', 'zend_ce_exception,', ); - if (SPCTarget::getTargetOS() === 'Darwin') { - FileSystem::replaceFileRegex( - $this->source_dir . '/config.m4', - '/GRPC_LIBDIR=.*$/m', - 'GRPC_LIBDIR=' . BUILD_LIB_PATH . "\n" . 'LDFLAGS="$LDFLAGS -framework CoreFoundation"' - ); + + // Fix include path conflict with pdo_sqlsrv: grpc's PHP ext dir is added to the global include path via + $grpc_php_dir = "{$this->source_dir}/src/php/ext/grpc"; + if (file_exists("{$grpc_php_dir}/version.h")) { + copy("{$grpc_php_dir}/version.h", "{$grpc_php_dir}/php_grpc_version.h"); + unlink("{$grpc_php_dir}/version.h"); + FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.h", '#include "version.h"', '#include "php_grpc_version.h"'); + FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.c", '#include "version.h"', '#include "php_grpc_version.h"'); } + + $config_m4 = <<<'M4' +PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])]) + +if test "$PHP_GRPC" != "no"; then + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) + GRPC_LIBDIR=@@build_lib_path@@ + PHP_ADD_LIBPATH($GRPC_LIBDIR) + PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD) + LIBS="-lpthread $LIBS" + PHP_ADD_LIBRARY(pthread) + + case $host in + *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) + ;; + *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(rt) + ;; + esac + + PHP_NEW_EXTENSION(grpc, @grpc_c_files@, $ext_shared, , -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1) + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_INSTALL_HEADERS([ext/grpc], [php_grpc.h]) +fi +M4; + $replace = get_pack_replace(); + // load grpc c files from src/php/ext/grpc + $c_files = glob($this->source_dir . '/src/php/ext/grpc/*.c'); + $replace['@grpc_c_files@'] = implode(" \\\n ", array_map(fn ($f) => 'src/php/ext/grpc/' . basename($f), $c_files)); + $config_m4 = str_replace(array_keys($replace), array_values($replace), $config_m4); + file_put_contents($this->source_dir . '/config.m4', $config_m4); + + copy($this->source_dir . '/src/php/ext/grpc/php_grpc.h', $this->source_dir . '/php_grpc.h'); return true; } @@ -48,7 +88,6 @@ public function patchBeforeConfigure(): bool public function patchBeforeMake(): bool { parent::patchBeforeMake(); - // 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; } diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index 04bd52261..fa55b9324 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -33,4 +33,14 @@ public function patchBeforeWindowsConfigure(): bool } return false; } + + public function patchBeforeMake(): bool + { + $makefile = SOURCE_PATH . '/php-src/Makefile'; + $makeContent = file_get_contents($makefile); + $makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/W4\b/m', '$1', $makeContent); + $makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/WX\b/m', '$1', $makeContent); + file_put_contents($makefile, $makeContent); + return true; + } } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 4e292a362..7da30ba69 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -50,19 +50,16 @@ public function getUnixConfigureArg(bool $shared = false): string // commonly used feature: coroutine-time $arg .= ' --enable-swoole-coro-time --with-pic'; + $arg .= ' --enable-swoole-ssh --enable-swoole-curl'; $arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; - // required features: curl, openssl (but curl hook is buggy for php 8.0) - $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; - $arg .= ' --enable-openssl'; - // additional features that only require libraries $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : ''; - $arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : ''; + $arg .= $this->builder->getLib('liburing') && getenv('SPC_LIBC') !== 'glibc' ? ' --enable-iouring --enable-uring-socket' : '--disable-iouring'; $arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : ''; // enable additional features that require the pdo extension, but conflict with pdo_* extensions @@ -74,6 +71,7 @@ public function getUnixConfigureArg(bool $shared = false): string $config = (new SPCConfigUtil($this->builder))->getLibraryConfig($this->builder->getLib('unixodbc')); $arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"'; } + $arg .= $this->builder->getExt('ftp')?->isBuildStatic() ? ' --disable-swoole-ftp' : ' --enable-swoole-ftp'; if ($this->getExtVersion() >= '6.1.0') { $arg .= ' --enable-swoole-stdext'; diff --git a/src/SPC/builder/extension/xlswriter.php b/src/SPC/builder/extension/xlswriter.php index 24d32d947..8ef826d00 100644 --- a/src/SPC/builder/extension/xlswriter.php +++ b/src/SPC/builder/extension/xlswriter.php @@ -7,6 +7,7 @@ use SPC\builder\Extension; use SPC\store\SourcePatcher; use SPC\util\CustomExt; +use SPC\util\GlobalEnvManager; #[CustomExt('xlswriter')] class xlswriter extends Extension @@ -28,6 +29,13 @@ public function getWindowsConfigureArg(bool $shared = false): string public function patchBeforeMake(): bool { $patched = parent::patchBeforeMake(); + + // Remove when https://github.com/viest/php-ext-xlswriter/pull/560 is merged + if (PHP_OS_FAMILY !== 'Windows') { + GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -std=gnu17'); + $patched = true; + } + if (PHP_OS_FAMILY === 'Windows') { // fix windows build with openssl extension duplicate symbol bug SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir); @@ -40,4 +48,10 @@ public function patchBeforeMake(): bool } return $patched; } + + // Remove when https://github.com/viest/php-ext-xlswriter/pull/560 is merged + protected function getExtraEnv(): array + { + return ['CFLAGS' => '-std=gnu17']; + } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 004c37def..d959aade6 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -162,7 +162,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void throw new WrongUsageException( "You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.\n" . 'Static musl libc does not implement `dlopen`, so your php binary is not able to load shared extensions.' . "\n" . - 'Either use SPC_LIBC=glibc to link against glibc on a glibc OS, or use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc`.' + 'Either use SPC_LIBC=glibc to link against glibc on a glibc OS, use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc` or use SPC_MUSL_DYNAMIC=true on alpine.' ); } logger()->info('Building shared extensions...'); diff --git a/src/SPC/builder/traits/UnixSystemUtilTrait.php b/src/SPC/builder/traits/UnixSystemUtilTrait.php index ff75bf7c2..33f824f36 100644 --- a/src/SPC/builder/traits/UnixSystemUtilTrait.php +++ b/src/SPC/builder/traits/UnixSystemUtilTrait.php @@ -72,6 +72,10 @@ public static function getDynamicExportedSymbols(string $lib_file): ?string if (!is_file($symbol_file)) { throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available."); } + // https://github.com/ziglang/zig/issues/24662 + if (ToolchainManager::getToolchainClass() === ZigToolchain::class) { + return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then + } // macOS/zig if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) { return "-Wl,-exported_symbols_list,{$symbol_file}"; diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 1b532bbcf..fd16656ce 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -457,6 +457,7 @@ protected function buildFrankenphp(): void 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' . + '-X \'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp\' ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index a10b7fb28..57c1ac05c 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -13,8 +13,8 @@ protected function build(): void { $cmake = UnixCMakeExecutor::create($this) ->optionalLib('libpng', ...cmake_boolean_args('FT_DISABLE_PNG', true)) - ->optionalLib('bzip2', ...cmake_boolean_args('FT_DISABLE_BZIP2', true)) - ->optionalLib('brotli', ...cmake_boolean_args('FT_DISABLE_BROTLI', true)) + ->addConfigureArgs('-DFT_DISABLE_BZIP2=ON') + ->addConfigureArgs('-DFT_DISABLE_BROTLI=ON') ->addConfigureArgs('-DFT_DISABLE_HARFBUZZ=ON'); // fix cmake 4.0 compatibility diff --git a/src/SPC/builder/unix/library/krb5.php b/src/SPC/builder/unix/library/krb5.php index 798346459..4cf0ad44e 100644 --- a/src/SPC/builder/unix/library/krb5.php +++ b/src/SPC/builder/unix/library/krb5.php @@ -13,7 +13,10 @@ protected function build(): void { $origin_source_dir = $this->source_dir; $this->source_dir .= '/src'; - shell()->cd($this->source_dir)->exec('autoreconf -if'); + shell()->cd($this->source_dir)->exec('ls -lah'); + if (!file_exists($this->source_dir . '/configure')) { + shell()->cd($this->source_dir)->exec('autoreconf -if'); + } $libs = array_map(fn ($x) => $x->getName(), $this->getDependencies(true)); $spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]); $config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false)); diff --git a/src/SPC/builder/unix/library/libde265.php b/src/SPC/builder/unix/library/libde265.php index 9549a2ec9..184a44261 100644 --- a/src/SPC/builder/unix/library/libde265.php +++ b/src/SPC/builder/unix/library/libde265.php @@ -11,7 +11,10 @@ trait libde265 protected function build(): void { UnixCMakeExecutor::create($this) - ->addConfigureArgs('-DENABLE_SDL=OFF') + ->addConfigureArgs( + '-DENABLE_SDL=OFF', + '-DENABLE_DECODER=OFF' + ) ->build(); $this->patchPkgconfPrefix(['libde265.pc']); } diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 862c1e88d..969fa0608 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -14,6 +14,10 @@ protected function build(): void ->addConfigureArgs( '-DENABLE_STATIC=ON', '-DENABLE_SHARED=OFF', + '-DWITH_SYSTEM_ZLIB=ON', + '-DWITH_TOOLS=OFF', + '-DWITH_TESTS=OFF', + '-DWITH_SIMD=OFF', ) ->build(); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 2ad4f51be..a3aed130b 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -93,8 +93,7 @@ protected function build(): void // remove dynamic libs shell()->cd($this->source_dir . '/build') - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*") - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so") + ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*") ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib"); FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber'); diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index 9a3cb63d1..cf923f24b 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -5,6 +5,7 @@ namespace SPC\builder\unix\library; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; trait unixodbc @@ -30,7 +31,15 @@ protected function build(): void '--enable-gui=no', ) ->make(); - $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); + $pkgConfigs = ['odbc.pc', 'odbccr.pc', 'odbcinst.pc']; + $this->patchPkgconfPrefix($pkgConfigs); + foreach ($pkgConfigs as $file) { + FileSystem::replaceFileStr( + BUILD_LIB_PATH . "/pkgconfig/{$file}", + '$(top_build_prefix)libltdl/libltdlc.la', + '' + ); + } $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/windows/library/brotli.php b/src/SPC/builder/windows/library/brotli.php new file mode 100644 index 000000000..f22f402ce --- /dev/null +++ b/src/SPC/builder/windows/library/brotli.php @@ -0,0 +1,36 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBROTLI_BUILD_TOOLS=OFF ' . + '-DBROTLI_BUNDLED_MODE=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/freetype.php b/src/SPC/builder/windows/library/freetype.php index ef13c8fe6..8401b4de4 100644 --- a/src/SPC/builder/windows/library/freetype.php +++ b/src/SPC/builder/windows/library/freetype.php @@ -24,6 +24,8 @@ protected function build(): void "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DFT_DISABLE_BROTLI=TRUE ' . + '-DFT_DISABLE_BZIP2=TRUE ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' ) ->execWithWrapper( diff --git a/src/SPC/builder/windows/library/icu_static_win.php b/src/SPC/builder/windows/library/icu_static_win.php index c152c6e7d..fdd9e6cd4 100644 --- a/src/SPC/builder/windows/library/icu_static_win.php +++ b/src/SPC/builder/windows/library/icu_static_win.php @@ -12,16 +12,16 @@ class icu_static_win extends WindowsLibraryBase protected function build(): void { - copy("{$this->source_dir}\\x64-windows-static\\lib\\icudt.lib", "{$this->getLibDir()}\\icudt.lib"); - copy("{$this->source_dir}\\x64-windows-static\\lib\\icuin.lib", "{$this->getLibDir()}\\icuin.lib"); - copy("{$this->source_dir}\\x64-windows-static\\lib\\icuio.lib", "{$this->getLibDir()}\\icuio.lib"); - copy("{$this->source_dir}\\x64-windows-static\\lib\\icuuc.lib", "{$this->getLibDir()}\\icuuc.lib"); + copy("{$this->source_dir}\\lib\\icudt.lib", "{$this->getLibDir()}\\icudt.lib"); + copy("{$this->source_dir}\\lib\\icuin.lib", "{$this->getLibDir()}\\icuin.lib"); + copy("{$this->source_dir}\\lib\\icuio.lib", "{$this->getLibDir()}\\icuio.lib"); + copy("{$this->source_dir}\\lib\\icuuc.lib", "{$this->getLibDir()}\\icuuc.lib"); // create libpq folder in buildroot/includes/libpq if (!file_exists("{$this->getIncludeDir()}\\unicode")) { mkdir("{$this->getIncludeDir()}\\unicode"); } - FileSystem::copyDir("{$this->source_dir}\\x64-windows-static\\include\\unicode", "{$this->getIncludeDir()}\\unicode"); + FileSystem::copyDir("{$this->source_dir}\\include\\unicode", "{$this->getIncludeDir()}\\unicode"); } } diff --git a/src/SPC/builder/windows/library/libaom.php b/src/SPC/builder/windows/library/libaom.php new file mode 100644 index 000000000..06d53cbc7 --- /dev/null +++ b/src/SPC/builder/windows/library/libaom.php @@ -0,0 +1,41 @@ +source_dir . '\builddir'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-S . -B builddir ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DAOM_TARGET_CPU=generic ' . + '-DENABLE_DOCS=OFF ' . + '-DENABLE_EXAMPLES=OFF ' . + '-DENABLE_TESTDATA=OFF ' . + '-DENABLE_TESTS=OFF ' . + '-DENABLE_TOOLS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build builddir --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/libjpeg.php b/src/SPC/builder/windows/library/libjpeg.php index d7ac718cd..0e5a69994 100644 --- a/src/SPC/builder/windows/library/libjpeg.php +++ b/src/SPC/builder/windows/library/libjpeg.php @@ -28,6 +28,7 @@ protected function build(): void '-DENABLE_STATIC=ON ' . '-DBUILD_TESTING=OFF ' . '-DWITH_JAVA=OFF ' . + '-DWITH_SIMD=OFF ' . '-DWITH_CRT_DLL=OFF ' . "-DENABLE_ZLIB_COMPRESSION={$zlib} " . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' diff --git a/src/SPC/builder/windows/library/ngtcp2.php b/src/SPC/builder/windows/library/ngtcp2.php index d0f557b71..79895dd6b 100644 --- a/src/SPC/builder/windows/library/ngtcp2.php +++ b/src/SPC/builder/windows/library/ngtcp2.php @@ -29,6 +29,7 @@ protected function build(): void '-DBUILD_SHARED_LIBS=OFF ' . '-DENABLE_STATIC_CRT=ON ' . '-DENABLE_LIB_ONLY=ON ' . + '-DENABLE_OPENSSL=OFF ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' ) ->execWithWrapper( diff --git a/src/SPC/builder/windows/library/zlib.php b/src/SPC/builder/windows/library/zlib.php index 03fd033b9..a5fd346ba 100644 --- a/src/SPC/builder/windows/library/zlib.php +++ b/src/SPC/builder/windows/library/zlib.php @@ -31,8 +31,24 @@ protected function build(): void $this->builder->makeSimpleWrapper('cmake'), "--build build --config Release --target install -j{$this->builder->concurrency}" ); - copy(BUILD_LIB_PATH . '\zlibstatic.lib', BUILD_LIB_PATH . '\zlib_a.lib'); - unlink(BUILD_ROOT_PATH . '\bin\zlib.dll'); - unlink(BUILD_LIB_PATH . '\zlib.lib'); + $detect_list = [ + 'zlibstatic.lib', + 'zs.lib', + 'libzs.lib', + 'libz.lib', + ]; + foreach ($detect_list as $item) { + if (file_exists(BUILD_LIB_PATH . '\\' . $item)) { + FileSystem::copy(BUILD_LIB_PATH . '\\' . $item, BUILD_LIB_PATH . '\zlib_a.lib'); + FileSystem::copy(BUILD_LIB_PATH . '\\' . $item, BUILD_LIB_PATH . '\zlibstatic.lib'); + break; + } + } + FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '\bin\zlib.dll'); + FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\zlib.lib'); + FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\libz.dll'); + FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\libz.lib'); + FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\z.lib'); + FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\z.dll'); } } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 00bcc1948..b7f2b078b 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -30,7 +30,7 @@ public function configure(): void $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); $this->addOption('shallow-clone', null, null, 'Clone shallow'); $this->addOption('with-openssl11', null, null, 'Use openssl 1.1'); - $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.4)', '8.4'); + $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.5)', '8.5'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 1d0815ce2..d2d44b51f 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -152,7 +152,7 @@ public static function copyDir(string $from, string $to): void $src_path = FileSystem::convertPath($from); switch (PHP_OS_FAMILY) { case 'Windows': - f_passthru('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/v/y/i'); + f_passthru('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/y/i'); break; case 'Linux': case 'Darwin': diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 7317c4f9d..43b750c43 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -634,7 +634,13 @@ public static function patchGDWin32(): bool FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gd/libgd/gdft.c', '#ifndef MSWIN32', '#ifndef _WIN32'); } // custom config.w32, because official config.w32 is hard-coded many things - $origin = $ver_id >= 80100 ? file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32') : file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32'); + if ($ver_id >= 80500) { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_85.w32'); + } elseif ($ver_id >= 80100) { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32'); + } else { + $origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32'); + } file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32')); return file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin) !== false; } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 02ba87554..bf33d6b7d 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -20,7 +20,7 @@ class PhpSource extends CustomSourceBase public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void { - $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; + $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.5'; if ($major === 'git') { Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force); } else { diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index 445c6242f..d9f751ef9 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -393,7 +393,7 @@ public static function validateAndParseCraftFile(mixed $craft_file, Command $com } // check php-version if (isset($craft['php-version'])) { - // validdate version, accept 8.x, 7.x, 8.x.x, 7.x.x, 8, 7 + // validate version, accept 8.x, 7.x, 8.x.x, 7.x.x, 8, 7 $version = strval($craft['php-version']); if (!preg_match('/^(\d+)(\.\d+)?(\.\d+)?$/', $version, $matches)) { throw new ValidationException('Craft file php-version is invalid'); diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index e04fe4f9c..9d57ef4eb 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -16,12 +16,11 @@ class UnixAutoconfExecutor extends Executor protected array $configure_args = []; - protected array $ignore_args = []; - public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library) { parent::__construct($library); $this->initShell(); + $this->configure_args = $this->getDefaultConfigureArgs(); } /** @@ -29,19 +28,12 @@ public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibra */ public function configure(...$args): static { - // remove all the ignored args - $args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args); - $args = array_diff($args, $this->ignore_args); + $args = array_merge($args, $this->configure_args); $configure_args = implode(' ', $args); return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}")); } - public function getConfigureArgsString(): string - { - return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args)); - } - /** * Run make * @@ -111,7 +103,7 @@ public function addConfigureArgs(...$args): static */ public function removeConfigureArgs(...$args): static { - $this->ignore_args = [...$this->ignore_args, ...$args]; + $this->configure_args = array_diff($this->configure_args, $args); return $this; } @@ -133,8 +125,8 @@ public function appendEnv(array $env): static private function getDefaultConfigureArgs(): array { return [ - '--disable-shared', '--enable-static', + '--disable-shared', "--prefix={$this->library->getBuildRootPath()}", '--with-pic', '--enable-pic', diff --git a/src/SPC/util/executor/UnixCMakeExecutor.php b/src/SPC/util/executor/UnixCMakeExecutor.php index eceab9014..d0241f567 100644 --- a/src/SPC/util/executor/UnixCMakeExecutor.php +++ b/src/SPC/util/executor/UnixCMakeExecutor.php @@ -183,6 +183,7 @@ private function makeCmakeToolchainFile(): string $cflags = getenv('SPC_DEFAULT_C_FLAGS'); $cc = getenv('CC'); $cxx = getenv('CCX'); + $include = BUILD_INCLUDE_PATH; logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'"); $root = BUILD_ROOT_PATH; $pkgConfigExecutable = PkgConfigUtil::findPkgConfig(); @@ -210,6 +211,8 @@ private function makeCmakeToolchainFile(): string set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "{$include}") +set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "{$include}") set(CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread -lm -lutil") CMAKE; // Whoops, linux may need CMAKE_AR sometimes diff --git a/src/StaticPHP/Artifact/Artifact.php b/src/StaticPHP/Artifact/Artifact.php index 0b5d8a6de..e241d4fe8 100644 --- a/src/StaticPHP/Artifact/Artifact.php +++ b/src/StaticPHP/Artifact/Artifact.php @@ -347,7 +347,11 @@ public function getSourceRoot(): string public function getBinaryExtractConfig(array $cache_info = []): array { if (is_string($cache_info['extract'] ?? null)) { - return ['path' => $this->replaceExtractPathVariables($cache_info['extract']), 'mode' => 'standard']; + $cache_extract = $cache_info['extract']; + if ($cache_extract === 'hosted') { + return ['path' => BUILD_ROOT_PATH, 'mode' => 'standard']; + } + return ['path' => $this->replaceExtractPathVariables($cache_extract), 'mode' => 'standard']; } $platform = SystemTarget::getCurrentPlatformString(); diff --git a/src/StaticPHP/Command/MicroCombineCommand.php b/src/StaticPHP/Command/MicroCombineCommand.php new file mode 100644 index 000000000..b46d995f7 --- /dev/null +++ b/src/StaticPHP/Command/MicroCombineCommand.php @@ -0,0 +1,120 @@ +addArgument('file', InputArgument::REQUIRED, 'The php or phar file to be combined'); + $this->addOption('with-micro', 'M', InputOption::VALUE_REQUIRED, 'Customize your micro.sfx file'); + $this->addOption('with-ini-set', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'ini to inject into micro.sfx when combining'); + $this->addOption('with-ini-file', 'N', InputOption::VALUE_REQUIRED, 'ini file to inject into micro.sfx when combining'); + $this->addOption('output', 'O', InputOption::VALUE_REQUIRED, 'Customize your output binary file name'); + } + + public function handle(): int + { + // 0. Initialize path variables + $internal = FileSystem::convertPath(BUILD_ROOT_PATH . '/bin/micro.sfx'); + $micro_file = $this->getOption('with-micro'); + $file = $this->getArgument('file'); + $ini_set = $this->getOption('with-ini-set'); + $ini_file = $this->getOption('with-ini-file'); + $target_ini = []; + $output = $this->getOption('output') ?? 'my-app'; + $ini_part = ''; + // 1. Make sure specified micro.sfx file exists + if ($micro_file !== null && !file_exists($micro_file)) { + $this->output->writeln('The micro.sfx file you specified is incorrect or does not exist!'); + return static::FAILURE; + } + // 2. Make sure buildroot/bin/micro.sfx exists + if ($micro_file === null && !file_exists($internal)) { + $this->output->writeln('You haven\'t compiled micro.sfx yet, please use "build" command and "--build-micro" to compile phpmicro first!'); + return static::FAILURE; + } + // 3. Use buildroot/bin/micro.sfx + if ($micro_file === null) { + $micro_file = $internal; + } + // 4. Make sure php or phar file exists + if (!is_file(FileSystem::convertPath($file))) { + $this->output->writeln('The file to combine does not exist!'); + return static::FAILURE; + } + // 5. Confirm ini files (ini-set has higher priority) + if ($ini_file !== null) { + // Check file exist first + if (!file_exists($ini_file)) { + $this->output->writeln('The ini file to combine does not exist! (' . $ini_file . ')'); + return static::FAILURE; + } + $arr = parse_ini_file($ini_file); + if ($arr === false) { + $this->output->writeln('Cannot parse ini file'); + return static::FAILURE; + } + $target_ini = array_merge($target_ini, $arr); + } + // 6. Confirm ini sets + if ($ini_set !== []) { + foreach ($ini_set as $item) { + $arr = parse_ini_string($item); + if ($arr === false) { + $this->output->writeln('--with-ini-set parse failed'); + return static::FAILURE; + } + $target_ini = array_merge($target_ini, $arr); + } + } + // 7. Generate ini injection parts + if (!empty($target_ini)) { + $ini_str = $this->encodeINI($target_ini); + logger()->debug('Injecting ini parts: ' . PHP_EOL . $ini_str); + $ini_part = "\xfd\xf6\x69\xe6"; + $ini_part .= pack('N', strlen($ini_str)); + $ini_part .= $ini_str; + } + // 8. Combine ! + $output = FileSystem::isRelativePath($output) ? (WORKING_DIR . '/' . $output) : $output; + $file_target = file_get_contents($micro_file) . $ini_part . file_get_contents($file); + if (PHP_OS_FAMILY === 'Windows' && !str_ends_with(strtolower($output), '.exe')) { + $output .= '.exe'; + } + $output = FileSystem::convertPath($output); + $result = file_put_contents($output, $file_target); + if ($result === false) { + $this->output->writeln('Combine failed.'); + return static::FAILURE; + } + // 9. chmod +x + chmod($output, 0755); + $this->output->writeln('Combine success! Binary file: ' . $output . ''); + return static::SUCCESS; + } + + private function encodeINI(array $array): string + { + $res = []; + foreach ($array as $key => $val) { + if (is_array($val)) { + $res[] = "[{$key}]"; + foreach ($val as $skey => $sval) { + $res[] = "{$skey}=" . (is_numeric($sval) ? $sval : '"' . $sval . '"'); + } + } else { + $res[] = "{$key}=" . (is_numeric($val) ? $val : '"' . $val . '"'); + } + } + return implode("\n", $res); + } +} diff --git a/src/StaticPHP/Command/ResetCommand.php b/src/StaticPHP/Command/ResetCommand.php index 4a55f792a..207f6484e 100644 --- a/src/StaticPHP/Command/ResetCommand.php +++ b/src/StaticPHP/Command/ResetCommand.php @@ -4,6 +4,7 @@ namespace StaticPHP\Command; +use StaticPHP\Runtime\Shell\Shell; use StaticPHP\Util\FileSystem; use StaticPHP\Util\InteractiveTerm; use Symfony\Component\Console\Attribute\AsCommand; @@ -87,20 +88,24 @@ private function removeDirectoryWindows(string $path): void // Try using PowerShell for force deletion $escaped_path = escapeshellarg($path); + Shell::passthruCallback(fn () => InteractiveTerm::advance()); // Use PowerShell Remove-Item with -Force and -Recurse - $ps_cmd = "powershell -Command \"Remove-Item -Path {$escaped_path} -Recurse -Force -ErrorAction SilentlyContinue\""; - f_exec($ps_cmd, $output, $ret_code); - + $result = cmd()->execWithResult("powershell -Command \"Remove-Item -Path {$escaped_path} -Recurse -Force -ErrorAction SilentlyContinue\"", false); + $ret_code = $result[0]; // If PowerShell fails or directory still exists, try cmd rmdir if ($ret_code !== 0 || is_dir($path)) { $cmd_command = "rmdir /s /q {$escaped_path}"; - f_exec($cmd_command, $output, $ret_code); + $result = cmd()->execWithResult($cmd_command, false); + if ($result[0] === 0) { + return; + } } // Final fallback: use FileSystem::removeDir if (is_dir($path)) { FileSystem::removeDir($path); } + Shell::passthruCallback(null); } } diff --git a/src/StaticPHP/Config/ArtifactConfig.php b/src/StaticPHP/Config/ArtifactConfig.php index e3e59fb55..8462091d1 100644 --- a/src/StaticPHP/Config/ArtifactConfig.php +++ b/src/StaticPHP/Config/ArtifactConfig.php @@ -42,13 +42,20 @@ public static function loadFromFile(string $file, string $registry_name): string if ($content === false) { throw new WrongUsageException("Failed to read artifact config file: {$file}"); } - $data = match (pathinfo($file, PATHINFO_EXTENSION)) { - 'json' => json_decode($content, true), - 'yml', 'yaml' => Yaml::parse($content), - default => throw new WrongUsageException("Unsupported artifact config file format: {$file}"), - }; - if (!is_array($data)) { - throw new WrongUsageException("Invalid JSON format in artifact config file: {$file}"); + // use cache to skip redundant parsing + $data = ConfigCache::get($content); + if ($data !== null) { + logger()->debug("Config cache hit: {$file}"); + } else { + $data = match (pathinfo($file, PATHINFO_EXTENSION)) { + 'json' => json_decode($content, true), + 'yml', 'yaml' => extension_loaded('yaml') ? yaml_parse($content) : Yaml::parse($content), + default => throw new WrongUsageException("Unsupported artifact config file format: {$file}"), + }; + if (!is_array($data)) { + throw new WrongUsageException("Invalid JSON format in artifact config file: {$file}"); + } + ConfigCache::set($content, $data); } ConfigValidator::validateAndLintArtifacts(basename($file), $data); foreach ($data as $artifact_name => $config) { @@ -68,6 +75,16 @@ public static function getAll(): array return self::$artifact_configs; } + /** + * Restore artifact configs from cache without re-parsing YAML files. + * + * @internal used by Registry cache layer only + */ + public static function _restoreFromCache(array $configs): void + { + self::$artifact_configs = array_merge(self::$artifact_configs, $configs); + } + /** * Get the configuration for a specific artifact by name. * diff --git a/src/StaticPHP/Config/ConfigCache.php b/src/StaticPHP/Config/ConfigCache.php new file mode 100644 index 000000000..a81879572 --- /dev/null +++ b/src/StaticPHP/Config/ConfigCache.php @@ -0,0 +1,67 @@ +/.spc.cache.php (plain PHP, var_export'd array). + * Written once on shutdown when any new entry was added. + */ +class ConfigCache +{ + private static ?array $cache = null; + + private static bool $dirty = false; + + /** + * Return the cached parsed result for $content, or null on miss. + */ + public static function get(string $content): ?array + { + self::load(); + return self::$cache[$content] ?? null; + } + + /** + * Store a parsed result. Will be persisted to disk on shutdown. + */ + public static function set(string $content, array $data): void + { + self::load(); + self::$cache[$content] = $data; + self::$dirty = true; + } + + /** + * Write cache to disk if anything changed. Called automatically on shutdown. + */ + public static function flush(): void + { + if (!self::$dirty) { + return; + } + file_put_contents(self::cachePath(), ' ConfigType::BOOL, 'notes' => ConfigType::BOOL, 'display-name' => ConfigType::STRING, + 'os' => ConfigType::LIST_ARRAY, // library and target fields 'headers' => ConfigType::LIST_ARRAY, // @ @@ -88,6 +89,7 @@ class ConfigValidator 'build-with-php' => false, 'notes' => false, 'display-name' => false, + 'os' => false, ]; public const array ARTIFACT_TYPE_FIELDS = [ // [required_fields, optional_fields] diff --git a/src/StaticPHP/Config/PackageConfig.php b/src/StaticPHP/Config/PackageConfig.php index 0e2d0af1c..e4474bf58 100644 --- a/src/StaticPHP/Config/PackageConfig.php +++ b/src/StaticPHP/Config/PackageConfig.php @@ -50,12 +50,20 @@ public static function loadFromFile(string $file, string $registry_name): string if ($content === false) { throw new WrongUsageException("Failed to read package config file: {$file}"); } - // judge extension - $data = match (pathinfo($file, PATHINFO_EXTENSION)) { - 'json' => json_decode($content, true), - 'yml', 'yaml' => Yaml::parse($content), - default => throw new WrongUsageException("Unsupported package config file format: {$file}"), - }; + // judge extension — use cache to skip redundant parsing + $data = ConfigCache::get($content); + if ($data !== null) { + logger()->debug("Config cache hit: {$file}"); + } else { + $data = match (pathinfo($file, PATHINFO_EXTENSION)) { + 'json' => json_decode($content, true), + 'yml', 'yaml' => extension_loaded('yaml') ? yaml_parse($content) : Yaml::parse($content), + default => throw new WrongUsageException("Unsupported package config file format: {$file}"), + }; + if (is_array($data)) { + ConfigCache::set($content, $data); + } + } ConfigValidator::validateAndLintPackages(basename($file), $data); foreach ($data as $pkg_name => $config) { self::$package_configs[$pkg_name] = $config; diff --git a/src/StaticPHP/ConsoleApplication.php b/src/StaticPHP/ConsoleApplication.php index a02b38c7d..0c8fec832 100644 --- a/src/StaticPHP/ConsoleApplication.php +++ b/src/StaticPHP/ConsoleApplication.php @@ -20,6 +20,7 @@ use StaticPHP\Command\DumpLicenseCommand; use StaticPHP\Command\ExtractCommand; use StaticPHP\Command\InstallPackageCommand; +use StaticPHP\Command\MicroCombineCommand; use StaticPHP\Command\ResetCommand; use StaticPHP\Command\SPCConfigCommand; use StaticPHP\Package\TargetPackage; @@ -29,7 +30,7 @@ class ConsoleApplication extends Application { - public const string VERSION = '3.0.0-dev'; + public const string VERSION = '3.0.0-alpha1'; private static array $additional_commands = []; @@ -65,6 +66,7 @@ public function __construct() new DumpLicenseCommand(), new ResetCommand(), new CheckUpdateCommand(), + new MicroCombineCommand(), // dev commands new ShellCommand(), diff --git a/src/StaticPHP/Package/PackageBuilder.php b/src/StaticPHP/Package/PackageBuilder.php index e50798adc..5138582fb 100644 --- a/src/StaticPHP/Package/PackageBuilder.php +++ b/src/StaticPHP/Package/PackageBuilder.php @@ -145,7 +145,7 @@ public function deployBinary(string $src, string $dst, bool $executable = true): shell()->exec(getenv('UPX_EXEC') . " --best {$dst}"); } elseif ($upx_option && SystemTarget::getTargetOS() === 'Windows' && $executable) { logger()->info("Compressing {$dst} with UPX"); - shell()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($dst)); + cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($dst)); } return $dst; diff --git a/src/StaticPHP/Package/PackageInstaller.php b/src/StaticPHP/Package/PackageInstaller.php index 16e8f45a9..ac4aa2e01 100644 --- a/src/StaticPHP/Package/PackageInstaller.php +++ b/src/StaticPHP/Package/PackageInstaller.php @@ -301,6 +301,32 @@ public function isPackageResolved(string $package_name): bool return isset($this->packages[$package_name]); } + /** + * Get resolved package names filtered to only packages whose build artifacts are available. + * This excludes library packages that haven't been built/installed yet, which naturally + * prevents SPCConfigUtil from checking static-lib files of libraries that come after + * the current target in the build order (e.g. 'watcher' for frankenphp isn't built + * when 'php' is being compiled). + * + * @return string[] Available resolved package names + */ + public function getAvailableResolvedPackageNames(): array + { + return array_values(array_filter( + array_keys($this->packages), + function (string $name): bool { + $pkg = $this->packages[$name] ?? null; + // Exclude library packages whose build artifacts don't exist yet. + // Extensions and targets are not filtered — extensions are compiled into PHP + // and don't have standalone build artifacts. + if ($pkg instanceof LibraryPackage && $pkg->getType() === 'library' && !$pkg->isInstalled()) { + return false; + } + return true; + } + )); + } + public function isPackageInstalled(Package|string $package_name): bool { if (empty($this->packages)) { @@ -729,6 +755,14 @@ private function printArrayInfo(array $info): void private function validatePackagesBeforeBuild(): void { foreach ($this->packages as $package) { + // Check OS support for php-extension packages + if ($package instanceof PhpExtensionPackage && !$package->isSupportedOnCurrentOS()) { + $supported = implode(', ', $package->getSupportedOSList()); + throw new WrongUsageException( + "Extension '{$package->getName()}' is not supported on current OS: " . SystemTarget::getTargetOS() . + ". Supported OS: [{$supported}]" + ); + } if ($package->getType() !== 'library') { continue; } diff --git a/src/StaticPHP/Package/PhpExtensionPackage.php b/src/StaticPHP/Package/PhpExtensionPackage.php index baaa27531..6ee1edf55 100644 --- a/src/StaticPHP/Package/PhpExtensionPackage.php +++ b/src/StaticPHP/Package/PhpExtensionPackage.php @@ -61,6 +61,28 @@ public function getExtensionName(): string return str_replace('ext-', '', $this->getName()); } + /** + * Get the list of OS platforms that this extension supports. + * Returns an empty array if no restriction is defined (all platforms supported). + */ + public function getSupportedOSList(): array + { + return $this->extension_config['os'] ?? []; + } + + /** + * Check if this extension is supported on the current target OS. + * Returns true if no 'os' restriction is defined, or if the current OS is in the list. + */ + public function isSupportedOnCurrentOS(): bool + { + $osList = $this->getSupportedOSList(); + if (empty($osList)) { + return true; + } + return in_array(SystemTarget::getTargetOS(), $osList, true); + } + public function addCustomPhpConfigureArgCallback(string $os, callable $fn): void { if ($os === '') { @@ -155,6 +177,43 @@ public function getDistName(): string return $this->extension_config['display-name'] ?? $this->getExtensionName(); } + /** + * Run smoke test for the extension on Unix CLI. + * Override this method in a subclass. + */ + public function runSmokeTestCliWindows(): void + { + if (($this->extension_config['smoke-test'] ?? true) === false) { + return; + } + + $distName = $this->getDistName(); + // empty display-name → no --ri check (e.g. password_argon2) + if ($distName === '') { + return; + } + + [$ret] = cmd()->execWithResult(BUILD_BIN_PATH . '\php.exe -n --ri "' . $distName . '"', false); + if ($ret !== 0) { + throw new ValidationException( + "extension {$this->getName()} failed compile check: php-cli returned {$ret}", + validation_module: 'Extension ' . $this->getName() . ' sanity check' + ); + } + + $test_file = ROOT_DIR . '/src/globals/ext-tests/' . $this->getExtensionName() . '.php'; + if (file_exists($test_file)) { + $test = self::escapeInlineTestWindows(file_get_contents($test_file)); + [$ret, $out] = cmd()->execWithResult(BUILD_BIN_PATH . '\php.exe -n -r "' . trim($test) . '"'); + if ($ret !== 0) { + throw new ValidationException( + "extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out), + validation_module: 'Extension ' . $this->getName() . ' function check' + ); + } + } + } + /** * Run smoke test for the extension on Unix CLI. * Override this method in a subclass. @@ -394,4 +453,17 @@ private static function escapeInlineTest(string $code): string $code ); } + + /** + * Escape PHP test file content for inline `-r` usage on Windows cmd. + * Strips json_decode($yaml, true), - 'yaml', 'yml' => Yaml::parse($yaml), + 'yaml', 'yml' => extension_loaded('yaml') ? yaml_parse($yaml) : Yaml::parse($yaml), default => throw new RegistryException("Unsupported registry file format: {$registry_file}"), }; if (!is_array($data)) { diff --git a/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php b/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php index 9442d30c2..1ddacb03b 100644 --- a/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php +++ b/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php @@ -10,10 +10,13 @@ use StaticPHP\Package\LibraryPackage; use StaticPHP\Package\PackageBuilder; use StaticPHP\Package\PackageInstaller; +use StaticPHP\Package\TargetPackage; use StaticPHP\Runtime\Shell\UnixShell; +use StaticPHP\Runtime\SystemTarget; use StaticPHP\Util\FileSystem; use StaticPHP\Util\InteractiveTerm; use StaticPHP\Util\PkgConfigUtil; +use StaticPHP\Util\SPCConfigUtil; use ZM\Logger\ConsoleColor; /** @@ -214,7 +217,7 @@ public function getConfigureArgsString(): string */ private function getDefaultCMakeArgs(): array { - return $this->custom_default_args ?? [ + $args = $this->custom_default_args ?? [ '-DCMAKE_BUILD_TYPE=Release', "-DCMAKE_INSTALL_PREFIX={$this->package->getBuildRootPath()}", '-DCMAKE_INSTALL_BINDIR=bin', @@ -224,6 +227,20 @@ private function getDefaultCMakeArgs(): array '-DBUILD_SHARED_LIBS=OFF', "-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}", ]; + + // EXE linker flags: base system libs + framework flags for target packages + $exeLinkerFlags = SystemTarget::getRuntimeLibs(); + if ($this->package instanceof TargetPackage) { + $resolvedNames = array_keys($this->installer->getResolvedPackages()); + $resolvedNames[] = $this->package->getName(); + $fwFlags = new SPCConfigUtil()->getFrameworksString($resolvedNames); + if ($fwFlags !== '') { + $exeLinkerFlags .= " {$fwFlags}"; + } + } + $args[] = "-DCMAKE_EXE_LINKER_FLAGS=\"{$exeLinkerFlags}\""; + + return $args; } /** @@ -253,6 +270,7 @@ private function makeCmakeToolchainFile(): string $cflags = getenv('SPC_DEFAULT_C_FLAGS'); $cc = getenv('CC'); $cxx = getenv('CXX'); + $include = BUILD_INCLUDE_PATH; logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'"); $root = BUILD_ROOT_PATH; $pkgConfigExecutable = PkgConfigUtil::findPkgConfig(); @@ -274,13 +292,15 @@ private function makeCmakeToolchainFile(): string SET(CMAKE_INSTALL_PREFIX "{$root}") SET(CMAKE_INSTALL_LIBDIR "lib") -set(PKG_CONFIG_EXECUTABLE "{$pkgConfigExecutable}") +set(PKG_CONFIG_EXECUTABLE "{$pkgConfigExecutable}" CACHE FILEPATH "pkg-config executable" FORCE) set(PKG_CONFIG_ARGN "--static" CACHE STRING "Extra arguments for pkg-config" FORCE) +set(ENV{PKG_CONFIG_PATH} "{$root}/lib/pkgconfig") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -set(CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread -lm -lutil") +set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "{$include}") +set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "{$include}") CMAKE; // Whoops, linux may need CMAKE_AR sometimes if (PHP_OS_FAMILY === 'Linux') { diff --git a/src/StaticPHP/Runtime/Shell/DefaultShell.php b/src/StaticPHP/Runtime/Shell/DefaultShell.php index 272011e49..8f77f62d7 100644 --- a/src/StaticPHP/Runtime/Shell/DefaultShell.php +++ b/src/StaticPHP/Runtime/Shell/DefaultShell.php @@ -133,7 +133,7 @@ public function executeTarExtract(string $archive_path, string $target_path, str }; $mute = $this->console_putput ? '' : ' 2>/dev/null'; - $tar = SystemTarget::isUnix() ? 'tar' : '"C:\\Windows\\system32\\tar.exe"'; + $tar = SystemTarget::isUnix() ? 'tar' : '"C:\Windows\system32\tar.exe"'; $cmd = "{$tar} {$compression_flag}xf {$archive_arg} --strip-components {$strip} -C {$target_arg}{$mute}"; $this->logCommandInfo($cmd); @@ -187,7 +187,7 @@ public function execute7zExtract(string $archive_path, string $target_path): boo }; $extname = FileSystem::extname($archive_path); - $tar = SystemTarget::isUnix() ? 'tar' : '"C:\\Windows\\system32\\tar.exe"'; + $tar = SystemTarget::isUnix() ? 'tar' : '"C:\Windows\system32\tar.exe"'; match ($extname) { 'tar' => $this->executeTarExtract($archive_path, $target_path, 'none'), diff --git a/src/StaticPHP/Runtime/Shell/WindowsCmd.php b/src/StaticPHP/Runtime/Shell/WindowsCmd.php index e9d7a6c0d..ad07f93bd 100644 --- a/src/StaticPHP/Runtime/Shell/WindowsCmd.php +++ b/src/StaticPHP/Runtime/Shell/WindowsCmd.php @@ -44,8 +44,10 @@ public function execWithResult(string $cmd, bool $with_log = true): array } else { logger()->debug('Running command with result: ' . $cmd); } + $original_command = $cmd; + $this->logCommandInfo($original_command); $cmd = $this->getExecString($cmd); - $result = $this->passthru($cmd, $this->console_putput, $cmd, capture_output: true, throw_on_error: false, cwd: $this->cd, env: $this->env); + $result = $this->passthru($cmd, $this->console_putput, $original_command, capture_output: true, throw_on_error: false, cwd: $this->cd, env: $this->env); $out = explode("\n", $result['output']); return [$result['code'], $out]; } diff --git a/src/StaticPHP/Util/FileSystem.php b/src/StaticPHP/Util/FileSystem.php index 38a614e01..cbb466030 100644 --- a/src/StaticPHP/Util/FileSystem.php +++ b/src/StaticPHP/Util/FileSystem.php @@ -120,7 +120,7 @@ public static function copyDir(string $from, string $to): void $src_path = FileSystem::convertPath($from); switch (PHP_OS_FAMILY) { case 'Windows': - cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/v/y/i'); + cmd(false)->exec('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/y/i'); break; case 'Linux': case 'Darwin': @@ -493,6 +493,44 @@ public static function fullpath(string $path, string $relative_path_base): strin return FileSystem::convertPath($path); } + /** + * Move file or directory, handling cross-device scenarios + * Uses rename() if possible, falls back to copy+delete for cross-device moves + * + * @param string $source Source path + * @param string $dest Destination path + */ + public static function moveFileOrDir(string $source, string $dest): void + { + $source = FileSystem::convertPath($source); + $dest = FileSystem::convertPath($dest); + + // Check if source and dest are on the same device to avoid cross-device rename errors + $source_stat = @stat($source); + $dest_parent = dirname($dest); + $dest_stat = @stat($dest_parent); + + // Only use rename if on same device + if ($source_stat !== false && $dest_stat !== false && $source_stat['dev'] === $dest_stat['dev']) { + if (@rename($source, $dest)) { + return; + } + } + + // Fall back to copy + delete for cross-device moves or if rename failed + if (is_dir($source)) { + FileSystem::copyDir($source, $dest); + FileSystem::removeDir($source); + } else { + if (!copy($source, $dest)) { + throw new FileSystemException("Failed to copy file from {$source} to {$dest}"); + } + if (!unlink($source)) { + throw new FileSystemException("Failed to remove source file: {$source}"); + } + } + } + private static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): false|int { logger()->debug('Replacing file with type[' . $replace_type . ']: ' . $filename); diff --git a/src/StaticPHP/Util/SPCConfigUtil.php b/src/StaticPHP/Util/SPCConfigUtil.php index 8b6fe6b37..63b0e90ef 100644 --- a/src/StaticPHP/Util/SPCConfigUtil.php +++ b/src/StaticPHP/Util/SPCConfigUtil.php @@ -62,8 +62,16 @@ public function config(array $packages = [], bool $include_suggests = false): ar } // C++ if ($this->hasCpp($resolved)) { - $libcpp = SystemTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; - $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + $target_os = SystemTarget::getTargetOS(); + if ($target_os === 'Darwin') { + $libcpp = '-lc++'; + $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + } elseif ($target_os !== 'Windows') { + // Linux and other Unix-like systems use libstdc++ + $libcpp = '-lstdc++'; + $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + } + // Windows (MSVC): C++ runtime is linked automatically, no explicit lib needed } if ($this->libs_only_deps) { @@ -80,7 +88,16 @@ public function config(array $packages = [], bool $include_suggests = false): ar // embed if (!$this->no_php) { - $libs = "-lphp {$libs} -lc"; + if (SystemTarget::getTargetOS() === 'Windows') { + // Windows: use php8embed.lib directly (either full path or short name) + $major = intdiv(PHP_VERSION_ID, 10000); + $php_lib = $this->absolute_libs ? BUILD_LIB_PATH . "\\php{$major}embed.lib" : "php{$major}embed.lib"; + // Windows system libs required by PHP + // Use same system libs as PHP Makefile: LIBS=kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib + $libs = "{$php_lib} {$libs} kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib dnsapi.lib psapi.lib bcrypt.lib"; + } else { + $libs = "-lphp {$libs} -lc"; + } } $allLibs = getenv('LIBS') . ' ' . $libs; @@ -225,8 +242,16 @@ public function configWithResolvedPackages(array $resolved_packages): array // C++ if ($this->hasCpp($resolved_packages)) { - $libcpp = SystemTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; - $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + $target_os = SystemTarget::getTargetOS(); + if ($target_os === 'Darwin') { + $libcpp = '-lc++'; + $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + } elseif ($target_os !== 'Windows') { + // Linux and other Unix-like systems use libstdc++ + $libcpp = '-lstdc++'; + $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; + } + // Windows (MSVC): C++ runtime is linked automatically, no explicit lib needed } if ($this->libs_only_deps) { @@ -260,6 +285,20 @@ public function configWithResolvedPackages(array $resolved_packages): array ]; } + public function getFrameworksString(array $extensions): string + { + $list = []; + foreach ($extensions as $extension) { + foreach (PackageConfig::get($extension, 'frameworks', []) as $fw) { + $ks = '-framework ' . $fw; + if (!in_array($ks, $list)) { + $list[] = $ks; + } + } + } + return implode(' ', $list); + } + private function hasCpp(array $packages): bool { foreach ($packages as $package) { @@ -274,45 +313,65 @@ private function hasCpp(array $packages): bool private function getIncludesString(array $packages): string { $base = BUILD_INCLUDE_PATH; - $includes = ["-I{$base}"]; - // link with libphp - if (!$this->no_php) { - $includes = [ - ...$includes, - "-I{$base}/php", - "-I{$base}/php/main", - "-I{$base}/php/TSRM", - "-I{$base}/php/Zend", - "-I{$base}/php/ext", - ]; + // Windows MSVC uses /I flag instead of -I + if (SystemTarget::getTargetOS() === 'Windows') { + $includes = ["/I\"{$base}\""]; + + // link with libphp + if (!$this->no_php) { + $includes = [ + ...$includes, + "/I\"{$base}\\php\"", + "/I\"{$base}\\php\\main\"", + "/I\"{$base}\\php\\TSRM\"", + "/I\"{$base}\\php\\Zend\"", + "/I\"{$base}\\php\\ext\"", + ]; + } + } else { + $includes = ["-I{$base}"]; + + // link with libphp + if (!$this->no_php) { + $includes = [ + ...$includes, + "-I{$base}/php", + "-I{$base}/php/main", + "-I{$base}/php/TSRM", + "-I{$base}/php/Zend", + "-I{$base}/php/ext", + ]; + } } - // parse pkg-configs - foreach ($packages as $package) { - $pc = PackageConfig::get($package, 'pkg-configs', []); - $pkg_config_path = getenv('PKG_CONFIG_PATH') ?: ''; - $search_paths = array_filter(explode(SystemTarget::isUnix() ? ':' : ';', $pkg_config_path)); - foreach ($pc as $file) { - $found = false; - foreach ($search_paths as $path) { - if (file_exists($path . "/{$file}.pc")) { - $found = true; - break; + // parse pkg-configs (only for Unix) + if (SystemTarget::isUnix()) { + foreach ($packages as $package) { + $pc = PackageConfig::get($package, 'pkg-configs', []); + $pkg_config_path = getenv('PKG_CONFIG_PATH') ?: ''; + $search_paths = array_filter(explode(':', $pkg_config_path)); + foreach ($pc as $file) { + $found = false; + foreach ($search_paths as $path) { + if (file_exists($path . "/{$file}.pc")) { + $found = true; + break; + } + } + if (!$found) { + throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$package}] does not exist. Please build it first."); } } - if (!$found) { - throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$package}] does not exist. Please build it first."); + $pc_cflags = implode(' ', $pc); + if ($pc_cflags !== '' && ($pc_cflags = PkgConfigUtil::getCflags($pc_cflags)) !== '') { + $arr = explode(' ', $pc_cflags); + $arr = array_unique($arr); + $arr = array_filter($arr, fn ($x) => !str_starts_with($x, 'SHELL:-Xarch_')); + $pc_cflags = implode(' ', $arr); + $includes[] = $pc_cflags; } } - $pc_cflags = implode(' ', $pc); - if ($pc_cflags !== '' && ($pc_cflags = PkgConfigUtil::getCflags($pc_cflags)) !== '') { - $arr = explode(' ', $pc_cflags); - $arr = array_unique($arr); - $arr = array_filter($arr, fn ($x) => !str_starts_with($x, 'SHELL:-Xarch_')); - $pc_cflags = implode(' ', $arr); - $includes[] = $pc_cflags; - } } $includes = array_unique($includes); return implode(' ', $includes); @@ -320,6 +379,10 @@ private function getIncludesString(array $packages): string private function getLdflagsString(): string { + // Windows MSVC uses /LIBPATH flag instead of -L + if (SystemTarget::getTargetOS() === 'Windows') { + return '/LIBPATH:"' . BUILD_LIB_PATH . '"'; + } return '-L' . BUILD_LIB_PATH; } @@ -401,15 +464,38 @@ private function getLibsString(array $packages, bool $use_short_libs = true): st private function getShortLibName(string $lib): string { + // Windows: library files are xxx.lib format (not libxxx.a) + if (SystemTarget::getTargetOS() === 'Windows') { + if (!str_ends_with($lib, '.lib')) { + return BUILD_LIB_PATH . '\\' . $lib; + } + // For Windows, return just the library filename (e.g., "libssl.lib") + return $lib; + } + + // Unix: library files are libxxx.a format if (!str_starts_with($lib, 'lib') || !str_ends_with($lib, '.a')) { return BUILD_LIB_PATH . '/' . $lib; } - // get short name + // get short name (e.g., "libssl.a" -> "-lssl") return '-l' . substr($lib, 3, -2); } private function getFullLibName(string $lib): string { + // Windows: libraries don't use -l prefix, return as-is or with full path + if (SystemTarget::getTargetOS() === 'Windows') { + if (str_ends_with($lib, '.lib') && !str_contains($lib, '\\') && !str_contains($lib, '/')) { + // It's a short lib name like "libssl.lib", convert to full path + $fullPath = BUILD_LIB_PATH . '\\' . $lib; + if (file_exists($fullPath)) { + return $fullPath; + } + } + return $lib; + } + + // Unix: convert -lxxx to full path if (!str_starts_with($lib, '-l')) { return $lib; } @@ -420,18 +506,4 @@ private function getFullLibName(string $lib): string } return $lib; } - - private function getFrameworksString(array $extensions): string - { - $list = []; - foreach ($extensions as $extension) { - foreach (PackageConfig::get($extension, 'frameworks', []) as $fw) { - $ks = '-framework ' . $fw; - if (!in_array($ks, $list)) { - $list[] = $ks; - } - } - } - return implode(' ', $list); - } } diff --git a/src/StaticPHP/Util/SourcePatcher.php b/src/StaticPHP/Util/SourcePatcher.php index b4e2e1c7b..70525e67f 100644 --- a/src/StaticPHP/Util/SourcePatcher.php +++ b/src/StaticPHP/Util/SourcePatcher.php @@ -196,6 +196,22 @@ public static function unpatchMicroPhar(): void FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); } + public static function patchMicroWin32(): void + { + // patch micro win32 + if (!file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) { + copy(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak'); + FileSystem::replaceFileStr(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', '#include "php_variables.h"', '#include "php_variables.h"' . "\n#define PHP_MICRO_WIN32_NO_CONSOLE 1"); + } + } + + public static function unpatchMicroWin32(): void + { + if (file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) { + rename(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c'); + } + } + public static function patchPhpSrc(?array $items = null): bool { $patch_dir = ROOT_DIR . '/src/globals/patch/php-src-patches'; diff --git a/src/StaticPHP/Util/System/WindowsUtil.php b/src/StaticPHP/Util/System/WindowsUtil.php index b6d943be4..150730c0a 100644 --- a/src/StaticPHP/Util/System/WindowsUtil.php +++ b/src/StaticPHP/Util/System/WindowsUtil.php @@ -138,6 +138,28 @@ public static function writeCmakeFindModules(): void FileSystem::writeFile($cmake_find_dir . DIRECTORY_SEPARATOR . 'FindOpenSSL.cmake', <<<'CMAKE' # Custom FindOpenSSL.cmake wrapper for static-php-cli Windows builds. +set(_spc_saved_module_path "${CMAKE_MODULE_PATH}") +list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +set(_spc_find_args "") +if(OpenSSL_FIND_VERSION) + list(APPEND _spc_find_args "${OpenSSL_FIND_VERSION}") + if(OpenSSL_FIND_VERSION_EXACT) + list(APPEND _spc_find_args EXACT) + endif() +endif() +if(OpenSSL_FIND_REQUIRED) + list(APPEND _spc_find_args REQUIRED) +endif() +if(OpenSSL_FIND_QUIETLY) + list(APPEND _spc_find_args QUIET) +endif() +find_package(OpenSSL ${_spc_find_args}) +unset(_spc_find_args) + +set(CMAKE_MODULE_PATH "${_spc_saved_module_path}") +unset(_spc_saved_module_path) + if(WIN32 AND (OpenSSL_FOUND OR OPENSSL_FOUND)) list(GET CMAKE_FIND_ROOT_PATH 0 _spc_buildroot) # Normalize to forward slashes — backslash paths cause 'Invalid character diff --git a/src/globals/ext-tests/openssl.php b/src/globals/ext-tests/openssl.php index c687d0fc7..117231604 100644 --- a/src/globals/ext-tests/openssl.php +++ b/src/globals/ext-tests/openssl.php @@ -31,6 +31,6 @@ } assert($valid); } -if (PHP_VERSION_ID >= 80500 && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) { +if (PHP_VERSION_ID >= 80500 && (!PHP_ZTS || PHP_OS_FAMILY !== 'Windows') && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) { assert(function_exists('openssl_password_hash')); } diff --git a/src/globals/extra/gd_config_85.w32 b/src/globals/extra/gd_config_85.w32 new file mode 100644 index 000000000..e980b003e --- /dev/null +++ b/src/globals/extra/gd_config_85.w32 @@ -0,0 +1,94 @@ +// vim:ft=javascript + +ARG_WITH("gd", "Bundled GD support", "yes"); + +if (PHP_GD != "no") { + // check for gd.h (required) + if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) { + ERROR("gd not enabled; libraries and headers not found"); + } + + // zlib ext support (required) + if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) { + ERROR("gd not enabled; zlib not enabled"); + } + + // libjpeg lib support + if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) { + AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support"); + AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support"); + } + + // libpng16 lib support + if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) { + AC_DEFINE("HAVE_LIBPNG", 1, "PNG support"); + AC_DEFINE("HAVE_GD_PNG", 1, "PNG support"); + } + + // freetype lib support + if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) { + AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support"); + AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support"); + } + + // xpm lib support + if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) { + AC_DEFINE("HAVE_LIBXPM", 1, "XPM support"); + AC_DEFINE("HAVE_GD_XPM", 1, "XPM support"); + } + + // iconv lib support + if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) && + CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) { + AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support"); + } + + // libwebp lib support + if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) && + CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") && + CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) { + AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support"); + AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support"); + } + + // libavif lib support + if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) && + CHECK_LIB("aom_a.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) { + ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF"); + } else if (CHECK_LIB("avif.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) { + ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF"); + } + + CHECK_LIB("User32.lib", "gd", PHP_GD); + CHECK_LIB("Gdi32.lib", "gd", PHP_GD); + + EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd"); + ADD_SOURCES("ext/gd/libgd", "gd.c \ + gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \ + gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \ + gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \ + gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \ + gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \ + gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); + + AC_DEFINE('HAVE_LIBGD', 1, 'GD support'); + AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD"); + AC_DEFINE('HAVE_GD_BMP', 1, "BMP support"); + AC_DEFINE('HAVE_GD_TGA', 1, "TGA support"); + ADD_FLAG("CFLAGS_GD", " \ +/D PHP_GD_EXPORTS=1 \ +/D HAVE_GD_GET_INTERPOLATION \ + "); + if (ICC_TOOLSET) { + ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); + } + + PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd"); +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ba02e672d..8281f88b7 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -15,7 +15,7 @@ $test_php_version = [ // '8.1', // '8.2', - // '8.3', + '8.3', // '8.4', '8.5', // 'git', @@ -23,13 +23,13 @@ // test os (macos-15-intel, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-15-intel', // bin/spc for x86_64 - // 'macos-15', // bin/spc for arm64 + 'macos-15-intel', // bin/spc for x86_64 + 'macos-15', // bin/spc for arm64 // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 - 'ubuntu-24.04', // bin/spc for x86_64 + // 'ubuntu-24.04', // bin/spc for x86_64 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 - 'ubuntu-24.04-arm', // bin/spc for arm64 + // 'ubuntu-24.04-arm', // bin/spc for arm64 // 'windows-2022', // .\bin\spc.ps1 // 'windows-2025', ]; @@ -42,7 +42,7 @@ // compress with upx $upx = false; -// whether to test frankenphp build, only available for macos and linux +// whether to test frankenphp build, only available for macOS and linux $frankenphp = false; // prefer downloading pre-built packages to speed up the build process @@ -50,8 +50,8 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'pgsql', - 'Windows' => 'com_dotnet', + 'Linux', 'Darwin' => 'curl,swoole', + 'Windows' => 'intl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). @@ -62,11 +62,11 @@ }; // If you want to test lib-suggests for all extensions and libraries, set it to true. -$with_suggested_libs = false; +$with_suggested_libs = true; // If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true. $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => '', + 'Linux', 'Darwin' => 'krb5', 'Windows' => '', };