mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 16:25:39 +08:00
Compare commits
1 Commits
fix/tool-p
...
v3c/llvm-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6df778f92f |
24
.gitattributes
vendored
24
.gitattributes
vendored
@@ -1,24 +0,0 @@
|
|||||||
# Force LF line endings for all text files.
|
|
||||||
# Prevents git from auto-converting LF -> CRLF on Windows checkouts.
|
|
||||||
* text=auto eol=lf
|
|
||||||
|
|
||||||
# Explicit binary files — git won't touch line endings for these
|
|
||||||
*.phar binary
|
|
||||||
*.png binary
|
|
||||||
*.jpg binary
|
|
||||||
*.jpeg binary
|
|
||||||
*.gif binary
|
|
||||||
*.ico binary
|
|
||||||
*.zip binary
|
|
||||||
*.gz binary
|
|
||||||
*.tgz binary
|
|
||||||
*.txz binary
|
|
||||||
*.xz binary
|
|
||||||
*.bz2 binary
|
|
||||||
*.7z binary
|
|
||||||
*.exe binary
|
|
||||||
*.dll binary
|
|
||||||
*.sfx binary
|
|
||||||
*.so binary
|
|
||||||
*.a binary
|
|
||||||
*.o binary
|
|
||||||
9
.github/workflows/release-build.yml
vendored
9
.github/workflows/release-build.yml
vendored
@@ -38,9 +38,6 @@ jobs:
|
|||||||
- name: "windows-x64"
|
- name: "windows-x64"
|
||||||
os: "ubuntu-latest"
|
os: "ubuntu-latest"
|
||||||
filename: "spc-windows-x64.exe"
|
filename: "spc-windows-x64.exe"
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
attestations: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: "actions/checkout@v5"
|
uses: "actions/checkout@v5"
|
||||||
@@ -108,12 +105,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "Generate build provenance attestation"
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: actions/attest-build-provenance@v4
|
|
||||||
with:
|
|
||||||
subject-path: "${{ github.workspace }}/${{ matrix.operating-system.name == 'windows-x64' && 'spc.exe' || 'spc' }}"
|
|
||||||
|
|
||||||
- name: "Copy file"
|
- name: "Copy file"
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then
|
if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ echo '<?php echo "Hello world!\n";' > a.php
|
|||||||
|
|
||||||
## 直接下载
|
## 直接下载
|
||||||
|
|
||||||
如果你暂时不想构建,或只想先测试,可以从 [Actions](https://github.com/static-php/hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译产物,或从自托管服务器下载。
|
如果你暂时不想构建,或只想先测试,可以从 [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译产物,或从自托管服务器下载。
|
||||||
|
|
||||||
我们为每个 PHP 版本提供 2 种扩展集合:
|
我们为每个 PHP 版本提供 2 种扩展集合:
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ see <https://static-php.dev>.
|
|||||||
|
|
||||||
## Direct Download
|
## Direct Download
|
||||||
|
|
||||||
If you do not want to build yet or just want to test first, you can download example pre-compiled artifacts from [Actions](https://github.com/static-php/hosted/actions/workflows/build-php-bulk.yml) or from a self-hosted server.
|
If you do not want to build yet or just want to test first, you can download example pre-compiled artifacts from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml) or from a self-hosted server.
|
||||||
|
|
||||||
We offer 2 types of extension sets for each PHP version:
|
We offer 2 types of extension sets for each PHP version:
|
||||||
|
|
||||||
|
|||||||
1
box.json
1
box.json
@@ -10,6 +10,7 @@
|
|||||||
"config",
|
"config",
|
||||||
"src",
|
"src",
|
||||||
"vendor/psr",
|
"vendor/psr",
|
||||||
|
"vendor/laravel/prompts",
|
||||||
"vendor/symfony",
|
"vendor/symfony",
|
||||||
"vendor/php-di",
|
"vendor/php-di",
|
||||||
"vendor/zhamao"
|
"vendor/zhamao"
|
||||||
|
|||||||
@@ -12,8 +12,10 @@
|
|||||||
"php": ">=8.4",
|
"php": ">=8.4",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-zlib": "*",
|
"ext-zlib": "*",
|
||||||
|
"laravel/prompts": "~0.1",
|
||||||
"php-di/php-di": "^7.1",
|
"php-di/php-di": "^7.1",
|
||||||
"symfony/console": "^5.4 || ^6 || ^7",
|
"symfony/console": "^5.4 || ^6 || ^7",
|
||||||
|
"symfony/process": "^7.2",
|
||||||
"symfony/yaml": "^7.2",
|
"symfony/yaml": "^7.2",
|
||||||
"zhamao/logger": "^1.1.4"
|
"zhamao/logger": "^1.1.4"
|
||||||
},
|
},
|
||||||
|
|||||||
568
composer.lock
generated
568
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,6 @@ ncurses:
|
|||||||
license-files:
|
license-files:
|
||||||
- COPYING
|
- COPYING
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/ncurses/'
|
|
||||||
regex: '/href="(?<file>ncurses-(?<version>[^"]+)\.tar\.gz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/ncurses/'
|
url: 'https://ftpmirror.gnu.org/gnu/ncurses/'
|
||||||
regex: '/href="(?<file>ncurses-(?<version>[^"]+)\.tar\.gz)"/'
|
regex: '/href="(?<file>ncurses-(?<version>[^"]+)\.tar\.gz)"/'
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ SPC_PRESERVE_LOGS="no"
|
|||||||
[windows]
|
[windows]
|
||||||
; build target: win7-static
|
; build target: win7-static
|
||||||
SPC_TARGET=native-windows
|
SPC_TARGET=native-windows
|
||||||
; MSYS2 root directory (msys64 subfolder), used by the Windows toolchain
|
; php-sdk-binary-tools path
|
||||||
SPC_MSYS2_PATH="${PKG_ROOT_PATH}\msys2-build-essentials\msys64"
|
PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
|
||||||
; upx executable path
|
; upx executable path
|
||||||
UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
|
UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
|
||||||
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
|
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
ext-fastchart:
|
|
||||||
type: php-extension
|
|
||||||
artifact:
|
|
||||||
source:
|
|
||||||
type: ghtar
|
|
||||||
repo: iliaal/fastchart
|
|
||||||
extract: php-src/ext/fastchart
|
|
||||||
prefer-stable: true
|
|
||||||
metadata:
|
|
||||||
license-files: [LICENSE]
|
|
||||||
depends:
|
|
||||||
- freetype
|
|
||||||
suggests:
|
|
||||||
- libpng
|
|
||||||
- libjpeg
|
|
||||||
- libwebp
|
|
||||||
php-extension:
|
|
||||||
os:
|
|
||||||
- Linux
|
|
||||||
- Darwin
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
ext-fastjson:
|
|
||||||
type: php-extension
|
|
||||||
artifact:
|
|
||||||
source:
|
|
||||||
type: ghtar
|
|
||||||
repo: iliaal/fastjson
|
|
||||||
extract: php-src/ext/fastjson
|
|
||||||
prefer-stable: true
|
|
||||||
metadata:
|
|
||||||
license-files: [LICENSE]
|
|
||||||
php-extension:
|
|
||||||
os:
|
|
||||||
- Linux
|
|
||||||
- Darwin
|
|
||||||
@@ -10,5 +10,3 @@ ext-gmssl:
|
|||||||
license: PHP-3.01
|
license: PHP-3.01
|
||||||
depends:
|
depends:
|
||||||
- gmssl
|
- gmssl
|
||||||
php-extension:
|
|
||||||
arg-type: with-path
|
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ ext-zip:
|
|||||||
license: PHP-3.01
|
license: PHP-3.01
|
||||||
depends:
|
depends:
|
||||||
- libzip
|
- libzip
|
||||||
depends@windows:
|
|
||||||
- libzip
|
|
||||||
- zlib
|
|
||||||
- xz
|
|
||||||
- bzip2
|
|
||||||
php-extension:
|
php-extension:
|
||||||
arg-type: custom
|
arg-type: custom
|
||||||
arg-type@windows: enable
|
arg-type@windows: enable
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ gettext:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/gettext/'
|
|
||||||
regex: '/href="(?<file>gettext-(?<version>[^"]+)\.tar\.xz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/gettext/'
|
url: 'https://ftpmirror.gnu.org/gnu/gettext/'
|
||||||
regex: '/href="(?<file>gettext-(?<version>[^"]+)\.tar\.xz)"/'
|
regex: '/href="(?<file>gettext-(?<version>[^"]+)\.tar\.xz)"/'
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ gmp:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/gmp/'
|
|
||||||
regex: '/href="(?<file>gmp-(?<version>[^"]+)\.tar\.xz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/gmp/'
|
url: 'https://ftpmirror.gnu.org/gnu/gmp/'
|
||||||
regex: '/href="(?<file>gmp-(?<version>[^"]+)\.tar\.xz)"/'
|
regex: '/href="(?<file>gmp-(?<version>[^"]+)\.tar\.xz)"/'
|
||||||
|
source-mirror:
|
||||||
|
type: url
|
||||||
|
url: 'https://dl.static-php.dev/static-php-cli/deps/gmp/gmp-6.3.0.tar.xz'
|
||||||
metadata:
|
metadata:
|
||||||
license-files: ['@/gmp.txt']
|
license-files: ['@/gmp.txt']
|
||||||
license: Custom
|
license: Custom
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ idn2:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/libidn/'
|
|
||||||
regex: '/href="(?<file>libidn2-(?<version>[^"]+)\.tar\.gz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/libidn/'
|
url: 'https://ftpmirror.gnu.org/gnu/libidn/'
|
||||||
regex: '/href="(?<file>libidn2-(?<version>[^"]+)\.tar\.gz)"/'
|
regex: '/href="(?<file>libidn2-(?<version>[^"]+)\.tar\.gz)"/'
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ libiconv:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/libiconv/'
|
|
||||||
regex: '/href="(?<file>libiconv-(?<version>[^"]+)\.tar\.gz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/libiconv/'
|
url: 'https://ftpmirror.gnu.org/gnu/libiconv/'
|
||||||
regex: '/href="(?<file>libiconv-(?<version>[^"]+)\.tar\.gz)"/'
|
regex: '/href="(?<file>libiconv-(?<version>[^"]+)\.tar\.gz)"/'
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ libssh2:
|
|||||||
metadata:
|
metadata:
|
||||||
license-files: [COPYING]
|
license-files: [COPYING]
|
||||||
license: BSD-3-Clause
|
license: BSD-3-Clause
|
||||||
depends@unix:
|
depends:
|
||||||
- openssl
|
- openssl
|
||||||
depends@windows:
|
|
||||||
- zlib
|
|
||||||
headers:
|
headers:
|
||||||
- libssh2.h
|
- libssh2.h
|
||||||
- libssh2_publickey.h
|
- libssh2_publickey.h
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ libunistring:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/libunistring/'
|
|
||||||
regex: '/href="(?<file>libunistring-(?<version>[^"]+)\.tar\.gz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/libunistring/'
|
url: 'https://ftpmirror.gnu.org/gnu/libunistring/'
|
||||||
regex: '/href="(?<file>libunistring-(?<version>[^"]+)\.tar\.gz)"/'
|
regex: '/href="(?<file>libunistring-(?<version>[^"]+)\.tar\.gz)"/'
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ openssl:
|
|||||||
- zlib
|
- zlib
|
||||||
depends@windows:
|
depends@windows:
|
||||||
- zlib
|
- zlib
|
||||||
|
- jom
|
||||||
headers:
|
headers:
|
||||||
- openssl
|
- openssl
|
||||||
static-libs@unix:
|
static-libs@unix:
|
||||||
@@ -25,6 +26,3 @@ openssl:
|
|||||||
static-libs@windows:
|
static-libs@windows:
|
||||||
- libssl.lib
|
- libssl.lib
|
||||||
- libcrypto.lib
|
- libcrypto.lib
|
||||||
tools@windows:
|
|
||||||
- jom
|
|
||||||
- strawberry-perl
|
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ readline:
|
|||||||
type: library
|
type: library
|
||||||
artifact:
|
artifact:
|
||||||
source:
|
source:
|
||||||
type: filelist
|
|
||||||
url: 'https://ftp.gnu.org/gnu/readline/'
|
|
||||||
regex: '/href="(?<file>readline-(?<version>[^"]+)\.tar\.gz)"/'
|
|
||||||
source-mirror:
|
|
||||||
type: filelist
|
type: filelist
|
||||||
url: 'https://ftpmirror.gnu.org/gnu/readline/'
|
url: 'https://ftpmirror.gnu.org/gnu/readline/'
|
||||||
regex: '/href="(?<file>readline-(?<version>[^"]+)\.tar\.gz)"/'
|
regex: '/href="(?<file>readline-(?<version>[^"]+)\.tar\.gz)"/'
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ frankenphp:
|
|||||||
license: MIT
|
license: MIT
|
||||||
depends:
|
depends:
|
||||||
- php-embed
|
- php-embed
|
||||||
|
- go-xcaddy
|
||||||
depends@windows:
|
depends@windows:
|
||||||
- php-embed
|
- php-embed
|
||||||
|
- go-win
|
||||||
- pthreads4w
|
- pthreads4w
|
||||||
suggests@unix:
|
suggests@unix:
|
||||||
- brotli
|
- brotli
|
||||||
@@ -22,7 +24,3 @@ frankenphp:
|
|||||||
- frankenphp
|
- frankenphp
|
||||||
static-bins@windows:
|
static-bins@windows:
|
||||||
- frankenphp.exe
|
- frankenphp.exe
|
||||||
tools:
|
|
||||||
- go-xcaddy
|
|
||||||
tools@windows:
|
|
||||||
- go-win
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
go-win:
|
go-win:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary: custom
|
binary: custom
|
||||||
env:
|
env:
|
||||||
@@ -8,8 +8,3 @@ go-win:
|
|||||||
GOPATH: '{pkg_root_path}/go-win/go'
|
GOPATH: '{pkg_root_path}/go-win/go'
|
||||||
path@windows:
|
path@windows:
|
||||||
- '{pkg_root_path}/go-win/bin'
|
- '{pkg_root_path}/go-win/bin'
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- go.exe
|
|
||||||
- gofmt.exe
|
|
||||||
binary-subdir: go-win/bin
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
go-xcaddy:
|
go-xcaddy:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary: custom
|
binary: custom
|
||||||
env:
|
env:
|
||||||
@@ -8,8 +8,5 @@ go-xcaddy:
|
|||||||
GOPATH: '{pkg_root_path}/go-xcaddy/go'
|
GOPATH: '{pkg_root_path}/go-xcaddy/go'
|
||||||
path@unix:
|
path@unix:
|
||||||
- '{pkg_root_path}/go-xcaddy/bin'
|
- '{pkg_root_path}/go-xcaddy/bin'
|
||||||
tool:
|
static-bins:
|
||||||
provides:
|
- xcaddy
|
||||||
- go
|
|
||||||
- gofmt
|
|
||||||
binary-subdir: go-xcaddy/bin
|
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
jom:
|
jom:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary:
|
binary:
|
||||||
windows-x86_64: { type: url, url: 'https://download.qt.io/official_releases/jom/jom.zip', extract: '{pkg_root_path}/jom' }
|
windows-x86_64: { type: url, url: 'https://download.qt.io/official_releases/jom/jom.zip', extract: '{pkg_root_path}/jom' }
|
||||||
path@windows:
|
path@windows:
|
||||||
- '{pkg_root_path}\jom'
|
- '{pkg_root_path}\jom'
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- jom.exe
|
|
||||||
binary-subdir: jom
|
|
||||||
6
config/pkg/target/llvm-tools.yml
Normal file
6
config/pkg/target/llvm-tools.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
llvm-tools:
|
||||||
|
type: target
|
||||||
|
artifact:
|
||||||
|
binary: custom
|
||||||
|
depends:
|
||||||
|
- zig
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
msys2-build-essentials:
|
|
||||||
type: target
|
|
||||||
artifact:
|
|
||||||
binary: custom
|
|
||||||
env:
|
|
||||||
SPC_MSYS2_PATH: '{pkg_root_path}/msys2-build-essentials/msys64'
|
|
||||||
path@windows:
|
|
||||||
- '{pkg_root_path}/msys2-build-essentials/msys64/usr/bin'
|
|
||||||
5
config/pkg/target/nasm.yml
Normal file
5
config/pkg/target/nasm.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
nasm:
|
||||||
|
type: target
|
||||||
|
artifact:
|
||||||
|
binary:
|
||||||
|
windows-x86_64: { type: url, url: 'https://dl.static-php.dev/static-php-cli/deps/nasm/nasm-2.16.01-win64.zip', extract: { nasm.exe: '{php_sdk_path}/bin/nasm.exe', ndisasm.exe: '{php_sdk_path}/bin/ndisasm.exe' } }
|
||||||
5
config/pkg/target/php-sdk-binary-tools.yml
Normal file
5
config/pkg/target/php-sdk-binary-tools.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
php-sdk-binary-tools:
|
||||||
|
type: target
|
||||||
|
artifact:
|
||||||
|
binary:
|
||||||
|
windows-x86_64: { type: git, rev: master, url: 'https://github.com/php/php-sdk-binary-tools.git', extract: '{php_sdk_path}' }
|
||||||
9
config/pkg/target/pkg-config.yml
Normal file
9
config/pkg/target/pkg-config.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
pkg-config:
|
||||||
|
type: target
|
||||||
|
artifact:
|
||||||
|
source: 'https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz'
|
||||||
|
binary:
|
||||||
|
linux-x86_64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-x86_64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||||
|
linux-aarch64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-aarch64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||||
|
macos-x86_64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-x86_64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||||
|
macos-aarch64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-aarch64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
protoc:
|
protoc:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary:
|
binary:
|
||||||
linux-x86_64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-x86_64\.zip', extract: '{pkg_root_path}/protoc' }
|
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' }
|
linux-aarch64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-aarch_64\.zip', extract: '{pkg_root_path}/protoc' }
|
||||||
path:
|
path:
|
||||||
- '{pkg_root_path}/protoc/bin'
|
- '{pkg_root_path}/protoc/bin'
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- protoc
|
|
||||||
binary-subdir: protoc/bin
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
strawberry-perl:
|
strawberry-perl:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary:
|
binary:
|
||||||
windows-x86_64: { type: url, url: 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip', extract: '{pkg_root_path}/strawberry-perl' }
|
windows-x86_64: { type: url, url: 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip', extract: '{pkg_root_path}/strawberry-perl' }
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- perl.exe
|
|
||||||
binary-subdir: strawberry-perl/perl/bin
|
|
||||||
@@ -1,13 +1,7 @@
|
|||||||
upx:
|
upx:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary:
|
binary:
|
||||||
linux-x86_64: { type: ghrel, repo: upx/upx, match: upx.+-amd64_linux\.tar\.xz, extract: { upx: '{pkg_root_path}/bin/upx' } }
|
linux-x86_64: { type: ghrel, repo: upx/upx, match: upx.+-amd64_linux\.tar\.xz, extract: { upx: '{pkg_root_path}/bin/upx' } }
|
||||||
linux-aarch64: { type: ghrel, repo: upx/upx, match: upx.+-arm64_linux\.tar\.xz, extract: { upx: '{pkg_root_path}/bin/upx' } }
|
linux-aarch64: { type: ghrel, repo: upx/upx, match: upx.+-arm64_linux\.tar\.xz, extract: { upx: '{pkg_root_path}/bin/upx' } }
|
||||||
windows-x86_64: { type: ghrel, repo: upx/upx, match: upx.+-win64\.zip, extract: { upx.exe: '{pkg_root_path}/bin/upx.exe' } }
|
windows-x86_64: { type: ghrel, repo: upx/upx, match: upx.+-win64\.zip, extract: { upx.exe: '{pkg_root_path}/bin/upx.exe' } }
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- upx
|
|
||||||
provides@windows:
|
|
||||||
- upx.exe
|
|
||||||
binary-subdir: bin
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
vswhere:
|
vswhere:
|
||||||
type: tool
|
type: target
|
||||||
artifact:
|
artifact:
|
||||||
binary:
|
binary:
|
||||||
windows-x86_64: { type: url, url: 'https://github.com/microsoft/vswhere/releases/download/3.1.7/vswhere.exe', extract: '{pkg_root_path}/bin/vswhere.exe' }
|
windows-x86_64: { type: url, url: 'https://github.com/microsoft/vswhere/releases/download/3.1.7/vswhere.exe', extract: '{pkg_root_path}/bin/vswhere.exe' }
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- vswhere.exe
|
|
||||||
binary-subdir: bin
|
|
||||||
4
config/pkg/target/zig.yml
Normal file
4
config/pkg/target/zig.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
zig:
|
||||||
|
type: target
|
||||||
|
artifact:
|
||||||
|
binary: custom
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
7za-win:
|
|
||||||
type: tool
|
|
||||||
artifact:
|
|
||||||
binary:
|
|
||||||
windows-x86_64: { type: url, url: 'https://dl.static-php.dev/v3/tools/7zip/7za.exe', extract: '{pkg_root_path}/bin/7za.exe' }
|
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- 7za.exe
|
|
||||||
binary-subdir: bin
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
nasm:
|
|
||||||
type: tool
|
|
||||||
artifact:
|
|
||||||
binary:
|
|
||||||
windows-x86_64: { type: url, url: 'https://dl.static-php.dev/static-php-cli/deps/nasm/nasm-2.16.01-win64.zip', extract: { nasm.exe: '{pkg_root_path}/bin/nasm.exe', ndisasm.exe: '{pkg_root_path}/bin/ndisasm.exe' } }
|
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- nasm.exe
|
|
||||||
- ndisasm.exe
|
|
||||||
binary-subdir: bin
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
pkg-config:
|
|
||||||
type: tool
|
|
||||||
artifact:
|
|
||||||
source: 'https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz'
|
|
||||||
binary:
|
|
||||||
linux-x86_64: { type: ghrel, repo: static-php/hosted, match: pkg-config-x86_64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
|
||||||
linux-aarch64: { type: ghrel, repo: static-php/hosted, match: pkg-config-aarch64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
|
||||||
macos-x86_64: { type: ghrel, repo: static-php/hosted, match: pkg-config-x86_64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
|
||||||
macos-aarch64: { type: ghrel, repo: static-php/hosted, match: pkg-config-aarch64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- pkg-config
|
|
||||||
binary-subdir: bin
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
zig:
|
|
||||||
type: tool
|
|
||||||
artifact:
|
|
||||||
binary: custom
|
|
||||||
tool:
|
|
||||||
provides:
|
|
||||||
- zig
|
|
||||||
- zig-cc
|
|
||||||
- zig-c++
|
|
||||||
- zig-ar
|
|
||||||
- zig-ld.lld
|
|
||||||
- zig-ranlib
|
|
||||||
- zig-objcopy
|
|
||||||
binary-subdir: zig
|
|
||||||
@@ -229,7 +229,7 @@ The following path placeholders are supported in string values of the `path`, `e
|
|||||||
| `{working_dir}` | Working directory (project root) |
|
| `{working_dir}` | Working directory (project root) |
|
||||||
| `{download_path}` | Download cache directory (`downloads/`) |
|
| `{download_path}` | Download cache directory (`downloads/`) |
|
||||||
| `{source_path}` | Extracted source directory (`source/`) |
|
| `{source_path}` | Extracted source directory (`source/`) |
|
||||||
| `{spc_msys2_path}` | MSYS2 root directory (`msys64/`) — Windows only |
|
| `{php_sdk_path}` | Windows PHP SDK directory |
|
||||||
|
|
||||||
## target Package Type
|
## target Package Type
|
||||||
|
|
||||||
|
|||||||
@@ -58,13 +58,7 @@ A single-file hook API for lightweight patches may be provided in a future relea
|
|||||||
|
|
||||||
### Windows-only: `--with-sdk-binary-dir` and `--vs-ver`
|
### Windows-only: `--with-sdk-binary-dir` and `--vs-ver`
|
||||||
|
|
||||||
These options are no longer accepted on the command line. In v3, the `php-sdk-binary-tools` dependency has been completely removed. v3 now manages its own **MSYS2** environment to support autotools-based library builds on Windows. Run `spc doctor --install` to download and configure MSYS2 automatically.
|
These options are no longer accepted on the command line. Instead, set the `PHP_SDK_PATH` environment variable to point to your PHP SDK binary tools directory. The Visual Studio version is now managed by the toolchain configuration.
|
||||||
|
|
||||||
If you need to point to a custom MSYS2 installation, set the `SPC_MSYS2_PATH` environment variable to the `msys64` directory (e.g. `C:\msys64`). Visual Studio is now auto-detected by the toolchain — no manual version flag needed.
|
|
||||||
|
|
||||||
::: warning Migrating from v2
|
|
||||||
v2 relied on `php-sdk-binary-tools` and required `--with-sdk-binary-dir` and `--vs-ver` on every build invocation. In v3 these options are gone. Remove them from all CI scripts and run `spc doctor --install` once to set up the Windows build environment.
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Renamed / Deprecated Options
|
## Renamed / Deprecated Options
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ openssl:
|
|||||||
| `{working_dir}` | 工作目录(项目根目录) |
|
| `{working_dir}` | 工作目录(项目根目录) |
|
||||||
| `{download_path}` | 下载缓存目录(`downloads/`) |
|
| `{download_path}` | 下载缓存目录(`downloads/`) |
|
||||||
| `{source_path}` | 解压源码目录(`source/`) |
|
| `{source_path}` | 解压源码目录(`source/`) |
|
||||||
| `{spc_msys2_path}` | MSYS2 根目录(`msys64/`)——仅 Windows |
|
| `{php_sdk_path}` | Windows PHP SDK 目录 |
|
||||||
|
|
||||||
## target 包类型
|
## target 包类型
|
||||||
|
|
||||||
|
|||||||
@@ -58,13 +58,7 @@ curl -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
|
|||||||
|
|
||||||
### Windows 专有:`--with-sdk-binary-dir` 和 `--vs-ver`
|
### Windows 专有:`--with-sdk-binary-dir` 和 `--vs-ver`
|
||||||
|
|
||||||
这两个选项已不再被命令行接受。在 v3 中,`php-sdk-binary-tools` 依赖已被完全移除。v3 现在通过管理自己的 **MSYS2** 环境来支持 Windows 上基于 autotools 的库构建。运行 `spc doctor --install` 即可自动下载并配置 MSYS2。
|
这两个选项已不再被命令行接受。请改为设置 `PHP_SDK_PATH` 环境变量,指向你的 PHP SDK binary tools 目录。Visual Studio 版本现在由工具链配置统一管理。
|
||||||
|
|
||||||
如需指向自定义 MSYS2 安装目录,请设置 `SPC_MSYS2_PATH` 环境变量,值为 `msys64` 目录路径(例如 `C:\msys64`)。Visual Studio 版本现在由工具链自动检测,无需手动指定版本号。
|
|
||||||
|
|
||||||
::: warning 从 v2 迁移
|
|
||||||
v2 依赖 `php-sdk-binary-tools`,并在每次构建时需要传入 `--with-sdk-binary-dir` 和 `--vs-ver` 参数。在 v3 中这些选项已被移除。请从所有 CI 脚本中删除这些参数,并使用 `spc doctor --install` 一次性完成 Windows 构建环境的配置。
|
|
||||||
:::
|
|
||||||
|
|
||||||
## 已重命名 / 已弃用的选项
|
## 已重命名 / 已弃用的选项
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
parameters:
|
parameters:
|
||||||
reportUnmatchedIgnoredErrors: false
|
reportUnmatchedIgnoredErrors: false
|
||||||
level: 5
|
level: 4
|
||||||
phpVersion: 80400
|
phpVersion: 80400
|
||||||
paths:
|
paths:
|
||||||
- ./src/
|
- ./src/
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ package:
|
|||||||
- config/pkg/lib/
|
- config/pkg/lib/
|
||||||
- config/pkg/target/
|
- config/pkg/target/
|
||||||
- config/pkg/ext/
|
- config/pkg/ext/
|
||||||
- config/pkg/tool/
|
|
||||||
artifact:
|
artifact:
|
||||||
config:
|
config:
|
||||||
- config/artifact/
|
- config/artifact/
|
||||||
|
|||||||
162
src/Package/Artifact/llvm_tools.php
Normal file
162
src/Package/Artifact/llvm_tools.php
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<?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\Artifact\Downloader\Type\GitHubTokenSetupTrait;
|
||||||
|
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
|
||||||
|
use StaticPHP\Attribute\Artifact\CustomBinary;
|
||||||
|
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
|
||||||
|
use StaticPHP\DI\ApplicationContext;
|
||||||
|
use StaticPHP\Exception\BuildFailureException;
|
||||||
|
use StaticPHP\Exception\DownloaderException;
|
||||||
|
use StaticPHP\Package\PackageBuilder;
|
||||||
|
|
||||||
|
class llvm_tools
|
||||||
|
{
|
||||||
|
use GitHubTokenSetupTrait;
|
||||||
|
|
||||||
|
public const array TOOLS = ['llvm-objcopy', 'llvm-strip', 'llvm-profdata'];
|
||||||
|
|
||||||
|
/** Install prefix for the locally-built llvm-tools. */
|
||||||
|
public static function path(): string
|
||||||
|
{
|
||||||
|
return PKG_ROOT_PATH . '/llvm-tools';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Path to a binary under llvm-tools/bin (llvm-objcopy, llvm-strip, llvm-profdata, …). */
|
||||||
|
public static function binary(string $name = 'llvm-strip'): string
|
||||||
|
{
|
||||||
|
return self::path() . '/bin/' . $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** True when every required TOOLS binary is present and executable. */
|
||||||
|
public static function isInstalled(): bool
|
||||||
|
{
|
||||||
|
foreach (self::TOOLS as $t) {
|
||||||
|
$p = self::binary($t);
|
||||||
|
if (!is_file($p) || !is_executable($p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[CustomBinary('llvm-tools', [
|
||||||
|
'linux-x86_64',
|
||||||
|
'linux-aarch64',
|
||||||
|
'macos-x86_64',
|
||||||
|
'macos-aarch64',
|
||||||
|
])]
|
||||||
|
public function downBinary(ArtifactDownloader $downloader): DownloadResult
|
||||||
|
{
|
||||||
|
$llvmVersion = $this->detectLlvmVersion()
|
||||||
|
?? throw new DownloaderException('Could not detect a clang version on host; install zig or clang first');
|
||||||
|
$tarball = "llvm-project-{$llvmVersion}.src.tar.xz";
|
||||||
|
$url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-{$llvmVersion}/{$tarball}";
|
||||||
|
$tarballPath = DOWNLOAD_PATH . '/' . $tarball;
|
||||||
|
default_shell()->executeCurlDownload($url, $tarballPath, headers: $this->getGitHubTokenHeaders(), retries: $downloader->getRetry());
|
||||||
|
return DownloadResult::archive($tarball, ['url' => $url, 'version' => $llvmVersion], extract: '{source_path}/llvm-tools', verified: false, version: $llvmVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[CustomBinaryCheckUpdate('llvm-tools', [
|
||||||
|
'linux-x86_64',
|
||||||
|
'linux-aarch64',
|
||||||
|
'macos-x86_64',
|
||||||
|
'macos-aarch64',
|
||||||
|
])]
|
||||||
|
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
|
||||||
|
{
|
||||||
|
$llvmVersion = $this->detectLlvmVersion()
|
||||||
|
?? throw new DownloaderException('Could not detect a clang version on host; install zig or clang first');
|
||||||
|
return new CheckUpdateResult(
|
||||||
|
old: $old_version,
|
||||||
|
new: $llvmVersion,
|
||||||
|
needUpdate: $old_version === null || $llvmVersion !== $old_version,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[AfterBinaryExtract('llvm-tools', [
|
||||||
|
'linux-x86_64',
|
||||||
|
'linux-aarch64',
|
||||||
|
'macos-x86_64',
|
||||||
|
'macos-aarch64',
|
||||||
|
])]
|
||||||
|
public function postExtract(string $target_path): void
|
||||||
|
{
|
||||||
|
$this->buildForHost($target_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForHost(?string $sourceRoot = null): void
|
||||||
|
{
|
||||||
|
$sourceRoot ??= SOURCE_PATH . '/llvm-tools';
|
||||||
|
if (self::isInstalled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$llvmDir = "{$sourceRoot}/llvm";
|
||||||
|
if (!is_dir($llvmDir)) {
|
||||||
|
throw new BuildFailureException("llvm-tools: missing source at {$llvmDir} (extraction layout changed?)");
|
||||||
|
}
|
||||||
|
$buildDir = "{$sourceRoot}/build";
|
||||||
|
$installDir = self::path();
|
||||||
|
$binDir = self::path() . '/bin';
|
||||||
|
f_mkdir($buildDir, recursive: true);
|
||||||
|
f_mkdir($binDir, recursive: true);
|
||||||
|
|
||||||
|
$cmakeArgs = implode(' ', array_map('escapeshellarg', [
|
||||||
|
'-S', $llvmDir,
|
||||||
|
'-B', $buildDir,
|
||||||
|
'-DCMAKE_BUILD_TYPE=Release',
|
||||||
|
'-DLLVM_ENABLE_PROJECTS=',
|
||||||
|
'-DLLVM_TARGETS_TO_BUILD=',
|
||||||
|
'-DLLVM_INCLUDE_BENCHMARKS=OFF',
|
||||||
|
'-DLLVM_INCLUDE_TESTS=OFF',
|
||||||
|
'-DLLVM_INCLUDE_EXAMPLES=OFF',
|
||||||
|
'-DLLVM_INCLUDE_DOCS=OFF',
|
||||||
|
'-DLLVM_ENABLE_ZLIB=OFF',
|
||||||
|
'-DLLVM_ENABLE_ZSTD=OFF',
|
||||||
|
'-DLLVM_ENABLE_LIBXML2=OFF',
|
||||||
|
'-DLLVM_ENABLE_TERMINFO=OFF',
|
||||||
|
'-DLLVM_ENABLE_LIBEDIT=OFF',
|
||||||
|
'-DLLVM_ENABLE_LIBPFM=OFF',
|
||||||
|
'-DLLVM_BUILD_LLVM_DYLIB=OFF',
|
||||||
|
'-DLLVM_LINK_LLVM_DYLIB=OFF',
|
||||||
|
'-DBUILD_SHARED_LIBS=OFF',
|
||||||
|
'-DCMAKE_C_COMPILER=' . zig::binary('zig-cc'),
|
||||||
|
'-DCMAKE_CXX_COMPILER=' . zig::binary('zig-c++'),
|
||||||
|
'-DCMAKE_INSTALL_PREFIX=' . $installDir,
|
||||||
|
]));
|
||||||
|
$jobs = ApplicationContext::get(PackageBuilder::class)->concurrency;
|
||||||
|
$targetArgs = implode(' ', array_map(fn ($t) => '--target ' . escapeshellarg($t), self::TOOLS));
|
||||||
|
|
||||||
|
shell()
|
||||||
|
->setEnv(['SPC_TARGET' => GNU_ARCH . '-linux-musl'])
|
||||||
|
->exec('cmake ' . $cmakeArgs)
|
||||||
|
->exec('cmake --build ' . escapeshellarg($buildDir) . ' ' . $targetArgs . " -j {$jobs}");
|
||||||
|
|
||||||
|
foreach (self::TOOLS as $t) {
|
||||||
|
$built = "{$buildDir}/bin/{$t}";
|
||||||
|
if (!is_file($built)) {
|
||||||
|
throw new BuildFailureException("llvm-tools: missing build output {$built}");
|
||||||
|
}
|
||||||
|
copy($built, self::binary($t));
|
||||||
|
chmod(self::binary($t), 0755);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function detectLlvmVersion(): ?string
|
||||||
|
{
|
||||||
|
if (!zig::isInstalled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
[$rc, $out] = shell()->execWithResult(escapeshellarg(zig::binary()) . ' cc --version', false);
|
||||||
|
if ($rc !== 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return preg_match('/clang version (\d+\.\d+\.\d+)/', implode("\n", $out), $m) ? $m[1] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Package\Artifact;
|
|
||||||
|
|
||||||
use StaticPHP\Artifact\ArtifactDownloader;
|
|
||||||
use StaticPHP\Artifact\Downloader\DownloadResult;
|
|
||||||
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
|
|
||||||
use StaticPHP\Attribute\Artifact\BinaryExtract;
|
|
||||||
use StaticPHP\Attribute\Artifact\CustomBinary;
|
|
||||||
use StaticPHP\Exception\DownloaderException;
|
|
||||||
use StaticPHP\Util\FileSystem;
|
|
||||||
use StaticPHP\Util\GlobalEnvManager;
|
|
||||||
|
|
||||||
class msys2_build_essentials
|
|
||||||
{
|
|
||||||
// MSYS subsystem packages required for autotools-based builds.
|
|
||||||
private const REQUIRED_PACKAGES = ['make', 'autoconf', 'automake', 'libtool', 'pkgconf', 'perl', 'bison', 're2c'];
|
|
||||||
|
|
||||||
#[CustomBinary('msys2-build-essentials', ['windows-x86_64'])]
|
|
||||||
public function downBinary(ArtifactDownloader $downloader): DownloadResult
|
|
||||||
{
|
|
||||||
// MSYS2 nightly self-extracting archive; running it with `-y -oTARGET` extracts to TARGET\msys64\.
|
|
||||||
$url = 'https://github.com/msys2/msys2-installer/releases/download/nightly-x86_64/msys2-base-x86_64-latest.sfx.exe';
|
|
||||||
$filename = 'msys2-base-x86_64-latest.sfx.exe';
|
|
||||||
$path = DOWNLOAD_PATH . DIRECTORY_SEPARATOR . $filename;
|
|
||||||
|
|
||||||
default_shell()->executeCurlDownload($url, $path, retries: $downloader->getRetry());
|
|
||||||
|
|
||||||
return DownloadResult::file(
|
|
||||||
$filename,
|
|
||||||
['url' => $url, 'version' => 'nightly'],
|
|
||||||
version: 'nightly',
|
|
||||||
extract: '{pkg_root_path}/msys2-build-essentials',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[BinaryExtract('msys2-build-essentials', ['windows-x86_64'])]
|
|
||||||
public function extractBinary(string $source_file, string $target_path): void
|
|
||||||
{
|
|
||||||
$target_path = FileSystem::convertPath($target_path);
|
|
||||||
$source_file = FileSystem::convertPath($source_file);
|
|
||||||
|
|
||||||
// Guard: skip re-extraction if already initialized (marker written at end of this method).
|
|
||||||
$marker = "{$target_path}\\.spc-msys2-initialized";
|
|
||||||
if (file_exists($marker)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_dir($target_path)) {
|
|
||||||
FileSystem::createDir($target_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd()->exec("\"{$source_file}\" -y -o\"{$target_path}\"");
|
|
||||||
|
|
||||||
$msys2_bin = "{$target_path}\\msys64\\usr\\bin";
|
|
||||||
if (!file_exists("{$msys2_bin}\\bash.exe")) {
|
|
||||||
throw new DownloaderException("MSYS2 extraction failed: bash.exe not found at {$msys2_bin}\\bash.exe");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add MSYS2 usr\bin to PATH so pacman.exe can load msys-2.0.dll.
|
|
||||||
GlobalEnvManager::addPathIfNotExists($msys2_bin);
|
|
||||||
GlobalEnvManager::putenv('CHERE_INVOKING=yes');
|
|
||||||
GlobalEnvManager::putenv('MSYSTEM=MSYS');
|
|
||||||
|
|
||||||
// Disable PGP signature checking: pacman-key --init requires a pseudo-TTY which is unavailable
|
|
||||||
// from PHP. Patching pacman.conf is the standard approach for CI pipelines.
|
|
||||||
$pacman_conf = "{$target_path}\\msys64\\etc\\pacman.conf";
|
|
||||||
FileSystem::replaceFileRegex($pacman_conf, '/^SigLevel\s*=.*$/m', 'SigLevel = Never');
|
|
||||||
|
|
||||||
$pacman = "{$target_path}\\msys64\\usr\\bin\\pacman.exe";
|
|
||||||
|
|
||||||
// Two-pass update as recommended by MSYS2 CI docs.
|
|
||||||
cmd()->exec("\"{$pacman}\" --noconfirm -Syuu");
|
|
||||||
cmd()->exec("\"{$pacman}\" --noconfirm -Syuu");
|
|
||||||
|
|
||||||
$pkgs = implode(' ', self::REQUIRED_PACKAGES);
|
|
||||||
cmd()->exec("\"{$pacman}\" --noconfirm -S --needed {$pkgs}");
|
|
||||||
|
|
||||||
FileSystem::writeFile($marker, date('Y-m-d H:i:s'));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[AfterBinaryExtract('msys2-build-essentials', ['windows-x86_64'])]
|
|
||||||
public function afterExtract(string $target_path): void
|
|
||||||
{
|
|
||||||
$target_path = FileSystem::convertPath($target_path);
|
|
||||||
$msys2_root = "{$target_path}\\msys64";
|
|
||||||
|
|
||||||
GlobalEnvManager::putenv("SPC_MSYS2_PATH={$msys2_root}");
|
|
||||||
GlobalEnvManager::addPathIfNotExists("{$msys2_root}\\usr\\bin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,23 @@ use StaticPHP\Runtime\SystemTarget;
|
|||||||
|
|
||||||
class zig
|
class zig
|
||||||
{
|
{
|
||||||
|
/** Directory zig extracts into. */
|
||||||
|
public static function path(): string
|
||||||
|
{
|
||||||
|
return PKG_ROOT_PATH . '/zig';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Path to a binary inside the zig install dir (zig, zig-cc, zig-c++, zig-ar, …). */
|
||||||
|
public static function binary(string $name = 'zig'): string
|
||||||
|
{
|
||||||
|
return self::path() . '/' . $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isInstalled(): bool
|
||||||
|
{
|
||||||
|
return is_file(self::binary());
|
||||||
|
}
|
||||||
|
|
||||||
#[CustomBinary('zig', [
|
#[CustomBinary('zig', [
|
||||||
'linux-x86_64',
|
'linux-x86_64',
|
||||||
'linux-aarch64',
|
'linux-aarch64',
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?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\PhpExtensionPackage;
|
|
||||||
use StaticPHP\Util\FileSystem;
|
|
||||||
|
|
||||||
#[Extension('gmssl')]
|
|
||||||
class gmssl extends PhpExtensionPackage
|
|
||||||
{
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gmssl')]
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')]
|
|
||||||
#[PatchDescription('Fix ext-gmssl v1.1.1 compatibility with GmSSL >= 3.1.0 where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')]
|
|
||||||
public function patchSm2VerifyCtx(): void
|
|
||||||
{
|
|
||||||
// See: https://github.com/crazywhalecc/static-php-cli/issues/1182
|
|
||||||
FileSystem::replaceFileStr(
|
|
||||||
"{$this->getSourceDir()}/gmssl.c",
|
|
||||||
'SM2_VERIFY_CTX',
|
|
||||||
'SM2_SIGN_CTX'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gmssl')]
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')]
|
|
||||||
#[PatchDescription('Fix ext-gmssl v1.1.1: pbkdf2_hmac_sm3_genkey was renamed to sm3_pbkdf2 in GmSSL >= 3.2.0')]
|
|
||||||
public function patchPbkdf2Rename(): void
|
|
||||||
{
|
|
||||||
FileSystem::replaceFileStr(
|
|
||||||
"{$this->getSourceDir()}/gmssl.c",
|
|
||||||
'pbkdf2_hmac_sm3_genkey',
|
|
||||||
'sm3_pbkdf2'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')]
|
|
||||||
#[PatchDescription('Add CHECK_LIB to config.w32 for static Windows builds')]
|
|
||||||
public function patchBeforeBuildconfWin(): bool
|
|
||||||
{
|
|
||||||
$configW32 = "{$this->getSourceDir()}/config.w32";
|
|
||||||
if (str_contains(FileSystem::readFile($configW32), 'CHECK_LIB(')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FileSystem::replaceFileStr(
|
|
||||||
$configW32,
|
|
||||||
'AC_DEFINE(',
|
|
||||||
'CHECK_LIB("gmssl.lib", "gmssl", PHP_GMSSL);' . PHP_EOL . 'AC_DEFINE('
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,6 @@ class gettext_win
|
|||||||
{
|
{
|
||||||
$ver = WindowsUtil::findVisualStudio();
|
$ver = WindowsUtil::findVisualStudio();
|
||||||
$vs_ver_dir = match ($ver['major_version']) {
|
$vs_ver_dir = match ($ver['major_version']) {
|
||||||
'18', // VS 2026 reuses the VS2022 (MSVC17) solution, which msbuild builds via forward compatibility.
|
|
||||||
'17' => '\MSVC17',
|
'17' => '\MSVC17',
|
||||||
'16' => '\MSVC16',
|
'16' => '\MSVC16',
|
||||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||||
@@ -45,9 +44,7 @@ class gettext_win
|
|||||||
{
|
{
|
||||||
$vs_ver_dir = ApplicationContext::get('gettext_win_vs_ver_dir');
|
$vs_ver_dir = ApplicationContext::get('gettext_win_vs_ver_dir');
|
||||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static")
|
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static")
|
||||||
// WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot
|
->exec('msbuild libintl_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0');
|
||||||
// read ("is not a native COFF file"); disable it so the .lib stays plain COFF.
|
|
||||||
->exec('msbuild libintl_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0 /p:WholeProgramOptimization=false');
|
|
||||||
FileSystem::createDir($lib->getLibDir());
|
FileSystem::createDir($lib->getLibDir());
|
||||||
FileSystem::createDir($lib->getIncludeDir());
|
FileSystem::createDir($lib->getIncludeDir());
|
||||||
// libintl_a.lib is the static library output; copy as libintl.lib for linker compatibility
|
// libintl_a.lib is the static library output; copy as libintl.lib for linker compatibility
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ class gmssl
|
|||||||
#[BuildFor('Darwin')]
|
#[BuildFor('Darwin')]
|
||||||
public function build(LibraryPackage $lib): void
|
public function build(LibraryPackage $lib): void
|
||||||
{
|
{
|
||||||
UnixCMakeExecutor::create($lib)
|
UnixCMakeExecutor::create($lib)->build();
|
||||||
->addConfigureArgs('-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON')
|
|
||||||
->build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[BuildFor('Windows')]
|
#[BuildFor('Windows')]
|
||||||
@@ -35,7 +33,6 @@ class gmssl
|
|||||||
'-G "NMake Makefiles"',
|
'-G "NMake Makefiles"',
|
||||||
'-DWIN32=ON',
|
'-DWIN32=ON',
|
||||||
'-DBUILD_SHARED_LIBS=OFF',
|
'-DBUILD_SHARED_LIBS=OFF',
|
||||||
'-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON',
|
|
||||||
'-DCMAKE_BUILD_TYPE=Release',
|
'-DCMAKE_BUILD_TYPE=Release',
|
||||||
'-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
'-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||||
'-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
'-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||||
@@ -45,13 +42,13 @@ class gmssl
|
|||||||
->toStep(1)
|
->toStep(1)
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
cmd()->cd($buildDir)->exec('nmake gmssl XCFLAGS=/MT');
|
// 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)
|
||||||
|
);
|
||||||
|
|
||||||
$libPath = "{$lib->getBuildRootPath()}/lib";
|
cmd()->cd($buildDir)->exec('nmake install XCFLAGS=/MT');
|
||||||
$incPath = "{$lib->getBuildRootPath()}/include/gmssl";
|
|
||||||
FileSystem::createDir($libPath);
|
|
||||||
FileSystem::createDir($incPath);
|
|
||||||
FileSystem::copy("{$buildDir}\\bin\\gmssl.lib", "{$libPath}/gmssl.lib");
|
|
||||||
FileSystem::copyDir("{$lib->getSourceDir()}\\include\\gmssl", $incPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class libffi_win
|
|||||||
{
|
{
|
||||||
$ver = WindowsUtil::findVisualStudio();
|
$ver = WindowsUtil::findVisualStudio();
|
||||||
$vs_ver_dir = match ($ver['major_version']) {
|
$vs_ver_dir = match ($ver['major_version']) {
|
||||||
'18', // VS 2026 reuses the vs17 solution, which msbuild builds via forward compatibility.
|
|
||||||
'17' => '\win32\vs17_x64',
|
'17' => '\win32\vs17_x64',
|
||||||
'16' => '\win32\vs16_x64',
|
'16' => '\win32\vs16_x64',
|
||||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported!"),
|
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported!"),
|
||||||
@@ -34,9 +33,7 @@ class libffi_win
|
|||||||
{
|
{
|
||||||
$vs_ver_dir = ApplicationContext::get('libffi_win_vs_ver_dir');
|
$vs_ver_dir = ApplicationContext::get('libffi_win_vs_ver_dir');
|
||||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
||||||
// WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot
|
->exec('msbuild libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64');
|
||||||
// read ("is not a native COFF file"); disable it so the .lib stays plain COFF.
|
|
||||||
->exec('msbuild libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WholeProgramOptimization=false');
|
|
||||||
FileSystem::createDir($lib->getLibDir());
|
FileSystem::createDir($lib->getLibDir());
|
||||||
FileSystem::createDir($lib->getIncludeDir());
|
FileSystem::createDir($lib->getIncludeDir());
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class libiconv_win
|
|||||||
{
|
{
|
||||||
$ver = WindowsUtil::findVisualStudio();
|
$ver = WindowsUtil::findVisualStudio();
|
||||||
$vs_ver_dir = match ($ver['major_version']) {
|
$vs_ver_dir = match ($ver['major_version']) {
|
||||||
'18', // VS 2026 reuses the VS2022 (MSVC17) solution, which msbuild builds via forward compatibility.
|
|
||||||
'17' => '\MSVC17',
|
'17' => '\MSVC17',
|
||||||
'16' => '\MSVC16',
|
'16' => '\MSVC16',
|
||||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||||
@@ -34,9 +33,7 @@ class libiconv_win
|
|||||||
{
|
{
|
||||||
$vs_ver_dir = ApplicationContext::get('vs_ver_dir');
|
$vs_ver_dir = ApplicationContext::get('vs_ver_dir');
|
||||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}")
|
||||||
// WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot
|
->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64');
|
||||||
// read ("is not a native COFF file"); disable it so the .lib stays plain COFF.
|
|
||||||
->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WholeProgramOptimization=false');
|
|
||||||
FileSystem::createDir($lib->getLibDir());
|
FileSystem::createDir($lib->getLibDir());
|
||||||
FileSystem::createDir($lib->getIncludeDir());
|
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.lib", "{$lib->getLibDir()}\\libiconv.lib");
|
||||||
|
|||||||
@@ -42,16 +42,13 @@ class libsodium
|
|||||||
{
|
{
|
||||||
$ver = WindowsUtil::findVisualStudio();
|
$ver = WindowsUtil::findVisualStudio();
|
||||||
$vs_ver_dir = match ($ver['major_version']) {
|
$vs_ver_dir = match ($ver['major_version']) {
|
||||||
'18', // VS 2026 reuses the vs2022 solution, which msbuild builds via forward compatibility.
|
|
||||||
'17' => '\vs2022',
|
'17' => '\vs2022',
|
||||||
'16' => '\vs2019',
|
'16' => '\vs2019',
|
||||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||||
};
|
};
|
||||||
|
|
||||||
cmd()->cd("{$lib->getSourceDir()}\\builds\\msvc{$vs_ver_dir}")
|
cmd()->cd("{$lib->getSourceDir()}\\builds\\msvc{$vs_ver_dir}")
|
||||||
// WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot
|
->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:PreprocessorDefinitions="SODIUM_STATIC=1"');
|
||||||
// read ("is not a native COFF file"); disable it so the .lib stays plain COFF.
|
|
||||||
->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:WholeProgramOptimization=false /p:PreprocessorDefinitions="SODIUM_STATIC=1"');
|
|
||||||
FileSystem::createDir($lib->getLibDir());
|
FileSystem::createDir($lib->getLibDir());
|
||||||
FileSystem::createDir($lib->getIncludeDir());
|
FileSystem::createDir($lib->getIncludeDir());
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class libssh2
|
|||||||
{
|
{
|
||||||
WindowsCMakeExecutor::create($lib)
|
WindowsCMakeExecutor::create($lib)
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DCRYPTO_BACKEND=WinCNG',
|
|
||||||
'-DENABLE_ZLIB_COMPRESSION=ON',
|
'-DENABLE_ZLIB_COMPRESSION=ON',
|
||||||
'-DBUILD_TESTING=OFF'
|
'-DBUILD_TESTING=OFF'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class mpir
|
|||||||
{
|
{
|
||||||
$ver = WindowsUtil::findVisualStudio();
|
$ver = WindowsUtil::findVisualStudio();
|
||||||
$vs_ver_dir = match ($ver['major_version']) {
|
$vs_ver_dir = match ($ver['major_version']) {
|
||||||
'18', // VS 2026 reuses the build.vc17 solution, which msbuild builds via forward compatibility.
|
|
||||||
'17' => '\build.vc17',
|
'17' => '\build.vc17',
|
||||||
'16' => '\build.vc16',
|
'16' => '\build.vc16',
|
||||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class openssl
|
|||||||
{
|
{
|
||||||
if (SystemTarget::getTargetOS() === 'Windows') {
|
if (SystemTarget::getTargetOS() === 'Windows') {
|
||||||
global $argv;
|
global $argv;
|
||||||
$perl_path_native = PKG_ROOT_PATH . '\strawberry-perl\perl\bin\perl.exe';
|
$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');
|
$perl = file_exists($perl_path_native) ? ($perl_path_native) : WindowsUtil::findCommand('perl.exe');
|
||||||
if ($perl === null) {
|
if ($perl === null) {
|
||||||
throw new EnvironmentException(
|
throw new EnvironmentException(
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ class unixodbc extends LibraryPackage
|
|||||||
{
|
{
|
||||||
$sysconf_selector = match ($os = SystemTarget::getTargetOS()) {
|
$sysconf_selector = match ($os = SystemTarget::getTargetOS()) {
|
||||||
'Darwin' => match (SystemTarget::getTargetArch()) {
|
'Darwin' => match (SystemTarget::getTargetArch()) {
|
||||||
'x86_64' => is_dir('/usr/local/etc') ? '/usr/local/etc' : '/opt/local/etc',
|
'x86_64' => '/usr/local/etc',
|
||||||
'aarch64' => is_dir('/opt/homebrew/etc') ? '/opt/homebrew/etc' : '/opt/local/etc',
|
'aarch64' => '/opt/homebrew/etc',
|
||||||
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
||||||
},
|
},
|
||||||
'Linux' => '/etc',
|
'Linux' => '/etc',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class curl
|
|||||||
->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DBUILD_CURL_EXE=ON',
|
'-DBUILD_CURL_EXE=ON',
|
||||||
'-DZSTD_LIBRARY=' . BUILD_LIB_PATH . '/zstd_static.lib',
|
'-DZSTD_LIBRARY=zstd_static.lib',
|
||||||
'-DBUILD_TESTING=OFF',
|
'-DBUILD_TESTING=OFF',
|
||||||
'-DBUILD_EXAMPLES=OFF',
|
'-DBUILD_EXAMPLES=OFF',
|
||||||
'-DUSE_LIBIDN2=OFF',
|
'-DUSE_LIBIDN2=OFF',
|
||||||
|
|||||||
@@ -255,13 +255,6 @@ class php extends TargetPackage
|
|||||||
$installer->addBuildPackage('php-embed');
|
$installer->addBuildPackage('php-embed');
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPX compression: ensure the upx tool package is installed when requested.
|
|
||||||
// upx is a ToolPackage now, so it's installed directly rather than added as a
|
|
||||||
// library dependency (tool packages bypass the DependencyResolver graph).
|
|
||||||
if ($package->getBuildOption('with-upx-pack')) {
|
|
||||||
$installer->addInstallPackage('upx');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [...$extensions_pkg, ...$additional_packages];
|
return [...$extensions_pkg, ...$additional_packages];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,13 +39,6 @@ trait windows
|
|||||||
InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat'));
|
InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat'));
|
||||||
cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat');
|
cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat');
|
||||||
|
|
||||||
// Bypass the phpsdk_version check in configure.js: we use MSVC + msys2 instead of PHP SDK, so phpsdk_version is not available and the check would always fail.
|
|
||||||
FileSystem::replaceFileStr(
|
|
||||||
"{$package->getSourceDir()}\\configure.js",
|
|
||||||
'check_binary_tools_sdk();',
|
|
||||||
'/* check_binary_tools_sdk(); skipped: using MSVC + msys2 without PHP SDK */'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($package->getBuildOption('enable-micro-win32') && $installer->isPackageResolved('php-micro')) {
|
if ($package->getBuildOption('enable-micro-win32') && $installer->isPackageResolved('php-micro')) {
|
||||||
SourcePatcher::patchMicroWin32();
|
SourcePatcher::patchMicroWin32();
|
||||||
} else {
|
} else {
|
||||||
@@ -95,17 +88,6 @@ trait windows
|
|||||||
cmd()->cd($package->getSourceDir())->exec(".\\configure.bat {$args} {$static_extension_str}");
|
cmd()->cd($package->getSourceDir())->exec(".\\configure.bat {$args} {$static_extension_str}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[BeforeStage('php', [self::class, 'makeCliForWindows'])]
|
|
||||||
#[PatchDescription('Patch Makefile to ensure buildroot/include comes before extension CFLAGS (fixes zip.h conflict with minizip)')]
|
|
||||||
public function patchMakefileIncludeOrder(TargetPackage $package): void
|
|
||||||
{
|
|
||||||
FileSystem::replaceFileStr(
|
|
||||||
"{$package->getSourceDir()}\\Makefile",
|
|
||||||
'$(CFLAGS_PHP_OBJ) $(CFLAGS)',
|
|
||||||
'$(CFLAGS) $(CFLAGS_PHP_OBJ)'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[BeforeStage('php', [self::class, 'makeCliForWindows'])]
|
#[BeforeStage('php', [self::class, 'makeCliForWindows'])]
|
||||||
#[PatchDescription('Patch Windows Makefile for CLI target')]
|
#[PatchDescription('Patch Windows Makefile for CLI target')]
|
||||||
public function patchCLITarget(TargetPackage $package): void
|
public function patchCLITarget(TargetPackage $package): void
|
||||||
@@ -530,7 +512,6 @@ HEADER;
|
|||||||
$vc_matches = ['unknown', 'unknown'];
|
$vc_matches = ['unknown', 'unknown'];
|
||||||
} else {
|
} else {
|
||||||
$vc_matches = match ($vc['major_version']) {
|
$vc_matches = match ($vc['major_version']) {
|
||||||
'18', // VS 2026 shares the VS2022 (v143) runtime conventions, so it reports as VS17.
|
|
||||||
'17' => ['VS17', 'Visual C++ 2022'],
|
'17' => ['VS17', 'Visual C++ 2022'],
|
||||||
'16' => ['VS16', 'Visual C++ 2019'],
|
'16' => ['VS16', 'Visual C++ 2019'],
|
||||||
default => ['unknown', 'unknown'],
|
default => ['unknown', 'unknown'],
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Package\Tool;
|
namespace Package\Target;
|
||||||
|
|
||||||
use StaticPHP\Attribute\Package\BuildFor;
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
use StaticPHP\Attribute\Package\InitPackage;
|
use StaticPHP\Attribute\Package\InitPackage;
|
||||||
use StaticPHP\Attribute\Package\Tool;
|
use StaticPHP\Attribute\Package\Target;
|
||||||
use StaticPHP\DI\ApplicationContext;
|
use StaticPHP\DI\ApplicationContext;
|
||||||
use StaticPHP\Package\ToolPackage;
|
use StaticPHP\Package\TargetPackage;
|
||||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||||
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||||
|
|
||||||
#[Tool('pkg-config')]
|
#[Target('pkg-config')]
|
||||||
class pkgconfig
|
class pkgconfig
|
||||||
{
|
{
|
||||||
#[InitPackage]
|
#[InitPackage]
|
||||||
@@ -23,7 +23,7 @@ class pkgconfig
|
|||||||
|
|
||||||
#[BuildFor('Linux')]
|
#[BuildFor('Linux')]
|
||||||
#[BuildFor('Darwin')]
|
#[BuildFor('Darwin')]
|
||||||
public function build(ToolPackage $package, ToolchainInterface $toolchain): void
|
public function build(TargetPackage $package, ToolchainInterface $toolchain): void
|
||||||
{
|
{
|
||||||
UnixAutoconfExecutor::create($package)
|
UnixAutoconfExecutor::create($package)
|
||||||
->appendEnv([
|
->appendEnv([
|
||||||
@@ -644,7 +644,7 @@ class Artifact
|
|||||||
'{artifact_name}' => $this->name,
|
'{artifact_name}' => $this->name,
|
||||||
'{pkg_root_path}' => PKG_ROOT_PATH,
|
'{pkg_root_path}' => PKG_ROOT_PATH,
|
||||||
'{build_root_path}' => BUILD_ROOT_PATH,
|
'{build_root_path}' => BUILD_ROOT_PATH,
|
||||||
'{spc_msys2_path}' => getenv('SPC_MSYS2_PATH'),
|
'{php_sdk_path}' => getenv('PHP_SDK_PATH') ?: WORKING_DIR . '/php-sdk-binary-tools',
|
||||||
'{working_dir}' => WORKING_DIR,
|
'{working_dir}' => WORKING_DIR,
|
||||||
'{download_path}' => DOWNLOAD_PATH,
|
'{download_path}' => DOWNLOAD_PATH,
|
||||||
'{source_path}' => SOURCE_PATH,
|
'{source_path}' => SOURCE_PATH,
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ use StaticPHP\Exception\DownloaderException;
|
|||||||
use StaticPHP\Exception\ExecutionException;
|
use StaticPHP\Exception\ExecutionException;
|
||||||
use StaticPHP\Exception\ValidationException;
|
use StaticPHP\Exception\ValidationException;
|
||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Package\ToolVersionRegistry;
|
|
||||||
use StaticPHP\Registry\ArtifactLoader;
|
use StaticPHP\Registry\ArtifactLoader;
|
||||||
use StaticPHP\Runtime\Shell\Shell;
|
use StaticPHP\Runtime\Shell\Shell;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
@@ -347,32 +346,12 @@ class ArtifactDownloader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkUpdate(string $artifact_name, bool $prefer_source = false, bool $bare = false, bool $use_installed = false): CheckUpdateResult
|
public function checkUpdate(string $artifact_name, bool $prefer_source = false, bool $bare = false): CheckUpdateResult
|
||||||
{
|
{
|
||||||
$artifact = ArtifactLoader::getArtifactInstance($artifact_name);
|
$artifact = ArtifactLoader::getArtifactInstance($artifact_name);
|
||||||
if ($artifact === null) {
|
if ($artifact === null) {
|
||||||
throw new WrongUsageException("Artifact '{$artifact_name}' not found, please check the name.");
|
throw new WrongUsageException("Artifact '{$artifact_name}' not found, please check the name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// --installed: prefer the version actually installed on disk (tool packages only) as the
|
|
||||||
// baseline, instead of the download cache. Falls back to the normal cache/bare logic below
|
|
||||||
// if this artifact has no recorded installed version (not a tool package, or not installed
|
|
||||||
// via the package installer yet).
|
|
||||||
if ($use_installed) {
|
|
||||||
$installed_version = ToolVersionRegistry::get($artifact_name);
|
|
||||||
if ($installed_version !== null) {
|
|
||||||
[$first, $second] = $prefer_source
|
|
||||||
? [fn () => $this->probeSourceCheckUpdate($artifact, $artifact_name, $installed_version), fn () => $this->probeBinaryCheckUpdate($artifact, $artifact_name, $installed_version)]
|
|
||||||
: [fn () => $this->probeBinaryCheckUpdate($artifact, $artifact_name, $installed_version), fn () => $this->probeSourceCheckUpdate($artifact, $artifact_name, $installed_version)];
|
|
||||||
$result = $first() ?? $second();
|
|
||||||
if ($result !== null) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
return new CheckUpdateResult(old: $installed_version, new: null, needUpdate: false, unsupported: true);
|
|
||||||
}
|
|
||||||
logger()->warning("Artifact '{$artifact_name}' has no recorded installed version (not a tool package, or not installed yet); falling back to download-cache based check.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bare) {
|
if ($bare) {
|
||||||
[$first, $second] = $prefer_source
|
[$first, $second] = $prefer_source
|
||||||
? [fn () => $this->probeSourceCheckUpdate($artifact, $artifact_name), fn () => $this->probeBinaryCheckUpdate($artifact, $artifact_name)]
|
? [fn () => $this->probeSourceCheckUpdate($artifact, $artifact_name), fn () => $this->probeBinaryCheckUpdate($artifact, $artifact_name)]
|
||||||
@@ -424,17 +403,16 @@ class ArtifactDownloader
|
|||||||
* @param bool $prefer_source Whether to prefer source over binary
|
* @param bool $prefer_source Whether to prefer source over binary
|
||||||
* @param bool $bare Check without requiring artifact to be downloaded first
|
* @param bool $bare Check without requiring artifact to be downloaded first
|
||||||
* @param null|callable $onResult Called immediately with (string $name, CheckUpdateResult) as each result arrives
|
* @param null|callable $onResult Called immediately with (string $name, CheckUpdateResult) as each result arrives
|
||||||
* @param bool $use_installed Prefer the installed (on-disk) version over the download cache (tool packages only)
|
|
||||||
* @return array<string, CheckUpdateResult> Results keyed by artifact name
|
* @return array<string, CheckUpdateResult> Results keyed by artifact name
|
||||||
*/
|
*/
|
||||||
public function checkUpdates(array $artifact_names, bool $prefer_source = false, bool $bare = false, ?callable $onResult = null, bool $use_installed = false): array
|
public function checkUpdates(array $artifact_names, bool $prefer_source = false, bool $bare = false, ?callable $onResult = null): array
|
||||||
{
|
{
|
||||||
if ($this->parallel > 1 && count($artifact_names) > 1) {
|
if ($this->parallel > 1 && count($artifact_names) > 1) {
|
||||||
return $this->checkUpdatesWithConcurrency($artifact_names, $prefer_source, $bare, $onResult, $use_installed);
|
return $this->checkUpdatesWithConcurrency($artifact_names, $prefer_source, $bare, $onResult);
|
||||||
}
|
}
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach ($artifact_names as $name) {
|
foreach ($artifact_names as $name) {
|
||||||
$result = $this->checkUpdate($name, $prefer_source, $bare, $use_installed);
|
$result = $this->checkUpdate($name, $prefer_source, $bare);
|
||||||
$results[$name] = $result;
|
$results[$name] = $result;
|
||||||
if ($onResult !== null) {
|
if ($onResult !== null) {
|
||||||
($onResult)($name, $result);
|
($onResult)($name, $result);
|
||||||
@@ -458,7 +436,7 @@ class ArtifactDownloader
|
|||||||
return $this->options[$name] ?? $default;
|
return $this->options[$name] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkUpdatesWithConcurrency(array $artifact_names, bool $prefer_source, bool $bare, ?callable $onResult, bool $use_installed = false): array
|
private function checkUpdatesWithConcurrency(array $artifact_names, bool $prefer_source, bool $bare, ?callable $onResult): array
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
$fiber_pool = [];
|
$fiber_pool = [];
|
||||||
@@ -473,8 +451,8 @@ class ArtifactDownloader
|
|||||||
// fill pool
|
// fill pool
|
||||||
while (count($fiber_pool) < $this->parallel && !empty($remaining)) {
|
while (count($fiber_pool) < $this->parallel && !empty($remaining)) {
|
||||||
$name = array_shift($remaining);
|
$name = array_shift($remaining);
|
||||||
$fiber = new \Fiber(function () use ($name, $prefer_source, $bare, $use_installed) {
|
$fiber = new \Fiber(function () use ($name, $prefer_source, $bare) {
|
||||||
return [$name, $this->checkUpdate($name, $prefer_source, $bare, $use_installed)];
|
return [$name, $this->checkUpdate($name, $prefer_source, $bare)];
|
||||||
});
|
});
|
||||||
$fiber->start();
|
$fiber->start();
|
||||||
$fiber_pool[$name] = $fiber;
|
$fiber_pool[$name] = $fiber;
|
||||||
@@ -513,12 +491,12 @@ class ArtifactDownloader
|
|||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function probeSourceCheckUpdate(Artifact $artifact, string $artifact_name, ?string $old_version = null): ?CheckUpdateResult
|
private function probeSourceCheckUpdate(Artifact $artifact, string $artifact_name): ?CheckUpdateResult
|
||||||
{
|
{
|
||||||
if (($callback = $artifact->getCustomSourceCheckUpdateCallback()) !== null) {
|
if (($callback = $artifact->getCustomSourceCheckUpdateCallback()) !== null) {
|
||||||
return ApplicationContext::invoke($callback, [
|
return ApplicationContext::invoke($callback, [
|
||||||
ArtifactDownloader::class => $this,
|
ArtifactDownloader::class => $this,
|
||||||
'old_version' => $old_version,
|
'old_version' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$config = $artifact->getDownloadConfig('source');
|
$config = $artifact->getDownloadConfig('source');
|
||||||
@@ -531,16 +509,16 @@ class ArtifactDownloader
|
|||||||
}
|
}
|
||||||
/** @var CheckUpdateInterface $dl */
|
/** @var CheckUpdateInterface $dl */
|
||||||
$dl = new $cls();
|
$dl = new $cls();
|
||||||
return $dl->checkUpdate($artifact_name, $config, $old_version, $this);
|
return $dl->checkUpdate($artifact_name, $config, null, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function probeBinaryCheckUpdate(Artifact $artifact, string $artifact_name, ?string $old_version = null): ?CheckUpdateResult
|
private function probeBinaryCheckUpdate(Artifact $artifact, string $artifact_name): ?CheckUpdateResult
|
||||||
{
|
{
|
||||||
// custom binary callback takes precedence over config-based binary
|
// custom binary callback takes precedence over config-based binary
|
||||||
if (($callback = $artifact->getCustomBinaryCheckUpdateCallback()) !== null) {
|
if (($callback = $artifact->getCustomBinaryCheckUpdateCallback()) !== null) {
|
||||||
return ApplicationContext::invoke($callback, [
|
return ApplicationContext::invoke($callback, [
|
||||||
ArtifactDownloader::class => $this,
|
ArtifactDownloader::class => $this,
|
||||||
'old_version' => $old_version,
|
'old_version' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$binary_config = $artifact->getDownloadConfig('binary');
|
$binary_config = $artifact->getDownloadConfig('binary');
|
||||||
@@ -554,7 +532,7 @@ class ArtifactDownloader
|
|||||||
}
|
}
|
||||||
/** @var CheckUpdateInterface $dl */
|
/** @var CheckUpdateInterface $dl */
|
||||||
$dl = new $cls();
|
$dl = new $cls();
|
||||||
return $dl->checkUpdate($artifact_name, $platform_config, $old_version, $this);
|
return $dl->checkUpdate($artifact_name, $platform_config, null, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function downloadWithType(Artifact $artifact, int $current, int $total, bool $parallel = false): int
|
private function downloadWithType(Artifact $artifact, int $current, int $total, bool $parallel = false): int
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ class ArtifactExtractor
|
|||||||
'{source_path}' => SOURCE_PATH,
|
'{source_path}' => SOURCE_PATH,
|
||||||
'{download_path}' => DOWNLOAD_PATH,
|
'{download_path}' => DOWNLOAD_PATH,
|
||||||
'{working_dir}' => WORKING_DIR,
|
'{working_dir}' => WORKING_DIR,
|
||||||
'{spc_msys2_path}' => getenv('SPC_MSYS2_PATH') ?: '',
|
'{php_sdk_path}' => getenv('PHP_SDK_PATH') ?: '',
|
||||||
];
|
];
|
||||||
return str_replace(array_keys($replacement), array_values($replacement), $path);
|
return str_replace(array_keys($replacement), array_values($replacement), $path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,9 @@ class DownloadResult
|
|||||||
?string $version = null,
|
?string $version = null,
|
||||||
array $metadata = [],
|
array $metadata = [],
|
||||||
?string $downloader = null,
|
?string $downloader = null,
|
||||||
mixed $extract = null,
|
|
||||||
): DownloadResult {
|
): DownloadResult {
|
||||||
$cache_type = self::isArchiveFile($filename) ? 'archive' : 'file';
|
$cache_type = self::isArchiveFile($filename) ? 'archive' : 'file';
|
||||||
return new self($cache_type, config: $config, filename: $filename, extract: $extract, verified: $verified, version: $version, metadata: $metadata, downloader: $downloader);
|
return new self($cache_type, config: $config, filename: $filename, verified: $verified, version: $version, metadata: $metadata, downloader: $downloader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,11 +45,7 @@ class FileList implements DownloadTypeInterface, CheckUpdateInterface
|
|||||||
throw new DownloaderException("Failed to get {$name} file list from {$config['url']}");
|
throw new DownloaderException("Failed to get {$name} file list from {$config['url']}");
|
||||||
}
|
}
|
||||||
$versions = [];
|
$versions = [];
|
||||||
$cnt = count($matches['version']);
|
logger()->debug('Matched ' . count($matches['version']) . " versions for {$name}");
|
||||||
if ($cnt === 0) {
|
|
||||||
throw new DownloaderException("Failed to get {$name} file list from {$config['url']}: no version parsed");
|
|
||||||
}
|
|
||||||
logger()->debug("Matched {$cnt} versions for {$name}");
|
|
||||||
foreach ($matches['version'] as $i => $version) {
|
foreach ($matches['version'] as $i => $version) {
|
||||||
$lower = strtolower($version);
|
$lower = strtolower($version);
|
||||||
foreach (['alpha', 'beta', 'rc', 'pre', 'nightly', 'snapshot', 'dev'] as $beta) {
|
foreach (['alpha', 'beta', 'rc', 'pre', 'nightly', 'snapshot', 'dev'] as $beta) {
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace StaticPHP\Attribute\Package;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that the annotated class defines a tool package.
|
|
||||||
*/
|
|
||||||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
|
|
||||||
readonly class Tool
|
|
||||||
{
|
|
||||||
public function __construct(public string $name) {}
|
|
||||||
}
|
|
||||||
@@ -54,10 +54,6 @@ abstract class BaseCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(static function ($error_no, $error_msg, $error_file, $error_line) {
|
set_error_handler(static function ($error_no, $error_msg, $error_file, $error_line) {
|
||||||
// Respect the @ suppression operator (error_reporting() returns 0 when @ is used)
|
|
||||||
if (error_reporting() === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$tips = [
|
$tips = [
|
||||||
E_WARNING => ['PHP Warning: ', 'warning'],
|
E_WARNING => ['PHP Warning: ', 'warning'],
|
||||||
E_NOTICE => ['PHP Notice: ', 'notice'],
|
E_NOTICE => ['PHP Notice: ', 'notice'],
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class CheckUpdateCommand extends BaseCommand
|
|||||||
$this->addArgument('artifact', InputArgument::OPTIONAL, 'The name of the artifact(s) to check for updates, comma-separated (default: all downloaded artifacts)');
|
$this->addArgument('artifact', InputArgument::OPTIONAL, 'The name of the artifact(s) to check for updates, comma-separated (default: all downloaded artifacts)');
|
||||||
$this->addOption('json', null, null, 'Output result in JSON format');
|
$this->addOption('json', null, null, 'Output result in JSON format');
|
||||||
$this->addOption('bare', null, null, 'Check update without requiring the artifact to be downloaded first (old version will be null)');
|
$this->addOption('bare', null, null, 'Check update without requiring the artifact to be downloaded first (old version will be null)');
|
||||||
$this->addOption('installed', null, null, 'Compare against the version actually installed on disk (tool packages only) instead of the download cache; falls back to normal behavior for artifacts with no recorded installed version');
|
|
||||||
$this->addOption('parallel', 'p', InputOption::VALUE_REQUIRED, 'Number of parallel update checks (default: 10)', 10);
|
$this->addOption('parallel', 'p', InputOption::VALUE_REQUIRED, 'Number of parallel update checks (default: 10)', 10);
|
||||||
|
|
||||||
// --with-php option for checking updates with a specific PHP version context
|
// --with-php option for checking updates with a specific PHP version context
|
||||||
@@ -46,9 +45,8 @@ class CheckUpdateCommand extends BaseCommand
|
|||||||
try {
|
try {
|
||||||
$downloader = new ArtifactDownloader($this->input->getOptions());
|
$downloader = new ArtifactDownloader($this->input->getOptions());
|
||||||
$bare = (bool) $this->getOption('bare');
|
$bare = (bool) $this->getOption('bare');
|
||||||
$use_installed = (bool) $this->getOption('installed');
|
|
||||||
if ($this->getOption('json')) {
|
if ($this->getOption('json')) {
|
||||||
$results = $downloader->checkUpdates($artifacts, bare: $bare, use_installed: $use_installed);
|
$results = $downloader->checkUpdates($artifacts, bare: $bare);
|
||||||
$outputs = [];
|
$outputs = [];
|
||||||
foreach ($results as $artifact => $result) {
|
foreach ($results as $artifact => $result) {
|
||||||
$outputs[$artifact] = [
|
$outputs[$artifact] = [
|
||||||
@@ -61,7 +59,7 @@ class CheckUpdateCommand extends BaseCommand
|
|||||||
$this->output->writeln(json_encode($outputs, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
$this->output->writeln(json_encode($outputs, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
return static::OK;
|
return static::OK;
|
||||||
}
|
}
|
||||||
$downloader->checkUpdates($artifacts, bare: $bare, use_installed: $use_installed, onResult: function (string $artifact, CheckUpdateResult $result) {
|
$downloader->checkUpdates($artifacts, bare: $bare, onResult: function (string $artifact, CheckUpdateResult $result) {
|
||||||
if ($result->unsupported) {
|
if ($result->unsupported) {
|
||||||
$this->output->writeln("Artifact <info>{$artifact}</info> does not support update checking, <comment>skipped</comment>");
|
$this->output->writeln("Artifact <info>{$artifact}</info> does not support update checking, <comment>skipped</comment>");
|
||||||
} elseif (!$result->needUpdate) {
|
} elseif (!$result->needUpdate) {
|
||||||
|
|||||||
@@ -36,15 +36,6 @@ class CraftCommand extends BaseCommand
|
|||||||
// set verbosity
|
// set verbosity
|
||||||
$this->output->setVerbosity($craft['verbosity']);
|
$this->output->setVerbosity($craft['verbosity']);
|
||||||
|
|
||||||
// sync logger level and ApplicationContext debug mode to match the new verbosity
|
|
||||||
$level = match ($this->output->getVerbosity()) {
|
|
||||||
OutputInterface::VERBOSITY_VERBOSE => 'info',
|
|
||||||
OutputInterface::VERBOSITY_VERY_VERBOSE, OutputInterface::VERBOSITY_DEBUG => 'debug',
|
|
||||||
default => 'warning',
|
|
||||||
};
|
|
||||||
logger()->setLevel($level);
|
|
||||||
ApplicationContext::setDebug($this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG);
|
|
||||||
|
|
||||||
// apply env
|
// apply env
|
||||||
array_walk($craft['extra-env'], fn ($v, $k) => f_putenv("{$k}={$v}"));
|
array_walk($craft['extra-env'], fn ($v, $k) => f_putenv("{$k}={$v}"));
|
||||||
|
|
||||||
@@ -119,7 +110,7 @@ class CraftCommand extends BaseCommand
|
|||||||
* shared-extensions: array<string>,
|
* shared-extensions: array<string>,
|
||||||
* packages: array<string>,
|
* packages: array<string>,
|
||||||
* sapi: array<string>,
|
* sapi: array<string>,
|
||||||
* verbosity: 128|16|256|32|64|8,
|
* verbosity: int,
|
||||||
* debug: bool,
|
* debug: bool,
|
||||||
* clean-build: bool,
|
* clean-build: bool,
|
||||||
* build-options: array<string, mixed>,
|
* build-options: array<string, mixed>,
|
||||||
@@ -180,16 +171,11 @@ class CraftCommand extends BaseCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// verbosity
|
// verbosity
|
||||||
|
$verbosity_level = $craft['verbosity'] ?? OutputInterface::VERBOSITY_NORMAL;
|
||||||
$debug = $craft['debug'] ?? false;
|
$debug = $craft['debug'] ?? false;
|
||||||
$verbosity_level = $debug
|
if ($debug) {
|
||||||
? OutputInterface::VERBOSITY_DEBUG
|
$verbosity_level = OutputInterface::VERBOSITY_DEBUG;
|
||||||
: match ((int) ($craft['verbosity'] ?? 0)) {
|
}
|
||||||
OutputInterface::VERBOSITY_QUIET => OutputInterface::VERBOSITY_QUIET,
|
|
||||||
OutputInterface::VERBOSITY_VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
|
|
||||||
OutputInterface::VERBOSITY_VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
|
||||||
OutputInterface::VERBOSITY_DEBUG => OutputInterface::VERBOSITY_DEBUG,
|
|
||||||
default => OutputInterface::VERBOSITY_NORMAL,
|
|
||||||
};
|
|
||||||
$craft['verbosity'] = $verbosity_level;
|
$craft['verbosity'] = $verbosity_level;
|
||||||
|
|
||||||
// clean-build (if true, reset before all builds)
|
// clean-build (if true, reset before all builds)
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ class DumpCapabilitiesCommand extends BaseCommand
|
|||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
// library / target / virtual-target / tool
|
// library / target / virtual-target
|
||||||
foreach (PackageLoader::getPackages(['library', 'target', 'virtual-target', 'tool']) as $name => $pkg) {
|
foreach (PackageLoader::getPackages(['library', 'target', 'virtual-target']) as $name => $pkg) {
|
||||||
$installable = [];
|
$installable = [];
|
||||||
$artifact = $pkg->getArtifact();
|
$artifact = $pkg->getArtifact();
|
||||||
if ($artifact !== null) {
|
if ($artifact !== null) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class GenExtTestMatrixCommand extends BaseCommand
|
|||||||
|
|
||||||
private const array OS_RUNNERS = [
|
private const array OS_RUNNERS = [
|
||||||
'linux' => ['arch' => 'x86_64', 'runner' => 'ubuntu-latest', 'os_key' => 'Linux'],
|
'linux' => ['arch' => 'x86_64', 'runner' => 'ubuntu-latest', 'os_key' => 'Linux'],
|
||||||
'windows' => ['arch' => 'x86_64', 'runner' => 'windows-2025', 'os_key' => 'Windows'],
|
'windows' => ['arch' => 'x86_64', 'runner' => 'windows-latest', 'os_key' => 'Windows'],
|
||||||
'macos' => ['arch' => 'aarch64', 'runner' => 'macos-15', 'os_key' => 'Darwin'],
|
'macos' => ['arch' => 'aarch64', 'runner' => 'macos-15', 'os_key' => 'Darwin'],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -60,8 +60,6 @@ class GenExtTestMatrixCommand extends BaseCommand
|
|||||||
'glfw',
|
'glfw',
|
||||||
'imagick',
|
'imagick',
|
||||||
'intl',
|
'intl',
|
||||||
'mongodb',
|
|
||||||
'gmssl',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class TestBotCommand extends BaseCommand
|
|||||||
'targets' => array_values($targets),
|
'targets' => array_values($targets),
|
||||||
'gen_matrix_args' => $gen_matrix_args,
|
'gen_matrix_args' => $gen_matrix_args,
|
||||||
'gen_matrix_args_tier2' => $gen_matrix_args_tier2,
|
'gen_matrix_args_tier2' => $gen_matrix_args_tier2,
|
||||||
'php_versions' => $php_versions,
|
'php_versions' => array_values($php_versions),
|
||||||
'tier2' => $tier2,
|
'tier2' => $tier2,
|
||||||
'comment_body' => $comment_body,
|
'comment_body' => $comment_body,
|
||||||
];
|
];
|
||||||
@@ -253,13 +253,6 @@ class TestBotCommand extends BaseCommand
|
|||||||
$fmt($targets),
|
$fmt($targets),
|
||||||
);
|
);
|
||||||
|
|
||||||
$available_labels = implode(', ', [
|
|
||||||
'`need-test` (gate)',
|
|
||||||
'`test/linux` `test/windows` `test/macos` (platform)',
|
|
||||||
'`test/tier2` (extra arch)',
|
|
||||||
'`test/php-83` `test/php-84` (PHP version)',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Case 1: need-test absent → invite the author to add it
|
// Case 1: need-test absent → invite the author to add it
|
||||||
if (!$need_test) {
|
if (!$need_test) {
|
||||||
return implode("\n", [
|
return implode("\n", [
|
||||||
@@ -268,9 +261,11 @@ class TestBotCommand extends BaseCommand
|
|||||||
'',
|
'',
|
||||||
$detected,
|
$detected,
|
||||||
'',
|
'',
|
||||||
'To trigger extension build tests on this PR, add the `need-test` label.',
|
'To trigger extension build tests on this PR, add the `need-test` label:',
|
||||||
'',
|
'',
|
||||||
'**Available labels**: ' . $available_labels,
|
'**Gate**: `need-test`',
|
||||||
|
'**Platform filter** (optional, default all): `test/linux` `test/windows` `test/macos` · `test/tier2`',
|
||||||
|
'**PHP version** (optional, default 8.5): `test/php-83` `test/php-84`',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +307,6 @@ class TestBotCommand extends BaseCommand
|
|||||||
'',
|
'',
|
||||||
$detected,
|
$detected,
|
||||||
'**Active labels**: ' . $labels_str,
|
'**Active labels**: ' . $labels_str,
|
||||||
'**Available labels**: ' . $available_labels,
|
|
||||||
'**Config**: ' . implode(' + ', $platform_parts) . ' | ' . $php_str,
|
'**Config**: ' . implode(' + ', $platform_parts) . ' | ' . $php_str,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class DoctorCommand extends BaseCommand
|
|||||||
{
|
{
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
$this->addOption('auto-fix', 'y', InputOption::VALUE_OPTIONAL, 'Automatically fix failed items (if possible)', false);
|
$this->addOption('auto-fix', null, InputOption::VALUE_OPTIONAL, 'Automatically fix failed items (if possible)', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class InstallPackageCommand extends BaseCommand
|
|||||||
'The package to install (name or path)',
|
'The package to install (name or path)',
|
||||||
suggestedValues: function (CompletionInput $input) {
|
suggestedValues: function (CompletionInput $input) {
|
||||||
$packages = [];
|
$packages = [];
|
||||||
foreach (PackageLoader::getPackages(['target', 'virtual-target', 'tool']) as $name => $_) {
|
foreach (PackageLoader::getPackages(['target', 'virtual-target']) as $name => $_) {
|
||||||
$packages[] = $name;
|
$packages[] = $name;
|
||||||
}
|
}
|
||||||
$val = $input->getCompletionValue();
|
$val = $input->getCompletionValue();
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace StaticPHP\Command;
|
namespace StaticPHP\Command;
|
||||||
|
|
||||||
use StaticPHP\Exception\SPCInternalException;
|
|
||||||
use StaticPHP\Runtime\Shell\Shell;
|
use StaticPHP\Runtime\Shell\Shell;
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
use StaticPHP\Util\InteractiveTerm;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
||||||
|
use function Laravel\Prompts\confirm;
|
||||||
|
|
||||||
#[AsCommand('reset')]
|
#[AsCommand('reset')]
|
||||||
class ResetCommand extends BaseCommand
|
class ResetCommand extends BaseCommand
|
||||||
@@ -47,11 +46,7 @@ class ResetCommand extends BaseCommand
|
|||||||
|
|
||||||
// Confirm with user unless --yes is specified
|
// Confirm with user unless --yes is specified
|
||||||
if (!$this->input->getOption('yes')) {
|
if (!$this->input->getOption('yes')) {
|
||||||
$helper = $this->getHelper('question');
|
if (!confirm('Are you sure you want to continue?', false)) {
|
||||||
if (!$helper instanceof QuestionHelper) {
|
|
||||||
throw new SPCInternalException('Question helper not provided');
|
|
||||||
}
|
|
||||||
if (!$helper->ask($this->input, $this->output, new ConfirmationQuestion('Are you sure you want to continue? [y/N] ', false))) {
|
|
||||||
InteractiveTerm::error(message: 'Reset operation cancelled.');
|
InteractiveTerm::error(message: 'Reset operation cancelled.');
|
||||||
return static::SUCCESS;
|
return static::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ArtifactConfig
|
|||||||
*/
|
*/
|
||||||
public static function loadFromFile(string $file, string $registry_name): string
|
public static function loadFromFile(string $file, string $registry_name): string
|
||||||
{
|
{
|
||||||
$content = @file_get_contents($file);
|
$content = file_get_contents($file);
|
||||||
if ($content === false) {
|
if ($content === false) {
|
||||||
throw new WrongUsageException("Failed to read artifact config file: {$file}");
|
throw new WrongUsageException("Failed to read artifact config file: {$file}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ enum ConfigType
|
|||||||
'php-extension',
|
'php-extension',
|
||||||
'target',
|
'target',
|
||||||
'virtual-target',
|
'virtual-target',
|
||||||
'tool',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function validateLicenseField(mixed $value): bool
|
public static function validateLicenseField(mixed $value): bool
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ class ConfigValidator
|
|||||||
'lang' => ConfigType::STRING,
|
'lang' => ConfigType::STRING,
|
||||||
'frameworks' => ConfigType::LIST_ARRAY, // @
|
'frameworks' => ConfigType::LIST_ARRAY, // @
|
||||||
|
|
||||||
// build-time tool dependency declaration (resolved independently of the library
|
|
||||||
// dependency graph, see PackageInstaller::collectRequiredTools())
|
|
||||||
'tools' => ConfigType::LIST_ARRAY, // @
|
|
||||||
|
|
||||||
// php-extension type fields
|
// php-extension type fields
|
||||||
'php-extension' => ConfigType::ASSOC_ARRAY,
|
'php-extension' => ConfigType::ASSOC_ARRAY,
|
||||||
'zend-extension' => ConfigType::BOOL,
|
'zend-extension' => ConfigType::BOOL,
|
||||||
@@ -48,13 +44,6 @@ class ConfigValidator
|
|||||||
'path' => ConfigType::LIST_ARRAY, // @
|
'path' => ConfigType::LIST_ARRAY, // @
|
||||||
'env' => ConfigType::ASSOC_ARRAY, // @
|
'env' => ConfigType::ASSOC_ARRAY, // @
|
||||||
'append-env' => ConfigType::ASSOC_ARRAY, // @
|
'append-env' => ConfigType::ASSOC_ARRAY, // @
|
||||||
|
|
||||||
// tool type fields (nested under 'tool' key)
|
|
||||||
'tool' => ConfigType::ASSOC_ARRAY,
|
|
||||||
'provides' => ConfigType::LIST_ARRAY,
|
|
||||||
'binary-subdir' => ConfigType::STRING,
|
|
||||||
'install-root' => ConfigType::STRING,
|
|
||||||
'min-version' => ConfigType::STRING,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public const array PACKAGE_FIELDS = [
|
public const array PACKAGE_FIELDS = [
|
||||||
@@ -67,9 +56,6 @@ class ConfigValidator
|
|||||||
'lang' => false,
|
'lang' => false,
|
||||||
'frameworks' => false, // @
|
'frameworks' => false, // @
|
||||||
|
|
||||||
// build-time tool dependency declaration
|
|
||||||
'tools' => false, // @
|
|
||||||
|
|
||||||
// php-extension type fields
|
// php-extension type fields
|
||||||
'php-extension' => false,
|
'php-extension' => false,
|
||||||
|
|
||||||
@@ -81,9 +67,6 @@ class ConfigValidator
|
|||||||
'path' => false, // @
|
'path' => false, // @
|
||||||
'env' => false, // @
|
'env' => false, // @
|
||||||
'append-env' => false, // @
|
'append-env' => false, // @
|
||||||
|
|
||||||
// tool fields (nested object)
|
|
||||||
'tool' => false,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public const array SUFFIX_ALLOWED_FIELDS = [
|
public const array SUFFIX_ALLOWED_FIELDS = [
|
||||||
@@ -95,7 +78,6 @@ class ConfigValidator
|
|||||||
'path',
|
'path',
|
||||||
'env',
|
'env',
|
||||||
'append-env',
|
'append-env',
|
||||||
'tools',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public const array PHP_EXTENSION_FIELDS = [
|
public const array PHP_EXTENSION_FIELDS = [
|
||||||
@@ -110,13 +92,6 @@ class ConfigValidator
|
|||||||
'os' => false,
|
'os' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
public const array TOOL_FIELDS = [
|
|
||||||
'provides' => true,
|
|
||||||
'binary-subdir' => false,
|
|
||||||
'install-root' => false,
|
|
||||||
'min-version' => false,
|
|
||||||
];
|
|
||||||
|
|
||||||
public const array ARTIFACT_TYPE_FIELDS = [ // [required_fields, optional_fields]
|
public const array ARTIFACT_TYPE_FIELDS = [ // [required_fields, optional_fields]
|
||||||
'filelist' => [['url', 'regex'], ['extract']],
|
'filelist' => [['url', 'regex'], ['extract']],
|
||||||
'git' => [['url'], ['extract', 'submodules', 'rev', 'regex']],
|
'git' => [['url'], ['extract', 'submodules', 'rev', 'regex']],
|
||||||
@@ -245,8 +220,8 @@ class ConfigValidator
|
|||||||
$fields = self::SUFFIX_ALLOWED_FIELDS;
|
$fields = self::SUFFIX_ALLOWED_FIELDS;
|
||||||
self::validateSuffixAllowedFields($name, $pkg, $fields, $suffixes);
|
self::validateSuffixAllowedFields($name, $pkg, $fields, $suffixes);
|
||||||
|
|
||||||
// check if "library|target|tool" package has artifact field
|
// check if "library|target" package has artifact field for target and library types
|
||||||
if (in_array($pkg['type'], ['target', 'library', 'tool']) && !isset($pkg['artifact'])) {
|
if (in_array($pkg['type'], ['target', 'library']) && !isset($pkg['artifact'])) {
|
||||||
throw new ValidationException("Package [{$name}] in {$config_file_name} of type '{$pkg['type']}' must have an 'artifact' field");
|
throw new ValidationException("Package [{$name}] in {$config_file_name} of type '{$pkg['type']}' must have an 'artifact' field");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,11 +235,6 @@ class ConfigValidator
|
|||||||
self::validatePhpExtensionFields($name, $pkg);
|
self::validatePhpExtensionFields($name, $pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if "tool" package has tool specific fields and validate inside
|
|
||||||
if ($pkg['type'] === 'tool') {
|
|
||||||
self::validateToolFields($name, $pkg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for unknown fields
|
// check for unknown fields
|
||||||
self::validateNoInvalidFields('package', $name, $pkg, array_keys(self::PACKAGE_FIELD_TYPES));
|
self::validateNoInvalidFields('package', $name, $pkg, array_keys(self::PACKAGE_FIELD_TYPES));
|
||||||
}
|
}
|
||||||
@@ -427,29 +397,6 @@ class ConfigValidator
|
|||||||
self::validateNoInvalidFields('php-extension', $name, $pkg['php-extension'], array_keys(self::PHP_EXTENSION_FIELDS));
|
self::validateNoInvalidFields('php-extension', $name, $pkg['php-extension'], array_keys(self::PHP_EXTENSION_FIELDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate tool specific fields for tool package type.
|
|
||||||
*/
|
|
||||||
private static function validateToolFields(int|string $name, mixed $pkg): void
|
|
||||||
{
|
|
||||||
if (!isset($pkg['tool'])) {
|
|
||||||
throw new ValidationException("Package {$name} of type 'tool' must have a 'tool' field");
|
|
||||||
}
|
|
||||||
if (!is_assoc_array($pkg['tool'])) {
|
|
||||||
throw new ValidationException("Package {$name} [tool] must be an object");
|
|
||||||
}
|
|
||||||
foreach (self::TOOL_FIELDS as $field => $required) {
|
|
||||||
if ($required && !isset($pkg['tool'][$field])) {
|
|
||||||
throw new ValidationException("Package {$name} [tool] must have required field [{$field}]");
|
|
||||||
}
|
|
||||||
if (isset($pkg['tool'][$field])) {
|
|
||||||
self::validatePackageFieldType($field, $pkg['tool'][$field], $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for unknown fields in tool
|
|
||||||
self::validateNoInvalidFields('tool', $name, $pkg['tool'], array_keys(self::TOOL_FIELDS));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function validateNoInvalidFields(string $config_type, int|string $item_name, mixed $item_content, array $allowed_fields): void
|
private static function validateNoInvalidFields(string $config_type, int|string $item_name, mixed $item_content, array $allowed_fields): void
|
||||||
{
|
{
|
||||||
foreach ($item_content as $k => $v) {
|
foreach ($item_content as $k => $v) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class PackageConfig
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load package configurations from a specified directory.
|
* Load package configurations from a specified directory.
|
||||||
* Only processes .json, .yml, and .yaml files (skips .gitkeep etc.).
|
* It will look for files matching the pattern 'pkg.*.json' and 'pkg.json'.
|
||||||
*/
|
*/
|
||||||
public static function loadFromDir(string $dir, string $registry_name): array
|
public static function loadFromDir(string $dir, string $registry_name): array
|
||||||
{
|
{
|
||||||
@@ -28,10 +28,6 @@ class PackageConfig
|
|||||||
$files = FileSystem::scanDirFiles($dir, false);
|
$files = FileSystem::scanDirFiles($dir, false);
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
|
||||||
if (!in_array($ext, ['json', 'yml', 'yaml'], true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
self::loadFromFile($file, $registry_name);
|
self::loadFromFile($file, $registry_name);
|
||||||
$loaded[] = $file;
|
$loaded[] = $file;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ use StaticPHP\Command\SPCConfigCommand;
|
|||||||
use StaticPHP\Package\TargetPackage;
|
use StaticPHP\Package\TargetPackage;
|
||||||
use StaticPHP\Registry\PackageLoader;
|
use StaticPHP\Registry\PackageLoader;
|
||||||
use StaticPHP\Registry\Registry;
|
use StaticPHP\Registry\Registry;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
class ConsoleApplication extends Application
|
class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
@@ -107,15 +104,4 @@ class ConsoleApplication extends Application
|
|||||||
{
|
{
|
||||||
self::$additional_commands = array_merge(self::$additional_commands, $additional_commands);
|
self::$additional_commands = array_merge(self::$additional_commands, $additional_commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook Symfony's doRun() to inject the real input/output into InteractiveTerm before
|
|
||||||
* any command executes. From this point forward, InteractiveTerm uses the configured
|
|
||||||
* Console (respecting --no-ansi, --verbose, etc.) instead of the lazy STDERR fallback.
|
|
||||||
*/
|
|
||||||
public function doRun(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
InteractiveTerm::init($input, $output);
|
|
||||||
return parent::doRun($input, $output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ class ApplicationContext
|
|||||||
/**
|
/**
|
||||||
* Get a service from the container.
|
* Get a service from the container.
|
||||||
*
|
*
|
||||||
* @template T of object
|
* @template T
|
||||||
*
|
*
|
||||||
* @param class-string<T>|string $id Service identifier
|
* @param class-string<T> $id Service identifier
|
||||||
*
|
*
|
||||||
* @return ($id is class-string<T> ? T : mixed)
|
* @return null|T
|
||||||
*/
|
*/
|
||||||
public static function get(string $id): mixed
|
public static function get(string $id): mixed
|
||||||
{
|
{
|
||||||
@@ -98,6 +98,25 @@ class ApplicationContext
|
|||||||
return self::getContainer()->has($id);
|
return self::getContainer()->has($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve $id, returning null if it can't be constructed.
|
||||||
|
* PHP-DI's has() returns true for any autowirable class even when get()
|
||||||
|
* would throw on missing scalar args — for "is this resolvable right now"
|
||||||
|
* semantics use this.
|
||||||
|
*
|
||||||
|
* @template T
|
||||||
|
* @param class-string<T> $id
|
||||||
|
* @return null|T
|
||||||
|
*/
|
||||||
|
public static function tryGet(string $id): mixed
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return self::getContainer()->get($id);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a service in the container.
|
* Set a service in the container.
|
||||||
* Use sparingly - prefer configuration-based definitions.
|
* Use sparingly - prefer configuration-based definitions.
|
||||||
|
|||||||
@@ -11,14 +11,11 @@ use StaticPHP\Registry\DoctorLoader;
|
|||||||
use StaticPHP\Runtime\Shell\Shell;
|
use StaticPHP\Runtime\Shell\Shell;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
use StaticPHP\Util\InteractiveTerm;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
||||||
use ZM\Logger\ConsoleColor;
|
use ZM\Logger\ConsoleColor;
|
||||||
|
|
||||||
|
use function Laravel\Prompts\confirm;
|
||||||
|
|
||||||
readonly class Doctor
|
readonly class Doctor
|
||||||
{
|
{
|
||||||
public function __construct(private ?OutputInterface $output = null, private int $auto_fix = FIX_POLICY_PROMPT, public readonly bool $interactive = true)
|
public function __construct(private ?OutputInterface $output = null, private int $auto_fix = FIX_POLICY_PROMPT, public readonly bool $interactive = true)
|
||||||
@@ -128,14 +125,9 @@ readonly class Doctor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// prompt for fix
|
// prompt for fix
|
||||||
if ($this->auto_fix === FIX_POLICY_PROMPT) {
|
if ($this->auto_fix === FIX_POLICY_PROMPT && !confirm('Do you want to try to fix this issue now?')) {
|
||||||
$helper = new QuestionHelper();
|
$this->output?->writeln('<comment>You canceled fix.</comment>');
|
||||||
$input = ApplicationContext::has(InputInterface::class) ? ApplicationContext::get(InputInterface::class) : new ArrayInput([]);
|
return false;
|
||||||
$output = ApplicationContext::has(OutputInterface::class) ? ApplicationContext::get(OutputInterface::class) : $this->output ?? new ConsoleOutput();
|
|
||||||
if (!$helper->ask($input, $output, new ConfirmationQuestion('Do you want to try to fix this issue now? [Y/n] ', true))) {
|
|
||||||
$this->output?->writeln('<comment>You canceled fix.</comment>');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// perform fix
|
// perform fix
|
||||||
InteractiveTerm::indicateProgress("Fixing {$result->getFixItem()} ... ");
|
InteractiveTerm::indicateProgress("Fixing {$result->getFixItem()} ... ");
|
||||||
|
|||||||
@@ -73,20 +73,13 @@ class LinuxMuslCheck
|
|||||||
$prefix = 'sudo ';
|
$prefix = 'sudo ';
|
||||||
logger()->warning('Current user is not root, using sudo for running command');
|
logger()->warning('Current user is not root, using sudo for running command');
|
||||||
}
|
}
|
||||||
$sysEnv = ['CC' => 'gcc', 'CXX' => 'g++', 'AR' => 'ar', 'LD' => 'ld', 'RANLIB' => 'ranlib'];
|
|
||||||
$envFlags = '';
|
|
||||||
foreach ($sysEnv as $k => $v) {
|
|
||||||
$envFlags .= "{$k}={$v} ";
|
|
||||||
}
|
|
||||||
$envFlags = rtrim($envFlags);
|
|
||||||
$shell = shell()->cd(SOURCE_PATH . '/musl-wrapper')
|
$shell = shell()->cd(SOURCE_PATH . '/musl-wrapper')
|
||||||
->setEnv($sysEnv)
|
->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper')
|
||||||
->exec('./configure --disable-gcc-wrapper')
|
->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j');
|
||||||
->exec('make -j');
|
|
||||||
if ($prefix !== '') {
|
if ($prefix !== '') {
|
||||||
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && {$envFlags} {$prefix}make install");
|
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||||
} else {
|
} else {
|
||||||
$shell->exec("{$prefix}make install");
|
$shell->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
44
src/StaticPHP/Doctor/Item/LlvmToolsCheck.php
Normal file
44
src/StaticPHP/Doctor/Item/LlvmToolsCheck.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace StaticPHP\Doctor\Item;
|
||||||
|
|
||||||
|
use Package\Artifact\llvm_tools;
|
||||||
|
use StaticPHP\Attribute\Doctor\CheckItem;
|
||||||
|
use StaticPHP\Attribute\Doctor\FixItem;
|
||||||
|
use StaticPHP\Attribute\Doctor\OptionalCheck;
|
||||||
|
use StaticPHP\DI\ApplicationContext;
|
||||||
|
use StaticPHP\Doctor\CheckResult;
|
||||||
|
use StaticPHP\Package\PackageInstaller;
|
||||||
|
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||||
|
use StaticPHP\Toolchain\ZigToolchain;
|
||||||
|
|
||||||
|
#[OptionalCheck([self::class, 'optionalCheck'])]
|
||||||
|
class LlvmToolsCheck
|
||||||
|
{
|
||||||
|
public static function optionalCheck(): bool
|
||||||
|
{
|
||||||
|
return ApplicationContext::get(ToolchainInterface::class) instanceof ZigToolchain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpUnused */
|
||||||
|
#[CheckItem('if llvm-tools (objcopy/strip/profdata) are built', level: 798)]
|
||||||
|
public function checkLlvmTools(): CheckResult
|
||||||
|
{
|
||||||
|
if (llvm_tools::isInstalled()) {
|
||||||
|
return CheckResult::ok(llvm_tools::path() . '/bin');
|
||||||
|
}
|
||||||
|
return CheckResult::fail('llvm-tools are not built', 'build-llvm-tools');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[FixItem('build-llvm-tools')]
|
||||||
|
public function fixLlvmTools(): bool
|
||||||
|
{
|
||||||
|
$installer = new PackageInstaller(interactive: false);
|
||||||
|
$installer->addInstallPackage('llvm-tools');
|
||||||
|
$installer->run(true);
|
||||||
|
new llvm_tools()->buildForHost();
|
||||||
|
return llvm_tools::isInstalled();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,20 +33,15 @@ class MacOSToolCheck
|
|||||||
'glibtoolize',
|
'glibtoolize',
|
||||||
];
|
];
|
||||||
|
|
||||||
#[CheckItem('if homebrew or macports has installed', limit_os: 'Darwin', level: 998)]
|
#[CheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)]
|
||||||
public function checkBrewOrPorts(): ?CheckResult
|
public function checkBrew(): ?CheckResult
|
||||||
{
|
{
|
||||||
$brewPath = MacOSUtil::findCommand('brew');
|
if (($path = MacOSUtil::findCommand('brew')) === null) {
|
||||||
$portPath = MacOSUtil::findCommand('port');
|
|
||||||
|
|
||||||
if ($brewPath && $brewPath !== '/opt/homebrew/bin/brew' && getenv('GNU_ARCH') === 'aarch64') {
|
|
||||||
return CheckResult::fail('Current homebrew (/usr/local/bin/homebrew) is not installed for M1 Mac, please re-install homebrew in /opt/homebrew/ !');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($brewPath === null && $portPath === null) {
|
|
||||||
return CheckResult::fail('Homebrew is not installed', 'brew');
|
return CheckResult::fail('Homebrew is not installed', 'brew');
|
||||||
}
|
}
|
||||||
|
if ($path !== '/opt/homebrew/bin/brew' && getenv('GNU_ARCH') === 'aarch64') {
|
||||||
|
return CheckResult::fail('Current homebrew (/usr/local/bin/homebrew) is not installed for M1 Mac, please re-install homebrew in /opt/homebrew/ !');
|
||||||
|
}
|
||||||
return CheckResult::ok();
|
return CheckResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +60,8 @@ class MacOSToolCheck
|
|||||||
return CheckResult::ok();
|
return CheckResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[CheckItem('if homebrew or macports llvm are installed', limit_os: 'Darwin')]
|
#[CheckItem('if homebrew llvm are installed', limit_os: 'Darwin')]
|
||||||
public function checkBrewOrPortsLLVM(): ?CheckResult
|
public function checkBrewLLVM(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (getenv('SPC_USE_LLVM') === 'brew') {
|
if (getenv('SPC_USE_LLVM') === 'brew') {
|
||||||
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
|
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
|
||||||
@@ -76,16 +71,6 @@ class MacOSToolCheck
|
|||||||
}
|
}
|
||||||
return CheckResult::ok($path);
|
return CheckResult::ok($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getenv('SPC_USE_LLVM') === 'port') {
|
|
||||||
$macportsPrefix = '/opt/local';
|
|
||||||
|
|
||||||
if (($path = MacOSUtil::findCommand('clang', ["{$macportsPrefix}/bin"])) === null) {
|
|
||||||
return CheckResult::fail('MacPorts llvm is not installed', 'build-tools', ['missing' => ['llvm']]);
|
|
||||||
}
|
|
||||||
return CheckResult::ok($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +91,7 @@ class MacOSToolCheck
|
|||||||
if ($command_path !== []) {
|
if ($command_path !== []) {
|
||||||
return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]);
|
return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]);
|
||||||
}
|
}
|
||||||
return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin', '/opt/local/bin']);
|
return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin']);
|
||||||
}
|
}
|
||||||
return CheckResult::ok($matches[0]);
|
return CheckResult::ok($matches[0]);
|
||||||
}
|
}
|
||||||
@@ -123,9 +108,6 @@ class MacOSToolCheck
|
|||||||
#[FixItem('build-tools')]
|
#[FixItem('build-tools')]
|
||||||
public function fixBuildTools(array $missing): bool
|
public function fixBuildTools(array $missing): bool
|
||||||
{
|
{
|
||||||
$brewPath = MacOSUtil::findCommand('brew');
|
|
||||||
$portPath = MacOSUtil::findCommand('port');
|
|
||||||
|
|
||||||
$replacement = [
|
$replacement = [
|
||||||
'glibtoolize' => 'libtool',
|
'glibtoolize' => 'libtool',
|
||||||
];
|
];
|
||||||
@@ -133,18 +115,7 @@ class MacOSToolCheck
|
|||||||
if (isset($replacement[$cmd])) {
|
if (isset($replacement[$cmd])) {
|
||||||
$cmd = $replacement[$cmd];
|
$cmd = $replacement[$cmd];
|
||||||
}
|
}
|
||||||
|
shell()->exec('brew install --formula ' . escapeshellarg($cmd));
|
||||||
if ($brewPath !== null) {
|
|
||||||
shell()->exec('brew install --formula ' . escapeshellarg($cmd));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($portPath !== null) {
|
|
||||||
shell()->exec('port install ' . escapeshellarg($cmd));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,24 +54,13 @@ class WindowsToolCheck
|
|||||||
return CheckResult::ok();
|
return CheckResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[CheckItem('if msys2-build-essentials is installed', limit_os: 'Windows', level: 996)]
|
#[CheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 996)]
|
||||||
public function checkMsys2(): ?CheckResult
|
public function checkSDK(): ?CheckResult
|
||||||
{
|
{
|
||||||
$marker = PKG_ROOT_PATH . '\msys2-build-essentials\.spc-msys2-initialized';
|
if (!file_exists(getenv('PHP_SDK_PATH') . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) {
|
||||||
if (!file_exists($marker)) {
|
return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk');
|
||||||
return CheckResult::fail('msys2-build-essentials not installed', 'install-msys2-build-essentials');
|
|
||||||
}
|
}
|
||||||
return CheckResult::ok(PKG_ROOT_PATH . '\msys2-build-essentials\msys64');
|
return CheckResult::ok(getenv('PHP_SDK_PATH'));
|
||||||
}
|
|
||||||
|
|
||||||
#[CheckItem('if 7za.exe is installed', limit_os: 'Windows', level: 999)]
|
|
||||||
public function check7zaWin(): ?CheckResult
|
|
||||||
{
|
|
||||||
$path = FileSystem::convertPath(PKG_ROOT_PATH . '\bin\7za.exe');
|
|
||||||
if (!file_exists($path)) {
|
|
||||||
return CheckResult::fail('7za.exe not found', 'install-7za-win');
|
|
||||||
}
|
|
||||||
return CheckResult::ok($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[CheckItem('if nasm installed', level: 995)]
|
#[CheckItem('if nasm installed', level: 995)]
|
||||||
@@ -123,20 +112,12 @@ class WindowsToolCheck
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[FixItem('install-msys2-build-essentials')]
|
#[FixItem('install-php-sdk')]
|
||||||
public function installMsys2(): bool
|
public function installSDK(): bool
|
||||||
{
|
{
|
||||||
|
FileSystem::removeDir(getenv('PHP_SDK_PATH'));
|
||||||
$installer = new PackageInstaller(interactive: false);
|
$installer = new PackageInstaller(interactive: false);
|
||||||
$installer->addInstallPackage('msys2-build-essentials');
|
$installer->addInstallPackage('php-sdk-binary-tools');
|
||||||
$installer->run(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[FixItem('install-7za-win')]
|
|
||||||
public function install7zaWin(): bool
|
|
||||||
{
|
|
||||||
$installer = new PackageInstaller(interactive: false);
|
|
||||||
$installer->addInstallPackage('7za-win');
|
|
||||||
$installer->run(true);
|
$installer->run(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,60 @@ class LibraryPackage extends Package
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get extra CFLAGS for current package.
|
||||||
|
* You need to define the environment variable in the format of {LIBRARY_NAME}_CFLAGS
|
||||||
|
* where {LIBRARY_NAME} is the snake_case name of the library.
|
||||||
|
* For example, for libjpeg, the environment variable should be libjpeg_CFLAGS.
|
||||||
|
*/
|
||||||
|
public function getLibExtraCFlags(): string
|
||||||
|
{
|
||||||
|
// get environment variable
|
||||||
|
$env = getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';
|
||||||
|
// get default c flags
|
||||||
|
$arch_c_flags = getenv('SPC_DEFAULT_CFLAGS') ?: '';
|
||||||
|
if (!empty(getenv('SPC_DEFAULT_CFLAGS')) && !str_contains($env, $arch_c_flags)) {
|
||||||
|
$env .= ' ' . $arch_c_flags;
|
||||||
|
}
|
||||||
|
return trim($env);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get extra CXXFLAGS for current package.
|
||||||
|
* You need to define the environment variable in the format of {LIBRARY_NAME}_CXXFLAGS
|
||||||
|
* where {LIBRARY_NAME} is the snake_case name of the library.
|
||||||
|
* For example, for libjpeg, the environment variable should be libjpeg_CXXFLAGS.
|
||||||
|
*/
|
||||||
|
public function getLibExtraCxxFlags(): string
|
||||||
|
{
|
||||||
|
// get environment variable
|
||||||
|
$env = getenv($this->getSnakeCaseName() . '_CXXFLAGS') ?: '';
|
||||||
|
// get default cxx flags
|
||||||
|
$arch_cxx_flags = getenv('SPC_DEFAULT_CXXFLAGS') ?: '';
|
||||||
|
if (!empty(getenv('SPC_DEFAULT_CXXFLAGS')) && !str_contains($env, $arch_cxx_flags)) {
|
||||||
|
$env .= ' ' . $arch_cxx_flags;
|
||||||
|
}
|
||||||
|
return trim($env);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get extra LDFLAGS for current package.
|
||||||
|
* You need to define the environment variable in the format of {LIBRARY_NAME}_LDFLAGS
|
||||||
|
* where {LIBRARY_NAME} is the snake_case name of the library.
|
||||||
|
* For example, for libjpeg, the environment variable should be libjpeg_LDFLAGS.
|
||||||
|
*/
|
||||||
|
public function getLibExtraLdFlags(): string
|
||||||
|
{
|
||||||
|
// get environment variable
|
||||||
|
$env = getenv($this->getSnakeCaseName() . '_LDFLAGS') ?: '';
|
||||||
|
// get default ld flags
|
||||||
|
$arch_ld_flags = getenv('SPC_DEFAULT_LDFLAGS') ?: '';
|
||||||
|
if (!empty(getenv('SPC_DEFAULT_LDFLAGS')) && !str_contains($env, $arch_ld_flags)) {
|
||||||
|
$env .= ' ' . $arch_ld_flags;
|
||||||
|
}
|
||||||
|
return trim($env);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch pkgconfig file prefix, exec_prefix, libdir, includedir for correct build.
|
* Patch pkgconfig file prefix, exec_prefix, libdir, includedir for correct build.
|
||||||
*
|
*
|
||||||
@@ -310,6 +364,17 @@ class LibraryPackage extends Package
|
|||||||
return $res['libs'];
|
return $res['libs'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get extra LIBS for current package.
|
||||||
|
* You need to define the environment variable in the format of {LIBRARY_NAME}_LIBS
|
||||||
|
* where {LIBRARY_NAME} is the snake_case name of the library.
|
||||||
|
* For example, for libjpeg, the environment variable should be libjpeg_LIBS.
|
||||||
|
*/
|
||||||
|
public function getLibExtraLibs(): string
|
||||||
|
{
|
||||||
|
return getenv($this->getSnakeCaseName() . '_LIBS') ?: '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tar compress options from suffix
|
* Get tar compress options from suffix
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -120,20 +120,6 @@ abstract class Package
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the target directory where this package's artifacts should be placed.
|
|
||||||
*
|
|
||||||
* Libraries install to BUILD_ROOT_PATH (static-libs, headers, pkg-configs).
|
|
||||||
* Tools install to PKG_ROOT_PATH (executables).
|
|
||||||
* Extensions install to php-src/ext/ (shared objects).
|
|
||||||
*
|
|
||||||
* Override in subclasses to change the default.
|
|
||||||
*/
|
|
||||||
public function getInstallTarget(): string
|
|
||||||
{
|
|
||||||
return BUILD_ROOT_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a stage to the package.
|
* Add a stage to the package.
|
||||||
*/
|
*/
|
||||||
@@ -284,71 +270,6 @@ abstract class Package
|
|||||||
return $this->getArtifact()?->hasPlatformBinary() ?? false;
|
return $this->getArtifact()?->hasPlatformBinary() ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get extra CFLAGS for current package.
|
|
||||||
* You need to define the environment variable in the format of {PACKAGE_NAME}_CFLAGS
|
|
||||||
* where {PACKAGE_NAME} is the snake_case name of the package.
|
|
||||||
* For example, for libjpeg, the environment variable should be libjpeg_CFLAGS.
|
|
||||||
*/
|
|
||||||
public function getLibExtraCFlags(): string
|
|
||||||
{
|
|
||||||
// get environment variable
|
|
||||||
$env = getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';
|
|
||||||
// get default c flags
|
|
||||||
$arch_c_flags = getenv('SPC_DEFAULT_CFLAGS') ?: '';
|
|
||||||
if (!empty(getenv('SPC_DEFAULT_CFLAGS')) && !str_contains($env, $arch_c_flags)) {
|
|
||||||
$env .= ' ' . $arch_c_flags;
|
|
||||||
}
|
|
||||||
return trim($env);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get extra CXXFLAGS for current package.
|
|
||||||
* You need to define the environment variable in the format of {PACKAGE_NAME}_CXXFLAGS
|
|
||||||
* where {PACKAGE_NAME} is the snake_case name of the package.
|
|
||||||
* For example, for libjpeg, the environment variable should be libjpeg_CXXFLAGS.
|
|
||||||
*/
|
|
||||||
public function getLibExtraCxxFlags(): string
|
|
||||||
{
|
|
||||||
// get environment variable
|
|
||||||
$env = getenv($this->getSnakeCaseName() . '_CXXFLAGS') ?: '';
|
|
||||||
// get default cxx flags
|
|
||||||
$arch_cxx_flags = getenv('SPC_DEFAULT_CXXFLAGS') ?: '';
|
|
||||||
if (!empty(getenv('SPC_DEFAULT_CXXFLAGS')) && !str_contains($env, $arch_cxx_flags)) {
|
|
||||||
$env .= ' ' . $arch_cxx_flags;
|
|
||||||
}
|
|
||||||
return trim($env);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get extra LDFLAGS for current package.
|
|
||||||
* You need to define the environment variable in the format of {PACKAGE_NAME}_LDFLAGS
|
|
||||||
* where {PACKAGE_NAME} is the snake_case name of the package.
|
|
||||||
* For example, for libjpeg, the environment variable should be libjpeg_LDFLAGS.
|
|
||||||
*/
|
|
||||||
public function getLibExtraLdFlags(): string
|
|
||||||
{
|
|
||||||
// get environment variable
|
|
||||||
$env = getenv($this->getSnakeCaseName() . '_LDFLAGS') ?: '';
|
|
||||||
// get default ld flags
|
|
||||||
$arch_ld_flags = getenv('SPC_DEFAULT_LDFLAGS') ?: '';
|
|
||||||
if (!empty(getenv('SPC_DEFAULT_LDFLAGS')) && !str_contains($env, $arch_ld_flags)) {
|
|
||||||
$env .= ' ' . $arch_ld_flags;
|
|
||||||
}
|
|
||||||
return trim($env);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get extra LIBS for current package.
|
|
||||||
* You need to define the environment variable in the format of {PACKAGE_NAME}_LIBS
|
|
||||||
* where {PACKAGE_NAME} is the snake_case name of the package.
|
|
||||||
* For example, for libjpeg, the environment variable should be libjpeg_LIBS.
|
|
||||||
*/
|
|
||||||
public function getLibExtraLibs(): string
|
|
||||||
{
|
|
||||||
return getenv($this->getSnakeCaseName() . '_LIBS') ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the snake_case name of the package.
|
* Get the snake_case name of the package.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace StaticPHP\Package;
|
namespace StaticPHP\Package;
|
||||||
|
|
||||||
use StaticPHP\Artifact\ArtifactCache;
|
use Package\Artifact\llvm_tools;
|
||||||
use StaticPHP\Config\PackageConfig;
|
use StaticPHP\Config\PackageConfig;
|
||||||
use StaticPHP\DI\ApplicationContext;
|
use StaticPHP\DI\ApplicationContext;
|
||||||
use StaticPHP\Exception\SPCException;
|
use StaticPHP\Exception\SPCException;
|
||||||
@@ -12,6 +12,8 @@ use StaticPHP\Exception\SPCInternalException;
|
|||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Runtime\Shell\Shell;
|
use StaticPHP\Runtime\Shell\Shell;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
|
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||||
|
use StaticPHP\Toolchain\ZigToolchain;
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
use StaticPHP\Util\GlobalPathTrait;
|
use StaticPHP\Util\GlobalPathTrait;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
use StaticPHP\Util\InteractiveTerm;
|
||||||
@@ -40,8 +42,8 @@ class PackageBuilder
|
|||||||
public function buildPackage(Package $package, bool $force = false): int
|
public function buildPackage(Package $package, bool $force = false): int
|
||||||
{
|
{
|
||||||
// init build dirs
|
// init build dirs
|
||||||
if (!$package instanceof LibraryPackage && !$package instanceof ToolPackage) {
|
if (!$package instanceof LibraryPackage) {
|
||||||
throw new SPCInternalException('Please, never try to build non-library, non-tool packages directly.');
|
throw new SPCInternalException('Please, never try to build non-library packages directly.');
|
||||||
}
|
}
|
||||||
FileSystem::createDir($package->getBuildRootPath());
|
FileSystem::createDir($package->getBuildRootPath());
|
||||||
FileSystem::createDir($package->getIncludeDir());
|
FileSystem::createDir($package->getIncludeDir());
|
||||||
@@ -79,14 +81,6 @@ class PackageBuilder
|
|||||||
$this->installLicense($package, $license);
|
$this->installLicense($package, $license);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the installed version for tool packages built from source, so
|
|
||||||
// `check-update --installed` reflects what's actually on disk (mirrors the
|
|
||||||
// binary-install recording in PackageInstaller::installBinary()).
|
|
||||||
if ($package instanceof ToolPackage) {
|
|
||||||
$source_info = ApplicationContext::get(ArtifactCache::class)->getSourceInfo($package->getName());
|
|
||||||
ToolVersionRegistry::record($package->getName(), $source_info['version'] ?? null);
|
|
||||||
}
|
|
||||||
} catch (SPCException $e) {
|
} catch (SPCException $e) {
|
||||||
// Ensure package information is bound if not already
|
// Ensure package information is bound if not already
|
||||||
if ($e->getPackageInfo() === null) {
|
if ($e->getPackageInfo() === null) {
|
||||||
@@ -187,14 +181,18 @@ class PackageBuilder
|
|||||||
if (SystemTarget::getTargetOS() === 'Darwin') {
|
if (SystemTarget::getTargetOS() === 'Darwin') {
|
||||||
shell()->exec("dsymutil -f {$binary_path} -o {$debug_file}");
|
shell()->exec("dsymutil -f {$binary_path} -o {$debug_file}");
|
||||||
} elseif (SystemTarget::getTargetOS() === 'Linux') {
|
} elseif (SystemTarget::getTargetOS() === 'Linux') {
|
||||||
|
$objcopy = getenv('OBJCOPY')
|
||||||
|
?: (ApplicationContext::tryGet(ToolchainInterface::class) instanceof ZigToolchain
|
||||||
|
? llvm_tools::binary('llvm-objcopy')
|
||||||
|
: 'objcopy');
|
||||||
if ($eu_strip = LinuxUtil::findCommand('eu-strip')) {
|
if ($eu_strip = LinuxUtil::findCommand('eu-strip')) {
|
||||||
shell()
|
shell()
|
||||||
->exec("{$eu_strip} -f {$debug_file} {$binary_path}")
|
->exec("{$eu_strip} -f {$debug_file} {$binary_path}")
|
||||||
->exec("objcopy --add-gnu-debuglink={$debug_file} {$binary_path}");
|
->exec("{$objcopy} --add-gnu-debuglink={$debug_file} {$binary_path}");
|
||||||
} else {
|
} else {
|
||||||
shell()
|
shell()
|
||||||
->exec("objcopy --only-keep-debug {$binary_path} {$debug_file}")
|
->exec("{$objcopy} --only-keep-debug {$binary_path} {$debug_file}")
|
||||||
->exec("objcopy --add-gnu-debuglink={$debug_file} {$binary_path}");
|
->exec("{$objcopy} --add-gnu-debuglink={$debug_file} {$binary_path}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger()->debug('extractDebugInfo is only supported on Linux and macOS');
|
logger()->debug('extractDebugInfo is only supported on Linux and macOS');
|
||||||
@@ -208,9 +206,12 @@ class PackageBuilder
|
|||||||
*/
|
*/
|
||||||
public function stripBinary(string $binary_path): void
|
public function stripBinary(string $binary_path): void
|
||||||
{
|
{
|
||||||
|
$strip = ApplicationContext::tryGet(ToolchainInterface::class) instanceof ZigToolchain
|
||||||
|
? llvm_tools::binary('llvm-strip')
|
||||||
|
: 'strip';
|
||||||
shell()->exec(match (SystemTarget::getTargetOS()) {
|
shell()->exec(match (SystemTarget::getTargetOS()) {
|
||||||
'Darwin' => "strip -S {$binary_path}",
|
'Darwin' => "{$strip} -S {$binary_path}",
|
||||||
'Linux' => "strip --strip-unneeded {$binary_path}",
|
'Linux' => "{$strip} --strip-unneeded {$binary_path}",
|
||||||
'Windows' => 'echo "Skip strip on Windows"', // Windows strip is not available for now
|
'Windows' => 'echo "Skip strip on Windows"', // Windows strip is not available for now
|
||||||
default => throw new SPCInternalException('stripBinary is only supported on Linux and macOS'),
|
default => throw new SPCInternalException('stripBinary is only supported on Linux and macOS'),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use StaticPHP\Artifact\ArtifactExtractor;
|
|||||||
use StaticPHP\Artifact\DownloaderOptions;
|
use StaticPHP\Artifact\DownloaderOptions;
|
||||||
use StaticPHP\Config\PackageConfig;
|
use StaticPHP\Config\PackageConfig;
|
||||||
use StaticPHP\DI\ApplicationContext;
|
use StaticPHP\DI\ApplicationContext;
|
||||||
use StaticPHP\Exception\EnvironmentException;
|
|
||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Registry\PackageLoader;
|
use StaticPHP\Registry\PackageLoader;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
@@ -76,9 +75,6 @@ class PackageInstaller
|
|||||||
}
|
}
|
||||||
// special check for php target packages
|
// special check for php target packages
|
||||||
if (in_array($package->getName(), ['php', 'php-cli', 'php-fpm', 'php-micro', 'php-cgi', 'php-embed', 'frankenphp'], true)) {
|
if (in_array($package->getName(), ['php', 'php-cli', 'php-fpm', 'php-micro', 'php-cgi', 'php-embed', 'frankenphp'], true)) {
|
||||||
if (!$package instanceof TargetPackage) {
|
|
||||||
throw new WrongUsageException("Package '{$package->getName()}' is expected to be a TargetPackage.");
|
|
||||||
}
|
|
||||||
$this->handlePhpTargetPackage($package);
|
$this->handlePhpTargetPackage($package);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -175,7 +171,7 @@ class PackageInstaller
|
|||||||
// These must always download binary (not source), regardless of global prefer-source setting.
|
// These must always download binary (not source), regardless of global prefer-source setting.
|
||||||
$binary_only_packages = array_filter(
|
$binary_only_packages = array_filter(
|
||||||
$this->packages,
|
$this->packages,
|
||||||
fn ($p) => ($p instanceof LibraryPackage || $p instanceof ToolPackage)
|
fn ($p) => $p instanceof LibraryPackage
|
||||||
&& !$this->isBuildPackage($p)
|
&& !$this->isBuildPackage($p)
|
||||||
&& !$p->hasStage('build')
|
&& !$p->hasStage('build')
|
||||||
&& ($p->getArtifact()?->hasPlatformBinary() ?? false)
|
&& ($p->getArtifact()?->hasPlatformBinary() ?? false)
|
||||||
@@ -213,8 +209,8 @@ class PackageInstaller
|
|||||||
$builder = ApplicationContext::get(PackageBuilder::class);
|
$builder = ApplicationContext::get(PackageBuilder::class);
|
||||||
foreach ($this->packages as $package) {
|
foreach ($this->packages as $package) {
|
||||||
$is_to_build = $this->isBuildPackage($package);
|
$is_to_build = $this->isBuildPackage($package);
|
||||||
$has_build_stage = ($package instanceof LibraryPackage || $package instanceof ToolPackage) && $package->hasStage('build');
|
$has_build_stage = $package instanceof LibraryPackage && $package->hasStage('build');
|
||||||
$should_use_binary = ($package instanceof LibraryPackage || $package instanceof ToolPackage) && ($package->getArtifact()?->shouldUseBinary() ?? false);
|
$should_use_binary = $package instanceof LibraryPackage && ($package->getArtifact()?->shouldUseBinary() ?? false);
|
||||||
$has_source = $package->hasSource();
|
$has_source = $package->hasSource();
|
||||||
if (!$is_to_build && $should_use_binary) {
|
if (!$is_to_build && $should_use_binary) {
|
||||||
// install binary
|
// install binary
|
||||||
@@ -277,11 +273,6 @@ class PackageInstaller
|
|||||||
|
|
||||||
// perform after-install actions and emit post-install events
|
// perform after-install actions and emit post-install events
|
||||||
$this->emitPostInstallEvents();
|
$this->emitPostInstallEvents();
|
||||||
|
|
||||||
// Final verification: declared build-time tools should have been auto-installed by the
|
|
||||||
// pipeline above (they were merged into $this->packages in resolvePackages()). This only
|
|
||||||
// throws if a tool genuinely failed to become available (e.g. no artifact for this platform).
|
|
||||||
$this->ensureRequiredTools();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBuildPackage(Package|string $package): bool
|
public function isBuildPackage(Package|string $package): bool
|
||||||
@@ -359,16 +350,12 @@ class PackageInstaller
|
|||||||
}
|
}
|
||||||
// Fallback: if the download cache is missing (e.g. download failed or cache was cleared),
|
// Fallback: if the download cache is missing (e.g. download failed or cache was cleared),
|
||||||
// still check whether the files are physically present in buildroot.
|
// still check whether the files are physically present in buildroot.
|
||||||
// Note: TargetPackage extends LibraryPackage, but target packages have no
|
// Note: TargetPackage extends LibraryPackage, but target packages (e.g. zig) have no
|
||||||
// static-libs/headers configured, so isInstalled() would trivially return true for them.
|
// static-libs/headers configured, so isInstalled() would trivially return true for them.
|
||||||
// Only apply this fallback to pure library packages.
|
// Only apply this fallback to pure library packages.
|
||||||
if ($package instanceof LibraryPackage && !($package instanceof TargetPackage)) {
|
if ($package instanceof LibraryPackage && !($package instanceof TargetPackage)) {
|
||||||
return $package->isInstalled();
|
return $package->isInstalled();
|
||||||
}
|
}
|
||||||
// Tool packages: fall back to checking their provided binaries directly on disk.
|
|
||||||
if ($package instanceof ToolPackage) {
|
|
||||||
return $package->isInstalled();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,16 +504,6 @@ class PackageInstaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$status = $extractor->extract($artifact);
|
$status = $extractor->extract($artifact);
|
||||||
|
|
||||||
// Record the installed version for tool packages, so `check-update --installed` can
|
|
||||||
// compare against what's actually on disk instead of only the download cache (which
|
|
||||||
// only reflects the last download and may be stale or cleared). Recorded regardless of
|
|
||||||
// $status so the registry self-heals if it was deleted separately from the install dir.
|
|
||||||
if ($package instanceof ToolPackage) {
|
|
||||||
$cache_info = ApplicationContext::get(ArtifactCache::class)->getBinaryInfo($artifact->getName(), SystemTarget::getCurrentPlatformString());
|
|
||||||
ToolVersionRegistry::record($artifact->getName(), $cache_info['version'] ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($status === SPC_STATUS_ALREADY_EXTRACTED) {
|
if ($status === SPC_STATUS_ALREADY_EXTRACTED) {
|
||||||
return SPC_STATUS_ALREADY_INSTALLED;
|
return SPC_STATUS_ALREADY_INSTALLED;
|
||||||
}
|
}
|
||||||
@@ -594,66 +571,6 @@ class PackageInstaller
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Collect all tool packages required by the currently resolved packages.
|
|
||||||
*
|
|
||||||
* Reads the 'tools' field from each resolved package's YAML config.
|
|
||||||
* The field supports platform suffixes (tools@windows, tools@linux, etc.)
|
|
||||||
* resolved automatically by PackageConfig::get().
|
|
||||||
*
|
|
||||||
* Tools are NOT part of the library dependency graph — they are
|
|
||||||
* build-time prerequisites that must be installed before any library
|
|
||||||
* build begins.
|
|
||||||
*
|
|
||||||
* @return string[] Unique tool package names required for this build
|
|
||||||
*/
|
|
||||||
public function collectRequiredTools(): array
|
|
||||||
{
|
|
||||||
$tools = [];
|
|
||||||
foreach ($this->packages as $package) {
|
|
||||||
$deps = PackageConfig::get($package->getName(), 'tools', []);
|
|
||||||
foreach ((array) $deps as $tool_name) {
|
|
||||||
$tools[$tool_name] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array_keys($tools);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check that all required tools are installed.
|
|
||||||
*
|
|
||||||
* Iterates through tools collected by collectRequiredTools(),
|
|
||||||
* resolves each to a ToolPackage instance, and checks isInstalled().
|
|
||||||
*
|
|
||||||
* @return array{missing: array<string>, installed: array<string>}
|
|
||||||
*/
|
|
||||||
public function checkRequiredTools(): array
|
|
||||||
{
|
|
||||||
$missing = [];
|
|
||||||
$installed = [];
|
|
||||||
foreach ($this->collectRequiredTools() as $tool_name) {
|
|
||||||
try {
|
|
||||||
$tool = PackageLoader::getPackage($tool_name);
|
|
||||||
} catch (WrongUsageException) {
|
|
||||||
$missing[] = $tool_name;
|
|
||||||
logger()->warning("Required tool '{$tool_name}' is not registered as a package.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$tool instanceof ToolPackage) {
|
|
||||||
logger()->warning("Package '{$tool_name}' is declared as a tool dependency but is not a ToolPackage (type: {$tool->getType()}).");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tool->isInstalled()) {
|
|
||||||
$installed[] = $tool_name;
|
|
||||||
} else {
|
|
||||||
$missing[] = $tool_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ['missing' => $missing, 'installed' => $installed];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Package[] $packages
|
* @param Package[] $packages
|
||||||
*/
|
*/
|
||||||
@@ -677,8 +594,8 @@ class PackageInstaller
|
|||||||
*/
|
*/
|
||||||
private function validatePackageArtifact(Package $package): void
|
private function validatePackageArtifact(Package $package): void
|
||||||
{
|
{
|
||||||
// target, library and tool packages must have at least source or platform binary
|
// target and library must have at least source or platform binary
|
||||||
if (in_array($package->getType(), ['library', 'target', 'tool']) && !$package->getArtifact()?->hasSource() && !$package->getArtifact()?->hasPlatformBinary()) {
|
if (in_array($package->getType(), ['library', 'target']) && !$package->getArtifact()?->hasSource() && !$package->getArtifact()?->hasPlatformBinary()) {
|
||||||
throw new WrongUsageException("Validation failed: Target package '{$package->getName()}' has no source or current platform (" . SystemTarget::getCurrentPlatformString() . ') binary defined.');
|
throw new WrongUsageException("Validation failed: Target package '{$package->getName()}' has no source or current platform (" . SystemTarget::getCurrentPlatformString() . ') binary defined.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,62 +628,11 @@ class PackageInstaller
|
|||||||
$this->packages[$pkg_name] = PackageLoader::getPackage($pkg_name);
|
$this->packages[$pkg_name] = PackageLoader::getPackage($pkg_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge in build-time tool packages declared via 'tools'/'tools@platform' fields on the
|
|
||||||
// packages resolved above. Tools are intentionally NOT part of the library dependency graph
|
|
||||||
// (DependencyResolver), but still need to ride the normal download/extract/install pipeline
|
|
||||||
// so they get auto-installed like any other package.
|
|
||||||
//
|
|
||||||
// Tools are prepended so they install BEFORE any package that declares them — otherwise a
|
|
||||||
// library that invokes e.g. jom.exe during its build stage would fail because the tool
|
|
||||||
// hasn't been extracted yet (tools were appended after the dependency graph in insertion
|
|
||||||
// order, which is also the build-loop iteration order).
|
|
||||||
$tool_packages = [];
|
|
||||||
foreach ($this->collectRequiredTools() as $tool_name) {
|
|
||||||
if (isset($this->packages[$tool_name])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$tool = PackageLoader::getPackage($tool_name);
|
|
||||||
} catch (WrongUsageException) {
|
|
||||||
continue; // will be reported as missing by ensureRequiredTools()
|
|
||||||
}
|
|
||||||
if ($tool instanceof ToolPackage) {
|
|
||||||
$tool_packages[$tool_name] = $tool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Prepend: tools first, then the dependency-resolved packages.
|
|
||||||
$this->packages = [...$tool_packages, ...$this->packages];
|
|
||||||
|
|
||||||
foreach ($this->packages as $package) {
|
foreach ($this->packages as $package) {
|
||||||
$this->injectPackageEnvs($package);
|
$this->injectPackageEnvs($package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure all required tools are installed, throwing if any are missing.
|
|
||||||
*
|
|
||||||
* Called at the end of run(), after the normal download/extract/build/install pipeline
|
|
||||||
* has had a chance to auto-install any tool package merged in resolvePackages(). This is
|
|
||||||
* a final safety net: it only throws if a declared tool still isn't available afterward
|
|
||||||
* (e.g. no artifact defined for the current platform, or the tool name doesn't resolve to
|
|
||||||
* a registered ToolPackage). "General" tools not declared via any package's 'tools' field
|
|
||||||
* (e.g. zig, musl-toolchain) are not covered here and remain purely Doctor-driven.
|
|
||||||
*/
|
|
||||||
private function ensureRequiredTools(): void
|
|
||||||
{
|
|
||||||
$status = $this->checkRequiredTools();
|
|
||||||
if (empty($status['missing'])) {
|
|
||||||
if (!empty($status['installed'])) {
|
|
||||||
logger()->info('Required tools: ' . implode(', ', $status['installed']) . ' — all installed.');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$msg = 'Missing required build tools: ' . implode(', ', $status['missing']) . "\n";
|
|
||||||
$msg .= "Run 'bin/spc doctor' to check your environment, or install the missing tools manually.";
|
|
||||||
throw new EnvironmentException($msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function injectPackageEnvs(Package $package): void
|
private function injectPackageEnvs(Package $package): void
|
||||||
{
|
{
|
||||||
$name = $package->getName();
|
$name = $package->getName();
|
||||||
|
|||||||
@@ -1,233 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace StaticPHP\Package;
|
|
||||||
|
|
||||||
use StaticPHP\Config\PackageConfig;
|
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
|
||||||
use StaticPHP\Util\FileSystem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a build-time tool package.
|
|
||||||
*
|
|
||||||
* Tool packages are NOT link-time dependencies. They provide executables
|
|
||||||
* that are needed during the build process (compilers, code generators,
|
|
||||||
* assemblers, etc.) and are installed into PKG_ROOT_PATH.
|
|
||||||
*
|
|
||||||
* Tool packages do NOT produce static-libs, headers, or pkg-config files.
|
|
||||||
* They are resolved and installed independently from the library dependency graph.
|
|
||||||
*
|
|
||||||
* YAML config schema (config/pkg/tool/<name>.yml):
|
|
||||||
*
|
|
||||||
* nasm:
|
|
||||||
* type: tool
|
|
||||||
* tool:
|
|
||||||
* provides: [nasm.exe, ndisasm.exe] # executables this tool installs
|
|
||||||
* binary-subdir: '' # subdirectory under install root (default: '')
|
|
||||||
* min-version: '2.16' # minimum required version (optional)
|
|
||||||
*
|
|
||||||
* Fields nested under 'tool' support the same '@windows'/'@unix'/'@macos'/'@linux' suffix
|
|
||||||
* overrides as top-level package fields (e.g. 'provides@windows' overrides 'provides' when
|
|
||||||
* building on Windows), useful when a tool provides differently-named binaries per OS
|
|
||||||
* (e.g. upx vs upx.exe).
|
|
||||||
* artifact:
|
|
||||||
* binary:
|
|
||||||
* windows-x86_64:
|
|
||||||
* type: url
|
|
||||||
* url: 'https://...'
|
|
||||||
* extract:
|
|
||||||
* nasm.exe: '{php_sdk_path}/bin/nasm.exe'
|
|
||||||
*/
|
|
||||||
class ToolPackage extends Package
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the build root ('--prefix') for a tool that builds from source.
|
|
||||||
*
|
|
||||||
* Unlike LibraryPackage (which installs into BUILD_ROOT_PATH), tool packages that build
|
|
||||||
* from source (e.g. pkg-config, via UnixAutoconfExecutor/UnixCMakeExecutor) install into
|
|
||||||
* their own install root (PKG_ROOT_PATH by default), consistent with pre-built tool binaries.
|
|
||||||
*/
|
|
||||||
public function getBuildRootPath(): string
|
|
||||||
{
|
|
||||||
return $this->getInstallRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tool packages don't produce headers for other packages to consume. Kept self-contained
|
|
||||||
* under the tool's own install root so a from-source build never accidentally picks up
|
|
||||||
* unrelated headers from BUILD_ROOT_PATH.
|
|
||||||
*/
|
|
||||||
public function getIncludeDir(): string
|
|
||||||
{
|
|
||||||
return $this->getInstallRoot() . DIRECTORY_SEPARATOR . 'include';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tool packages don't produce libraries for other packages to consume. Kept self-contained
|
|
||||||
* under the tool's own install root (see getIncludeDir()).
|
|
||||||
*/
|
|
||||||
public function getLibDir(): string
|
|
||||||
{
|
|
||||||
return $this->getInstallRoot() . DIRECTORY_SEPARATOR . 'lib';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Where this tool's own executables live, i.e. {install-root}/{binary-subdir}.
|
|
||||||
*/
|
|
||||||
public function getBinDir(): string
|
|
||||||
{
|
|
||||||
return $this->getBinaryDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the install root directory for this tool.
|
|
||||||
*
|
|
||||||
* Defaults to PKG_ROOT_PATH. Override via 'tool.install-root' in YAML
|
|
||||||
* or via the TOOL_INSTALL_ROOT_{NAME} environment variable.
|
|
||||||
*/
|
|
||||||
public function getInstallRoot(): string
|
|
||||||
{
|
|
||||||
$env_var = 'TOOL_INSTALL_ROOT_' . strtoupper(str_replace('-', '_', $this->name));
|
|
||||||
if ($root = getenv($env_var)) {
|
|
||||||
return $root;
|
|
||||||
}
|
|
||||||
$config_root = $this->getToolField('install-root');
|
|
||||||
if ($config_root !== null) {
|
|
||||||
return FileSystem::replacePathVariable((string) $config_root);
|
|
||||||
}
|
|
||||||
return PKG_ROOT_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the directory where this tool's binaries reside.
|
|
||||||
*
|
|
||||||
* This is {install-root}/{binary-subdir}. If binary-subdir is not
|
|
||||||
* configured, returns the install root directly.
|
|
||||||
*/
|
|
||||||
public function getBinaryDir(): string
|
|
||||||
{
|
|
||||||
$subdir = $this->getToolField('binary-subdir') ?? '';
|
|
||||||
if ($subdir === '') {
|
|
||||||
return $this->getInstallRoot();
|
|
||||||
}
|
|
||||||
return $this->getInstallRoot() . DIRECTORY_SEPARATOR . $subdir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the list of executables this tool provides.
|
|
||||||
*
|
|
||||||
* Reads from YAML 'tool.provides' field (with '@windows'/'@unix'/'@macos'/'@linux'
|
|
||||||
* suffix override support). Each entry is a bare filename (e.g. 'nasm.exe'), resolved
|
|
||||||
* relative to getBinaryDir().
|
|
||||||
*
|
|
||||||
* @return string[] Bare executable names (not full paths)
|
|
||||||
*/
|
|
||||||
public function getProvides(): array
|
|
||||||
{
|
|
||||||
return $this->getToolField('provides') ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the full path to a specific binary provided by this tool.
|
|
||||||
*
|
|
||||||
* @param string $name Bare executable name (must be listed in tool.provides).
|
|
||||||
* If empty, defaults to the first entry in provides.
|
|
||||||
* @return string Full absolute path to the binary
|
|
||||||
*/
|
|
||||||
public function getBinary(string $name = ''): string
|
|
||||||
{
|
|
||||||
$provides = $this->getProvides();
|
|
||||||
if ($name === '') {
|
|
||||||
$name = $provides[0] ?? throw new \RuntimeException("Tool '{$this->name}' has no 'tool.provides' configured.");
|
|
||||||
}
|
|
||||||
if (!in_array($name, $provides, true)) {
|
|
||||||
throw new \RuntimeException("Binary '{$name}' is not listed in tool.provides for '{$this->name}'. Available: " . implode(', ', $provides));
|
|
||||||
}
|
|
||||||
return $this->getBinaryDir() . DIRECTORY_SEPARATOR . $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether this tool is installed (all provided binaries exist on disk).
|
|
||||||
*/
|
|
||||||
public function isInstalled(): bool
|
|
||||||
{
|
|
||||||
return array_all($this->getProvides(), fn ($binary) => file_exists($this->getBinary($binary)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the version currently installed on disk, as recorded by ToolVersionRegistry when this
|
|
||||||
* tool's binary was last (re-)installed via PackageInstaller::installBinary().
|
|
||||||
*
|
|
||||||
* Returns null if the tool was never installed through the package installer (e.g. installed
|
|
||||||
* manually, or not installed at all), or if its artifact doesn't expose a version string.
|
|
||||||
* This reflects what's actually on disk, unlike the download cache which only reflects the
|
|
||||||
* last download and may be stale or cleared.
|
|
||||||
*/
|
|
||||||
public function getInstalledVersion(): ?string
|
|
||||||
{
|
|
||||||
return ToolVersionRegistry::get($this->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the minimum required version for this tool, if specified.
|
|
||||||
*
|
|
||||||
* Returns null if no version constraint is configured.
|
|
||||||
*/
|
|
||||||
public function getMinVersion(): ?string
|
|
||||||
{
|
|
||||||
$version = $this->getToolField('min-version');
|
|
||||||
return $version !== null ? (string) $version : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tools install to PKG_ROOT_PATH (or the configured install-root),
|
|
||||||
* not BUILD_ROOT_PATH.
|
|
||||||
*/
|
|
||||||
public function getInstallTarget(): string
|
|
||||||
{
|
|
||||||
return $this->getBinaryDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the 'tool' sub-config for this package.
|
|
||||||
*
|
|
||||||
* Returns the nested array under the 'tool' key in the package YAML,
|
|
||||||
* or an empty array if not configured.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
private function getToolConfig(): array
|
|
||||||
{
|
|
||||||
$config = PackageConfig::get($this->name);
|
|
||||||
if (!is_array($config) || !isset($config['tool']) || !is_array($config['tool'])) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return $config['tool'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a field from the nested 'tool' config block, honoring the same
|
|
||||||
* '@windows'/'@unix'/'@macos'/'@linux'/'@bsd'/'@freebsd' suffix override priority
|
|
||||||
* that PackageConfig::get() applies to top-level fields. This lets a tool declare a
|
|
||||||
* per-OS override, e.g. 'provides' + 'provides@windows', without needing platform-
|
|
||||||
* specific package config files.
|
|
||||||
*/
|
|
||||||
private function getToolField(string $field): mixed
|
|
||||||
{
|
|
||||||
$tool = $this->getToolConfig();
|
|
||||||
$suffixes = match (SystemTarget::getTargetOS()) {
|
|
||||||
'Windows' => ['@windows', ''],
|
|
||||||
'Darwin' => ['@macos', '@unix', ''],
|
|
||||||
'Linux' => ['@linux', '@unix', ''],
|
|
||||||
'BSD' => ['@freebsd', '@bsd', '@unix', ''],
|
|
||||||
};
|
|
||||||
foreach ($suffixes as $suffix) {
|
|
||||||
$key = "{$field}{$suffix}";
|
|
||||||
if (isset($tool[$key])) {
|
|
||||||
return $tool[$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace StaticPHP\Package;
|
|
||||||
|
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tracks the version actually installed on disk for tool packages (PKG_ROOT_PATH), separate from
|
|
||||||
* the download cache (ArtifactCache). Tools are installed once and reused across many builds, so
|
|
||||||
* the download cache (which only reflects the last download) can drift from what's really on disk
|
|
||||||
* (e.g. cache cleared, or installed a long time ago via `doctor`). This registry is the source of
|
|
||||||
* truth for "what version is currently installed", used by ToolPackage::getInstalledVersion() and
|
|
||||||
* the `check-update --installed` flag.
|
|
||||||
*
|
|
||||||
* Backed by a small JSON file at PKG_ROOT_PATH/.spc-tool-versions.json, mirroring the same
|
|
||||||
* read-once/write-through pattern used by StaticPHP\Artifact\ArtifactCache.
|
|
||||||
*/
|
|
||||||
class ToolVersionRegistry
|
|
||||||
{
|
|
||||||
/** @var null|array<string, array{version: null|string, platform: string, installed_at: string}> */
|
|
||||||
private static ?array $data = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the recorded installed version for a tool, or null if never recorded (not a tool
|
|
||||||
* package, not installed yet, or the artifact doesn't expose a version).
|
|
||||||
*/
|
|
||||||
public static function get(string $tool_name): ?string
|
|
||||||
{
|
|
||||||
self::load();
|
|
||||||
return self::$data[$tool_name]['version'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Record the version currently installed for a tool. Called after a tool package's binary
|
|
||||||
* has been (re-)installed, regardless of whether extraction actually ran (keeps the registry
|
|
||||||
* self-healing if it was deleted separately from the installed files).
|
|
||||||
*/
|
|
||||||
public static function record(string $tool_name, ?string $version): void
|
|
||||||
{
|
|
||||||
self::load();
|
|
||||||
self::$data[$tool_name] = [
|
|
||||||
'version' => $version,
|
|
||||||
'platform' => SystemTarget::getCurrentPlatformString(),
|
|
||||||
'installed_at' => date('c'),
|
|
||||||
];
|
|
||||||
self::save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getPath(): string
|
|
||||||
{
|
|
||||||
return PKG_ROOT_PATH . '/.spc-tool-versions.json';
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function load(): void
|
|
||||||
{
|
|
||||||
if (self::$data !== null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$path = self::getPath();
|
|
||||||
if (!file_exists($path)) {
|
|
||||||
self::$data = [];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$content = file_get_contents($path);
|
|
||||||
self::$data = is_string($content) ? (json_decode($content, true) ?: []) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function save(): void
|
|
||||||
{
|
|
||||||
$path = self::getPath();
|
|
||||||
$dir = dirname($path);
|
|
||||||
if (!is_dir($dir)) {
|
|
||||||
@mkdir($dir, 0755, true);
|
|
||||||
}
|
|
||||||
file_put_contents($path, json_encode(self::$data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@ use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
|||||||
use StaticPHP\Attribute\Package\ResolveBuild;
|
use StaticPHP\Attribute\Package\ResolveBuild;
|
||||||
use StaticPHP\Attribute\Package\Stage;
|
use StaticPHP\Attribute\Package\Stage;
|
||||||
use StaticPHP\Attribute\Package\Target;
|
use StaticPHP\Attribute\Package\Target;
|
||||||
use StaticPHP\Attribute\Package\Tool;
|
|
||||||
use StaticPHP\Attribute\Package\Validate;
|
use StaticPHP\Attribute\Package\Validate;
|
||||||
use StaticPHP\Config\PackageConfig;
|
use StaticPHP\Config\PackageConfig;
|
||||||
use StaticPHP\DI\ApplicationContext;
|
use StaticPHP\DI\ApplicationContext;
|
||||||
@@ -28,7 +27,6 @@ use StaticPHP\Package\Package;
|
|||||||
use StaticPHP\Package\PackageInstaller;
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\PhpExtensionPackage;
|
use StaticPHP\Package\PhpExtensionPackage;
|
||||||
use StaticPHP\Package\TargetPackage;
|
use StaticPHP\Package\TargetPackage;
|
||||||
use StaticPHP\Package\ToolPackage;
|
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
|
|
||||||
class PackageLoader
|
class PackageLoader
|
||||||
@@ -90,7 +88,6 @@ class PackageLoader
|
|||||||
'target', 'virtual-target' => new TargetPackage($name, $item['type']),
|
'target', 'virtual-target' => new TargetPackage($name, $item['type']),
|
||||||
'library' => new LibraryPackage($name, $item['type']),
|
'library' => new LibraryPackage($name, $item['type']),
|
||||||
'php-extension' => new PhpExtensionPackage($name, $item['type']),
|
'php-extension' => new PhpExtensionPackage($name, $item['type']),
|
||||||
'tool' => new ToolPackage($name, $item['type']),
|
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
if ($pkg !== null) {
|
if ($pkg !== null) {
|
||||||
@@ -193,8 +190,7 @@ class PackageLoader
|
|||||||
$attribute_instance = $attribute->newInstance();
|
$attribute_instance = $attribute->newInstance();
|
||||||
if ($attribute_instance instanceof Target === false &&
|
if ($attribute_instance instanceof Target === false &&
|
||||||
$attribute_instance instanceof Library === false &&
|
$attribute_instance instanceof Library === false &&
|
||||||
$attribute_instance instanceof Extension === false &&
|
$attribute_instance instanceof Extension === false) {
|
||||||
$attribute_instance instanceof Tool === false) {
|
|
||||||
// not a package attribute
|
// not a package attribute
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -220,7 +216,6 @@ class PackageLoader
|
|||||||
Target::class => ['target', 'virtual-target'],
|
Target::class => ['target', 'virtual-target'],
|
||||||
Library::class => ['library'],
|
Library::class => ['library'],
|
||||||
Extension::class => ['php-extension'],
|
Extension::class => ['php-extension'],
|
||||||
Tool::class => ['tool'],
|
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
if (!in_array($package_type, $pkg_type_attr, true)) {
|
if (!in_array($package_type, $pkg_type_attr, true)) {
|
||||||
@@ -375,10 +370,7 @@ class PackageLoader
|
|||||||
// match condition
|
// match condition
|
||||||
$installer = ApplicationContext::get(PackageInstaller::class);
|
$installer = ApplicationContext::get(PackageInstaller::class);
|
||||||
$stages = self::$before_stages[$package_name][$stage] ?? [];
|
$stages = self::$before_stages[$package_name][$stage] ?? [];
|
||||||
foreach ($stages as $entry) {
|
foreach ($stages as [$callback, $only_when_package_resolved, $conditionals]) {
|
||||||
$callback = $entry[0];
|
|
||||||
$only_when_package_resolved = $entry[1] ?? null;
|
|
||||||
$conditionals = $entry[2] ?? [];
|
|
||||||
if ($only_when_package_resolved !== null && !$installer->isPackageResolved($only_when_package_resolved)) {
|
if ($only_when_package_resolved !== null && !$installer->isPackageResolved($only_when_package_resolved)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -397,10 +389,7 @@ class PackageLoader
|
|||||||
$installer = ApplicationContext::get(PackageInstaller::class);
|
$installer = ApplicationContext::get(PackageInstaller::class);
|
||||||
$stages = self::$after_stages[$package_name][$stage] ?? [];
|
$stages = self::$after_stages[$package_name][$stage] ?? [];
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($stages as $entry) {
|
foreach ($stages as [$callback, $only_when_package_resolved, $conditionals]) {
|
||||||
$callback = $entry[0];
|
|
||||||
$only_when_package_resolved = $entry[1] ?? null;
|
|
||||||
$conditionals = $entry[2] ?? [];
|
|
||||||
if ($only_when_package_resolved !== null && !$installer->isPackageResolved($only_when_package_resolved)) {
|
if ($only_when_package_resolved !== null && !$installer->isPackageResolved($only_when_package_resolved)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -444,9 +433,7 @@ class PackageLoader
|
|||||||
}
|
}
|
||||||
$pkg = self::getPackage($package_name);
|
$pkg = self::getPackage($package_name);
|
||||||
foreach ($stages as $stage_name => $before_events) {
|
foreach ($stages as $stage_name => $before_events) {
|
||||||
foreach ($before_events as $entry) {
|
foreach ($before_events as [$event_callable, $only_when_package_resolved, $conditionals]) {
|
||||||
$event_callable = $entry[0];
|
|
||||||
$only_when_package_resolved = $entry[1] ?? null;
|
|
||||||
// check only_when_package_resolved package exists
|
// check only_when_package_resolved package exists
|
||||||
if ($only_when_package_resolved !== null && !self::hasPackage($only_when_package_resolved)) {
|
if ($only_when_package_resolved !== null && !self::hasPackage($only_when_package_resolved)) {
|
||||||
throw new RegistryException("{$event_name} event in package [{$package_name}] for stage [{$stage_name}] has unknown only_when_package_resolved package [{$only_when_package_resolved}].");
|
throw new RegistryException("{$event_name} event in package [{$package_name}] for stage [{$stage_name}] has unknown only_when_package_resolved package [{$only_when_package_resolved}].");
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ declare(strict_types=1);
|
|||||||
namespace StaticPHP\Runtime\Executor;
|
namespace StaticPHP\Runtime\Executor;
|
||||||
|
|
||||||
use StaticPHP\Package\LibraryPackage;
|
use StaticPHP\Package\LibraryPackage;
|
||||||
use StaticPHP\Package\ToolPackage;
|
|
||||||
|
|
||||||
abstract class Executor
|
abstract class Executor
|
||||||
{
|
{
|
||||||
public function __construct(protected LibraryPackage|ToolPackage $package) {}
|
public function __construct(protected LibraryPackage $package) {}
|
||||||
|
|
||||||
public static function create(LibraryPackage|ToolPackage $package): static
|
public static function create(LibraryPackage $package): static
|
||||||
{
|
{
|
||||||
return new static($package);
|
return new static($package);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use StaticPHP\Exception\SPCInternalException;
|
|||||||
use StaticPHP\Package\LibraryPackage;
|
use StaticPHP\Package\LibraryPackage;
|
||||||
use StaticPHP\Package\PackageBuilder;
|
use StaticPHP\Package\PackageBuilder;
|
||||||
use StaticPHP\Package\PackageInstaller;
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\ToolPackage;
|
|
||||||
use StaticPHP\Runtime\Shell\UnixShell;
|
use StaticPHP\Runtime\Shell\UnixShell;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
use StaticPHP\Util\InteractiveTerm;
|
||||||
use ZM\Logger\ConsoleColor;
|
use ZM\Logger\ConsoleColor;
|
||||||
@@ -23,7 +22,7 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
|
|
||||||
protected PackageInstaller $installer;
|
protected PackageInstaller $installer;
|
||||||
|
|
||||||
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
|
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
|
||||||
{
|
{
|
||||||
parent::__construct($package);
|
parent::__construct($package);
|
||||||
if ($installer !== null) {
|
if ($installer !== null) {
|
||||||
@@ -118,7 +117,7 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Add configure args.
|
* Add configure args.
|
||||||
*/
|
*/
|
||||||
public function addConfigureArgs(string ...$args): static
|
public function addConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->configure_args = [...$this->configure_args, ...$args];
|
$this->configure_args = [...$this->configure_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
@@ -127,7 +126,7 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Remove some configure args, to bypass the configure option checking for some libs.
|
* Remove some configure args, to bypass the configure option checking for some libs.
|
||||||
*/
|
*/
|
||||||
public function removeConfigureArgs(string ...$args): static
|
public function removeConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->configure_args = array_diff($this->configure_args, $args);
|
$this->configure_args = array_diff($this->configure_args, $args);
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use StaticPHP\Package\LibraryPackage;
|
|||||||
use StaticPHP\Package\PackageBuilder;
|
use StaticPHP\Package\PackageBuilder;
|
||||||
use StaticPHP\Package\PackageInstaller;
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\TargetPackage;
|
use StaticPHP\Package\TargetPackage;
|
||||||
use StaticPHP\Package\ToolPackage;
|
|
||||||
use StaticPHP\Runtime\Shell\UnixShell;
|
use StaticPHP\Runtime\Shell\UnixShell;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
@@ -41,7 +40,7 @@ class UnixCMakeExecutor extends Executor
|
|||||||
|
|
||||||
protected PackageInstaller $installer;
|
protected PackageInstaller $installer;
|
||||||
|
|
||||||
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
|
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
|
||||||
{
|
{
|
||||||
parent::__construct($package);
|
parent::__construct($package);
|
||||||
if ($installer !== null) {
|
if ($installer !== null) {
|
||||||
@@ -136,7 +135,7 @@ class UnixCMakeExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Add configure args.
|
* Add configure args.
|
||||||
*/
|
*/
|
||||||
public function addConfigureArgs(string ...$args): static
|
public function addConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->configure_args = [...$this->configure_args, ...$args];
|
$this->configure_args = [...$this->configure_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
@@ -145,7 +144,7 @@ class UnixCMakeExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Remove some configure args, to bypass the configure option checking for some libs.
|
* Remove some configure args, to bypass the configure option checking for some libs.
|
||||||
*/
|
*/
|
||||||
public function removeConfigureArgs(string ...$args): static
|
public function removeConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->ignore_args = [...$this->ignore_args, ...$args];
|
$this->ignore_args = [...$this->ignore_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
@@ -303,12 +302,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|||||||
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "{$include}")
|
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "{$include}")
|
||||||
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "{$include}")
|
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "{$include}")
|
||||||
CMAKE;
|
CMAKE;
|
||||||
// pin AR/RANLIB so cmake uses zig-ar/zig-ranlib instead of system /usr/bin/ranlib (zig archives need it)
|
// Whoops, linux may need CMAKE_AR sometimes
|
||||||
if (PHP_OS_FAMILY === 'Linux') {
|
if (PHP_OS_FAMILY === 'Linux') {
|
||||||
$ar = getenv('SPC_DEFAULT_AR') ?: getenv('AR') ?: 'ar';
|
$toolchain .= "\nSET(CMAKE_AR \"ar\")";
|
||||||
$ranlib = getenv('SPC_DEFAULT_RANLIB') ?: (getenv('RANLIB') ?: 'ranlib');
|
|
||||||
$toolchain .= "\nSET(CMAKE_AR \"{$ar}\")";
|
|
||||||
$toolchain .= "\nSET(CMAKE_RANLIB \"{$ranlib}\")";
|
|
||||||
}
|
}
|
||||||
FileSystem::writeFile(SOURCE_PATH . '/toolchain.cmake', $toolchain);
|
FileSystem::writeFile(SOURCE_PATH . '/toolchain.cmake', $toolchain);
|
||||||
return $created = realpath(SOURCE_PATH . '/toolchain.cmake');
|
return $created = realpath(SOURCE_PATH . '/toolchain.cmake');
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use StaticPHP\Exception\SPCInternalException;
|
|||||||
use StaticPHP\Package\LibraryPackage;
|
use StaticPHP\Package\LibraryPackage;
|
||||||
use StaticPHP\Package\PackageBuilder;
|
use StaticPHP\Package\PackageBuilder;
|
||||||
use StaticPHP\Package\PackageInstaller;
|
use StaticPHP\Package\PackageInstaller;
|
||||||
use StaticPHP\Package\ToolPackage;
|
|
||||||
use StaticPHP\Runtime\Shell\WindowsCmd;
|
use StaticPHP\Runtime\Shell\WindowsCmd;
|
||||||
use StaticPHP\Util\FileSystem;
|
use StaticPHP\Util\FileSystem;
|
||||||
use StaticPHP\Util\InteractiveTerm;
|
use StaticPHP\Util\InteractiveTerm;
|
||||||
@@ -36,7 +35,7 @@ class WindowsCMakeExecutor extends Executor
|
|||||||
|
|
||||||
protected PackageInstaller $installer;
|
protected PackageInstaller $installer;
|
||||||
|
|
||||||
public function __construct(protected LibraryPackage|ToolPackage $package)
|
public function __construct(protected LibraryPackage $package)
|
||||||
{
|
{
|
||||||
parent::__construct($this->package);
|
parent::__construct($this->package);
|
||||||
$this->builder = ApplicationContext::get(PackageBuilder::class);
|
$this->builder = ApplicationContext::get(PackageBuilder::class);
|
||||||
@@ -100,7 +99,7 @@ class WindowsCMakeExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Add configure args.
|
* Add configure args.
|
||||||
*/
|
*/
|
||||||
public function addConfigureArgs(string ...$args): static
|
public function addConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->configure_args = [...$this->configure_args, ...$args];
|
$this->configure_args = [...$this->configure_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
@@ -109,7 +108,7 @@ class WindowsCMakeExecutor extends Executor
|
|||||||
/**
|
/**
|
||||||
* Remove some configure args, to bypass the configure option checking for some libs.
|
* Remove some configure args, to bypass the configure option checking for some libs.
|
||||||
*/
|
*/
|
||||||
public function removeConfigureArgs(string ...$args): static
|
public function removeConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->ignore_args = [...$this->ignore_args, ...$args];
|
$this->ignore_args = [...$this->ignore_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
@@ -190,10 +189,6 @@ class WindowsCMakeExecutor extends Executor
|
|||||||
{
|
{
|
||||||
return $this->custom_default_args ?? [
|
return $this->custom_default_args ?? [
|
||||||
'-A x64',
|
'-A x64',
|
||||||
// CMake 4.x hard-errors on projects requesting compatibility with CMake < 3.5
|
|
||||||
// (e.g. wineditline). This is the documented escape hatch; modern projects and
|
|
||||||
// older CMake releases ignore it.
|
|
||||||
'-DCMAKE_POLICY_VERSION_MINIMUM=3.5',
|
|
||||||
'-DCMAKE_BUILD_TYPE=Release',
|
'-DCMAKE_BUILD_TYPE=Release',
|
||||||
'-DBUILD_SHARED_LIBS=OFF',
|
'-DBUILD_SHARED_LIBS=OFF',
|
||||||
'-DBUILD_STATIC_LIBS=ON',
|
'-DBUILD_STATIC_LIBS=ON',
|
||||||
|
|||||||
@@ -184,14 +184,12 @@ class DefaultShell extends Shell
|
|||||||
*/
|
*/
|
||||||
public function execute7zExtract(string $archive_path, string $target_path): bool
|
public function execute7zExtract(string $archive_path, string $target_path): bool
|
||||||
{
|
{
|
||||||
// 7za.exe is installed by the 7za-win target package into PKG_ROOT_PATH\bin,
|
$sdk_path = getenv('PHP_SDK_PATH');
|
||||||
// which is added to PATH by MSVCToolchain::initEnv().
|
if ($sdk_path === false) {
|
||||||
$_7z_path = FileSystem::convertPath(PKG_ROOT_PATH . '\bin\7za.exe');
|
throw new SPCInternalException('PHP_SDK_PATH environment variable is not set');
|
||||||
if (!file_exists($_7z_path)) {
|
|
||||||
throw new SPCInternalException('7za.exe not found. Please install the 7za-win target package.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$_7z = escapeshellarg(FileSystem::convertPath($_7z_path));
|
$_7z = escapeshellarg(FileSystem::convertPath($sdk_path . '/bin/7za.exe'));
|
||||||
$archive_arg = escapeshellarg(FileSystem::convertPath($archive_path));
|
$archive_arg = escapeshellarg(FileSystem::convertPath($archive_path));
|
||||||
$target_arg = escapeshellarg(FileSystem::convertPath($target_path));
|
$target_arg = escapeshellarg(FileSystem::convertPath($target_path));
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user