mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 16:25:39 +08:00
Compare commits
10 Commits
5913cb07fd
...
fix/tool-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b02f62b7e | ||
|
|
924fac137c | ||
|
|
d9c41a73da | ||
|
|
dd1e70a394 | ||
|
|
1bdbdfc08c | ||
|
|
90846ab149 | ||
|
|
8dd7882869 | ||
|
|
7f6be12bf1 | ||
|
|
45b97581d8 | ||
|
|
12a5217f17 |
24
.gitattributes
vendored
Normal file
24
.gitattributes
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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
|
||||
136
.github/workflows/vitepress-deploy.yml
vendored
136
.github/workflows/vitepress-deploy.yml
vendored
@@ -1,68 +1,68 @@
|
||||
name: Docs build test and auto deploy
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "v3" ]
|
||||
types: [ opened, synchronize, reopened ]
|
||||
paths:
|
||||
- 'config/**.yml'
|
||||
- 'docs/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/vitepress-deploy.yml'
|
||||
push:
|
||||
branches: [ "v3" ]
|
||||
paths:
|
||||
- 'config/**.yml'
|
||||
- 'docs/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/vitepress-deploy.yml'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Deploy docs
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
|
||||
- run: npm install
|
||||
|
||||
- name: "Install PHP for official runners"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
php-version: 8.4
|
||||
ini-values: memory_limit=-1
|
||||
extensions: curl, openssl, mbstring
|
||||
|
||||
- name: "Get Composer Cache Directory"
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: "Cache Composer dependencies"
|
||||
uses: "actions/cache@v4"
|
||||
with:
|
||||
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||
key: "php-8.2-locked-composer-${{ hashFiles('**/composer.lock') }}"
|
||||
restore-keys: |
|
||||
php-8.2-locked-composer
|
||||
|
||||
- name: "Install Locked Dependencies"
|
||||
run: "composer install --no-interaction --no-progress"
|
||||
|
||||
- name: Build
|
||||
run: npm run docs:build
|
||||
|
||||
# Deploy to GitHub Pages only when the workflow is triggered by a push to the v3 branch
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/v3'
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: docs/.vitepress/dist
|
||||
name: Docs build test and auto deploy
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "v3" ]
|
||||
types: [ opened, synchronize, reopened ]
|
||||
paths:
|
||||
- 'config/**.yml'
|
||||
- 'docs/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/vitepress-deploy.yml'
|
||||
push:
|
||||
branches: [ "v3" ]
|
||||
paths:
|
||||
- 'config/**.yml'
|
||||
- 'docs/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/vitepress-deploy.yml'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Deploy docs
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
|
||||
- run: npm install
|
||||
|
||||
- name: "Install PHP for official runners"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
php-version: 8.4
|
||||
ini-values: memory_limit=-1
|
||||
extensions: curl, openssl, mbstring
|
||||
|
||||
- name: "Get Composer Cache Directory"
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: "Cache Composer dependencies"
|
||||
uses: "actions/cache@v4"
|
||||
with:
|
||||
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||
key: "php-8.2-locked-composer-${{ hashFiles('**/composer.lock') }}"
|
||||
restore-keys: |
|
||||
php-8.2-locked-composer
|
||||
|
||||
- name: "Install Locked Dependencies"
|
||||
run: "composer install --no-interaction --no-progress"
|
||||
|
||||
- name: Build
|
||||
run: npm run docs:build
|
||||
|
||||
# Deploy to GitHub Pages only when the workflow is triggered by a push to the v3 branch
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/v3'
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: docs/.vitepress/dist
|
||||
|
||||
312
README-zh.md
312
README-zh.md
@@ -1,156 +1,156 @@
|
||||
# StaticPHP
|
||||
|
||||
[](README-zh.md)
|
||||
[](README.md)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/releases)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
|
||||
[](https://discord.gg/xf6Rd4pEAk)
|
||||
|
||||
**StaticPHP** 是一个强大的工具,用于构建可移植的可执行文件,包括 PHP、扩展等。
|
||||
|
||||
> [!IMPORTANT]
|
||||
> 我们正准备发布 **v3** 版本,届时项目名称将从 **static-php-cli** 更改为 **StaticPHP**。
|
||||
> 此分支对应 v3 版本。v2 版本请查看 [v2 分支](https://github.com/crazywhalecc/static-php-cli/tree/main)。
|
||||
> 请更新您的参考资料,并关注正式版发布。
|
||||
|
||||
## 特性
|
||||
|
||||
- :elephant: 支持多个 PHP 版本 - PHP 8.1, 8.2, 8.3, 8.4, 8.5
|
||||
- :handbag: 构建零依赖的单文件 PHP 可执行程序
|
||||
- :hamburger: 构建 **[phpmicro](https://github.com/static-php/phpmicro)** 自解压可执行文件(将 PHP 二进制和源码合并为单个文件)
|
||||
- :pill: 自动构建环境检查器,支持自动修复
|
||||
- :zap: 支持 `Linux`、`macOS`、`Windows`
|
||||
- :wrench: 通过 vendor 模式和自定义注册表实现便捷扩展
|
||||
- :books: 智能依赖管理
|
||||
- 📦 自包含 `spc` 可执行文件,便于自安装
|
||||
- :fire: 支持 100+ 热门 [PHP 扩展](https://static-php.dev/en/guide/extensions.html)
|
||||
- :floppy_disk: 支持 UPX 压缩(二进制体积可缩小 30-50%)
|
||||
|
||||
**单文件独立 php-cli:**
|
||||
|
||||
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
|
||||
|
||||
**使用 phpmicro 将 PHP 代码与 PHP 解释器结合:**
|
||||
|
||||
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 下载 spc 二进制
|
||||
|
||||
```bash
|
||||
# For Linux x86_64
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
|
||||
# For Linux aarch64
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64
|
||||
# macOS x86_64 (Intel)
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64
|
||||
# macOS aarch64 (Apple)
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64
|
||||
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
|
||||
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x64.exe
|
||||
```
|
||||
|
||||
对于 macOS 和 Linux,请先添加可执行权限:
|
||||
|
||||
```bash
|
||||
chmod +x ./spc
|
||||
```
|
||||
|
||||
### 2. 构建静态 PHP
|
||||
|
||||
首先,创建 `craft.yml` 文件,并从 [扩展列表](https://static-php.dev/en/guide/extensions.html) 或 [命令生成器](https://static-php.dev/en/guide/cli-generator.html) 指定要包含的扩展:
|
||||
|
||||
```yml
|
||||
# PHP version support: 8.1, 8.2, 8.3, 8.4, 8.5
|
||||
php-version: 8.5
|
||||
# Put your extension list here
|
||||
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
|
||||
sapi:
|
||||
- cli
|
||||
- micro
|
||||
download-options:
|
||||
parallel: 10
|
||||
```
|
||||
|
||||
运行命令:
|
||||
|
||||
```bash
|
||||
./spc craft
|
||||
|
||||
# 输出完整控制台日志
|
||||
./spc craft -vvv
|
||||
```
|
||||
|
||||
### 3. 静态 PHP 使用
|
||||
|
||||
现在你可以将 StaticPHP 构建的二进制复制到另一台机器并在无依赖环境下运行:
|
||||
|
||||
```
|
||||
# php-cli
|
||||
buildroot/bin/php -v
|
||||
|
||||
# phpmicro
|
||||
echo '<?php echo "Hello world!\n";' > a.php
|
||||
./spc micro:combine a.php -O my-app
|
||||
./my-app
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
当前 README 包含基础用法。有关 StaticPHP 的完整功能集,
|
||||
请访问 <https://static-php.dev>。
|
||||
|
||||
## 直接下载
|
||||
|
||||
如果你暂时不想构建,或只想先测试,可以从 [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译产物,或从自托管服务器下载。
|
||||
|
||||
我们为每个 PHP 版本提供 2 种扩展集合:
|
||||
|
||||
- **gigantic**:尽可能包含更多扩展,二进制大小约 100-150MB。
|
||||
- **base**:仅包含 StaticPHP 自身使用的少量扩展,二进制大小约 10MB。
|
||||
|
||||
> WIP
|
||||
|
||||
### 在线构建(使用 GitHub Actions)
|
||||
|
||||
当上方直接下载的二进制无法满足你的需求时,
|
||||
你可以使用 GitHub Actions 轻松构建静态编译的 PHP,
|
||||
并同时自定义要编译的扩展列表。
|
||||
|
||||
1. Fork 此仓库。
|
||||
2. 进入项目的 Actions 并选择 `CI`。
|
||||
3. 选择 `Run workflow`,填写你要编译的 PHP 版本、目标类型和扩展列表。(扩展用逗号分隔,例如 `bcmath,curl,mbstring`)
|
||||
4. 等待工作流执行完成后,进入对应运行记录并下载 `Artifacts`。
|
||||
|
||||
如果你启用 `debug`,构建时将输出所有日志,包括编译日志,便于排查问题。
|
||||
|
||||
> 我们也计划在未来提供可复用的 GitHub Actions 工作流,
|
||||
> 这样你无需 fork 本项目,也能在自己的仓库中轻松构建 static PHP。
|
||||
|
||||
## 贡献
|
||||
|
||||
如果你需要的扩展缺失,可以创建 issue。
|
||||
如果你熟悉本项目,也欢迎发起 pull request。
|
||||
|
||||
如果你想贡献文档,请直接编辑 `docs/`。
|
||||
|
||||
## 赞助本项目
|
||||
|
||||
你可以通过 [GitHub Sponsor](https://github.com/crazywhalecc) 赞助我或我的项目。你捐赠的一部分将用于维护 **static-php.dev** 服务器。
|
||||
|
||||
**特别感谢以下赞助商:**
|
||||
|
||||
<a href="https://beyondco.de/"><img src="/docs/public/images/beyondcode-seeklogo.png" width="300" alt="Beyond Code Logo" /></a>
|
||||
|
||||
<a href="https://nativephp.com/"><img src="/docs/public/images/nativephp-logo.svg" width="300" alt="NativePHP Logo" /></a>
|
||||
|
||||
## 开源许可证
|
||||
|
||||
本项目本身采用 MIT 许可证。
|
||||
一些新添加的扩展和依赖可能来自其他项目。
|
||||
这些源码文件头部也可能包含额外的 LICENSE 和 AUTHOR 信息。
|
||||
|
||||
请在编译后使用 `bin/spc dump-license` 命令导出项目中使用的开源许可证,
|
||||
并遵守对应项目的 LICENSE。
|
||||
# StaticPHP
|
||||
|
||||
[](README-zh.md)
|
||||
[](README.md)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/releases)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
|
||||
[](https://discord.gg/xf6Rd4pEAk)
|
||||
|
||||
**StaticPHP** 是一个强大的工具,用于构建可移植的可执行文件,包括 PHP、扩展等。
|
||||
|
||||
> [!IMPORTANT]
|
||||
> 我们正准备发布 **v3** 版本,届时项目名称将从 **static-php-cli** 更改为 **StaticPHP**。
|
||||
> 此分支对应 v3 版本。v2 版本请查看 [v2 分支](https://github.com/crazywhalecc/static-php-cli/tree/main)。
|
||||
> 请更新您的参考资料,并关注正式版发布。
|
||||
|
||||
## 特性
|
||||
|
||||
- :elephant: 支持多个 PHP 版本 - PHP 8.1, 8.2, 8.3, 8.4, 8.5
|
||||
- :handbag: 构建零依赖的单文件 PHP 可执行程序
|
||||
- :hamburger: 构建 **[phpmicro](https://github.com/static-php/phpmicro)** 自解压可执行文件(将 PHP 二进制和源码合并为单个文件)
|
||||
- :pill: 自动构建环境检查器,支持自动修复
|
||||
- :zap: 支持 `Linux`、`macOS`、`Windows`
|
||||
- :wrench: 通过 vendor 模式和自定义注册表实现便捷扩展
|
||||
- :books: 智能依赖管理
|
||||
- 📦 自包含 `spc` 可执行文件,便于自安装
|
||||
- :fire: 支持 100+ 热门 [PHP 扩展](https://static-php.dev/en/guide/extensions.html)
|
||||
- :floppy_disk: 支持 UPX 压缩(二进制体积可缩小 30-50%)
|
||||
|
||||
**单文件独立 php-cli:**
|
||||
|
||||
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
|
||||
|
||||
**使用 phpmicro 将 PHP 代码与 PHP 解释器结合:**
|
||||
|
||||
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 下载 spc 二进制
|
||||
|
||||
```bash
|
||||
# For Linux x86_64
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
|
||||
# For Linux aarch64
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64
|
||||
# macOS x86_64 (Intel)
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64
|
||||
# macOS aarch64 (Apple)
|
||||
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64
|
||||
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
|
||||
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x64.exe
|
||||
```
|
||||
|
||||
对于 macOS 和 Linux,请先添加可执行权限:
|
||||
|
||||
```bash
|
||||
chmod +x ./spc
|
||||
```
|
||||
|
||||
### 2. 构建静态 PHP
|
||||
|
||||
首先,创建 `craft.yml` 文件,并从 [扩展列表](https://static-php.dev/en/guide/extensions.html) 或 [命令生成器](https://static-php.dev/en/guide/cli-generator.html) 指定要包含的扩展:
|
||||
|
||||
```yml
|
||||
# PHP version support: 8.1, 8.2, 8.3, 8.4, 8.5
|
||||
php-version: 8.5
|
||||
# Put your extension list here
|
||||
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
|
||||
sapi:
|
||||
- cli
|
||||
- micro
|
||||
download-options:
|
||||
parallel: 10
|
||||
```
|
||||
|
||||
运行命令:
|
||||
|
||||
```bash
|
||||
./spc craft
|
||||
|
||||
# 输出完整控制台日志
|
||||
./spc craft -vvv
|
||||
```
|
||||
|
||||
### 3. 静态 PHP 使用
|
||||
|
||||
现在你可以将 StaticPHP 构建的二进制复制到另一台机器并在无依赖环境下运行:
|
||||
|
||||
```
|
||||
# php-cli
|
||||
buildroot/bin/php -v
|
||||
|
||||
# phpmicro
|
||||
echo '<?php echo "Hello world!\n";' > a.php
|
||||
./spc micro:combine a.php -O my-app
|
||||
./my-app
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
当前 README 包含基础用法。有关 StaticPHP 的完整功能集,
|
||||
请访问 <https://static-php.dev>。
|
||||
|
||||
## 直接下载
|
||||
|
||||
如果你暂时不想构建,或只想先测试,可以从 [Actions](https://github.com/static-php/hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译产物,或从自托管服务器下载。
|
||||
|
||||
我们为每个 PHP 版本提供 2 种扩展集合:
|
||||
|
||||
- **gigantic**:尽可能包含更多扩展,二进制大小约 100-150MB。
|
||||
- **base**:仅包含 StaticPHP 自身使用的少量扩展,二进制大小约 10MB。
|
||||
|
||||
> WIP
|
||||
|
||||
### 在线构建(使用 GitHub Actions)
|
||||
|
||||
当上方直接下载的二进制无法满足你的需求时,
|
||||
你可以使用 GitHub Actions 轻松构建静态编译的 PHP,
|
||||
并同时自定义要编译的扩展列表。
|
||||
|
||||
1. Fork 此仓库。
|
||||
2. 进入项目的 Actions 并选择 `CI`。
|
||||
3. 选择 `Run workflow`,填写你要编译的 PHP 版本、目标类型和扩展列表。(扩展用逗号分隔,例如 `bcmath,curl,mbstring`)
|
||||
4. 等待工作流执行完成后,进入对应运行记录并下载 `Artifacts`。
|
||||
|
||||
如果你启用 `debug`,构建时将输出所有日志,包括编译日志,便于排查问题。
|
||||
|
||||
> 我们也计划在未来提供可复用的 GitHub Actions 工作流,
|
||||
> 这样你无需 fork 本项目,也能在自己的仓库中轻松构建 static PHP。
|
||||
|
||||
## 贡献
|
||||
|
||||
如果你需要的扩展缺失,可以创建 issue。
|
||||
如果你熟悉本项目,也欢迎发起 pull request。
|
||||
|
||||
如果你想贡献文档,请直接编辑 `docs/`。
|
||||
|
||||
## 赞助本项目
|
||||
|
||||
你可以通过 [GitHub Sponsor](https://github.com/crazywhalecc) 赞助我或我的项目。你捐赠的一部分将用于维护 **static-php.dev** 服务器。
|
||||
|
||||
**特别感谢以下赞助商:**
|
||||
|
||||
<a href="https://beyondco.de/"><img src="/docs/public/images/beyondcode-seeklogo.png" width="300" alt="Beyond Code Logo" /></a>
|
||||
|
||||
<a href="https://nativephp.com/"><img src="/docs/public/images/nativephp-logo.svg" width="300" alt="NativePHP Logo" /></a>
|
||||
|
||||
## 开源许可证
|
||||
|
||||
本项目本身采用 MIT 许可证。
|
||||
一些新添加的扩展和依赖可能来自其他项目。
|
||||
这些源码文件头部也可能包含额外的 LICENSE 和 AUTHOR 信息。
|
||||
|
||||
请在编译后使用 `bin/spc dump-license` 命令导出项目中使用的开源许可证,
|
||||
并遵守对应项目的 LICENSE。
|
||||
|
||||
@@ -104,7 +104,7 @@ see <https://static-php.dev>.
|
||||
|
||||
## 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/static-php-cli-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/hosted/actions/workflows/build-php-bulk.yml) or from a self-hosted server.
|
||||
|
||||
We offer 2 types of extension sets for each PHP version:
|
||||
|
||||
|
||||
@@ -1,116 +1,116 @@
|
||||
param (
|
||||
[string] ${action}
|
||||
)
|
||||
|
||||
function AddToPath {
|
||||
param (
|
||||
[string]$pathToAdd
|
||||
)
|
||||
|
||||
$currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
|
||||
if ($currentPath -notlike "*$pathToAdd*") {
|
||||
$newPath = $currentPath + ";$pathToAdd"
|
||||
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "Added '$pathToAdd' to Path."
|
||||
Write-Host "To remove path, use: " -NoNewline
|
||||
Write-Host "bin/setup-runtime remove-path" -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host "Path already exists."
|
||||
}
|
||||
}
|
||||
|
||||
function RemoveFromPath {
|
||||
param (
|
||||
[string]$pathToRemove
|
||||
)
|
||||
|
||||
$currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
|
||||
if ($currentPath -like "*$pathToRemove*") {
|
||||
$newPath = $currentPath -replace [regex]::Escape(';' + $pathToRemove), ''
|
||||
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "Removed Path '$pathToRemove'"
|
||||
} else {
|
||||
Write-Host "Path '$pathToRemove' not in Path"
|
||||
}
|
||||
}
|
||||
|
||||
# working dir
|
||||
$WorkingDir = (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Definition))
|
||||
|
||||
if ($action -eq 'add-path') {
|
||||
AddToPath ($WorkingDir + '\runtime')
|
||||
exit 0
|
||||
} elseif ($action -eq 'remove-path') {
|
||||
RemoveFromPath ($WorkingDir + '\runtime')
|
||||
exit 0
|
||||
} elseif (-not($action -eq '')) {
|
||||
Write-Host ("Invalid action: " + $action) -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# get php 8.1 specific version
|
||||
|
||||
# php windows download
|
||||
$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/archives/php-8.4.4-nts-Win32-vs17-x64.zip"
|
||||
Write-Host "Downloading PHP from: " -NoNewline
|
||||
Write-Host $PHPRuntimeUrl -ForegroundColor Cyan
|
||||
$ComposerUrl = "https://getcomposer.org/download/latest-stable/composer.phar"
|
||||
|
||||
# create dir
|
||||
New-Item -Path "downloads" -ItemType Directory -Force | Out-Null
|
||||
|
||||
# download php
|
||||
if (-not(Test-Path "downloads\php.zip"))
|
||||
{
|
||||
Write-Host "Downloading PHP ..."
|
||||
Invoke-WebRequest $PHPRuntimeUrl -OutFile "downloads\php.zip"
|
||||
}
|
||||
|
||||
# extract php
|
||||
New-Item -Path "runtime" -ItemType Directory -Force | Out-Null
|
||||
Write-Host "Extracting php.zip ..."
|
||||
Expand-Archive -Path "downloads/php.zip" -DestinationPath "runtime" -Force
|
||||
# make php.ini
|
||||
Move-Item -Path "runtime\php.ini-production" -Destination "runtime\php.ini" -Force
|
||||
$OriginINI = Get-Content -Path "runtime\php.ini" -Raw
|
||||
$OriginINI = $OriginINI -replace ';extension=openssl', 'extension=openssl'
|
||||
$OriginINI = $OriginINI -replace ';extension=curl', 'extension=curl'
|
||||
$OriginINI = $OriginINI -replace ';extension=mbstring', 'extension=mbstring'
|
||||
$OriginINI = $OriginINI -replace ';extension=sodium', 'extension=sodium'
|
||||
$OriginINI = $OriginINI -replace ';extension_dir = "./"', ('extension_dir = "' + (Split-Path -Parent $MyInvocation.MyCommand.Definition) + '\..\runtime\ext"')
|
||||
$OriginINI | Set-Content -Path "runtime\php.ini"
|
||||
|
||||
# download composer
|
||||
if (-not(Test-Path "runtime\composer.phar"))
|
||||
{
|
||||
Write-Host "Downloading composer ..."
|
||||
Invoke-WebRequest $ComposerUrl -OutFile "downloads\composer.phar"
|
||||
Move-Item -Path "downloads\composer.phar" -Destination "runtime\composer.phar" -Force
|
||||
}
|
||||
|
||||
# create runtime\composer.ps1
|
||||
$ComposerContent = '
|
||||
$WorkingDir = (Split-Path -Parent $MyInvocation.MyCommand.Definition)
|
||||
& ($WorkingDir + "\php.exe") (Join-Path $WorkingDir "\composer.phar") @args
|
||||
'
|
||||
$ComposerContent | Set-Content -Path 'runtime\composer.ps1' -Encoding UTF8
|
||||
|
||||
Write-Host "Successfully downloaded PHP and Composer !" -ForegroundColor Green
|
||||
Write-Host "Use static-php-cli: " -NoNewline
|
||||
Write-Host "bin/spc" -ForegroundColor Cyan
|
||||
Write-Host "Use php: " -NoNewline
|
||||
Write-Host "runtime/php" -ForegroundColor Cyan
|
||||
Write-Host "Use composer: " -NoNewline
|
||||
Write-Host "runtime/composer" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Don't forget installing composer dependencies '" -NoNewline
|
||||
Write-Host "runtime/composer install" -ForegroundColor Cyan -NoNewline
|
||||
Write-Host "' before using static-php-cli !"
|
||||
Write-Host ""
|
||||
Write-Host "If you want to use this PHP for quality tools (like phpstan, php-cs-fixer) or other project,"
|
||||
Write-Host "or use PHP, Composer as system executable,"
|
||||
Write-Host "use '" -NoNewline
|
||||
Write-Host "bin/setup-runtime add-path" -ForegroundColor Cyan -NoNewline
|
||||
Write-Host "' to add runtime dir in Path."
|
||||
param (
|
||||
[string] ${action}
|
||||
)
|
||||
|
||||
function AddToPath {
|
||||
param (
|
||||
[string]$pathToAdd
|
||||
)
|
||||
|
||||
$currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
|
||||
if ($currentPath -notlike "*$pathToAdd*") {
|
||||
$newPath = $currentPath + ";$pathToAdd"
|
||||
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "Added '$pathToAdd' to Path."
|
||||
Write-Host "To remove path, use: " -NoNewline
|
||||
Write-Host "bin/setup-runtime remove-path" -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host "Path already exists."
|
||||
}
|
||||
}
|
||||
|
||||
function RemoveFromPath {
|
||||
param (
|
||||
[string]$pathToRemove
|
||||
)
|
||||
|
||||
$currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
|
||||
if ($currentPath -like "*$pathToRemove*") {
|
||||
$newPath = $currentPath -replace [regex]::Escape(';' + $pathToRemove), ''
|
||||
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "Removed Path '$pathToRemove'"
|
||||
} else {
|
||||
Write-Host "Path '$pathToRemove' not in Path"
|
||||
}
|
||||
}
|
||||
|
||||
# working dir
|
||||
$WorkingDir = (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Definition))
|
||||
|
||||
if ($action -eq 'add-path') {
|
||||
AddToPath ($WorkingDir + '\runtime')
|
||||
exit 0
|
||||
} elseif ($action -eq 'remove-path') {
|
||||
RemoveFromPath ($WorkingDir + '\runtime')
|
||||
exit 0
|
||||
} elseif (-not($action -eq '')) {
|
||||
Write-Host ("Invalid action: " + $action) -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# get php 8.1 specific version
|
||||
|
||||
# php windows download
|
||||
$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/archives/php-8.4.4-nts-Win32-vs17-x64.zip"
|
||||
Write-Host "Downloading PHP from: " -NoNewline
|
||||
Write-Host $PHPRuntimeUrl -ForegroundColor Cyan
|
||||
$ComposerUrl = "https://getcomposer.org/download/latest-stable/composer.phar"
|
||||
|
||||
# create dir
|
||||
New-Item -Path "downloads" -ItemType Directory -Force | Out-Null
|
||||
|
||||
# download php
|
||||
if (-not(Test-Path "downloads\php.zip"))
|
||||
{
|
||||
Write-Host "Downloading PHP ..."
|
||||
Invoke-WebRequest $PHPRuntimeUrl -OutFile "downloads\php.zip"
|
||||
}
|
||||
|
||||
# extract php
|
||||
New-Item -Path "runtime" -ItemType Directory -Force | Out-Null
|
||||
Write-Host "Extracting php.zip ..."
|
||||
Expand-Archive -Path "downloads/php.zip" -DestinationPath "runtime" -Force
|
||||
# make php.ini
|
||||
Move-Item -Path "runtime\php.ini-production" -Destination "runtime\php.ini" -Force
|
||||
$OriginINI = Get-Content -Path "runtime\php.ini" -Raw
|
||||
$OriginINI = $OriginINI -replace ';extension=openssl', 'extension=openssl'
|
||||
$OriginINI = $OriginINI -replace ';extension=curl', 'extension=curl'
|
||||
$OriginINI = $OriginINI -replace ';extension=mbstring', 'extension=mbstring'
|
||||
$OriginINI = $OriginINI -replace ';extension=sodium', 'extension=sodium'
|
||||
$OriginINI = $OriginINI -replace ';extension_dir = "./"', ('extension_dir = "' + (Split-Path -Parent $MyInvocation.MyCommand.Definition) + '\..\runtime\ext"')
|
||||
$OriginINI | Set-Content -Path "runtime\php.ini"
|
||||
|
||||
# download composer
|
||||
if (-not(Test-Path "runtime\composer.phar"))
|
||||
{
|
||||
Write-Host "Downloading composer ..."
|
||||
Invoke-WebRequest $ComposerUrl -OutFile "downloads\composer.phar"
|
||||
Move-Item -Path "downloads\composer.phar" -Destination "runtime\composer.phar" -Force
|
||||
}
|
||||
|
||||
# create runtime\composer.ps1
|
||||
$ComposerContent = '
|
||||
$WorkingDir = (Split-Path -Parent $MyInvocation.MyCommand.Definition)
|
||||
& ($WorkingDir + "\php.exe") (Join-Path $WorkingDir "\composer.phar") @args
|
||||
'
|
||||
$ComposerContent | Set-Content -Path 'runtime\composer.ps1' -Encoding UTF8
|
||||
|
||||
Write-Host "Successfully downloaded PHP and Composer !" -ForegroundColor Green
|
||||
Write-Host "Use static-php-cli: " -NoNewline
|
||||
Write-Host "bin/spc" -ForegroundColor Cyan
|
||||
Write-Host "Use php: " -NoNewline
|
||||
Write-Host "runtime/php" -ForegroundColor Cyan
|
||||
Write-Host "Use composer: " -NoNewline
|
||||
Write-Host "runtime/composer" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Don't forget installing composer dependencies '" -NoNewline
|
||||
Write-Host "runtime/composer install" -ForegroundColor Cyan -NoNewline
|
||||
Write-Host "' before using static-php-cli !"
|
||||
Write-Host ""
|
||||
Write-Host "If you want to use this PHP for quality tools (like phpstan, php-cs-fixer) or other project,"
|
||||
Write-Host "or use PHP, Composer as system executable,"
|
||||
Write-Host "use '" -NoNewline
|
||||
Write-Host "bin/setup-runtime add-path" -ForegroundColor Cyan -NoNewline
|
||||
Write-Host "' to add runtime dir in Path."
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
& "$PHP_Exec" -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
& "$PHP_Exec" -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
|
||||
24
bin/spc.ps1
24
bin/spc.ps1
@@ -1,12 +1,12 @@
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
& "$PHP_Exec" ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
& "$PHP_Exec" ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
|
||||
@@ -10,6 +10,11 @@ ext-zip:
|
||||
license: PHP-3.01
|
||||
depends:
|
||||
- libzip
|
||||
depends@windows:
|
||||
- libzip
|
||||
- zlib
|
||||
- xz
|
||||
- bzip2
|
||||
php-extension:
|
||||
arg-type: custom
|
||||
arg-type@windows: enable
|
||||
|
||||
@@ -17,7 +17,6 @@ openssl:
|
||||
- zlib
|
||||
depends@windows:
|
||||
- zlib
|
||||
- jom
|
||||
headers:
|
||||
- openssl
|
||||
static-libs@unix:
|
||||
@@ -26,3 +25,6 @@ openssl:
|
||||
static-libs@windows:
|
||||
- libssl.lib
|
||||
- libcrypto.lib
|
||||
tools@windows:
|
||||
- jom
|
||||
- strawberry-perl
|
||||
|
||||
@@ -10,10 +10,8 @@ frankenphp:
|
||||
license: MIT
|
||||
depends:
|
||||
- php-embed
|
||||
- go-xcaddy
|
||||
depends@windows:
|
||||
- php-embed
|
||||
- go-win
|
||||
- pthreads4w
|
||||
suggests@unix:
|
||||
- brotli
|
||||
@@ -24,3 +22,7 @@ frankenphp:
|
||||
- frankenphp
|
||||
static-bins@windows:
|
||||
- frankenphp.exe
|
||||
tools:
|
||||
- go-xcaddy
|
||||
tools@windows:
|
||||
- go-win
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
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,4 +0,0 @@
|
||||
zig:
|
||||
type: target
|
||||
artifact:
|
||||
binary: custom
|
||||
@@ -1,5 +1,9 @@
|
||||
7za-win:
|
||||
type: target
|
||||
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,5 +1,5 @@
|
||||
go-win:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
binary: custom
|
||||
env:
|
||||
@@ -8,3 +8,8 @@ go-win:
|
||||
GOPATH: '{pkg_root_path}/go-win/go'
|
||||
path@windows:
|
||||
- '{pkg_root_path}/go-win/bin'
|
||||
tool:
|
||||
provides:
|
||||
- go.exe
|
||||
- gofmt.exe
|
||||
binary-subdir: go-win/bin
|
||||
@@ -1,5 +1,5 @@
|
||||
go-xcaddy:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
binary: custom
|
||||
env:
|
||||
@@ -8,5 +8,8 @@ go-xcaddy:
|
||||
GOPATH: '{pkg_root_path}/go-xcaddy/go'
|
||||
path@unix:
|
||||
- '{pkg_root_path}/go-xcaddy/bin'
|
||||
static-bins:
|
||||
- xcaddy
|
||||
tool:
|
||||
provides:
|
||||
- go
|
||||
- gofmt
|
||||
binary-subdir: go-xcaddy/bin
|
||||
@@ -1,7 +1,11 @@
|
||||
jom:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
binary:
|
||||
windows-x86_64: { type: url, url: 'https://download.qt.io/official_releases/jom/jom.zip', extract: '{pkg_root_path}/jom' }
|
||||
path@windows:
|
||||
- '{pkg_root_path}\jom'
|
||||
tool:
|
||||
provides:
|
||||
- jom.exe
|
||||
binary-subdir: jom
|
||||
@@ -1,5 +1,10 @@
|
||||
nasm:
|
||||
type: target
|
||||
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
|
||||
13
config/pkg/tool/pkg-config.yml
Normal file
13
config/pkg/tool/pkg-config.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
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,8 +1,12 @@
|
||||
protoc:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
binary:
|
||||
linux-x86_64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-x86_64\.zip', extract: '{pkg_root_path}/protoc' }
|
||||
linux-aarch64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-aarch_64\.zip', extract: '{pkg_root_path}/protoc' }
|
||||
path:
|
||||
- '{pkg_root_path}/protoc/bin'
|
||||
tool:
|
||||
provides:
|
||||
- protoc
|
||||
binary-subdir: protoc/bin
|
||||
@@ -1,5 +1,9 @@
|
||||
strawberry-perl:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
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' }
|
||||
tool:
|
||||
provides:
|
||||
- perl.exe
|
||||
binary-subdir: strawberry-perl/perl/bin
|
||||
@@ -1,7 +1,13 @@
|
||||
upx:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
binary:
|
||||
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' } }
|
||||
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,5 +1,9 @@
|
||||
vswhere:
|
||||
type: target
|
||||
type: tool
|
||||
artifact:
|
||||
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' }
|
||||
tool:
|
||||
provides:
|
||||
- vswhere.exe
|
||||
binary-subdir: bin
|
||||
14
config/pkg/tool/zig.yml
Normal file
14
config/pkg/tool/zig.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
@@ -10,6 +10,7 @@ package:
|
||||
- config/pkg/lib/
|
||||
- config/pkg/target/
|
||||
- config/pkg/ext/
|
||||
- config/pkg/tool/
|
||||
artifact:
|
||||
config:
|
||||
- config/artifact/
|
||||
|
||||
@@ -255,9 +255,11 @@ class php extends TargetPackage
|
||||
$installer->addBuildPackage('php-embed');
|
||||
}
|
||||
|
||||
// UPX compression: ensure the upx binary package is installed when requested
|
||||
// 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')) {
|
||||
$additional_packages[] = 'upx';
|
||||
$installer->addInstallPackage('upx');
|
||||
}
|
||||
|
||||
return [...$extensions_pkg, ...$additional_packages];
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Target;
|
||||
namespace Package\Tool;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\InitPackage;
|
||||
use StaticPHP\Attribute\Package\Target;
|
||||
use StaticPHP\Attribute\Package\Tool;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Package\TargetPackage;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||
|
||||
#[Target('pkg-config')]
|
||||
#[Tool('pkg-config')]
|
||||
class pkgconfig
|
||||
{
|
||||
#[InitPackage]
|
||||
@@ -23,7 +23,7 @@ class pkgconfig
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(TargetPackage $package, ToolchainInterface $toolchain): void
|
||||
public function build(ToolPackage $package, ToolchainInterface $toolchain): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($package)
|
||||
->appendEnv([
|
||||
@@ -26,6 +26,7 @@ use StaticPHP\Exception\DownloaderException;
|
||||
use StaticPHP\Exception\ExecutionException;
|
||||
use StaticPHP\Exception\ValidationException;
|
||||
use StaticPHP\Exception\WrongUsageException;
|
||||
use StaticPHP\Package\ToolVersionRegistry;
|
||||
use StaticPHP\Registry\ArtifactLoader;
|
||||
use StaticPHP\Runtime\Shell\Shell;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
@@ -346,12 +347,32 @@ class ArtifactDownloader
|
||||
}
|
||||
}
|
||||
|
||||
public function checkUpdate(string $artifact_name, bool $prefer_source = false, bool $bare = false): CheckUpdateResult
|
||||
public function checkUpdate(string $artifact_name, bool $prefer_source = false, bool $bare = false, bool $use_installed = false): CheckUpdateResult
|
||||
{
|
||||
$artifact = ArtifactLoader::getArtifactInstance($artifact_name);
|
||||
if ($artifact === null) {
|
||||
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) {
|
||||
[$first, $second] = $prefer_source
|
||||
? [fn () => $this->probeSourceCheckUpdate($artifact, $artifact_name), fn () => $this->probeBinaryCheckUpdate($artifact, $artifact_name)]
|
||||
@@ -403,16 +424,17 @@ class ArtifactDownloader
|
||||
* @param bool $prefer_source Whether to prefer source over binary
|
||||
* @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 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
|
||||
*/
|
||||
public function checkUpdates(array $artifact_names, bool $prefer_source = false, bool $bare = false, ?callable $onResult = null): array
|
||||
public function checkUpdates(array $artifact_names, bool $prefer_source = false, bool $bare = false, ?callable $onResult = null, bool $use_installed = false): array
|
||||
{
|
||||
if ($this->parallel > 1 && count($artifact_names) > 1) {
|
||||
return $this->checkUpdatesWithConcurrency($artifact_names, $prefer_source, $bare, $onResult);
|
||||
return $this->checkUpdatesWithConcurrency($artifact_names, $prefer_source, $bare, $onResult, $use_installed);
|
||||
}
|
||||
$results = [];
|
||||
foreach ($artifact_names as $name) {
|
||||
$result = $this->checkUpdate($name, $prefer_source, $bare);
|
||||
$result = $this->checkUpdate($name, $prefer_source, $bare, $use_installed);
|
||||
$results[$name] = $result;
|
||||
if ($onResult !== null) {
|
||||
($onResult)($name, $result);
|
||||
@@ -436,7 +458,7 @@ class ArtifactDownloader
|
||||
return $this->options[$name] ?? $default;
|
||||
}
|
||||
|
||||
private function checkUpdatesWithConcurrency(array $artifact_names, bool $prefer_source, bool $bare, ?callable $onResult): array
|
||||
private function checkUpdatesWithConcurrency(array $artifact_names, bool $prefer_source, bool $bare, ?callable $onResult, bool $use_installed = false): array
|
||||
{
|
||||
$results = [];
|
||||
$fiber_pool = [];
|
||||
@@ -451,8 +473,8 @@ class ArtifactDownloader
|
||||
// fill pool
|
||||
while (count($fiber_pool) < $this->parallel && !empty($remaining)) {
|
||||
$name = array_shift($remaining);
|
||||
$fiber = new \Fiber(function () use ($name, $prefer_source, $bare) {
|
||||
return [$name, $this->checkUpdate($name, $prefer_source, $bare)];
|
||||
$fiber = new \Fiber(function () use ($name, $prefer_source, $bare, $use_installed) {
|
||||
return [$name, $this->checkUpdate($name, $prefer_source, $bare, $use_installed)];
|
||||
});
|
||||
$fiber->start();
|
||||
$fiber_pool[$name] = $fiber;
|
||||
@@ -491,12 +513,12 @@ class ArtifactDownloader
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function probeSourceCheckUpdate(Artifact $artifact, string $artifact_name): ?CheckUpdateResult
|
||||
private function probeSourceCheckUpdate(Artifact $artifact, string $artifact_name, ?string $old_version = null): ?CheckUpdateResult
|
||||
{
|
||||
if (($callback = $artifact->getCustomSourceCheckUpdateCallback()) !== null) {
|
||||
return ApplicationContext::invoke($callback, [
|
||||
ArtifactDownloader::class => $this,
|
||||
'old_version' => null,
|
||||
'old_version' => $old_version,
|
||||
]);
|
||||
}
|
||||
$config = $artifact->getDownloadConfig('source');
|
||||
@@ -509,16 +531,16 @@ class ArtifactDownloader
|
||||
}
|
||||
/** @var CheckUpdateInterface $dl */
|
||||
$dl = new $cls();
|
||||
return $dl->checkUpdate($artifact_name, $config, null, $this);
|
||||
return $dl->checkUpdate($artifact_name, $config, $old_version, $this);
|
||||
}
|
||||
|
||||
private function probeBinaryCheckUpdate(Artifact $artifact, string $artifact_name): ?CheckUpdateResult
|
||||
private function probeBinaryCheckUpdate(Artifact $artifact, string $artifact_name, ?string $old_version = null): ?CheckUpdateResult
|
||||
{
|
||||
// custom binary callback takes precedence over config-based binary
|
||||
if (($callback = $artifact->getCustomBinaryCheckUpdateCallback()) !== null) {
|
||||
return ApplicationContext::invoke($callback, [
|
||||
ArtifactDownloader::class => $this,
|
||||
'old_version' => null,
|
||||
'old_version' => $old_version,
|
||||
]);
|
||||
}
|
||||
$binary_config = $artifact->getDownloadConfig('binary');
|
||||
@@ -532,7 +554,7 @@ class ArtifactDownloader
|
||||
}
|
||||
/** @var CheckUpdateInterface $dl */
|
||||
$dl = new $cls();
|
||||
return $dl->checkUpdate($artifact_name, $platform_config, null, $this);
|
||||
return $dl->checkUpdate($artifact_name, $platform_config, $old_version, $this);
|
||||
}
|
||||
|
||||
private function downloadWithType(Artifact $artifact, int $current, int $total, bool $parallel = false): int
|
||||
|
||||
@@ -23,6 +23,7 @@ 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->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('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);
|
||||
|
||||
// --with-php option for checking updates with a specific PHP version context
|
||||
@@ -45,8 +46,9 @@ class CheckUpdateCommand extends BaseCommand
|
||||
try {
|
||||
$downloader = new ArtifactDownloader($this->input->getOptions());
|
||||
$bare = (bool) $this->getOption('bare');
|
||||
$use_installed = (bool) $this->getOption('installed');
|
||||
if ($this->getOption('json')) {
|
||||
$results = $downloader->checkUpdates($artifacts, bare: $bare);
|
||||
$results = $downloader->checkUpdates($artifacts, bare: $bare, use_installed: $use_installed);
|
||||
$outputs = [];
|
||||
foreach ($results as $artifact => $result) {
|
||||
$outputs[$artifact] = [
|
||||
@@ -59,7 +61,7 @@ class CheckUpdateCommand extends BaseCommand
|
||||
$this->output->writeln(json_encode($outputs, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
return static::OK;
|
||||
}
|
||||
$downloader->checkUpdates($artifacts, bare: $bare, onResult: function (string $artifact, CheckUpdateResult $result) {
|
||||
$downloader->checkUpdates($artifacts, bare: $bare, use_installed: $use_installed, onResult: function (string $artifact, CheckUpdateResult $result) {
|
||||
if ($result->unsupported) {
|
||||
$this->output->writeln("Artifact <info>{$artifact}</info> does not support update checking, <comment>skipped</comment>");
|
||||
} elseif (!$result->needUpdate) {
|
||||
|
||||
@@ -54,8 +54,8 @@ class DumpCapabilitiesCommand extends BaseCommand
|
||||
{
|
||||
$result = [];
|
||||
|
||||
// library / target / virtual-target
|
||||
foreach (PackageLoader::getPackages(['library', 'target', 'virtual-target']) as $name => $pkg) {
|
||||
// library / target / virtual-target / tool
|
||||
foreach (PackageLoader::getPackages(['library', 'target', 'virtual-target', 'tool']) as $name => $pkg) {
|
||||
$installable = [];
|
||||
$artifact = $pkg->getArtifact();
|
||||
if ($artifact !== null) {
|
||||
|
||||
@@ -13,7 +13,7 @@ class DoctorCommand extends BaseCommand
|
||||
{
|
||||
public function configure(): void
|
||||
{
|
||||
$this->addOption('auto-fix', null, InputOption::VALUE_OPTIONAL, 'Automatically fix failed items (if possible)', false);
|
||||
$this->addOption('auto-fix', 'y', InputOption::VALUE_OPTIONAL, 'Automatically fix failed items (if possible)', false);
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
|
||||
@@ -23,7 +23,7 @@ class InstallPackageCommand extends BaseCommand
|
||||
'The package to install (name or path)',
|
||||
suggestedValues: function (CompletionInput $input) {
|
||||
$packages = [];
|
||||
foreach (PackageLoader::getPackages(['target', 'virtual-target']) as $name => $_) {
|
||||
foreach (PackageLoader::getPackages(['target', 'virtual-target', 'tool']) as $name => $_) {
|
||||
$packages[] = $name;
|
||||
}
|
||||
$val = $input->getCompletionValue();
|
||||
|
||||
@@ -24,6 +24,10 @@ class ConfigValidator
|
||||
'lang' => ConfigType::STRING,
|
||||
'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' => ConfigType::ASSOC_ARRAY,
|
||||
'zend-extension' => ConfigType::BOOL,
|
||||
@@ -63,6 +67,9 @@ class ConfigValidator
|
||||
'lang' => false,
|
||||
'frameworks' => false, // @
|
||||
|
||||
// build-time tool dependency declaration
|
||||
'tools' => false, // @
|
||||
|
||||
// php-extension type fields
|
||||
'php-extension' => false,
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ use StaticPHP\Command\SPCConfigCommand;
|
||||
use StaticPHP\Package\TargetPackage;
|
||||
use StaticPHP\Registry\PackageLoader;
|
||||
use StaticPHP\Registry\Registry;
|
||||
use StaticPHP\Util\InteractiveTerm;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
@@ -104,4 +107,15 @@ class ConsoleApplication extends Application
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,60 +113,6 @@ 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.
|
||||
*
|
||||
@@ -364,17 +310,6 @@ class LibraryPackage extends Package
|
||||
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
|
||||
*
|
||||
|
||||
@@ -284,6 +284,71 @@ abstract class Package
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace StaticPHP\Package;
|
||||
|
||||
use StaticPHP\Artifact\ArtifactCache;
|
||||
use StaticPHP\Config\PackageConfig;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\SPCException;
|
||||
@@ -39,8 +40,8 @@ class PackageBuilder
|
||||
public function buildPackage(Package $package, bool $force = false): int
|
||||
{
|
||||
// init build dirs
|
||||
if (!$package instanceof LibraryPackage) {
|
||||
throw new SPCInternalException('Please, never try to build non-library packages directly.');
|
||||
if (!$package instanceof LibraryPackage && !$package instanceof ToolPackage) {
|
||||
throw new SPCInternalException('Please, never try to build non-library, non-tool packages directly.');
|
||||
}
|
||||
FileSystem::createDir($package->getBuildRootPath());
|
||||
FileSystem::createDir($package->getIncludeDir());
|
||||
@@ -78,6 +79,14 @@ class PackageBuilder
|
||||
$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) {
|
||||
// Ensure package information is bound if not already
|
||||
if ($e->getPackageInfo() === null) {
|
||||
|
||||
@@ -168,9 +168,6 @@ class PackageInstaller
|
||||
// Early validation: check if packages can be built or installed before downloading
|
||||
$this->validatePackagesBeforeBuild();
|
||||
|
||||
// Check that all required tools are installed before proceeding
|
||||
$this->ensureRequiredTools();
|
||||
|
||||
// check download
|
||||
if ($this->download) {
|
||||
$downloaderOptions = DownloaderOptions::extractFromConsoleOptions($this->options, 'dl');
|
||||
@@ -178,7 +175,7 @@ class PackageInstaller
|
||||
// These must always download binary (not source), regardless of global prefer-source setting.
|
||||
$binary_only_packages = array_filter(
|
||||
$this->packages,
|
||||
fn ($p) => $p instanceof LibraryPackage
|
||||
fn ($p) => ($p instanceof LibraryPackage || $p instanceof ToolPackage)
|
||||
&& !$this->isBuildPackage($p)
|
||||
&& !$p->hasStage('build')
|
||||
&& ($p->getArtifact()?->hasPlatformBinary() ?? false)
|
||||
@@ -216,8 +213,8 @@ class PackageInstaller
|
||||
$builder = ApplicationContext::get(PackageBuilder::class);
|
||||
foreach ($this->packages as $package) {
|
||||
$is_to_build = $this->isBuildPackage($package);
|
||||
$has_build_stage = $package instanceof LibraryPackage && $package->hasStage('build');
|
||||
$should_use_binary = $package instanceof LibraryPackage && ($package->getArtifact()?->shouldUseBinary() ?? false);
|
||||
$has_build_stage = ($package instanceof LibraryPackage || $package instanceof ToolPackage) && $package->hasStage('build');
|
||||
$should_use_binary = ($package instanceof LibraryPackage || $package instanceof ToolPackage) && ($package->getArtifact()?->shouldUseBinary() ?? false);
|
||||
$has_source = $package->hasSource();
|
||||
if (!$is_to_build && $should_use_binary) {
|
||||
// install binary
|
||||
@@ -280,6 +277,11 @@ class PackageInstaller
|
||||
|
||||
// perform after-install actions and emit post-install events
|
||||
$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
|
||||
@@ -357,12 +359,16 @@ class PackageInstaller
|
||||
}
|
||||
// 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.
|
||||
// Note: TargetPackage extends LibraryPackage, but target packages (e.g. zig) have no
|
||||
// Note: TargetPackage extends LibraryPackage, but target packages have no
|
||||
// static-libs/headers configured, so isInstalled() would trivially return true for them.
|
||||
// Only apply this fallback to pure library packages.
|
||||
if ($package instanceof LibraryPackage && !($package instanceof TargetPackage)) {
|
||||
return $package->isInstalled();
|
||||
}
|
||||
// Tool packages: fall back to checking their provided binaries directly on disk.
|
||||
if ($package instanceof ToolPackage) {
|
||||
return $package->isInstalled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -511,6 +517,16 @@ class PackageInstaller
|
||||
}
|
||||
|
||||
$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) {
|
||||
return SPC_STATUS_ALREADY_INSTALLED;
|
||||
}
|
||||
@@ -661,8 +677,8 @@ class PackageInstaller
|
||||
*/
|
||||
private function validatePackageArtifact(Package $package): void
|
||||
{
|
||||
// target and library must have at least source or platform binary
|
||||
if (in_array($package->getType(), ['library', 'target']) && !$package->getArtifact()?->hasSource() && !$package->getArtifact()?->hasPlatformBinary()) {
|
||||
// target, library and tool packages must have at least source or platform binary
|
||||
if (in_array($package->getType(), ['library', 'target', 'tool']) && !$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.');
|
||||
}
|
||||
}
|
||||
@@ -695,6 +711,32 @@ class PackageInstaller
|
||||
$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) {
|
||||
$this->injectPackageEnvs($package);
|
||||
}
|
||||
@@ -703,8 +745,12 @@ class PackageInstaller
|
||||
/**
|
||||
* Ensure all required tools are installed, throwing if any are missing.
|
||||
*
|
||||
* Called early in the build pipeline (before download/extract).
|
||||
* When tools are missing, lists them with install hints.
|
||||
* 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
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace StaticPHP\Package;
|
||||
|
||||
use StaticPHP\Config\PackageConfig;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\GlobalPathTrait;
|
||||
|
||||
/**
|
||||
* Represents a build-time tool package.
|
||||
@@ -26,6 +26,11 @@ use StaticPHP\Util\GlobalPathTrait;
|
||||
* 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:
|
||||
@@ -36,7 +41,44 @@ use StaticPHP\Util\GlobalPathTrait;
|
||||
*/
|
||||
class ToolPackage extends Package
|
||||
{
|
||||
use GlobalPathTrait;
|
||||
/**
|
||||
* 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.
|
||||
@@ -50,7 +92,7 @@ class ToolPackage extends Package
|
||||
if ($root = getenv($env_var)) {
|
||||
return $root;
|
||||
}
|
||||
$config_root = $this->getToolConfig()['install-root'] ?? null;
|
||||
$config_root = $this->getToolField('install-root');
|
||||
if ($config_root !== null) {
|
||||
return FileSystem::replacePathVariable((string) $config_root);
|
||||
}
|
||||
@@ -65,7 +107,7 @@ class ToolPackage extends Package
|
||||
*/
|
||||
public function getBinaryDir(): string
|
||||
{
|
||||
$subdir = $this->getToolConfig()['binary-subdir'] ?? '';
|
||||
$subdir = $this->getToolField('binary-subdir') ?? '';
|
||||
if ($subdir === '') {
|
||||
return $this->getInstallRoot();
|
||||
}
|
||||
@@ -75,14 +117,15 @@ class ToolPackage extends Package
|
||||
/**
|
||||
* Get the list of executables this tool provides.
|
||||
*
|
||||
* Reads from YAML 'tool.provides' field. Each entry is a bare filename
|
||||
* (e.g. 'nasm.exe'), resolved relative to getBinaryDir().
|
||||
* 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->getToolConfig()['provides'] ?? [];
|
||||
return $this->getToolField('provides') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +155,20 @@ class ToolPackage extends Package
|
||||
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.
|
||||
*
|
||||
@@ -119,7 +176,7 @@ class ToolPackage extends Package
|
||||
*/
|
||||
public function getMinVersion(): ?string
|
||||
{
|
||||
$version = $this->getToolConfig()['min-version'] ?? null;
|
||||
$version = $this->getToolField('min-version');
|
||||
return $version !== null ? (string) $version : null;
|
||||
}
|
||||
|
||||
@@ -148,4 +205,29 @@ class ToolPackage extends Package
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
79
src/StaticPHP/Package/ToolVersionRegistry.php
Normal file
79
src/StaticPHP/Package/ToolVersionRegistry.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,13 @@ declare(strict_types=1);
|
||||
namespace StaticPHP\Runtime\Executor;
|
||||
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
|
||||
abstract class Executor
|
||||
{
|
||||
public function __construct(protected LibraryPackage $package) {}
|
||||
public function __construct(protected LibraryPackage|ToolPackage $package) {}
|
||||
|
||||
public static function create(LibraryPackage $package): static
|
||||
public static function create(LibraryPackage|ToolPackage $package): static
|
||||
{
|
||||
return new static($package);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use StaticPHP\Exception\SPCInternalException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
use StaticPHP\Runtime\Shell\UnixShell;
|
||||
use StaticPHP\Util\InteractiveTerm;
|
||||
use ZM\Logger\ConsoleColor;
|
||||
@@ -22,7 +23,7 @@ class UnixAutoconfExecutor extends Executor
|
||||
|
||||
protected PackageInstaller $installer;
|
||||
|
||||
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
|
||||
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
|
||||
{
|
||||
parent::__construct($package);
|
||||
if ($installer !== null) {
|
||||
|
||||
@@ -11,6 +11,7 @@ use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\TargetPackage;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
use StaticPHP\Runtime\Shell\UnixShell;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
@@ -40,7 +41,7 @@ class UnixCMakeExecutor extends Executor
|
||||
|
||||
protected PackageInstaller $installer;
|
||||
|
||||
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
|
||||
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
|
||||
{
|
||||
parent::__construct($package);
|
||||
if ($installer !== null) {
|
||||
|
||||
@@ -9,6 +9,7 @@ use StaticPHP\Exception\SPCInternalException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\PackageBuilder;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
use StaticPHP\Runtime\Shell\WindowsCmd;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\InteractiveTerm;
|
||||
@@ -35,7 +36,7 @@ class WindowsCMakeExecutor extends Executor
|
||||
|
||||
protected PackageInstaller $installer;
|
||||
|
||||
public function __construct(protected LibraryPackage $package)
|
||||
public function __construct(protected LibraryPackage|ToolPackage $package)
|
||||
{
|
||||
parent::__construct($this->package);
|
||||
$this->builder = ApplicationContext::get(PackageBuilder::class);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace StaticPHP\Runtime\Shell;
|
||||
|
||||
use StaticPHP\Exception\SPCInternalException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Package\ToolPackage;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use ZM\Logger\ConsoleColor;
|
||||
|
||||
@@ -40,9 +41,9 @@ class UnixShell extends Shell
|
||||
/**
|
||||
* Init the environment variable that common build will be used.
|
||||
*
|
||||
* @param LibraryPackage $library Library package
|
||||
* @param LibraryPackage|ToolPackage $library Library or tool package
|
||||
*/
|
||||
public function initializeEnv(LibraryPackage $library): UnixShell
|
||||
public function initializeEnv(LibraryPackage|ToolPackage $library): UnixShell
|
||||
{
|
||||
$this->setEnv([
|
||||
'CFLAGS' => $library->getLibExtraCFlags(),
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace StaticPHP\Util;
|
||||
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use Symfony\Component\Console\Helper\ProgressIndicator;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
@@ -15,10 +14,31 @@ class InteractiveTerm
|
||||
{
|
||||
private static ?ProgressIndicator $indicator = null;
|
||||
|
||||
private static ?OutputInterface $output = null;
|
||||
|
||||
private static ?bool $noAnsi = null;
|
||||
|
||||
/**
|
||||
* Initialize with a real Symfony Console input/output (called from ConsoleApplication::doRun()).
|
||||
* After this call, all output goes through the configured Console, and noAnsi reflects
|
||||
* the user's --no-ansi flag.
|
||||
*/
|
||||
public static function init(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
self::$output = $output;
|
||||
try {
|
||||
self::$noAnsi = (bool) $input->getOption('no-ansi');
|
||||
} catch (\InvalidArgumentException) {
|
||||
// Symfony hasn't bound the application-level input definition yet
|
||||
// (e.g. ArgvInput passed directly to doRun() on some versions).
|
||||
self::$noAnsi = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function notice(string $message, bool $indent = false): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
logger()->notice(strip_ansi_colors($message));
|
||||
} else {
|
||||
@@ -29,8 +49,8 @@ class InteractiveTerm
|
||||
|
||||
public static function success(string $message, bool $indent = false): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
logger()->info(strip_ansi_colors($message));
|
||||
} else {
|
||||
@@ -41,8 +61,8 @@ class InteractiveTerm
|
||||
|
||||
public static function plain(string $message, string $level = 'info'): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
match ($level) {
|
||||
'debug' => logger()->debug(strip_ansi_colors($message)),
|
||||
@@ -59,8 +79,8 @@ class InteractiveTerm
|
||||
|
||||
public static function info(string $message): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if (!$output->isVerbose()) {
|
||||
$output->writeln(($no_ansi ? 'strip_ansi_colors' : 'strval')(ConsoleColor::green('▶ ') . $message));
|
||||
}
|
||||
@@ -69,8 +89,8 @@ class InteractiveTerm
|
||||
|
||||
public static function error(string $message, bool $indent = true): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
logger()->error(strip_ansi_colors($message));
|
||||
} else {
|
||||
@@ -86,16 +106,16 @@ class InteractiveTerm
|
||||
|
||||
public static function setMessage(string $message): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$no_ansi = self::noAnsi();
|
||||
self::$indicator?->setMessage(($no_ansi ? 'strip_ansi_colors' : 'strval')($message));
|
||||
logger()->debug(strip_ansi_colors($message));
|
||||
}
|
||||
|
||||
public static function finish(string $message, bool $status = true): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$no_ansi = self::noAnsi();
|
||||
$message = $no_ansi ? strip_ansi_colors($message) : $message;
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
if ($status) {
|
||||
logger()->info($message);
|
||||
@@ -116,8 +136,8 @@ class InteractiveTerm
|
||||
|
||||
public static function indicateProgress(string $message): void
|
||||
{
|
||||
$no_ansi = (bool) ApplicationContext::get(InputInterface::class)->getOption('no-ansi');
|
||||
$output = ApplicationContext::get(OutputInterface::class);
|
||||
$no_ansi = self::noAnsi();
|
||||
$output = self::output();
|
||||
if ($output->isVerbose()) {
|
||||
logger()->info(strip_ansi_colors($message));
|
||||
return;
|
||||
@@ -131,11 +151,41 @@ class InteractiveTerm
|
||||
logger()->debug(strip_ansi_colors($message));
|
||||
// if no ansi, use a dot instead of spinner
|
||||
if ($no_ansi) {
|
||||
self::$indicator = new ProgressIndicator(ApplicationContext::get(OutputInterface::class), 'verbose', 100, [' •', ' •']);
|
||||
self::$indicator = new ProgressIndicator(self::output(), 'verbose', 100, [' •', ' •']);
|
||||
self::$indicator->start(strip_ansi_colors($message));
|
||||
return;
|
||||
}
|
||||
self::$indicator = new ProgressIndicator(ApplicationContext::get(OutputInterface::class), 'verbose', 100, [' ⠏', ' ⠛', ' ⠹', ' ⢸', ' ⣰', ' ⣤', ' ⣆', ' ⡇']);
|
||||
self::$indicator = new ProgressIndicator(self::output(), 'verbose', 100, [' ⠏', ' ⠛', ' ⠹', ' ⢸', ' ⣰', ' ⣤', ' ⣆', ' ⡇']);
|
||||
self::$indicator->start($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy default initialization used when init() was never called (early-boot errors,
|
||||
* tests, programmatic usage). Creates a plain STDERR output so error messages are
|
||||
* visible without depending on the Symfony Console lifecycle.
|
||||
*/
|
||||
private static function initDefault(): void
|
||||
{
|
||||
if (self::$output !== null) {
|
||||
return;
|
||||
}
|
||||
self::$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, false);
|
||||
self::$noAnsi = false;
|
||||
}
|
||||
|
||||
private static function noAnsi(): bool
|
||||
{
|
||||
if (self::$output === null) {
|
||||
self::initDefault();
|
||||
}
|
||||
return self::$noAnsi ?? false;
|
||||
}
|
||||
|
||||
private static function output(): OutputInterface
|
||||
{
|
||||
if (self::$output === null) {
|
||||
self::initDefault();
|
||||
}
|
||||
return self::$output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
|
||||
CC=cl.exe /nologo
|
||||
AR=lib.exe /nologo
|
||||
LINK=link.exe /nologo
|
||||
|
||||
!IF "" == "$(MACHINE)"
|
||||
MACHINE=x64
|
||||
!ENDIF
|
||||
|
||||
!IF "" == "$(CRT)"
|
||||
CRT=vc15
|
||||
!ENDIF
|
||||
|
||||
!IF "" == "$(PREFIX)"
|
||||
PREFIX="$(CRT)-$(MACHINE)"
|
||||
!ENDIF
|
||||
|
||||
COMMON_CFLAGS=/D SQLITE_THREADSAFE=1 /DSQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1
|
||||
!IF "$(DEBUG)"=="1"
|
||||
SQLITE3_STATIC_BASE=libsqlite3_a_debug
|
||||
SQLITE3_DLL_BASE=libsqlite3_debug
|
||||
SQLITE3_EXE_BASE=sqlite3
|
||||
CFLAGS=$(COMMON_CFLAGS) /Zi /MDd /Od /W3
|
||||
LDFLAGS=/DEBUG /GUARD:CF /INCREMENTAL:NO
|
||||
!ELSE
|
||||
SQLITE3_STATIC_BASE=libsqlite3_a
|
||||
SQLITE3_DLL_BASE=libsqlite3
|
||||
SQLITE3_EXE_BASE=sqlite3
|
||||
CFLAGS=$(COMMON_CFLAGS) /Zi /MT /guard:cf /Zc:inline /Qspectre /Ox /W3 /GF /Gw
|
||||
LDFLAGS=/GUARD:CF /INCREMENTAL:NO /NXCOMPAT /DYNAMICBASE
|
||||
!ENDIF
|
||||
|
||||
|
||||
all: $(SQLITE3_STATIC_BASE).lib $(SQLITE3_EXE_BASE).exe $(SQLITE3_DLL_BASE).dll
|
||||
|
||||
install: all
|
||||
if not exist $(PREFIX)\bin mkdir $(PREFIX)\bin
|
||||
if not exist $(PREFIX)\include mkdir $(PREFIX)\include
|
||||
if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib
|
||||
copy /Y sqlite3.h $(PREFIX)\include
|
||||
copy /Y sqlite3ext.h $(PREFIX)\include
|
||||
copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_STATIC_BASE).pdb $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_DLL_BASE).lib $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_DLL_BASE).pdb $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_DLL_BASE).dll $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_EXE_BASE).exe $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_EXE_BASE).pdb $(PREFIX)\bin
|
||||
|
||||
install-static: $(SQLITE3_STATIC_BASE).lib
|
||||
if not exist $(PREFIX)\include mkdir $(PREFIX)\include
|
||||
if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib
|
||||
copy /Y sqlite3.h $(PREFIX)\include
|
||||
copy /Y sqlite3ext.h $(PREFIX)\include
|
||||
copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib
|
||||
|
||||
clean:
|
||||
del *.obj *.lib *.exe *.pdb *.dll *.exp
|
||||
|
||||
$(SQLITE3_STATIC_BASE).lib: sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) /Fd$(SQLITE3_STATIC_BASE).pdb /c sqlite3.c
|
||||
$(AR) sqlite3.obj /OUT:$(SQLITE3_STATIC_BASE).lib
|
||||
|
||||
$(SQLITE3_EXE_BASE).exe: shell.c sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) shell.c sqlite3.c /Fd$(SQLITE3_EXE_BASE).pdb /Fe$(SQLITE3_EXE_BASE).exe
|
||||
|
||||
$(SQLITE3_DLL_BASE).dll: sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) /DSQLITE_API=__declspec(dllexport) /Fd$(SQLITE3_DLL_BASE).pdb /c sqlite3.c
|
||||
|
||||
CC=cl.exe /nologo
|
||||
AR=lib.exe /nologo
|
||||
LINK=link.exe /nologo
|
||||
|
||||
!IF "" == "$(MACHINE)"
|
||||
MACHINE=x64
|
||||
!ENDIF
|
||||
|
||||
!IF "" == "$(CRT)"
|
||||
CRT=vc15
|
||||
!ENDIF
|
||||
|
||||
!IF "" == "$(PREFIX)"
|
||||
PREFIX="$(CRT)-$(MACHINE)"
|
||||
!ENDIF
|
||||
|
||||
COMMON_CFLAGS=/D SQLITE_THREADSAFE=1 /DSQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1
|
||||
!IF "$(DEBUG)"=="1"
|
||||
SQLITE3_STATIC_BASE=libsqlite3_a_debug
|
||||
SQLITE3_DLL_BASE=libsqlite3_debug
|
||||
SQLITE3_EXE_BASE=sqlite3
|
||||
CFLAGS=$(COMMON_CFLAGS) /Zi /MDd /Od /W3
|
||||
LDFLAGS=/DEBUG /GUARD:CF /INCREMENTAL:NO
|
||||
!ELSE
|
||||
SQLITE3_STATIC_BASE=libsqlite3_a
|
||||
SQLITE3_DLL_BASE=libsqlite3
|
||||
SQLITE3_EXE_BASE=sqlite3
|
||||
CFLAGS=$(COMMON_CFLAGS) /Zi /MT /guard:cf /Zc:inline /Qspectre /Ox /W3 /GF /Gw
|
||||
LDFLAGS=/GUARD:CF /INCREMENTAL:NO /NXCOMPAT /DYNAMICBASE
|
||||
!ENDIF
|
||||
|
||||
|
||||
all: $(SQLITE3_STATIC_BASE).lib $(SQLITE3_EXE_BASE).exe $(SQLITE3_DLL_BASE).dll
|
||||
|
||||
install: all
|
||||
if not exist $(PREFIX)\bin mkdir $(PREFIX)\bin
|
||||
if not exist $(PREFIX)\include mkdir $(PREFIX)\include
|
||||
if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib
|
||||
copy /Y sqlite3.h $(PREFIX)\include
|
||||
copy /Y sqlite3ext.h $(PREFIX)\include
|
||||
copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_STATIC_BASE).pdb $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_DLL_BASE).lib $(PREFIX)\lib
|
||||
copy /Y $(SQLITE3_DLL_BASE).pdb $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_DLL_BASE).dll $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_EXE_BASE).exe $(PREFIX)\bin
|
||||
copy /Y $(SQLITE3_EXE_BASE).pdb $(PREFIX)\bin
|
||||
|
||||
install-static: $(SQLITE3_STATIC_BASE).lib
|
||||
if not exist $(PREFIX)\include mkdir $(PREFIX)\include
|
||||
if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib
|
||||
copy /Y sqlite3.h $(PREFIX)\include
|
||||
copy /Y sqlite3ext.h $(PREFIX)\include
|
||||
copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib
|
||||
|
||||
clean:
|
||||
del *.obj *.lib *.exe *.pdb *.dll *.exp
|
||||
|
||||
$(SQLITE3_STATIC_BASE).lib: sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) /Fd$(SQLITE3_STATIC_BASE).pdb /c sqlite3.c
|
||||
$(AR) sqlite3.obj /OUT:$(SQLITE3_STATIC_BASE).lib
|
||||
|
||||
$(SQLITE3_EXE_BASE).exe: shell.c sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) shell.c sqlite3.c /Fd$(SQLITE3_EXE_BASE).pdb /Fe$(SQLITE3_EXE_BASE).exe
|
||||
|
||||
$(SQLITE3_DLL_BASE).dll: sqlite3.c sqlite3.h
|
||||
$(CC) $(CFLAGS) /DSQLITE_API=__declspec(dllexport) /Fd$(SQLITE3_DLL_BASE).pdb /c sqlite3.c
|
||||
$(LINK) /DLL /OUT:$(SQLITE3_DLL_BASE).dll sqlite3.obj
|
||||
@@ -1,86 +1,86 @@
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib is not supported on php <= 8.0
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib is not supported on php <= 8.0
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib support
|
||||
if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_LIB("aom_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
} else if (CHECK_LIB("avif.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
}
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib support
|
||||
if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_LIB("aom_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
} else if (CHECK_LIB("avif.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
}
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib support
|
||||
if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_LIB("aom_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
} else if (CHECK_LIB("avif.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
}
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("gd", "Bundled GD support", "yes");
|
||||
|
||||
if (PHP_GD != "no") {
|
||||
// check for gd.h (required)
|
||||
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
|
||||
ERROR("gd not enabled; libraries and headers not found");
|
||||
}
|
||||
|
||||
// zlib ext support (required)
|
||||
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
|
||||
ERROR("gd not enabled; zlib not enabled");
|
||||
}
|
||||
|
||||
// libjpeg lib support
|
||||
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
|
||||
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
|
||||
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
|
||||
}
|
||||
|
||||
// libpng16 lib support
|
||||
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
|
||||
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
|
||||
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
|
||||
}
|
||||
|
||||
// freetype lib support
|
||||
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
|
||||
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
|
||||
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
|
||||
}
|
||||
|
||||
// xpm lib support
|
||||
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
|
||||
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
|
||||
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
|
||||
}
|
||||
|
||||
// iconv lib support
|
||||
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
|
||||
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
|
||||
}
|
||||
|
||||
// libwebp lib support
|
||||
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
|
||||
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
|
||||
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
|
||||
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
|
||||
}
|
||||
|
||||
// libavif lib support
|
||||
if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_LIB("aom_a.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
} else if (CHECK_LIB("avif.lib", "gd", PHP_GD) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
|
||||
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
|
||||
}
|
||||
|
||||
CHECK_LIB("User32.lib", "gd", PHP_GD);
|
||||
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
|
||||
|
||||
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
|
||||
ADD_SOURCES("ext/gd/libgd", "gd.c \
|
||||
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
|
||||
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
|
||||
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
|
||||
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
|
||||
gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
|
||||
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
|
||||
|
||||
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
|
||||
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
|
||||
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
|
||||
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
|
||||
ADD_FLAG("CFLAGS_GD", " \
|
||||
/D PHP_GD_EXPORTS=1 \
|
||||
/D HAVE_GD_GET_INTERPOLATION \
|
||||
");
|
||||
if (ICC_TOOLSET) {
|
||||
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
|
||||
}
|
||||
|
||||
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
PostgreSQL Database Management System
|
||||
(also known as Postgres, formerly known as Postgres95)
|
||||
|
||||
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement
|
||||
is hereby granted, provided that the above copyright notice and this
|
||||
paragraph and the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
PostgreSQL Database Management System
|
||||
(also known as Postgres, formerly known as Postgres95)
|
||||
|
||||
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement
|
||||
is hereby granted, provided that the above copyright notice and this
|
||||
paragraph and the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
|
||||
@@ -517,13 +517,13 @@ class PackageLoaderTest extends TestCase
|
||||
mkdir($psr4Dir, 0755, true);
|
||||
|
||||
// Create test class file
|
||||
$classContent = '<?php
|
||||
namespace Test\Package;
|
||||
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
|
||||
#[Library("test-lib")]
|
||||
class TestPackage1 {
|
||||
$classContent = '<?php
|
||||
namespace Test\Package;
|
||||
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
|
||||
#[Library("test-lib")]
|
||||
class TestPackage1 {
|
||||
}';
|
||||
file_put_contents($psr4Dir . '/TestPackage1.php', $classContent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user