mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 18:05:36 +08:00
Compare commits
117 Commits
9e2a5ce188
...
ttt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3003d363e | ||
|
|
b5b4e8f622 | ||
|
|
d316ea81e4 | ||
|
|
b96586e4d3 | ||
|
|
d535e4f102 | ||
|
|
5a5f54bdcd | ||
|
|
8f7897e13b | ||
|
|
daae5f2a7c | ||
|
|
844bb69f0d | ||
|
|
766f7fa34f | ||
|
|
ecf712b2b7 | ||
|
|
94dd44e68d | ||
|
|
2fa07700ef | ||
|
|
13a15b1a5a | ||
|
|
d2c7fee8fa | ||
|
|
9cd3125544 | ||
|
|
590a94a723 | ||
|
|
b625d80dc0 | ||
|
|
93c099dd31 | ||
|
|
fcd0052d12 | ||
|
|
6c52451c6c | ||
|
|
175567fd11 | ||
|
|
bf05af7e16 | ||
|
|
7c3022b7e3 | ||
|
|
2a50015c12 | ||
|
|
1f42f1a479 | ||
|
|
41f5948392 | ||
|
|
6d91f8b2d3 | ||
|
|
141c737380 | ||
|
|
d35cbd7bf8 | ||
|
|
d076df6b04 | ||
|
|
a99b6bebae | ||
|
|
af97263596 | ||
|
|
864678ab46 | ||
|
|
c03508a84b | ||
|
|
963e2a084a | ||
|
|
508cfa67e5 | ||
|
|
08dca4253d | ||
|
|
e4434643ff | ||
|
|
adff728999 | ||
|
|
9af132d67e | ||
|
|
a950f3d716 | ||
|
|
33f33439d1 | ||
|
|
36177e4948 | ||
|
|
801d41efeb | ||
|
|
43d8c9d9d6 | ||
|
|
75dd01aa91 | ||
|
|
bf4d227a55 | ||
|
|
520767638f | ||
|
|
5ff973e446 | ||
|
|
230be2ebe8 | ||
|
|
bd73b4a6dc | ||
|
|
327bb8bc0f | ||
|
|
deb979416f | ||
|
|
f6e00c67cc | ||
|
|
7df861696d | ||
|
|
92861669c2 | ||
|
|
893f640469 | ||
|
|
eff7037e74 | ||
|
|
1213cb578e | ||
|
|
d1ec473f21 | ||
|
|
19bfb6bc83 | ||
|
|
94c579a453 | ||
|
|
d7d41f4d89 | ||
|
|
4c6b7a3d55 | ||
|
|
5404926a14 | ||
|
|
295df19484 | ||
|
|
b970bf8e3a | ||
|
|
54915028d7 | ||
|
|
03cd7e141c | ||
|
|
9f3e353699 | ||
|
|
b21d5716e1 | ||
|
|
464ddeb29d | ||
|
|
0c389d9069 | ||
|
|
1d2916fa8f | ||
|
|
46132ee1c8 | ||
|
|
3c9e868ce1 | ||
|
|
c5efcc0c93 | ||
|
|
64d692e105 | ||
|
|
dc79ac9c9a | ||
|
|
e9be3a41db | ||
|
|
00649d816e | ||
|
|
11376cc6ad | ||
|
|
c6207d8c7c | ||
|
|
b0eff0ba6e | ||
|
|
9d748a6e08 | ||
|
|
b0522205da | ||
|
|
beeb0b8721 | ||
|
|
823fe96942 | ||
|
|
f2fa29809a | ||
|
|
463ec546fa | ||
|
|
60b2aea09e | ||
|
|
4625c6a885 | ||
|
|
85b0cd8b4b | ||
|
|
1fcb74ad9b | ||
|
|
1049a3ce66 | ||
|
|
1b8b53d47f | ||
|
|
a232f578a4 | ||
|
|
70285cb53b | ||
|
|
a335d050cf | ||
|
|
ef4b2997a7 | ||
|
|
901da8fa41 | ||
|
|
e49a5d7a50 | ||
|
|
281b958075 | ||
|
|
e31f64864e | ||
|
|
92f5b56c74 | ||
|
|
2350d2d5ca | ||
|
|
086c855a43 | ||
|
|
4fa5292913 | ||
|
|
9634b8bcda | ||
|
|
5d5a50a33c | ||
|
|
1edf14e642 | ||
|
|
2277390a1a | ||
|
|
f93ad27c17 | ||
|
|
b690566b39 | ||
|
|
16e772e1a8 | ||
|
|
ad356b4a23 |
79
.github/workflows/build-unix.yml
vendored
79
.github/workflows/build-unix.yml
vendored
@@ -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:
|
||||
|
||||
57
TODO.md
Normal file
57
TODO.md
Normal file
@@ -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)
|
||||
- [ ] 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)
|
||||
12
bin/spc-debug.ps1
Normal file
12
bin/spc-debug.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
& "$PHP_Exec" -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
@@ -134,6 +134,8 @@ OPENSSLDIR=""
|
||||
; build target: macho or macho (possibly we could support macho-universal in the future)
|
||||
; Currently we do not support universal and cross-compilation for macOS.
|
||||
SPC_TARGET=native-macos
|
||||
; Whether to use brew version of llvm or system version (valid options: 'system', 'brew', default: 'system')
|
||||
SPC_USE_LLVM=system
|
||||
; compiler environments (default value is defined by selected toolchain)
|
||||
CC=${SPC_DEFAULT_CC}
|
||||
CXX=${SPC_DEFAULT_CXX}
|
||||
|
||||
@@ -252,6 +252,7 @@
|
||||
"arg-type-unix": "enable-path",
|
||||
"cpp-extension": true,
|
||||
"lib-depends": [
|
||||
"grpc",
|
||||
"zlib",
|
||||
"openssl",
|
||||
"libcares"
|
||||
|
||||
@@ -143,9 +143,7 @@
|
||||
"zlib"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"libpng",
|
||||
"bzip2",
|
||||
"brotli"
|
||||
"libpng"
|
||||
]
|
||||
},
|
||||
"gettext": {
|
||||
@@ -355,6 +353,9 @@
|
||||
"static-libs-unix": [
|
||||
"libaom.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"aom.lib"
|
||||
],
|
||||
"cpp-library": true
|
||||
},
|
||||
"libargon2": {
|
||||
@@ -493,7 +494,7 @@
|
||||
"static-libs-windows": [
|
||||
"libjpeg_a.lib"
|
||||
],
|
||||
"lib-suggests-windows": [
|
||||
"lib-depends": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
@@ -862,6 +863,9 @@
|
||||
},
|
||||
"openssl": {
|
||||
"source": "openssl",
|
||||
"pkg-configs": [
|
||||
"openssl"
|
||||
],
|
||||
"static-libs-unix": [
|
||||
"libssl.a",
|
||||
"libcrypto.a"
|
||||
@@ -974,6 +978,11 @@
|
||||
},
|
||||
"unixodbc": {
|
||||
"source": "unixodbc",
|
||||
"pkg-configs": [
|
||||
"odbc",
|
||||
"odbccr",
|
||||
"odbcinst"
|
||||
],
|
||||
"static-libs-unix": [
|
||||
"libodbc.a",
|
||||
"libodbccr.a",
|
||||
@@ -1015,6 +1024,9 @@
|
||||
},
|
||||
"zlib": {
|
||||
"source": "zlib",
|
||||
"pkg-configs": [
|
||||
"zlib"
|
||||
],
|
||||
"static-libs-unix": [
|
||||
"libz.a"
|
||||
],
|
||||
@@ -1028,6 +1040,9 @@
|
||||
},
|
||||
"zstd": {
|
||||
"source": "zstd",
|
||||
"pkg-configs": [
|
||||
"libzstd"
|
||||
],
|
||||
"static-libs-unix": [
|
||||
"libzstd.a"
|
||||
],
|
||||
|
||||
@@ -16,6 +16,7 @@ ext-curl:
|
||||
depends:
|
||||
- curl
|
||||
depends@windows:
|
||||
- curl
|
||||
- ext-zlib
|
||||
- ext-openssl
|
||||
php-extension:
|
||||
@@ -342,6 +343,6 @@ ext-zlib:
|
||||
- zlib
|
||||
php-extension:
|
||||
arg-type: custom
|
||||
arg-type@windows: with
|
||||
arg-type@windows: enable
|
||||
build-with-php: true
|
||||
build-shared: false
|
||||
|
||||
@@ -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@'
|
||||
|
||||
@@ -15,3 +15,7 @@ brotli:
|
||||
- libbrotlicommon
|
||||
- libbrotlidec
|
||||
- libbrotlienc
|
||||
static-libs@windows:
|
||||
- brotlicommon.lib
|
||||
- brotlidec.lib
|
||||
- brotlienc.lib
|
||||
|
||||
@@ -16,3 +16,6 @@ bzip2:
|
||||
- bzlib.h
|
||||
static-libs@unix:
|
||||
- libbz2.a
|
||||
static-libs@windows:
|
||||
- libbz2.lib
|
||||
- libbz2_a.lib
|
||||
|
||||
@@ -11,6 +11,7 @@ freetype:
|
||||
depends:
|
||||
- zlib
|
||||
suggests:
|
||||
- libpng
|
||||
- bzip2
|
||||
- brotli
|
||||
headers@unix:
|
||||
|
||||
@@ -6,11 +6,20 @@ icu:
|
||||
repo: unicode-org/icu
|
||||
match: icu4c.+-src\.tgz
|
||||
prefer-stable: true
|
||||
binary:
|
||||
windows-x86_64: { type: url, url: 'https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip', extract: hosted }
|
||||
metadata:
|
||||
license-files: [LICENSE]
|
||||
license-files: ['@/icu.txt']
|
||||
license: ICU
|
||||
headers@windows:
|
||||
- unicode
|
||||
lang: cpp
|
||||
pkg-configs:
|
||||
- icu-uc
|
||||
- icu-i18n
|
||||
- icu-io
|
||||
static-libs@windows:
|
||||
- icudt.lib
|
||||
- icuin.lib
|
||||
- icuio.lib
|
||||
- icuuc.lib
|
||||
|
||||
@@ -10,3 +10,5 @@ libaom:
|
||||
lang: cpp
|
||||
static-libs@unix:
|
||||
- libaom.a
|
||||
static-libs@windows:
|
||||
- aom.lib
|
||||
|
||||
@@ -16,3 +16,5 @@ libavif:
|
||||
- libpng
|
||||
static-libs@unix:
|
||||
- libavif.a
|
||||
static-libs@windows:
|
||||
- avif.lib
|
||||
|
||||
12
config/pkg/lib/libffi-win.yml
Normal file
12
config/pkg/lib/libffi-win.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
libffi-win:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: git
|
||||
rev: master
|
||||
url: 'https://github.com/static-php/libffi-win.git'
|
||||
metadata:
|
||||
license-files: [LICENSE]
|
||||
license: MIT
|
||||
static-libs@windows:
|
||||
- libffi.lib
|
||||
13
config/pkg/lib/libiconv-win.yml
Normal file
13
config/pkg/lib/libiconv-win.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
libiconv-win:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: git
|
||||
rev: master
|
||||
url: 'https://github.com/static-php/libiconv-win.git'
|
||||
metadata:
|
||||
license-files: [source/COPYING]
|
||||
license: GPL-3.0-or-later
|
||||
static-libs@windows:
|
||||
- libiconv.lib
|
||||
- libiconv_a.lib
|
||||
@@ -7,6 +7,10 @@ libjpeg:
|
||||
metadata:
|
||||
license-files: [LICENSE.md]
|
||||
license: IJG
|
||||
suggests@windows:
|
||||
- zlib
|
||||
static-libs@unix:
|
||||
- libjpeg.a
|
||||
- libturbojpeg.a
|
||||
static-libs@windows:
|
||||
- libjpeg_a.lib
|
||||
|
||||
@@ -14,3 +14,6 @@ libpng:
|
||||
- zlib
|
||||
static-libs@unix:
|
||||
- libpng16.a
|
||||
static-libs@windows:
|
||||
- libpng16_static.lib
|
||||
- libpng_a.lib
|
||||
|
||||
@@ -12,3 +12,5 @@ librabbitmq:
|
||||
- openssl
|
||||
static-libs@unix:
|
||||
- librabbitmq.a
|
||||
static-libs@windows:
|
||||
- rabbitmq.4.lib
|
||||
|
||||
@@ -13,3 +13,5 @@ libsodium:
|
||||
- libsodium
|
||||
static-libs@unix:
|
||||
- libsodium.a
|
||||
static-libs@windows:
|
||||
- libsodium.lib
|
||||
|
||||
@@ -20,3 +20,5 @@ libssh2:
|
||||
- libssh2
|
||||
static-libs@unix:
|
||||
- libssh2.a
|
||||
static-libs@windows:
|
||||
- libssh2.lib
|
||||
|
||||
@@ -14,3 +14,8 @@ libwebp:
|
||||
- libwebpdemux
|
||||
- libwebpmux
|
||||
- libsharpyuv
|
||||
static-libs@windows:
|
||||
- libwebp.lib
|
||||
- libwebpdecoder.lib
|
||||
- libwebpdemux.lib
|
||||
- libsharpyuv.lib
|
||||
|
||||
@@ -12,7 +12,13 @@ libxml2:
|
||||
- libiconv
|
||||
- zlib
|
||||
- xz
|
||||
depends@windows:
|
||||
- zlib
|
||||
- libiconv-win
|
||||
headers:
|
||||
- libxml2
|
||||
pkg-configs:
|
||||
- libxml-2.0
|
||||
static-libs@windows:
|
||||
- libxml2s.lib
|
||||
- libxml2_a.lib
|
||||
|
||||
@@ -13,3 +13,5 @@ libyaml:
|
||||
- yaml.h
|
||||
static-libs@unix:
|
||||
- libyaml.a
|
||||
static-libs@windows:
|
||||
- yaml.lib
|
||||
|
||||
@@ -8,9 +8,10 @@ libzip:
|
||||
prefer-stable: true
|
||||
metadata:
|
||||
license-files: [LICENSE]
|
||||
depends@unix:
|
||||
license: BSD-3-Clause
|
||||
depends:
|
||||
- zlib
|
||||
suggests@unix:
|
||||
suggests:
|
||||
- bzip2
|
||||
- xz
|
||||
- zstd
|
||||
@@ -20,3 +21,5 @@ libzip:
|
||||
- zipconf.h
|
||||
static-libs@unix:
|
||||
- libzip.a
|
||||
static-libs@windows:
|
||||
- libzip_a.lib
|
||||
|
||||
@@ -22,3 +22,5 @@ nghttp2:
|
||||
- libnghttp2
|
||||
static-libs@unix:
|
||||
- libnghttp2.a
|
||||
static-libs@windows:
|
||||
- nghttp2.lib
|
||||
|
||||
@@ -17,3 +17,5 @@ nghttp3:
|
||||
- libnghttp3
|
||||
static-libs@unix:
|
||||
- libnghttp3.a
|
||||
static-libs@windows:
|
||||
- nghttp3.lib
|
||||
|
||||
@@ -11,9 +11,6 @@ ngtcp2:
|
||||
license: MIT
|
||||
depends:
|
||||
- openssl
|
||||
suggests:
|
||||
- nghttp3
|
||||
- brotli
|
||||
headers:
|
||||
- ngtcp2
|
||||
pkg-configs:
|
||||
@@ -22,3 +19,5 @@ ngtcp2:
|
||||
static-libs@unix:
|
||||
- libngtcp2.a
|
||||
- libngtcp2_crypto_ossl.a
|
||||
static-libs@windows:
|
||||
- ngtcp2.lib
|
||||
|
||||
@@ -13,3 +13,6 @@ onig:
|
||||
- oniguruma.h
|
||||
static-libs@unix:
|
||||
- libonig.a
|
||||
static-libs@windows:
|
||||
- onig.lib
|
||||
- onig_a.lib
|
||||
|
||||
@@ -16,8 +16,14 @@ openssl:
|
||||
license: OpenSSL
|
||||
depends:
|
||||
- zlib
|
||||
depends@windows:
|
||||
- zlib
|
||||
- jom
|
||||
headers:
|
||||
- openssl
|
||||
static-libs@unix:
|
||||
- libssl.a
|
||||
- libcrypto.a
|
||||
static-libs@windows:
|
||||
- libssl.lib
|
||||
- libcrypto.lib
|
||||
|
||||
@@ -5,19 +5,25 @@ postgresql:
|
||||
type: ghtagtar
|
||||
repo: postgres/postgres
|
||||
match: REL_18_\d+
|
||||
binary:
|
||||
windows-x86_64: { type: url, url: 'https://get.enterprisedb.com/postgresql/postgresql-16.8-1-windows-x64-binaries.zip', extract: { lib/libpq.lib: '{build_root_path}/lib/libpq.lib', lib/libpgport.lib: '{build_root_path}/lib/libpgport.lib', lib/libpgcommon.lib: '{build_root_path}/lib/libpgcommon.lib', include/libpq-fe.h: '{build_root_path}/include/libpq-fe.h', include/postgres_ext.h: '{build_root_path}/include/postgres_ext.h', include/pg_config_ext.h: '{build_root_path}/include/pg_config_ext.h', include/libpq/libpq-fs.h: '{build_root_path}/include/libpq/libpq-fs.h' } }
|
||||
metadata:
|
||||
license-files: [COPYRIGHT]
|
||||
license-files: ['@/postgresql.txt']
|
||||
license: PostgreSQL
|
||||
depends:
|
||||
depends@unix:
|
||||
- libiconv
|
||||
- libxml2
|
||||
- openssl
|
||||
- zlib
|
||||
- libedit
|
||||
suggests:
|
||||
suggests@unix:
|
||||
- icu
|
||||
- libxslt
|
||||
- ldap
|
||||
- zstd
|
||||
pkg-configs:
|
||||
- libpq
|
||||
static-libs@windows:
|
||||
- libpq.lib
|
||||
- libpgport.lib
|
||||
- libpgcommon.lib
|
||||
|
||||
12
config/pkg/lib/pthreads4w.yml
Normal file
12
config/pkg/lib/pthreads4w.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
pthreads4w:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: git
|
||||
rev: master
|
||||
url: 'https://git.code.sf.net/p/pthreads4w/code'
|
||||
metadata:
|
||||
license-files: [LICENSE]
|
||||
license: Apache-2.0
|
||||
static-libs@windows:
|
||||
- libpthreadVC3.lib
|
||||
@@ -10,3 +10,5 @@ qdbm:
|
||||
license: 'GPL-2.0-only OR LGPL-2.1-only'
|
||||
static-libs@unix:
|
||||
- libqdbm.a
|
||||
static-libs@windows:
|
||||
- qdbm_a.lib
|
||||
|
||||
@@ -10,3 +10,5 @@ sqlite:
|
||||
- sqlite3ext.h
|
||||
static-libs@unix:
|
||||
- libsqlite3.a
|
||||
static-libs@windows:
|
||||
- libsqlite3_a.lib
|
||||
|
||||
@@ -14,7 +14,13 @@ xz:
|
||||
- libiconv
|
||||
headers@unix:
|
||||
- lzma
|
||||
headers@windows:
|
||||
- lzma
|
||||
- lzma.h
|
||||
pkg-configs:
|
||||
- liblzma
|
||||
static-libs@unix:
|
||||
- liblzma.a
|
||||
static-libs@windows:
|
||||
- lzma.lib
|
||||
- liblzma_a.lib
|
||||
|
||||
@@ -14,3 +14,6 @@ zlib:
|
||||
- zconf.h
|
||||
static-libs@unix:
|
||||
- libz.a
|
||||
static-libs@windows:
|
||||
- zlibstatic.lib
|
||||
- zlib_a.lib
|
||||
|
||||
@@ -17,3 +17,5 @@ zstd:
|
||||
- libzstd
|
||||
static-libs@unix:
|
||||
- libzstd.a
|
||||
static-libs@windows:
|
||||
- zstd_static.lib
|
||||
|
||||
@@ -12,6 +12,10 @@ curl:
|
||||
depends@unix:
|
||||
- openssl
|
||||
- zlib
|
||||
depends@windows:
|
||||
- zlib
|
||||
- libssh2
|
||||
- nghttp2
|
||||
suggests@unix:
|
||||
- libssh2
|
||||
- brotli
|
||||
@@ -23,6 +27,9 @@ curl:
|
||||
- ldap
|
||||
- idn2
|
||||
- krb5
|
||||
suggests@windows:
|
||||
- brotli
|
||||
- zstd
|
||||
frameworks:
|
||||
- CoreFoundation
|
||||
- CoreServices
|
||||
@@ -33,3 +40,5 @@ curl:
|
||||
- curl
|
||||
static-libs@unix:
|
||||
- libcurl.a
|
||||
static-libs@windows:
|
||||
- libcurl_a.lib
|
||||
|
||||
@@ -2,5 +2,11 @@ go-xcaddy:
|
||||
type: target
|
||||
artifact:
|
||||
binary: custom
|
||||
env:
|
||||
GOROOT: '{pkg_root_path}/go-xcaddy'
|
||||
GOBIN: '{pkg_root_path}/go-xcaddy/bin'
|
||||
GOPATH: '{pkg_root_path}/go-xcaddy/go'
|
||||
path@unix:
|
||||
- '{pkg_root_path}/go-xcaddy/bin'
|
||||
static-bins:
|
||||
- xcaddy
|
||||
|
||||
7
config/pkg/target/jom.yml
Normal file
7
config/pkg/target/jom.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
jom:
|
||||
type: target
|
||||
artifact:
|
||||
binary:
|
||||
windows-x86_64: { type: url, url: 'https://download.qt.io/official_releases/jom/jom.zip', extract: '{pkg_root_path}/jom' }
|
||||
path@windows:
|
||||
- '{pkg_root_path}\jom'
|
||||
8
config/pkg/target/protoc.yml
Normal file
8
config/pkg/target/protoc.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
protoc:
|
||||
type: target
|
||||
artifact:
|
||||
binary:
|
||||
linux-x86_64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-x86_64\.zip', extract: '{pkg_root_path}/protoc' }
|
||||
linux-aarch64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-aarch_64\.zip', extract: '{pkg_root_path}/protoc' }
|
||||
path:
|
||||
- '{pkg_root_path}/protoc/bin'
|
||||
6
config/pkg/target/rust.yml
Normal file
6
config/pkg/target/rust.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
rust:
|
||||
type: target
|
||||
artifact:
|
||||
binary: custom
|
||||
path:
|
||||
- '{pkg_root_path}/rust/bin'
|
||||
@@ -641,6 +641,7 @@
|
||||
"libjpeg": {
|
||||
"type": "ghtar",
|
||||
"repo": "libjpeg-turbo/libjpeg-turbo",
|
||||
"prefer-stable": true,
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE.md"
|
||||
@@ -1054,7 +1055,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": {
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
|
||||
|
||||
|
||||
85
src/Package/Artifact/rust.php
Normal file
85
src/Package/Artifact/rust.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Artifact;
|
||||
|
||||
use StaticPHP\Artifact\ArtifactDownloader;
|
||||
use StaticPHP\Artifact\Downloader\DownloadResult;
|
||||
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
|
||||
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
|
||||
use StaticPHP\Attribute\Artifact\CustomBinary;
|
||||
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
|
||||
use StaticPHP\Exception\DownloaderException;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\System\LinuxUtil;
|
||||
|
||||
class rust
|
||||
{
|
||||
#[CustomBinary('rust', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
])]
|
||||
public function downBinary(ArtifactDownloader $downloader): DownloadResult
|
||||
{
|
||||
// determine distro first
|
||||
$distro = LinuxUtil::isMuslDist() ? 'musl' : 'gnu';
|
||||
$arch = SystemTarget::getTargetArch();
|
||||
|
||||
// get latest rust version from link
|
||||
$toml_config = default_shell()->executeCurl('https://static.rust-lang.org/dist/channel-rust-stable.toml', retries: $downloader->getRetry());
|
||||
// parse toml by regex since we want to avoid adding a toml parser dependency just for this
|
||||
$cnt = preg_match_all('/^version = "([^"]+)"$/m', $toml_config ?: '', $matches);
|
||||
if (!$cnt) {
|
||||
throw new DownloaderException('Failed to parse Rust version from channel config');
|
||||
}
|
||||
$versions = $matches[1];
|
||||
// strip version num \d.\d.\d (some version number is like "x.x.x (abcdefg 1970-01-01)"
|
||||
$versions = array_filter(array_map(fn ($v) => preg_match('/^(\d+\.\d+\.\d+)/', $v, $m) ? $m[1] : null, $versions));
|
||||
usort($versions, 'version_compare');
|
||||
$latest_version = end($versions);
|
||||
if (!$latest_version) {
|
||||
throw new DownloaderException('Could not determine latest Rust version');
|
||||
}
|
||||
|
||||
// merge download link
|
||||
$download_url = "https://static.rust-lang.org/dist/rust-{$latest_version}-{$arch}-unknown-linux-{$distro}.tar.xz";
|
||||
$path = DOWNLOAD_PATH . DIRECTORY_SEPARATOR . basename($download_url);
|
||||
default_shell()->executeCurlDownload($download_url, $path, retries: $downloader->getRetry());
|
||||
return DownloadResult::archive(basename($path), ['url' => $download_url, 'version' => $latest_version], extract: PKG_ROOT_PATH . '/rust-install', verified: false, version: $latest_version);
|
||||
}
|
||||
|
||||
#[CustomBinaryCheckUpdate('rust', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
])]
|
||||
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
|
||||
{
|
||||
$toml_config = default_shell()->executeCurl('https://static.rust-lang.org/dist/channel-rust-stable.toml', retries: $downloader->getRetry());
|
||||
$cnt = preg_match_all('/^version = "([^"]+)"$/m', $toml_config ?: '', $matches);
|
||||
if (!$cnt) {
|
||||
throw new DownloaderException('Failed to parse Rust version from channel config');
|
||||
}
|
||||
$versions = array_filter(array_map(fn ($v) => preg_match('/^(\d+\.\d+\.\d+)/', $v, $m) ? $m[1] : null, $matches[1]));
|
||||
usort($versions, 'version_compare');
|
||||
$latest_version = end($versions);
|
||||
if (!$latest_version) {
|
||||
throw new DownloaderException('Could not determine latest Rust version');
|
||||
}
|
||||
return new CheckUpdateResult(
|
||||
old: $old_version,
|
||||
new: $latest_version,
|
||||
needUpdate: $old_version === null || $latest_version !== $old_version,
|
||||
);
|
||||
}
|
||||
|
||||
#[AfterBinaryExtract('rust', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
])]
|
||||
public function postExtractRust(string $target_path): void
|
||||
{
|
||||
$prefix = PKG_ROOT_PATH . '/rust';
|
||||
shell()->exec("cd {$target_path} && ./install.sh --prefix={$prefix}");
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ class zig
|
||||
$index_json = default_shell()->executeCurl('https://ziglang.org/download/index.json', retries: $downloader->getRetry());
|
||||
$index_json = json_decode($index_json ?: '', true);
|
||||
$latest_version = null;
|
||||
if ($index_json === null) {
|
||||
throw new DownloaderException('Failed to fetch Zig version index');
|
||||
}
|
||||
foreach ($index_json as $version => $data) {
|
||||
if ($version !== 'master') {
|
||||
$latest_version = $version;
|
||||
|
||||
26
src/Package/Extension/curl.php
Normal file
26
src/Package/Extension/curl.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
|
||||
#[Extension('curl')]
|
||||
class curl
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-curl')]
|
||||
#[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Schannel SSL support')]
|
||||
public function addSecur32LibForWindows(): void
|
||||
{
|
||||
// curl on Windows uses Schannel (USE_WINDOWS_SSPI=ON, CURL_USE_SCHANNEL=ON),
|
||||
// which requires secur32.lib for SSL/TLS functions (SslEncryptPackage, etc.).
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
if (!str_contains($extra_libs, 'secur32.lib')) {
|
||||
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs . ' secur32.lib'));
|
||||
}
|
||||
}
|
||||
}
|
||||
30
src/Package/Extension/gettext.php
Normal file
30
src/Package/Extension/gettext.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Extension('gettext')]
|
||||
class gettext
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gettext')]
|
||||
#[PatchDescription('Patch gettext extension config.m4 to fix library detection on macOS')]
|
||||
public function patchBeforeBuildconf(PackageInstaller $installer): void
|
||||
{
|
||||
spc_skip_unless(SystemTarget::getTargetOS() === 'Darwin', 'gettext extension patch is only needed on macOS');
|
||||
$php_src = $installer->getTargetPackage('php')->getSourceDir();
|
||||
FileSystem::replaceFileStr(
|
||||
"{$php_src}/ext/gettext/config.m4",
|
||||
['AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB([$GETTEXT_CHECK_IN_LIB'],
|
||||
['AC_CHECK_LIB(intl', 'AC_CHECK_LIB([intl'] // new php versions use a bracket
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,19 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('brotli')]
|
||||
class brotli
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $package): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($package)->build();
|
||||
// FileSystem::copy("{$package->getLibDir()}\\onig.lib", "{$package->getLibDir()}\\onig_a.lib");
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
|
||||
@@ -20,6 +20,17 @@ class bzip2
|
||||
FileSystem::replaceFileStr($lib->getSourceDir() . '/Makefile', 'CFLAGS=-Wall', 'CFLAGS=-fPIC -Wall');
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $package): void
|
||||
{
|
||||
cmd()->cd($package->getSourceDir())
|
||||
->exec('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo" clean')
|
||||
->exec('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo" lib');
|
||||
FileSystem::copy("{$package->getSourceDir()}\\libbz2.lib", "{$package->getLibDir()}\\libbz2.lib");
|
||||
FileSystem::copy("{$package->getSourceDir()}\\libbz2.lib", "{$package->getLibDir()}\\libbz2_a.lib");
|
||||
FileSystem::copy("{$package->getSourceDir()}\\bzlib.h", "{$package->getIncludeDir()}\\bzlib.h");
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib, PackageBuilder $builder): void
|
||||
|
||||
@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('freetype')]
|
||||
@@ -33,4 +34,18 @@ class freetype
|
||||
$lib->patchPkgconfPrefix(['freetype2.pc']);
|
||||
FileSystem::replaceFileStr("{$lib->getBuildRootPath()}/lib/pkgconfig/freetype2.pc", ' -L/lib ', " -L{$lib->getBuildRootPath()}/lib ");
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->optionalPackage('libpng', ...cmake_boolean_args('FT_DISABLE_PNG', true))
|
||||
->optionalPackage('bzip2', ...cmake_boolean_args('FT_DISABLE_BZIP2', true))
|
||||
->optionalPackage('brotli', ...cmake_boolean_args('FT_DISABLE_BROTLI', true))
|
||||
->addConfigureArgs('-DFT_DISABLE_HARFBUZZ=ON')
|
||||
->build();
|
||||
|
||||
// freetype.lib to libfreetype_a.lib
|
||||
FileSystem::copy("{$lib->getLibDir()}\\freetype.lib", "{$lib->getLibDir()}\\libfreetype_a.lib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('gmssl')]
|
||||
class gmssl
|
||||
@@ -18,4 +20,35 @@ class gmssl
|
||||
{
|
||||
UnixCMakeExecutor::create($lib)->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
$buildDir = "{$lib->getSourceDir()}\\builddir";
|
||||
|
||||
// GmSSL requires NMake Makefiles generator on Windows
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->setBuildDir($buildDir)
|
||||
->setCustomDefaultArgs(
|
||||
'-G "NMake Makefiles"',
|
||||
'-DWIN32=ON',
|
||||
'-DBUILD_SHARED_LIBS=OFF',
|
||||
'-DCMAKE_BUILD_TYPE=Release',
|
||||
'-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||
'-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||
'-DCMAKE_INSTALL_PREFIX=' . escapeshellarg($lib->getBuildRootPath()),
|
||||
'-B ' . escapeshellarg($buildDir),
|
||||
)
|
||||
->toStep(1)
|
||||
->build();
|
||||
|
||||
// fix cmake_install.cmake install prefix (GmSSL overrides it internally)
|
||||
$installCmake = "{$buildDir}\\cmake_install.cmake";
|
||||
FileSystem::writeFile(
|
||||
$installCmake,
|
||||
'set(CMAKE_INSTALL_PREFIX "' . str_replace('\\', '/', $lib->getBuildRootPath()) . '")' . PHP_EOL . FileSystem::readFile($installCmake)
|
||||
);
|
||||
|
||||
cmd()->cd($buildDir)->exec('nmake install XCFLAGS=/MT');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('idn2')]
|
||||
class idn2
|
||||
@@ -29,5 +30,10 @@ class idn2
|
||||
->make();
|
||||
$lib->patchPkgconfPrefix(['libidn2.pc']);
|
||||
$lib->patchLaDependencyPrefix();
|
||||
// libunistring is in Libs.private of libidn2.pc, but CMake's pkg_check_modules
|
||||
// does not follow Libs.private for static linking. Promote it to Libs so that
|
||||
// consumers linking static binaries (e.g. the curl exe) can resolve _uc_* / _u32_* symbols.
|
||||
$libidn2_pc = BUILD_ROOT_PATH . '/lib/pkgconfig/libidn2.pc';
|
||||
FileSystem::replaceFileStr($libidn2_pc, 'Libs: -L${libdir} -lidn2', 'Libs: -L${libdir} -lidn2 -lunistring');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\SPCConfigUtil;
|
||||
|
||||
#[Library('krb5')]
|
||||
@@ -59,5 +60,11 @@ class krb5
|
||||
'mit-krb5.pc',
|
||||
'gssrpc.pc',
|
||||
]);
|
||||
// libkrb5support is in Libs.private of mit-krb5.pc, but CMake's pkg_check_modules
|
||||
// does not follow Libs.private for static linking. Promote it to Libs so that
|
||||
// consumers linking static binaries (e.g. the curl exe) can resolve _k5_* symbols.
|
||||
$mit_krb5_pc = BUILD_ROOT_PATH . '/lib/pkgconfig/mit-krb5.pc';
|
||||
FileSystem::replaceFileStr($mit_krb5_pc, 'Libs.private: -lkrb5support', 'Libs.private:');
|
||||
FileSystem::replaceFileStr($mit_krb5_pc, '-lcom_err', '-lcom_err -lkrb5support');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,28 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||
use StaticPHP\Toolchain\ZigToolchain;
|
||||
|
||||
#[Library('libaom')]
|
||||
class libaom extends LibraryPackage
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($this)
|
||||
->setBuildDir("{$this->getSourceDir()}/builddir")
|
||||
->addConfigureArgs(
|
||||
'-DAOM_TARGET_CPU=generic',
|
||||
'-DENABLE_TESTS=OFF',
|
||||
'-DENABLE_EXAMPLES=OFF',
|
||||
'-DENABLE_TOOLS=OFF',
|
||||
'-DENABLE_DOCS=OFF',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Darwin')]
|
||||
#[BuildFor('Linux')]
|
||||
public function buildUnix(ToolchainInterface $toolchain): void
|
||||
|
||||
@@ -6,12 +6,25 @@ namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libavif')]
|
||||
class libavif
|
||||
{
|
||||
#[PatchBeforeBuild]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): void
|
||||
{
|
||||
// workaround for libavif 1.2.0 bug: MSVC does not support empty initializer list
|
||||
if (SystemTarget::getTargetOS() === 'Windows') {
|
||||
FileSystem::replaceFileStr($lib->getSourceDir() . '/src/read.c', 'avifFileType ftyp = {};', 'avifFileType ftyp = { 0 };');
|
||||
}
|
||||
}
|
||||
|
||||
#[BuildFor('Darwin')]
|
||||
#[BuildFor('Linux')]
|
||||
public function buildUnix(LibraryPackage $lib): void
|
||||
@@ -27,4 +40,17 @@ class libavif
|
||||
// patch pkgconfig
|
||||
$lib->patchPkgconfPrefix(['libavif.pc']);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DAVIF_BUILD_APPS=OFF',
|
||||
'-DAVIF_BUILD_TESTS=OFF',
|
||||
'-DAVIF_LIBYUV=OFF',
|
||||
'-DAVIF_ENABLE_GTEST=OFF',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
}
|
||||
|
||||
47
src/Package/Library/libffi_win.php
Normal file
47
src/Package/Library/libffi_win.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\Validate;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\System\WindowsUtil;
|
||||
|
||||
#[Library('libffi-win')]
|
||||
class libffi_win
|
||||
{
|
||||
#[Validate]
|
||||
public function validate(): void
|
||||
{
|
||||
$ver = WindowsUtil::findVisualStudio();
|
||||
$vs_ver_dir = match ($ver['major_version']) {
|
||||
'17' => '\win32\vs17_x64',
|
||||
'16' => '\win32\vs16_x64',
|
||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported!"),
|
||||
};
|
||||
ApplicationContext::set('libffi_win_vs_ver_dir', $vs_ver_dir);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
$vs_ver_dir = ApplicationContext::get('libffi_win_vs_ver_dir');
|
||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
||||
->exec('msbuild libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64');
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
|
||||
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\Release\\libffi.lib", "{$lib->getLibDir()}\\libffi.lib");
|
||||
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\Release\\libffi.pdb", "{$lib->getLibDir()}\\libffi.pdb");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\include\\ffi.h", "{$lib->getIncludeDir()}\\ffi.h");
|
||||
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\ffi.h", '#define LIBFFI_H', "#define LIBFFI_H\n#define FFI_BUILDING");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\src\\x86\\ffitarget.h", "{$lib->getIncludeDir()}\\ffitarget.h");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\fficonfig.h", "{$lib->getIncludeDir()}\\fficonfig.h");
|
||||
}
|
||||
}
|
||||
43
src/Package/Library/libiconv_win.php
Normal file
43
src/Package/Library/libiconv_win.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\Validate;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\System\WindowsUtil;
|
||||
|
||||
#[Library('libiconv-win')]
|
||||
class libiconv_win
|
||||
{
|
||||
#[Validate]
|
||||
public function validate(): void
|
||||
{
|
||||
$ver = WindowsUtil::findVisualStudio();
|
||||
$vs_ver_dir = match ($ver['major_version']) {
|
||||
'17' => '\MSVC17',
|
||||
'16' => '\MSVC16',
|
||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||
};
|
||||
ApplicationContext::set('vs_ver_dir', $vs_ver_dir);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
$vs_ver_dir = ApplicationContext::get('vs_ver_dir');
|
||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
||||
->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64');
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\lib\\libiconv.lib", "{$lib->getLibDir()}\\libiconv.lib");
|
||||
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\lib\\libiconv_a.lib", "{$lib->getLibDir()}\\libiconv_a.lib");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\source\\include\\iconv.h", "{$lib->getIncludeDir()}\\iconv.h");
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libjpeg')]
|
||||
class libjpeg
|
||||
@@ -25,4 +27,20 @@ class libjpeg
|
||||
// patch pkgconfig
|
||||
$lib->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_SHARED=OFF',
|
||||
'-DENABLE_STATIC=ON',
|
||||
'-DBUILD_TESTING=OFF',
|
||||
'-DWITH_JAVA=OFF',
|
||||
'-DWITH_CRT_DLL=OFF',
|
||||
)
|
||||
->optionalPackage('zlib', '-DENABLE_ZLIB_COMPRESSION=ON', '-DENABLE_ZLIB_COMPRESSION=OFF')
|
||||
->build();
|
||||
FileSystem::copy("{$lib->getLibDir()}\\jpeg-static.lib", "{$lib->getLibDir()}\\libjpeg_a.lib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libpng')]
|
||||
class libpng
|
||||
@@ -44,4 +46,21 @@ class libpng
|
||||
$lib->patchPkgconfPrefix(['libpng16.pc']);
|
||||
$lib->patchLaDependencyPrefix();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DSKIP_INSTALL_PROGRAM=ON',
|
||||
'-DSKIP_INSTALL_FILES=ON',
|
||||
'-DPNG_STATIC=ON',
|
||||
'-DPNG_SHARED=OFF',
|
||||
'-DPNG_TESTS=OFF',
|
||||
)
|
||||
->build();
|
||||
|
||||
// libpng16_static.lib to libpng_a.lib
|
||||
FileSystem::copy("{$lib->getLibDir()}\\libpng16_static.lib", "{$lib->getLibDir()}\\libpng_a.lib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('librabbitmq')]
|
||||
class librabbitmq extends LibraryPackage
|
||||
@@ -18,4 +19,11 @@ class librabbitmq extends LibraryPackage
|
||||
{
|
||||
UnixCMakeExecutor::create($this)->addConfigureArgs('-DBUILD_STATIC_LIBS=ON')->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($this)->build();
|
||||
rename("{$this->getLibDir()}\\librabbitmq.4.lib", "{$this->getLibDir()}\\rabbitmq.4.lib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,27 @@ namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Exception\BuildFailureException;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\System\WindowsUtil;
|
||||
|
||||
#[Library('libsodium')]
|
||||
class libsodium
|
||||
{
|
||||
#[PatchBeforeBuild]
|
||||
#[PatchDescription('Replace SODIUM_STATIC define guard with unconditional #if 1 for MSVC static linking')]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): void
|
||||
{
|
||||
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
|
||||
FileSystem::replaceFileStr($lib->getSourceDir() . '\src\libsodium\include\sodium\export.h', '#ifdef SODIUM_STATIC', '#if 1');
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
@@ -21,4 +36,39 @@ class libsodium
|
||||
// Patch pkg-config file
|
||||
$lib->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
$ver = WindowsUtil::findVisualStudio();
|
||||
$vs_ver_dir = match ($ver['major_version']) {
|
||||
'17' => '\vs2022',
|
||||
'16' => '\vs2019',
|
||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||
};
|
||||
|
||||
cmd()->cd("{$lib->getSourceDir()}\\builds\\msvc{$vs_ver_dir}")
|
||||
->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:PreprocessorDefinitions="SODIUM_STATIC=1"');
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
|
||||
// copy include
|
||||
FileSystem::copyDir("{$lib->getSourceDir()}\\src\\libsodium\\include\\sodium", "{$lib->getIncludeDir()}\\sodium");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\src\\libsodium\\include\\sodium.h", "{$lib->getIncludeDir()}\\sodium.h");
|
||||
// copy lib
|
||||
$ls = FileSystem::scanDirFiles("{$lib->getSourceDir()}\\bin");
|
||||
$find = false;
|
||||
foreach ($ls as $file) {
|
||||
if (str_ends_with($file, 'libsodium.lib')) {
|
||||
FileSystem::copy($file, "{$lib->getLibDir()}\\libsodium.lib");
|
||||
$find = true;
|
||||
}
|
||||
if (str_ends_with($file, 'libsodium.pdb')) {
|
||||
FileSystem::copy($file, "{$lib->getLibDir()}\\libsodium.pdb");
|
||||
}
|
||||
}
|
||||
if (!$find) {
|
||||
throw new BuildFailureException("Build libsodium success, but cannot find libsodium.lib in {$lib->getSourceDir()}\\bin .");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,22 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('libssh2')]
|
||||
class libssh2
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_ZLIB_COMPRESSION=ON',
|
||||
'-DBUILD_TESTING=OFF'
|
||||
)
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
|
||||
@@ -8,6 +8,7 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('libwebp')]
|
||||
class libwebp extends LibraryPackage
|
||||
@@ -41,4 +42,23 @@ int main() { return _mm256_cvtsi256_si32(_mm256_setzero_si256()); }';
|
||||
$this->patchPkgconfPrefix(patch_option: PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
|
||||
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($this)
|
||||
->addConfigureArgs(
|
||||
'-DWEBP_BUILD_EXTRAS=OFF',
|
||||
'-DWEBP_BUILD_ANIM_UTILS=OFF',
|
||||
'-DWEBP_BUILD_CWEBP=OFF',
|
||||
'-DWEBP_BUILD_DWEBP=OFF',
|
||||
'-DWEBP_BUILD_GIF2WEBP=OFF',
|
||||
'-DWEBP_BUILD_IMG2WEBP=OFF',
|
||||
'-DWEBP_BUILD_VWEBP=OFF',
|
||||
'-DWEBP_BUILD_WEBPINFO=OFF',
|
||||
'-DWEBP_BUILD_WEBPMUX=OFF',
|
||||
'-DWEBP_BUILD_FUZZTEST=OFF',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,33 @@ namespace Package\Library;
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libxml2')]
|
||||
class libxml2
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildForWindows(LibraryPackage $lib, PackageInstaller $installer): void
|
||||
{
|
||||
$iconv_win = $installer->getLibraryPackage('libiconv-win');
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DLIBXML2_WITH_ICONV=ON',
|
||||
"-DIconv_LIBRARY={$iconv_win->getLibDir()}",
|
||||
"-DIconv_INCLUDE_DIR={$iconv_win->getIncludeDir()}",
|
||||
'-DLIBXML2_WITH_ZLIB=ON',
|
||||
'-DLIBXML2_WITH_PYTHON=OFF',
|
||||
'-DLIBXML2_WITH_LZMA=OFF',
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF',
|
||||
'-DLIBXML2_WITH_TESTS=OFF',
|
||||
)
|
||||
->build();
|
||||
FileSystem::copy("{$lib->getLibDir()}\\libxml2s.lib", "{$lib->getLibDir()}\\libxml2_a.lib");
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
public function buildForLinux(LibraryPackage $lib): void
|
||||
{
|
||||
|
||||
@@ -6,16 +6,44 @@ namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libyaml')]
|
||||
class libyaml
|
||||
{
|
||||
#[PatchBeforeBuild]
|
||||
#[PatchDescription('Copy missing cmake helper files required for MSVC build (not included in libyaml git source)')]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): void
|
||||
{
|
||||
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
|
||||
// check missing files: cmake\config.h.in and .\YamlConfig.cmake.in
|
||||
if (!file_exists($lib->getSourceDir() . '\cmake\config.h.in')) {
|
||||
FileSystem::createDir($lib->getSourceDir() . '\cmake');
|
||||
FileSystem::copy(ROOT_DIR . '/src/globals/extra/libyaml_config.h.in', $lib->getSourceDir() . '\cmake\config.h.in');
|
||||
}
|
||||
if (!file_exists($lib->getSourceDir() . '\YamlConfig.cmake.in')) {
|
||||
FileSystem::copy(ROOT_DIR . '/src/globals/extra/libyaml_yamlConfig.cmake.in', $lib->getSourceDir() . '\YamlConfig.cmake.in');
|
||||
}
|
||||
}
|
||||
|
||||
#[BuildFor('Darwin')]
|
||||
#[BuildFor('Linux')]
|
||||
public function buildUnix(LibraryPackage $lib): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($lib)->configure()->make();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs('-DBUILD_TESTING=OFF')
|
||||
->build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libzip')]
|
||||
class libzip
|
||||
@@ -33,4 +35,28 @@ class libzip
|
||||
->build();
|
||||
$lib->patchPkgconfPrefix(['libzip.pc'], PKGCONF_PATCH_PREFIX);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->optionalPackage('bzip2', ...cmake_boolean_args('ENABLE_BZIP2'))
|
||||
->optionalPackage('xz', ...cmake_boolean_args('ENABLE_LZMA'))
|
||||
->optionalPackage('openssl', ...cmake_boolean_args('ENABLE_OPENSSL'))
|
||||
->optionalPackage('zstd', ...cmake_boolean_args('ENABLE_ZSTD'))
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_GNUTLS=OFF',
|
||||
'-DENABLE_MBEDTLS=OFF',
|
||||
'-DBUILD_DOC=OFF',
|
||||
'-DBUILD_EXAMPLES=OFF',
|
||||
'-DBUILD_REGRESS=OFF',
|
||||
'-DBUILD_TOOLS=OFF',
|
||||
'-DBUILD_OSSFUZZ=OFF',
|
||||
)
|
||||
->build();
|
||||
FileSystem::copy(
|
||||
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'zip.lib',
|
||||
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'libzip_a.lib'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,29 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('nghttp2')]
|
||||
class nghttp2
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_SHARED_LIB=OFF',
|
||||
'-DENABLE_STATIC_LIB=ON',
|
||||
'-DENABLE_STATIC_CRT=ON',
|
||||
'-DENABLE_LIB_ONLY=ON',
|
||||
'-DENABLE_DOC=OFF',
|
||||
'-DBUILD_TESTING=OFF',
|
||||
)
|
||||
->build();
|
||||
|
||||
FileSystem::replaceFileStr($lib->getIncludeDir() . '\nghttp2\nghttp2.h', '#ifdef NGHTTP2_STATICLIB', '#if 1');
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
|
||||
@@ -8,10 +8,26 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('nghttp3')]
|
||||
class nghttp3
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_SHARED_LIB=OFF',
|
||||
'-DENABLE_STATIC_LIB=ON',
|
||||
'-DBUILD_STATIC_LIBS=ON',
|
||||
'-DBUILD_SHARED_LIBS=OFF',
|
||||
'-DENABLE_STATIC_CRT=ON',
|
||||
'-DENABLE_LIB_ONLY=ON',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
|
||||
@@ -8,10 +8,27 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('ngtcp2')]
|
||||
class ngtcp2
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_SHARED_LIB=OFF',
|
||||
'-DENABLE_STATIC_LIB=ON',
|
||||
'-DBUILD_STATIC_LIBS=ON',
|
||||
'-DBUILD_SHARED_LIBS=OFF',
|
||||
'-DENABLE_STATIC_CRT=ON',
|
||||
'-DENABLE_LIB_ONLY=ON',
|
||||
'-DENABLE_OPENSSL=ON',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
@@ -26,18 +43,6 @@ class ngtcp2
|
||||
]),
|
||||
'--with-openssl=no'
|
||||
)
|
||||
->optionalPackage('nghttp3', ...ac_with_args('libnghttp3', true))
|
||||
->optionalPackage(
|
||||
'brotli',
|
||||
fn (LibraryPackage $brotli) => implode(' ', [
|
||||
'--with-brotlidec=yes',
|
||||
"LIBBROTLIDEC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||
"LIBBROTLIDEC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||
'--with-libbrotlienc=yes',
|
||||
"LIBBROTLIENC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||
"LIBBROTLIENC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||
])
|
||||
)
|
||||
->appendEnv(['PKG_CONFIG' => '$PKG_CONFIG --static'])
|
||||
->configure('--enable-lib-only')
|
||||
->make();
|
||||
|
||||
@@ -6,13 +6,72 @@ namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\Validate;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\System\LinuxUtil;
|
||||
use StaticPHP\Util\System\WindowsUtil;
|
||||
|
||||
#[Library('openssl')]
|
||||
class openssl
|
||||
{
|
||||
#[Validate]
|
||||
public function validate(): void
|
||||
{
|
||||
if (SystemTarget::getTargetOS() === 'Windows') {
|
||||
global $argv;
|
||||
$perl_path_native = PKG_ROOT_PATH . '\strawberry-perl-' . arch2gnu(php_uname('m')) . '-win\perl\bin\perl.exe';
|
||||
$perl = file_exists($perl_path_native) ? ($perl_path_native) : WindowsUtil::findCommand('perl.exe');
|
||||
if ($perl === null) {
|
||||
throw new EnvironmentException(
|
||||
'You need to install perl first!',
|
||||
"Please run \"{$argv[0]} doctor\" to fix the environment.",
|
||||
);
|
||||
}
|
||||
ApplicationContext::set('perl', $perl);
|
||||
}
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib, PackageBuilder $builder): void
|
||||
{
|
||||
$perl = ApplicationContext::get('perl');
|
||||
$cmd = cmd()->cd($lib->getSourceDir())
|
||||
->exec(
|
||||
"{$perl} Configure zlib VC-WIN64A " .
|
||||
'no-shared ' .
|
||||
'--prefix=' . quote($lib->getBuildRootPath()) . ' ' .
|
||||
'--with-zlib-lib=' . quote($lib->getLibDir()) . ' ' .
|
||||
'--with-zlib-include=' . quote($lib->getIncludeDir()) . ' ' .
|
||||
'--release ' .
|
||||
'no-legacy ' .
|
||||
'no-tests ' .
|
||||
'/FS'
|
||||
);
|
||||
|
||||
// patch zlib
|
||||
FileSystem::replaceFileStr("{$lib->getSourceDir()}\\Makefile", 'ZLIB1', 'zlibstatic.lib');
|
||||
// patch debug: https://stackoverflow.com/questions/18486243/how-do-i-build-openssl-statically-linked-against-windows-runtime
|
||||
FileSystem::replaceFileStr("{$lib->getSourceDir()}\\Makefile", '/debug', '/incremental:no /opt:icf /dynamicbase /nxcompat /ltcg /nodefaultlib:msvcrt');
|
||||
|
||||
// build
|
||||
$cmd->exec("jom.exe /j{$builder->concurrency} install_dev CNF_LDFLAGS=\"/NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:msvcrt /NODEFAULTLIB:msvcrtd /DEFAULTLIB:libcmt /LIBPATH:{$lib->getLibDir()} zlibstatic.lib\"");
|
||||
|
||||
// copy necessary c files
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\ms\\applink.c", "{$lib->getIncludeDir()}\\openssl\\applink.c");
|
||||
|
||||
// patch cmake outputs
|
||||
FileSystem::replaceFileRegex(
|
||||
"{$lib->getLibDir()}\\cmake\\OpenSSL\\OpenSSLConfig.cmake",
|
||||
'/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m',
|
||||
'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}" ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib)'
|
||||
);
|
||||
}
|
||||
|
||||
#[BuildFor('Darwin')]
|
||||
public function buildForDarwin(LibraryPackage $pkg): void
|
||||
{
|
||||
|
||||
@@ -73,6 +73,11 @@ class postgresql extends LibraryPackage
|
||||
|
||||
FileSystem::resetDir("{$this->getSourceDir()}/build");
|
||||
|
||||
if ($installer->isPackageResolved('ldap')) {
|
||||
$ldap_libs = clean_spaces(implode(' ', PkgConfigUtil::getLibsArray('ldap')));
|
||||
FileSystem::replaceFileStr("{$this->getSourceDir()}/configure", '-lldap', $ldap_libs);
|
||||
}
|
||||
|
||||
// PHP source relies on the non-private encoding functions in libpgcommon.a
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/src/common/Makefile",
|
||||
|
||||
34
src/Package/Library/pthreads4w.php
Normal file
34
src/Package/Library/pthreads4w.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('pthreads4w')]
|
||||
class pthreads4w
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
cmd()->cd($lib->getSourceDir())
|
||||
->exec(
|
||||
'nmake /E /nologo /f Makefile ' .
|
||||
'DESTROOT=' . $lib->getBuildRootPath() . ' ' .
|
||||
'XCFLAGS="/MT" ' . // no dll
|
||||
'EHFLAGS="/I. /DHAVE_CONFIG_H /Os /Ob2 /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" ' .
|
||||
'pthreadVC3.inlined_static_stamp'
|
||||
);
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\libpthreadVC3.lib", "{$lib->getLibDir()}\\libpthreadVC3.lib");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\_ptw32.h", "{$lib->getIncludeDir()}\\_ptw32.h");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\pthread.h", "{$lib->getIncludeDir()}\\pthread.h");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\sched.h", "{$lib->getIncludeDir()}\\sched.h");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\semaphore.h", "{$lib->getIncludeDir()}\\semaphore.h");
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,15 @@ class qdbm
|
||||
$ac->make(SystemTarget::getTargetOS() === 'Darwin' ? 'mac' : '');
|
||||
$lib->patchPkgconfPrefix(['qdbm.pc']);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
cmd()->cd($lib->getSourceDir())
|
||||
->exec('nmake /f VCMakefile');
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\qdbm_a.lib", "{$lib->getLibDir()}\\qdbm_a.lib");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\depot.h", "{$lib->getIncludeDir()}\\depot.h");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@ namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('sqlite')]
|
||||
class sqlite
|
||||
@@ -19,4 +22,18 @@ class sqlite
|
||||
UnixAutoconfExecutor::create($lib)->configure()->make();
|
||||
$lib->patchPkgconfPrefix(['sqlite3.pc']);
|
||||
}
|
||||
|
||||
#[PatchBeforeBuild]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): void
|
||||
{
|
||||
spc_skip_if(SystemTarget::getTargetOS() !== 'Windows', 'This patch is only for Windows builds.');
|
||||
FileSystem::copy(ROOT_DIR . '/src/globals/extra/Makefile-sqlite', "{$lib->getSourceDir()}\\Makefile");
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
cmd()->cd($lib->getSourceDir())
|
||||
->exec("nmake PREFIX={$lib->getBuildRootPath()} install-static");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('xz')]
|
||||
class xz
|
||||
@@ -27,4 +29,14 @@ class xz
|
||||
$lib->patchPkgconfPrefix(['liblzma.pc']);
|
||||
$lib->patchLaDependencyPrefix();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)->build();
|
||||
// copy lzma.lib to liblzma_a.lib
|
||||
FileSystem::copy("{$lib->getLibDir()}\\lzma.lib", "{$lib->getLibDir()}\\liblzma_a.lib");
|
||||
// patch lzma.h: make static API always available on Windows
|
||||
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\lzma.h", 'defined(LZMA_API_STATIC)', 'defined(_WIN32)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('zlib')]
|
||||
class zlib
|
||||
@@ -21,4 +23,29 @@ class zlib
|
||||
// Patch pkg-config file
|
||||
$lib->patchPkgconfPrefix(['zlib.pc'], PKGCONF_PATCH_PREFIX);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)->build();
|
||||
$detect_list = [
|
||||
'zlibstatic.lib',
|
||||
'zs.lib',
|
||||
'libzs.lib',
|
||||
'libz.lib',
|
||||
];
|
||||
foreach ($detect_list as $item) {
|
||||
if (file_exists("{$lib->getLibDir()}\\{$item}")) {
|
||||
FileSystem::copy("{$lib->getLibDir()}\\{$item}", "{$lib->getLibDir()}\\zlib_a.lib");
|
||||
FileSystem::copy("{$lib->getLibDir()}\\{$item}", "{$lib->getLibDir()}\\zlibstatic.lib");
|
||||
break;
|
||||
}
|
||||
}
|
||||
FileSystem::removeFileIfExists("{$lib->getBinDir()}\\zlib.dll");
|
||||
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\zlib.lib");
|
||||
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\libz.dll");
|
||||
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\libz.lib");
|
||||
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\z.lib");
|
||||
FileSystem::removeFileIfExists("{$lib->getLibDir()}\\z.dll");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,24 @@ use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
|
||||
#[Library('zstd')]
|
||||
class zstd
|
||||
{
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $package): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($package)
|
||||
->setWorkingDir("{$package->getSourceDir()}/build/cmake")
|
||||
->setBuildDir("{$package->getSourceDir()}/build/cmake/build")
|
||||
->addConfigureArgs(
|
||||
'-DZSTD_BUILD_STATIC=ON',
|
||||
'-DZSTD_BUILD_SHARED=OFF',
|
||||
)
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
|
||||
@@ -10,6 +10,7 @@ use StaticPHP\Attribute\Package\Target;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
@@ -20,7 +21,9 @@ class curl
|
||||
#[PatchDescription('Remove CMAKE_C_IMPLICIT_LINK_LIBRARIES and fix macOS framework detection')]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): bool
|
||||
{
|
||||
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
||||
if (SystemTarget::getTargetOS() !== 'Windows') {
|
||||
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
||||
}
|
||||
if (SystemTarget::getTargetOS() === 'Darwin') {
|
||||
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE');
|
||||
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE');
|
||||
@@ -29,6 +32,34 @@ class curl
|
||||
return true;
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
WindowsCMakeExecutor::create($lib)
|
||||
->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD'))
|
||||
->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
||||
->addConfigureArgs(
|
||||
'-DBUILD_CURL_EXE=OFF',
|
||||
'-DZSTD_LIBRARY=zstd_static.lib',
|
||||
'-DBUILD_TESTING=OFF',
|
||||
'-DBUILD_EXAMPLES=OFF',
|
||||
'-DUSE_LIBIDN2=OFF',
|
||||
'-DCURL_USE_LIBPSL=OFF',
|
||||
'-DUSE_WINDOWS_SSPI=ON',
|
||||
'-DCURL_USE_SCHANNEL=ON',
|
||||
'-DCURL_USE_OPENSSL=OFF',
|
||||
'-DCURL_ENABLE_SSL=ON',
|
||||
'-DUSE_NGHTTP2=ON',
|
||||
'-DSHARE_LIB_OBJECT=OFF',
|
||||
'-DCURL_USE_LIBSSH2=ON',
|
||||
'-DENABLE_IPV6=ON',
|
||||
)
|
||||
->build();
|
||||
// move libcurl.lib to libcurl_a.lib
|
||||
rename("{$lib->getLibDir()}\\libcurl.lib", "{$lib->getLibDir()}\\libcurl_a.lib");
|
||||
FileSystem::replaceFileStr("{$lib->getIncludeDir()}\\curl\\curl.h", '#ifdef CURL_STATICLIB', '#if 1');
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
@@ -50,16 +81,19 @@ class curl
|
||||
->addConfigureArgs(
|
||||
'-DBUILD_CURL_EXE=ON',
|
||||
'-DBUILD_LIBCURL_DOCS=OFF',
|
||||
'-DCURL_USE_PKGCONFIG=ON',
|
||||
)
|
||||
->build();
|
||||
|
||||
// patch pkgconf
|
||||
$lib->patchPkgconfPrefix(['libcurl.pc']);
|
||||
// curl's CMake embeds krb5 link flags directly without following Requires.private chain,
|
||||
// so -lkrb5support (from mit-krb5.pc Libs.private) is missing from libcurl.pc.
|
||||
// Ensure -lkrb5support is present in libcurl.pc for downstream consumers.
|
||||
// krb5.php already promotes it to Libs in mit-krb5.pc before the build, so
|
||||
// CMake should have embedded it; this is a safety fallback if it was missed.
|
||||
$pc_path = "{$lib->getLibDir()}/pkgconfig/libcurl.pc";
|
||||
if (str_contains(FileSystem::readFile($pc_path), '-lgssapi_krb5')) {
|
||||
FileSystem::replaceFileRegex($pc_path, '/-lcom_err$/m', '-lcom_err -lkrb5support');
|
||||
$pc_content = FileSystem::readFile($pc_path);
|
||||
if (str_contains($pc_content, '-lgssapi_krb5') && !str_contains($pc_content, '-lkrb5support')) {
|
||||
FileSystem::replaceFileRegex($pc_path, '/-lcom_err\b/', '-lcom_err -lkrb5support');
|
||||
}
|
||||
shell()->cd("{$lib->getLibDir()}/cmake/CURL/")
|
||||
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"{$lib->getLibDir()}/libcurl.a\"|g' CURLTargets-release.cmake");
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Target;
|
||||
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\InitPackage;
|
||||
use StaticPHP\Attribute\Package\Target;
|
||||
use StaticPHP\Util\GlobalEnvManager;
|
||||
|
||||
#[Target('go-xcaddy')]
|
||||
class go_xcaddy
|
||||
{
|
||||
#[InitPackage]
|
||||
#[BeforeStage('frankenphp', 'build', 'go-xcaddy')]
|
||||
public function init(): void
|
||||
{
|
||||
if (is_dir(PKG_ROOT_PATH . '/go-xcaddy/bin')) {
|
||||
GlobalEnvManager::addPathIfNotExists(PKG_ROOT_PATH . '/go-xcaddy/bin');
|
||||
GlobalEnvManager::putenv('GOROOT=' . PKG_ROOT_PATH . '/go-xcaddy');
|
||||
GlobalEnvManager::putenv('GOBIN=' . PKG_ROOT_PATH . '/go-xcaddy/bin');
|
||||
GlobalEnvManager::putenv('GOPATH=' . PKG_ROOT_PATH . '/go-xcaddy/go');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use StaticPHP\Attribute\Package\BeforeStage;
|
||||
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\Interface\ToolchainInterface;
|
||||
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 @@ class php extends TargetPackage
|
||||
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 = [];
|
||||
|
||||
@@ -469,27 +469,6 @@ trait unix
|
||||
$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
|
||||
*/
|
||||
@@ -662,7 +641,7 @@ trait unix
|
||||
/**
|
||||
* Generate micro extension test php code.
|
||||
*/
|
||||
private function generateMicroExtTests(PackageInstaller $installer): string
|
||||
protected function generateMicroExtTests(PackageInstaller $installer): string
|
||||
{
|
||||
$php = "<?php\n\necho '[micro-test-start]' . PHP_EOL;\n";
|
||||
foreach ($installer->getResolvedPackages(PhpExtensionPackage::class) as $ext) {
|
||||
|
||||
@@ -8,10 +8,15 @@ use StaticPHP\Attribute\Package\BeforeStage;
|
||||
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;
|
||||
@@ -52,9 +57,11 @@ trait windows
|
||||
$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';
|
||||
@@ -98,18 +105,31 @@ trait windows
|
||||
throw new PatchException('Windows Makefile patching for php.exe target', 'Cannot patch windows CLI Makefile, Makefile does not contain "$(BUILD_DIR)\php.exe:" line');
|
||||
}
|
||||
$lines[$line_num] = '$(BUILD_DIR)\php.exe: generated_files $(DEPS_CLI) $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest';
|
||||
$lines[$line_num + 1] = "\t" . '"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286';
|
||||
$lines[$line_num + 1] = "\t" . '"$(LINK)” /nologo $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286';
|
||||
FileSystem::writeFile("{$package->getSourceDir()}\\Makefile", implode("\r\n", $lines));
|
||||
}
|
||||
|
||||
#[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 +151,68 @@ trait windows
|
||||
$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 +229,193 @@ trait windows
|
||||
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 +484,195 @@ trait windows
|
||||
}
|
||||
}
|
||||
|
||||
#[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', '<?php echo "<h1>Hello, World!</h1>"; ?>');
|
||||
[$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
|
||||
? '<?php echo "[micro-test-start][micro-test-end]";'
|
||||
: $this->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 <sapi/embed/php_embed.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
PHP_EMBED_START_BLOCK(argc, argv)
|
||||
|
||||
zend_file_handle file_handle;
|
||||
zend_stream_init_filename(&file_handle, "embed.php");
|
||||
|
||||
if (!php_execute_script(&file_handle)) {
|
||||
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', "<?php\n\ndeclare(strict_types=1);\necho 'hello' . PHP_EOL;\n");
|
||||
|
||||
// Get build configuration using spc-config
|
||||
$util = new \StaticPHP\Util\SPCConfigUtil();
|
||||
$config = $util->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 <sapi/embed/php_embed.h>, 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 +689,95 @@ trait windows
|
||||
|
||||
$builder->deployBinary($src_file, $dst_file);
|
||||
|
||||
// make debug info file path
|
||||
// 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]}");
|
||||
}
|
||||
|
||||
// with-upx-pack for cli, cgi and micro
|
||||
if ($builder->getOption('with-upx-pack', false)) {
|
||||
if (in_array($sapi, ['php-cli', 'php-cgi', 'php-micro'], true)) {
|
||||
cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($dst_file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const string VERSION = '2.8.3';
|
||||
public const string VERSION = '2.8.4';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -96,7 +96,8 @@ class Extension
|
||||
fn ($x) => $x->getStaticLibFiles(),
|
||||
$this->getLibraryDependencies(recursive: true)
|
||||
);
|
||||
return implode(' ', $ret);
|
||||
$libs = implode(' ', $ret);
|
||||
return deduplicate_flags($libs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -365,6 +365,27 @@ abstract class LibraryBase
|
||||
|
||||
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;
|
||||
|
||||
@@ -11,7 +11,6 @@ use SPC\store\FileSystem;
|
||||
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,50 @@ class grpc extends Extension
|
||||
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"'
|
||||
);
|
||||
}
|
||||
|
||||
$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 +79,6 @@ class grpc extends Extension
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -50,19 +50,16 @@ class swoole extends Extension
|
||||
|
||||
// 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') ? ' --enable-iouring --enable-uring-socket' : '';
|
||||
$arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : '';
|
||||
|
||||
// enable additional features that require the pdo extension, but conflict with pdo_* extensions
|
||||
@@ -74,6 +71,7 @@ class swoole extends Extension
|
||||
$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';
|
||||
|
||||
@@ -162,7 +162,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
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...');
|
||||
|
||||
@@ -72,6 +72,10 @@ trait UnixSystemUtilTrait
|
||||
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}";
|
||||
|
||||
@@ -457,6 +457,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
'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}",
|
||||
|
||||
@@ -13,8 +13,8 @@ trait freetype
|
||||
{
|
||||
$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
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ trait libjpeg
|
||||
->addConfigureArgs(
|
||||
'-DENABLE_STATIC=ON',
|
||||
'-DENABLE_SHARED=OFF',
|
||||
'-DWITH_SYSTEM_ZLIB=ON'
|
||||
)
|
||||
->build();
|
||||
// patch pkgconfig
|
||||
|
||||
@@ -93,8 +93,7 @@ trait postgresql
|
||||
|
||||
// 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');
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
trait unixodbc
|
||||
@@ -30,7 +31,15 @@ trait unixodbc
|
||||
'--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();
|
||||
}
|
||||
}
|
||||
|
||||
36
src/SPC/builder/windows/library/brotli.php
Normal file
36
src/SPC/builder/windows/library/brotli.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class brotli extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'brotli';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->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}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ class freetype extends WindowsLibraryBase
|
||||
"-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(
|
||||
|
||||
41
src/SPC/builder/windows/library/libaom.php
Normal file
41
src/SPC/builder/windows/library/libaom.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libaom extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libaom';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
// libaom source tree contains a build/cmake/ directory with its own
|
||||
// cmake modules, so we must use a different name for the build dir.
|
||||
FileSystem::resetDir($this->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}"
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user