mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 00:05:42 +08:00
Compare commits
267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96dd5ba87b | ||
|
|
d4c0290195 | ||
|
|
f5d1df5407 | ||
|
|
9664709f21 | ||
|
|
b46655ecfe | ||
|
|
842e0add29 | ||
|
|
254764761d | ||
|
|
5f6c1a0f40 | ||
|
|
d5dcd193cf | ||
|
|
5012da96be | ||
|
|
df0e37cd0f | ||
|
|
4ab7b6bfdc | ||
|
|
f498250001 | ||
|
|
3945ac037b | ||
|
|
b0d8b00fcc | ||
|
|
62b0bf8af0 | ||
|
|
905e080770 | ||
|
|
097ecd3fb0 | ||
|
|
b9359759dd | ||
|
|
50fe366c42 | ||
|
|
9dd89e6b02 | ||
|
|
c03220d1ee | ||
|
|
9db843ab66 | ||
|
|
304973d9bc | ||
|
|
ab386f820c | ||
|
|
4adf1f5e2e | ||
|
|
b4ae87585c | ||
|
|
ae3298472d | ||
|
|
d241cb993e | ||
|
|
8376122634 | ||
|
|
a30e054d7d | ||
|
|
78f4317660 | ||
|
|
3ac3dab6c8 | ||
|
|
1a7e436ee1 | ||
|
|
f11b36ab3c | ||
|
|
e2ef195a84 | ||
|
|
645e2a9fc2 | ||
|
|
d59b8457c6 | ||
|
|
a2d1262cbf | ||
|
|
2f9a1e8601 | ||
|
|
b239f60fe4 | ||
|
|
983521e225 | ||
|
|
aeed04a5ec | ||
|
|
faed569e8a | ||
|
|
49ddb3ec13 | ||
|
|
71c0387ab0 | ||
|
|
e5d2d5e689 | ||
|
|
be2394b39b | ||
|
|
158298b96c | ||
|
|
ffa84f8b91 | ||
|
|
0954ddcc96 | ||
|
|
d9bd96af71 | ||
|
|
2649dcd05c | ||
|
|
939db75268 | ||
|
|
227bf73870 | ||
|
|
05e3898e7a | ||
|
|
9777c9aa93 | ||
|
|
b8d8461e61 | ||
|
|
b977543c72 | ||
|
|
4d87cd11cc | ||
|
|
957daf0547 | ||
|
|
3dae904122 | ||
|
|
e835196972 | ||
|
|
52ed0e2cee | ||
|
|
1e898d271d | ||
|
|
39754cde59 | ||
|
|
a6f7b938e1 | ||
|
|
0ad501af9a | ||
|
|
73035067e3 | ||
|
|
421b3830b6 | ||
|
|
59dcb905fe | ||
|
|
d222190fc7 | ||
|
|
06e9864d19 | ||
|
|
0b1a321615 | ||
|
|
9ee7d7769a | ||
|
|
2440a65d8e | ||
|
|
839931d65f | ||
|
|
2591b48abe | ||
|
|
2549597871 | ||
|
|
2064172bed | ||
|
|
dc19d0c61d | ||
|
|
05c6dc6dab | ||
|
|
4b653bc293 | ||
|
|
1c3476b8e9 | ||
|
|
61ca501c2a | ||
|
|
d916feec62 | ||
|
|
0dcecf6ca4 | ||
|
|
a04deb458f | ||
|
|
34f810571e | ||
|
|
5ab4d140d5 | ||
|
|
104778d17a | ||
|
|
5f8641f417 | ||
|
|
17b69ec1e9 | ||
|
|
8de942c274 | ||
|
|
a7d5a48b48 | ||
|
|
fdc00301c0 | ||
|
|
7620d5900e | ||
|
|
e973fe743e | ||
|
|
149e844d59 | ||
|
|
12ea3218e8 | ||
|
|
f9e7af1c9a | ||
|
|
8d2f6baaa2 | ||
|
|
25a2684e5a | ||
|
|
13e0e12181 | ||
|
|
81df124b42 | ||
|
|
d3d8230a09 | ||
|
|
d4eb199504 | ||
|
|
6562bc200c | ||
|
|
0b322f494b | ||
|
|
ceed1005cc | ||
|
|
6efcb75224 | ||
|
|
a45f2f357d | ||
|
|
0c2de9f936 | ||
|
|
ac005d1e0f | ||
|
|
fce0c2f896 | ||
|
|
a0a0b01cc3 | ||
|
|
450ec21c90 | ||
|
|
7b2c3ac12d | ||
|
|
8d4a375400 | ||
|
|
eda3a9b486 | ||
|
|
5b581a54aa | ||
|
|
5549068275 | ||
|
|
daf0d2eb32 | ||
|
|
bff1a6168f | ||
|
|
54ba41d1b3 | ||
|
|
cb5e13e39a | ||
|
|
269e95e0fe | ||
|
|
dabdb518ce | ||
|
|
eac4763d82 | ||
|
|
fa0ea5443d | ||
|
|
31c71f180b | ||
|
|
5c7552f826 | ||
|
|
fa1bd340f1 | ||
|
|
539aaefd72 | ||
|
|
d54bf42ba8 | ||
|
|
cbfbec41b4 | ||
|
|
db7532cad3 | ||
|
|
6b8df97282 | ||
|
|
584f96484c | ||
|
|
e1e5515694 | ||
|
|
d3ff6fd8c0 | ||
|
|
6bcda6a5a0 | ||
|
|
3828ba7c77 | ||
|
|
a632caed54 | ||
|
|
1e0265e673 | ||
|
|
a39cd9a238 | ||
|
|
2d437952f2 | ||
|
|
7e5b0d6f43 | ||
|
|
cf198e0f0a | ||
|
|
248918e458 | ||
|
|
c4cfc01b88 | ||
|
|
339c03adb2 | ||
|
|
48551cc602 | ||
|
|
e0550b4a45 | ||
|
|
93a55e87d5 | ||
|
|
e68f1ce3fe | ||
|
|
3573007485 | ||
|
|
b961c34d9a | ||
|
|
33e1759caa | ||
|
|
d72ee53cb4 | ||
|
|
a5fa46b82d | ||
|
|
bc15de0dfb | ||
|
|
1f7bdb94fb | ||
|
|
ea64e50ce5 | ||
|
|
ed8b606761 | ||
|
|
b722b3edd4 | ||
|
|
9266a4c504 | ||
|
|
d8ce5f69f4 | ||
|
|
0cfac49560 | ||
|
|
3e9ddc8e01 | ||
|
|
83dd1bd5c3 | ||
|
|
42f448cf17 | ||
|
|
f0319de93e | ||
|
|
c7e9294908 | ||
|
|
c1758bd754 | ||
|
|
bba2d0dbf7 | ||
|
|
00689b951b | ||
|
|
98b7164de3 | ||
|
|
d3e4470e1f | ||
|
|
433c91b68d | ||
|
|
3185d98b1a | ||
|
|
e603e441e7 | ||
|
|
b1bf8bb848 | ||
|
|
b1958ea0c4 | ||
|
|
930849758c | ||
|
|
7ee431725c | ||
|
|
7c866cb0e3 | ||
|
|
266108b25f | ||
|
|
82e3a86f17 | ||
|
|
ba18819b41 | ||
|
|
6b23c90bba | ||
|
|
edfd371973 | ||
|
|
8ed95602e2 | ||
|
|
cee1346bec | ||
|
|
400007c206 | ||
|
|
443e615066 | ||
|
|
ed22945ae2 | ||
|
|
5db084ba0e | ||
|
|
c7b3275a72 | ||
|
|
41cd319d4e | ||
|
|
1c307d0d59 | ||
|
|
9dcda873f3 | ||
|
|
4400c6271e | ||
|
|
0589690eaa | ||
|
|
5449e05898 | ||
|
|
93e64e1d5a | ||
|
|
7a2e237069 | ||
|
|
c95da8c150 | ||
|
|
89afd44344 | ||
|
|
04f100da8b | ||
|
|
2e24976b71 | ||
|
|
36a30cc23b | ||
|
|
869130572f | ||
|
|
2bb08af89b | ||
|
|
b3d41ef969 | ||
|
|
9c904409cd | ||
|
|
859182abff | ||
|
|
c0e88bf4bd | ||
|
|
79bcd35c0e | ||
|
|
2e637524fc | ||
|
|
a2c687599f | ||
|
|
d09a3074ad | ||
|
|
5736964b2e | ||
|
|
edaa82b8c5 | ||
|
|
2a6441a500 | ||
|
|
3bd5a05725 | ||
|
|
a6fbcc954e | ||
|
|
66cebb5fe4 | ||
|
|
e3671387fc | ||
|
|
f7c73c00af | ||
|
|
74536bd2e1 | ||
|
|
a8f2b0096b | ||
|
|
2d192fc390 | ||
|
|
031da802f3 | ||
|
|
5fdeb33031 | ||
|
|
347da67b71 | ||
|
|
65ef9ab20c | ||
|
|
3d64c6349e | ||
|
|
31cf9bb5b7 | ||
|
|
7c4a991c0e | ||
|
|
07f943af7e | ||
|
|
fbf5c958d0 | ||
|
|
672a4102cd | ||
|
|
52d61365b7 | ||
|
|
ff74f0cdaf | ||
|
|
dccfde9f39 | ||
|
|
5db23e1db7 | ||
|
|
b1ae48a209 | ||
|
|
3604ea6d67 | ||
|
|
967292be5c | ||
|
|
4f5335bba4 | ||
|
|
ac7a236763 | ||
|
|
1bf39c1f06 | ||
|
|
678283cd98 | ||
|
|
97a76aba8a | ||
|
|
af464e7b3d | ||
|
|
5ee7dd9200 | ||
|
|
9e1c2c6dd5 | ||
|
|
d29ba16cbc | ||
|
|
7bef45eb32 | ||
|
|
772ab77d2e | ||
|
|
58897c6941 | ||
|
|
8230e1bcec | ||
|
|
0569c69634 | ||
|
|
1b734073b0 | ||
|
|
47d068e6d3 | ||
|
|
4537bfb247 |
12
.github/pull_request_template.md
vendored
Normal file
12
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
## What does this PR do?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Checklist before merging
|
||||||
|
|
||||||
|
> If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
|
||||||
|
> If a modification is not involved, please skip it directly.
|
||||||
|
|
||||||
|
- [ ] If it's a extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`.
|
||||||
|
- [ ] If you changed the behavior of static-php-cli, add docs in [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) .
|
||||||
|
- [ ] If you updated `config/xxxx.json` content, run `bin/spc dev:sort-config xxx`.
|
||||||
5
.github/workflows/build-linux-arm.yml
vendored
5
.github/workflows/build-linux-arm.yml
vendored
@@ -15,6 +15,7 @@ on:
|
|||||||
default: '8.2'
|
default: '8.2'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
|
- '8.3'
|
||||||
- '8.2'
|
- '8.2'
|
||||||
- '8.1'
|
- '8.1'
|
||||||
- '8.0'
|
- '8.0'
|
||||||
@@ -51,7 +52,7 @@ jobs:
|
|||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: downloads
|
path: downloads
|
||||||
key: php-${{ inputs.version }}-dependencies
|
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||||
|
|
||||||
# With or without debug
|
# With or without debug
|
||||||
- if: inputs.debug == true
|
- if: inputs.debug == true
|
||||||
@@ -67,7 +68,7 @@ jobs:
|
|||||||
|
|
||||||
# If there's no dependencies cache, fetch sources, with or without debug
|
# If there's no dependencies cache, fetch sources, with or without debug
|
||||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||||
run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
|
run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }}
|
||||||
|
|
||||||
# Run build command
|
# Run build command
|
||||||
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||||
|
|||||||
5
.github/workflows/build-linux-x86_64.yml
vendored
5
.github/workflows/build-linux-x86_64.yml
vendored
@@ -9,6 +9,7 @@ on:
|
|||||||
default: '8.2'
|
default: '8.2'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
|
- '8.3'
|
||||||
- '8.2'
|
- '8.2'
|
||||||
- '8.1'
|
- '8.1'
|
||||||
- '8.0'
|
- '8.0'
|
||||||
@@ -56,7 +57,7 @@ jobs:
|
|||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: downloads
|
path: downloads
|
||||||
key: php-${{ inputs.version }}-dependencies
|
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||||
|
|
||||||
# With or without debug
|
# With or without debug
|
||||||
- if: inputs.debug == true
|
- if: inputs.debug == true
|
||||||
@@ -72,7 +73,7 @@ jobs:
|
|||||||
|
|
||||||
# If there's no dependencies cache, fetch sources, with or without debug
|
# If there's no dependencies cache, fetch sources, with or without debug
|
||||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||||
run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
|
run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }}
|
||||||
|
|
||||||
# Run build command
|
# Run build command
|
||||||
- run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
- run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||||
|
|||||||
127
.github/workflows/build-macos-aarch64.yml
vendored
Normal file
127
.github/workflows/build-macos-aarch64.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
name: CI on arm64 macOS
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
required: true
|
||||||
|
description: php version to compile
|
||||||
|
default: '8.2'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- '8.3'
|
||||||
|
- '8.2'
|
||||||
|
- '8.1'
|
||||||
|
- '8.0'
|
||||||
|
- '7.4'
|
||||||
|
build-cli:
|
||||||
|
description: build cli binary
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
build-micro:
|
||||||
|
description: build phpmicro binary
|
||||||
|
type: boolean
|
||||||
|
build-fpm:
|
||||||
|
description: build fpm binary
|
||||||
|
type: boolean
|
||||||
|
extensions:
|
||||||
|
description: extensions to compile (comma separated)
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
debug:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build ${{ inputs.version }} on macOS arm64
|
||||||
|
runs-on: macos-14
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Install macOS missing packages and mark os suffix
|
||||||
|
- run: |
|
||||||
|
brew install automake gzip
|
||||||
|
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Setup PHP"
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: 8.1
|
||||||
|
tools: pecl, composer
|
||||||
|
extensions: curl, openssl, mbstring, tokenizer
|
||||||
|
ini-values: memory_limit=-1
|
||||||
|
|
||||||
|
|
||||||
|
# Cache composer dependencies
|
||||||
|
- id: cache-composer-deps
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: vendor
|
||||||
|
key: composer-dependencies
|
||||||
|
|
||||||
|
# If there's no Composer cache, install dependencies
|
||||||
|
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||||
|
run: composer update --no-dev --classmap-authoritative
|
||||||
|
|
||||||
|
# Cache downloaded source
|
||||||
|
- id: cache-download
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: downloads
|
||||||
|
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||||
|
|
||||||
|
# With or without debug
|
||||||
|
- if: inputs.debug == true
|
||||||
|
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# With target select: cli, micro or both
|
||||||
|
- if: ${{ inputs.build-cli == true }}
|
||||||
|
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
|
||||||
|
- if: ${{ inputs.build-micro == true }}
|
||||||
|
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
|
||||||
|
- if: ${{ inputs.build-fpm == true }}
|
||||||
|
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# If there's no dependencies cache, fetch sources, with or without debug
|
||||||
|
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||||
|
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }}
|
||||||
|
|
||||||
|
# Run build command
|
||||||
|
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||||
|
|
||||||
|
# Upload cli executable
|
||||||
|
- if: ${{ inputs.build-cli == true }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||||
|
path: buildroot/bin/php
|
||||||
|
|
||||||
|
# Upload micro self-extracted executable
|
||||||
|
- if: ${{ inputs.build-micro == true }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||||
|
path: buildroot/bin/micro.sfx
|
||||||
|
|
||||||
|
# Upload fpm executable
|
||||||
|
- if: ${{ inputs.build-fpm == true }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||||
|
path: buildroot/bin/php-fpm
|
||||||
|
|
||||||
|
# Upload extensions metadata
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: license-files
|
||||||
|
path: buildroot/license/
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-meta
|
||||||
|
path: |
|
||||||
|
buildroot/build-extensions.json
|
||||||
|
buildroot/build-libraries.json
|
||||||
5
.github/workflows/build-macos-x86_64.yml
vendored
5
.github/workflows/build-macos-x86_64.yml
vendored
@@ -9,6 +9,7 @@ on:
|
|||||||
default: '8.2'
|
default: '8.2'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
|
- '8.3'
|
||||||
- '8.2'
|
- '8.2'
|
||||||
- '8.1'
|
- '8.1'
|
||||||
- '8.0'
|
- '8.0'
|
||||||
@@ -61,7 +62,7 @@ jobs:
|
|||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: downloads
|
path: downloads
|
||||||
key: php-${{ inputs.version }}-dependencies
|
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||||
|
|
||||||
# With or without debug
|
# With or without debug
|
||||||
- if: inputs.debug == true
|
- if: inputs.debug == true
|
||||||
@@ -77,7 +78,7 @@ jobs:
|
|||||||
|
|
||||||
# If there's no dependencies cache, fetch sources, with or without debug
|
# If there's no dependencies cache, fetch sources, with or without debug
|
||||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||||
run: ./bin/spc download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
|
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }}
|
||||||
|
|
||||||
# Run build command
|
# Run build command
|
||||||
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||||
|
|||||||
40
.github/workflows/download-cache.yml
vendored
40
.github/workflows/download-cache.yml
vendored
@@ -1,40 +0,0 @@
|
|||||||
name: archive download sources weekly
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: "* 14 * * 5"
|
|
||||||
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
download:
|
|
||||||
name: cache download sources
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
php-version: [ "8.0", "8.1", "8.2" ]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
# Cache composer dependencies
|
|
||||||
- id: cache-composer-deps
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: vendor
|
|
||||||
key: composer-dependencies
|
|
||||||
|
|
||||||
# If there's no Composer cache, install dependencies
|
|
||||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
|
||||||
run: composer update --no-dev
|
|
||||||
|
|
||||||
# If there's no dependencies cache, fetch sources, with or without debug
|
|
||||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
|
||||||
run: ./bin/spc download --with-php=${{ matrix.php-version }} --all --debug
|
|
||||||
|
|
||||||
# Upload downloaded files
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: download-files-${{ matrix.php-version }}
|
|
||||||
path: downloads/
|
|
||||||
100
.github/workflows/release-build.yml
vendored
100
.github/workflows/release-build.yml
vendored
@@ -1,6 +1,8 @@
|
|||||||
name: Upload SPC Binary (Release)
|
name: Build SPC Binary
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
release:
|
release:
|
||||||
types:
|
types:
|
||||||
- published
|
- published
|
||||||
@@ -8,40 +10,116 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release-artifacts:
|
build-release-artifacts:
|
||||||
name: "Upload SPC Binary (Release)"
|
name: "Build SPC Binary"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
php-version:
|
||||||
|
- "8.2"
|
||||||
|
micro-version:
|
||||||
|
- "8.2.16"
|
||||||
operating-system:
|
operating-system:
|
||||||
- "linux-x86_64"
|
- "linux-x86_64"
|
||||||
- "macos-x86_64"
|
- "macos-x86_64"
|
||||||
- "linux-aarch64"
|
- "linux-aarch64"
|
||||||
- "macos-aarch64"
|
- "macos-aarch64"
|
||||||
|
- "windows-x64"
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: "actions/checkout@v4"
|
uses: "actions/checkout@v4"
|
||||||
|
|
||||||
- name: Reuse static-php-cli-hosted artifacts
|
- if: inputs.debug == true
|
||||||
uses: dawidd6/action-download-artifact@v2
|
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: "Install PHP for official runners"
|
||||||
|
uses: "shivammathur/setup-php@v2"
|
||||||
with:
|
with:
|
||||||
repo: crazywhalecc/static-php-cli-hosted
|
coverage: none
|
||||||
branch: master
|
tools: composer:v2
|
||||||
workflow: build-spc-release.yml
|
php-version: "${{ matrix.php-version }}"
|
||||||
name: "spc-${{ matrix.operating-system }}"
|
ini-values: memory_limit=-1
|
||||||
|
|
||||||
|
- 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@v3"
|
||||||
|
with:
|
||||||
|
path: "${{ steps.composer-cache.outputs.dir }}"
|
||||||
|
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
|
||||||
|
restore-keys: |
|
||||||
|
php-${{ matrix.php-version }}-locked-composer
|
||||||
|
|
||||||
|
- name: "Install Locked Dependencies"
|
||||||
|
run: "composer install --no-interaction --no-progress"
|
||||||
|
|
||||||
|
- name: "Build PHAR File"
|
||||||
|
run: "composer build:phar"
|
||||||
|
|
||||||
|
- name: "Download minimal combination"
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
|
||||||
|
curl https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ matrix.micro-version }}-micro-win.zip -o tmp.zip
|
||||||
|
unzip tmp.zip
|
||||||
|
else
|
||||||
|
curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz
|
||||||
|
tar -zxvf tmp.tgz
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Generate Executable"
|
||||||
|
run: |
|
||||||
|
bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G"
|
||||||
|
if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
|
||||||
|
mv spc spc.exe
|
||||||
|
else
|
||||||
|
chmod +x spc
|
||||||
|
fi
|
||||||
|
|
||||||
- name: "Archive Executable"
|
- name: "Archive Executable"
|
||||||
run: |
|
run: |
|
||||||
|
if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
|
||||||
tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
|
tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
|
||||||
echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV
|
echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV
|
||||||
|
echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
|
||||||
|
if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then
|
||||||
|
./spc dev:extensions
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "filename=spc-${{ matrix.operating-system }}.exe" >> $GITHUB_ENV
|
||||||
|
echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Copy file"
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
|
||||||
|
mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS
|
||||||
|
else
|
||||||
|
mkdir dist/ && cp spc.exe dist/${{ env.filename }}
|
||||||
|
echo "SUFFIX=.exe" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
- name: upload binaries to release
|
- name: upload binaries to release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: ${{startsWith(github.ref, 'refs/tags/') }}
|
if: ${{startsWith(github.ref, 'refs/tags/') }}
|
||||||
with:
|
with:
|
||||||
files: ${{ env.filename }}
|
files: dist/${{ env.filename }}
|
||||||
|
|
||||||
|
- name: "Deploy to Self-Hosted Server"
|
||||||
|
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||||
|
uses: easingthemes/ssh-deploy@main
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
|
||||||
|
ARGS: "-rltgoDzvO"
|
||||||
|
SOURCE: "dist/"
|
||||||
|
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
|
||||||
|
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
|
||||||
|
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
|
||||||
|
TARGET: ${{ secrets.DEPLOY_SERVER_TARGET_SPC_NIGHTLY }}
|
||||||
|
|
||||||
- name: "Upload Artifact"
|
- name: "Upload Artifact"
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: spc
|
path: spc${{ env.SUFFIX }}
|
||||||
name: spc-${{ matrix.operating-system }}
|
name: spc-${{ matrix.operating-system }}${{ env.SUFFIX }}
|
||||||
|
|||||||
102
.github/workflows/tests.yml
vendored
102
.github/workflows/tests.yml
vendored
@@ -2,7 +2,10 @@ name: Tests
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'src/globals/test-extensions.php'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
@@ -14,10 +17,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: "Checkout"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.1'
|
php-version: '8.1'
|
||||||
@@ -32,10 +35,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: "Checkout"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.1'
|
php-version: '8.1'
|
||||||
@@ -43,7 +46,7 @@ jobs:
|
|||||||
ini-values: memory_limit=-1
|
ini-values: memory_limit=-1
|
||||||
tools: composer
|
tools: composer
|
||||||
|
|
||||||
- name: Cache Composer packages
|
- name: "Cache Composer packages"
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
@@ -52,14 +55,14 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-phpstan-
|
${{ runner.os }}-phpstan-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: "Install Dependencies"
|
||||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||||
|
|
||||||
- name: Run phpstan
|
- name: "Run phpstan"
|
||||||
run: vendor/bin/phpstan analyse
|
run: vendor/bin/phpstan analyse
|
||||||
|
|
||||||
phpunit:
|
phpunit:
|
||||||
name: PHPUnit (PHP ${{ matrix.php }})
|
name: "PHPUnit (PHP ${{ matrix.php }})"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
strategy:
|
strategy:
|
||||||
@@ -67,13 +70,13 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- php: '8.1'
|
- php: '8.1'
|
||||||
- php: '8.2'
|
- php: '8.2'
|
||||||
fail-fast: false
|
- php: '8.3'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: "Checkout"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: "${{ matrix.php }}"
|
php-version: "${{ matrix.php }}"
|
||||||
@@ -81,7 +84,7 @@ jobs:
|
|||||||
extensions: curl, openssl, mbstring
|
extensions: curl, openssl, mbstring
|
||||||
ini-values: memory_limit=-1
|
ini-values: memory_limit=-1
|
||||||
|
|
||||||
- name: Cache Composer packages
|
- name: "Cache Composer packages"
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
@@ -90,9 +93,78 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-php-
|
${{ runner.os }}-php-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: "Install Dependencies"
|
||||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||||
|
|
||||||
- name: Run PHPUnit tests
|
- name: "Run PHPUnit Tests"
|
||||||
run: |
|
run: |
|
||||||
vendor/bin/phpunit tests/ --no-coverage
|
vendor/bin/phpunit tests/ --no-coverage
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
timeout-minutes: 120
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php:
|
||||||
|
- "8.0"
|
||||||
|
- "8.1"
|
||||||
|
- "8.2"
|
||||||
|
- "8.3"
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
- macos-14
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: "Setup PHP"
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: 8.2
|
||||||
|
tools: pecl, composer
|
||||||
|
extensions: curl, openssl, mbstring
|
||||||
|
ini-values: memory_limit=-1
|
||||||
|
|
||||||
|
- name: "Use test token if exists"
|
||||||
|
if: matrix.os != 'windows-latest'
|
||||||
|
run: |
|
||||||
|
if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then
|
||||||
|
echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Cache Composer packages"
|
||||||
|
id: composer-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: vendor
|
||||||
|
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-php-
|
||||||
|
|
||||||
|
# Cache downloaded source
|
||||||
|
- id: cache-download
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: downloads
|
||||||
|
key: php-${{ matrix.php }}-dependencies
|
||||||
|
|
||||||
|
- name: "Install Dependencies"
|
||||||
|
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||||
|
|
||||||
|
- name: "Run Build Tests (doctor)"
|
||||||
|
run: bin/spc doctor --auto-fix
|
||||||
|
|
||||||
|
- name: "Run Build Tests (download)"
|
||||||
|
uses: nick-fields/retry@v3
|
||||||
|
with:
|
||||||
|
timeout_minutes: 10
|
||||||
|
max_attempts: 3
|
||||||
|
retry_on: error
|
||||||
|
command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug
|
||||||
|
|
||||||
|
- name: "Run Build Tests (build)"
|
||||||
|
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug
|
||||||
|
|||||||
43
.github/workflows/update-docs-config.yml
vendored
Normal file
43
.github/workflows/update-docs-config.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Update Docs Config
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'config/**.json'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-docs-config:
|
||||||
|
name: "Update Docs Config"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||||
|
steps:
|
||||||
|
- name: "Checkout static-php-cli"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
path: static-php-cli
|
||||||
|
|
||||||
|
- name: "Checkout static-php-cli-docs"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: static-php/static-php-cli-docs
|
||||||
|
ref: master
|
||||||
|
token: ${{ secrets.DOCS_REPO_TOKEN }}
|
||||||
|
path: static-php-cli-docs
|
||||||
|
|
||||||
|
- name: "Set up Git"
|
||||||
|
run: |
|
||||||
|
git config --global user.email "actions@github.com"
|
||||||
|
git config --global user.name "GitHub Actions"
|
||||||
|
|
||||||
|
- name: "Copy Config Files"
|
||||||
|
run: cp -r static-php-cli/config/* static-php-cli-docs/docs/.vitepress/config/
|
||||||
|
|
||||||
|
- name: "Commit and Push Changes"
|
||||||
|
run: |
|
||||||
|
cd static-php-cli-docs
|
||||||
|
git add -A
|
||||||
|
git commit -m "Sync config files from main"
|
||||||
|
git push origin master
|
||||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -16,15 +16,21 @@ docker/source/
|
|||||||
# default source build root directory
|
# default source build root directory
|
||||||
/buildroot/
|
/buildroot/
|
||||||
|
|
||||||
|
# default package root directory
|
||||||
|
/pkgroot/
|
||||||
|
|
||||||
# tools cache files
|
# tools cache files
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
|
||||||
# exclude self-runtime
|
# exclude self-runtime
|
||||||
/bin/*
|
/bin/*
|
||||||
!/bin/spc
|
!/bin/spc*
|
||||||
!/bin/setup-runtime
|
!/bin/setup-runtime*
|
||||||
!/bin/spc-alpine-docker
|
!/bin/spc-alpine-docker
|
||||||
|
|
||||||
|
# exclude windows build tools
|
||||||
|
/php-sdk-binary-tools/
|
||||||
|
|
||||||
# default test directory
|
# default test directory
|
||||||
/tests/var/
|
/tests/var/
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ return (new PhpCsFixer\Config())
|
|||||||
'phpdoc_summary' => false,
|
'phpdoc_summary' => false,
|
||||||
'php_unit_test_class_requires_covers' => false,
|
'php_unit_test_class_requires_covers' => false,
|
||||||
'phpdoc_var_without_name' => false,
|
'phpdoc_var_without_name' => false,
|
||||||
|
'fully_qualified_strict_types' => false,
|
||||||
])
|
])
|
||||||
->setFinder(
|
->setFinder(
|
||||||
PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC'])
|
PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC'])
|
||||||
|
|||||||
210
README-zh.md
210
README-zh.md
@@ -1,59 +1,93 @@
|
|||||||
# static-php-cli
|
# static-php-cli
|
||||||
|
|
||||||
Build single static PHP binary, with PHP project together, with popular extensions included.
|
[](README.md)
|
||||||
|
[](README-zh.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://static-php.dev/zh/guide/extensions.html)
|
||||||
|
|
||||||
🌐 **[中文](README-zh.md)** | **[English](README.md)**
|
**static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。
|
||||||
|
|
||||||
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI)
|
目前 static-php-cli 支持 `cli`、`fpm`、`embed` 和 `micro` SAPI。
|
||||||
|
|
||||||
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
|
**static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。
|
||||||
|
|
||||||
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(micro SAPI)
|
## 特性
|
||||||
|
|
||||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
static-php-cli(简称 `spc`)有许多特性:
|
||||||
|
|
||||||
> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。
|
- :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖
|
||||||
|
- :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件)
|
||||||
|
- :pill: 提供一键检查和修复编译环境的 Doctor 模块
|
||||||
|
- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、`Windows`
|
||||||
|
- :wrench: 高度自定义的代码 patch 功能
|
||||||
|
- :books: 自带编译依赖管理
|
||||||
|
- 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建)
|
||||||
|
- :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html)
|
||||||
|
- :floppy_disk: 整合 UPX 工具(减小二进制文件体积)
|
||||||
|
|
||||||
[]()
|
**静态 php-cli:**
|
||||||
[]()
|
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
|
||||||
[]()
|
|
||||||
[]()
|
|
||||||
|
|
||||||
> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎
|
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
|
||||||
|
|
||||||
|
**使用 phpmicro 打包 PHP 代码:**
|
||||||
|
|
||||||
|
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
|
||||||
|
|
||||||
## 文档
|
## 文档
|
||||||
|
|
||||||
目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:<https://static-php.dev>。
|
目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:<https://static-php.dev>。
|
||||||
|
|
||||||
## 自托管直接下载
|
## 直接下载
|
||||||
|
|
||||||
如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/)
|
如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载。
|
||||||
|
|
||||||
> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
- [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/):common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 22MB 左右。
|
||||||
|
- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。
|
||||||
|
- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。
|
||||||
|
|
||||||
|
对于 Windows 系统,目前支持的扩展较少,故仅提供 SPC 自身运行的最小扩展组合的 `cli` 和 `micro`:[扩展组合 - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/)。
|
||||||
|
|
||||||
## 使用 static-php-cli 构建 PHP
|
## 使用 static-php-cli 构建 PHP
|
||||||
|
|
||||||
### 编译环境需求
|
### 编译环境需求
|
||||||
|
|
||||||
|
- PHP >= 8.1(这是 spc 自身需要的版本,不是支持的构建版本)
|
||||||
|
- 扩展:`mbstring,tokenizer,phar`
|
||||||
|
- 系统安装了 `curl` 和 `git`
|
||||||
|
|
||||||
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
|
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
|
||||||
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。
|
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含上面提到的扩展和 PHP 版本大于等于 8.1 即可。
|
||||||
|
|
||||||
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
|
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
|
||||||
|
|
||||||
| | x86_64 | aarch64 |
|
| | x86_64 | aarch64 |
|
||||||
|---------|----------------------|----------------------|
|
|---------|----------------------|----------------------|
|
||||||
| macOS | :octocat: :computer: | :computer: |
|
| macOS | :octocat: :computer: | :octocat: :computer: |
|
||||||
| Linux | :octocat: :computer: | :octocat: :computer: |
|
| Linux | :octocat: :computer: | :octocat: :computer: |
|
||||||
| Windows | | |
|
| Windows | :computer: | |
|
||||||
| FreeBSD | :computer: | :computer: |
|
| FreeBSD | :computer: | :computer: |
|
||||||
|
|
||||||
> macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。
|
当前支持编译的 PHP 版本:
|
||||||
|
|
||||||
目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。
|
> :warning: 支持,但可能不再提供修复
|
||||||
|
>
|
||||||
|
> :heavy_check_mark: 支持
|
||||||
|
>
|
||||||
|
> :x: 不支持
|
||||||
|
|
||||||
### 支持的扩展情况
|
| PHP Version | Status | Comment |
|
||||||
|
|-------------|--------------------|------------------------------|
|
||||||
|
| 7.2 | :x: | |
|
||||||
|
| 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
|
||||||
|
| 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
|
||||||
|
| 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 |
|
||||||
|
| 8.1 | :heavy_check_mark: | |
|
||||||
|
| 8.2 | :heavy_check_mark: | |
|
||||||
|
| 8.3 | :heavy_check_mark: | |
|
||||||
|
|
||||||
|
### 支持的扩展
|
||||||
|
|
||||||
请先根据下方扩展列表选择你要编译的扩展。
|
请先根据下方扩展列表选择你要编译的扩展。
|
||||||
|
|
||||||
@@ -62,7 +96,7 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
|||||||
|
|
||||||
> 如果这里没有你需要的扩展,可以提交 Issue。
|
> 如果这里没有你需要的扩展,可以提交 Issue。
|
||||||
|
|
||||||
### 使用 Actions 构建
|
### 在线构建(使用 GitHub Actions)
|
||||||
|
|
||||||
使用 GitHub Action 可以方便地构建一个静态编译的 PHP,同时可以自行定义要编译的扩展。
|
使用 GitHub Action 可以方便地构建一个静态编译的 PHP,同时可以自行定义要编译的扩展。
|
||||||
|
|
||||||
@@ -73,72 +107,85 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
|||||||
|
|
||||||
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
|
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
|
||||||
|
|
||||||
### 手动构建(使用 SPC 二进制)
|
### 本地构建(使用 spc 二进制)
|
||||||
|
|
||||||
本项目提供了一个 static-php-cli 的二进制文件,你可以直接下载对应平台的二进制文件,然后使用它来构建静态的 PHP。目前 `spc` 二进制支持的平台有 Linux 和 macOS。
|
该项目提供了 static-php-cli 的二进制文件:`spc`。
|
||||||
|
您可以使用 `spc` 二进制文件,无需安装任何运行时(用起来就像 golang 程序)。
|
||||||
|
目前,`spc` 二进制文件提供的平台有 Linux 和 macOS。
|
||||||
|
|
||||||
下面是从 GitHub Action 下载的方法:
|
使用以下命令从自托管服务器下载:
|
||||||
|
|
||||||
1. 进入 [GitHub Action](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
|
|
||||||
2. 选择一个最新的构建任务,进入后选择 `Artifacts`,下载对应平台的二进制文件。
|
|
||||||
3. 解压 `.zip` 文件。解压后,为其添加执行权限:`chmod +x ./spc`。
|
|
||||||
|
|
||||||
你也可以从自托管的服务器下载二进制文件:[进入](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/)。
|
|
||||||
|
|
||||||
### 手动构建(使用源码)
|
|
||||||
|
|
||||||
先克隆本项目:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Download from self-hosted nightly builds (sync with main branch)
|
||||||
|
# For Linux x86_64
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
|
||||||
|
# For Linux aarch64
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
|
||||||
|
# macOS x86_64 (Intel)
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
|
||||||
|
# macOS aarch64 (Apple)
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
|
||||||
|
# Windows (x86_64, win10 build 17063 or later)
|
||||||
|
curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
|
||||||
|
|
||||||
|
# Add execute perm (Linux and macOS only)
|
||||||
|
chmod +x ./spc
|
||||||
|
|
||||||
|
# Run (Linux and macOS)
|
||||||
|
./spc --version
|
||||||
|
# Run (Windows powershell)
|
||||||
|
.\spc.exe --version
|
||||||
|
```
|
||||||
|
|
||||||
|
自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
|
||||||
|
|
||||||
|
### 本地构建(使用 git 源码)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# clone 仓库即可
|
||||||
git clone https://github.com/crazywhalecc/static-php-cli.git
|
git clone https://github.com/crazywhalecc/static-php-cli.git
|
||||||
```
|
```
|
||||||
|
|
||||||
如果你本机没有安装 PHP,你需要先使用包管理(例如 brew、apt、yum、apk 等)安装 php。
|
如果您的系统上尚未安装 php,我们建议你使用内置的 setup-runtime 自动安装 PHP 和 Composer。
|
||||||
|
|
||||||
你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd static-php-cli
|
cd static-php-cli
|
||||||
chmod +x bin/setup-runtime
|
chmod +x bin/setup-runtime
|
||||||
./bin/setup-runtime
|
# it will download static php (from self-hosted server) and composer (from getcomposer)
|
||||||
|
bin/setup-runtime
|
||||||
# 使用独立的 php 运行 static-php-cli
|
# initialize composer deps
|
||||||
./bin/php bin/spc
|
bin/composer install
|
||||||
|
# chmod
|
||||||
# 使用 composer
|
|
||||||
./bin/php bin/composer
|
|
||||||
|
|
||||||
# 初始化本项目
|
|
||||||
cd static-php-cli
|
|
||||||
composer update
|
|
||||||
chmod +x bin/spc
|
chmod +x bin/spc
|
||||||
|
bin/spc --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 static-php-cli 命令行程序
|
### 开始构建 PHP
|
||||||
|
|
||||||
下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法:
|
下面是使用 static-php-cli 的基础用法:
|
||||||
|
|
||||||
> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `bin/spc` 替换为 `./spc`。
|
> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `./bin/spc` 替换为 `./spc`。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 检查环境依赖,并根据提示的命令安装缺失的编译工具
|
# 检查环境依赖,并根据尝试自动安装缺失的编译工具
|
||||||
./bin/spc doctor
|
./bin/spc doctor --auto-fix
|
||||||
|
|
||||||
# 拉取所有依赖库
|
# 拉取所有依赖库
|
||||||
./bin/spc fetch --all
|
./bin/spc download --all
|
||||||
# 只拉取编译指定扩展需要的所有依赖
|
# 只拉取编译指定扩展需要的所有依赖(推荐)
|
||||||
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
|
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
|
||||||
|
# 下载编译不同版本的 PHP (--with-php=x.y,推荐 7.3 ~ 8.3)
|
||||||
|
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
|
||||||
|
|
||||||
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
|
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
|
||||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
||||||
|
# 编译线程安全版本 (--enable-zts)
|
||||||
|
./bin/spc build "curl,phar" --enable-zts --build-cli
|
||||||
|
# 编译后使用 UPX 减小可执行文件体积 (--with-upx-pack) (至少压缩至原来的 30~50%)
|
||||||
|
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
|
||||||
```
|
```
|
||||||
|
|
||||||
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.2:
|
其中,目前支持构建 cli,micro,fpm 和 embed,使用以下参数的一个或多个来指定编译的 SAPI:
|
||||||
|
|
||||||
```bash
|
|
||||||
# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建
|
|
||||||
./bin/spc download --with-php=8.2 --all
|
|
||||||
```
|
|
||||||
|
|
||||||
其中,目前支持构建 cli,micro,fpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI:
|
|
||||||
|
|
||||||
- `--build-cli`:构建 cli 二进制
|
- `--build-cli`:构建 cli 二进制
|
||||||
- `--build-micro`:构建 phpmicro 自执行二进制
|
- `--build-micro`:构建 phpmicro 自执行二进制
|
||||||
@@ -149,18 +196,10 @@ chmod +x bin/spc
|
|||||||
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
|
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/spc build openssl,pcntl,mbstring --debug --build-all
|
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
|
||||||
./bin/spc fetch --all --debug
|
./bin/spc download --all --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本(ZTS),只需添加参数 `--enable-zts` 即可。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./bin/spc build openssl,pcntl --build-all --enable-zts
|
|
||||||
```
|
|
||||||
|
|
||||||
同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。
|
|
||||||
|
|
||||||
## 不同 SAPI 的使用
|
## 不同 SAPI 的使用
|
||||||
|
|
||||||
### 使用 cli
|
### 使用 cli
|
||||||
@@ -232,22 +271,21 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys
|
|||||||
|
|
||||||
另外,添加新扩展的贡献方式,可以参考下方 `进阶`。
|
另外,添加新扩展的贡献方式,可以参考下方 `进阶`。
|
||||||
|
|
||||||
如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。
|
如果你想贡献文档内容,请到项目仓库 [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) 贡献。
|
||||||
|
|
||||||
## 赞助本项目
|
## 赞助本项目
|
||||||
|
|
||||||
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。
|
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。你捐赠的一部分将会被用于维护 **static-php.dev** 服务器。
|
||||||
|
|
||||||
## 开源协议
|
## 开源协议
|
||||||
|
|
||||||
本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目:
|
本项目采用 MIT License 许可开源,下面是类似的项目:
|
||||||
|
|
||||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证)
|
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
|
||||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE)
|
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
|
||||||
|
|
||||||
|
该项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 中的一些代码,例如 Windows 静态构建目标和 libiconv 库支持。
|
||||||
|
lwmbs 使用 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可进行分发。对应文件有关于作者和许可的特殊说明,除此之外,均使用 MIT 授权许可。
|
||||||
|
|
||||||
因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
|
因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
|
||||||
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
|
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
|
||||||
|
|
||||||
## 进阶
|
|
||||||
|
|
||||||
本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。
|
|
||||||
|
|||||||
245
README.md
245
README.md
@@ -1,60 +1,99 @@
|
|||||||
# static-php-cli
|
# static-php-cli
|
||||||
|
|
||||||
Build single static PHP binary, with PHP project together, with popular extensions included.
|
[](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://static-php.dev/en/guide/extensions.html)
|
||||||
|
|
||||||
🌐 **[中文](README-zh.md)** | **[English](README.md)**
|
**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime
|
||||||
|
with popular extensions.
|
||||||
|
|
||||||
The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎
|
Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro` SAPI.
|
||||||
|
|
||||||
Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI)
|
**static-php-cli** also has the ability to package PHP projects
|
||||||
|
along with the PHP interpreter into one single executable file.
|
||||||
|
|
||||||
<img width="600" alt="2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
|
## Features
|
||||||
|
|
||||||
You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI)
|
static-php-cli (you can call it `spc`) has a lot of features:
|
||||||
|
|
||||||
<img width="600" alt="2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
- :handbag: Build single-file php executable, without any dependencies
|
||||||
|
- :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file)
|
||||||
|
- :pill: Automatic build environment checker (Doctor module)
|
||||||
|
- :zap: `Linux`, `macOS`, `FreeBSD`, `Windows` support
|
||||||
|
- :wrench: Configurable source code patches
|
||||||
|
- :books: Build dependency management
|
||||||
|
- 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box))
|
||||||
|
- :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html)
|
||||||
|
- :floppy_disk: UPX integration (significantly reduces binary size)
|
||||||
|
|
||||||
> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
|
**Single-file standalone php-cli:**
|
||||||
|
|
||||||
[]()
|
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
|
||||||
[]()
|
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
|
||||||
|
|
||||||
[]()
|
**Combine PHP code with PHP interpreter using phpmicro:**
|
||||||
[]()
|
|
||||||
|
|
||||||
## Docs
|
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
The current README contains basic usage. For all the features of static-php-cli,
|
The current README contains basic usage. For all the features of static-php-cli,
|
||||||
see <https://static-php.dev> .
|
see <https://static-php.dev> .
|
||||||
|
|
||||||
## Direct Download
|
## Direct Download
|
||||||
|
|
||||||
If you don't want to compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/)
|
If you don't want to build or want to test first, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml), or from self-hosted server.
|
||||||
|
|
||||||
> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
Below are several precompiled static-php binaries with different extension combinations,
|
||||||
|
which can be downloaded directly according to your needs.
|
||||||
|
|
||||||
## Use static-php-cli to build PHP
|
- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB.
|
||||||
|
- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size.
|
||||||
|
- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size.
|
||||||
|
|
||||||
|
For Windows systems, there are currently fewer extensions supported,
|
||||||
|
so only `cli` and `micro` that run the minimum extension combination of SPC itself are provided: [Extension-Combination - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/).
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
### Compilation Requirements
|
### Compilation Requirements
|
||||||
|
|
||||||
Yes, this project is written in PHP, pretty funny.
|
You can say I made a PHP builder written in PHP, pretty funny.
|
||||||
But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension.
|
But static-php-cli runtime only requires an environment above PHP 8.1 and extensions mentioned below.
|
||||||
|
|
||||||
Here is the architecture support status, where :octocat: represents support for GitHub Action builds,
|
- PHP >= 8.1 (This is the version required by spc itself, not the build version)
|
||||||
|
- Extension: `mbstring,tokenizer,phar`
|
||||||
|
- Supported OS with `curl` and `git` installed
|
||||||
|
|
||||||
|
Here is the supported OS and arch, where :octocat: represents support for GitHub Action builds,
|
||||||
:computer: represents support for local manual builds, and blank represents not currently supported.
|
:computer: represents support for local manual builds, and blank represents not currently supported.
|
||||||
|
|
||||||
| | x86_64 | aarch64 |
|
| | x86_64 | aarch64 |
|
||||||
|---------|----------------------|----------------------|
|
|---------|----------------------|----------------------|
|
||||||
| macOS | :octocat: :computer: | :computer: |
|
| macOS | :octocat: :computer: | :octocat: :computer: |
|
||||||
| Linux | :octocat: :computer: | :octocat: :computer: |
|
| Linux | :octocat: :computer: | :octocat: :computer: |
|
||||||
| Windows | | |
|
| Windows | :computer: | |
|
||||||
| FreeBSD | :computer: | :computer: |
|
| FreeBSD | :computer: | :computer: |
|
||||||
|
|
||||||
> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine.
|
Currently supported PHP versions for compilation:
|
||||||
|
|
||||||
Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`.
|
> :warning: supported but not maintained
|
||||||
|
>
|
||||||
|
> :heavy_check_mark: supported
|
||||||
|
>
|
||||||
|
> :x: not supported
|
||||||
|
|
||||||
|
| PHP Version | Status | Comment |
|
||||||
|
|-------------|--------------------|---------------------------------------------------|
|
||||||
|
| 7.2 | :x: | |
|
||||||
|
| 7.3 | :warning: | phpmicro and some extensions not supported on 7.x |
|
||||||
|
| 7.4 | :warning: | phpmicro and some extensions not supported on 7.x |
|
||||||
|
| 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 |
|
||||||
|
| 8.1 | :heavy_check_mark: | |
|
||||||
|
| 8.2 | :heavy_check_mark: | |
|
||||||
|
| 8.3 | :heavy_check_mark: | |
|
||||||
|
|
||||||
### Supported Extensions
|
### Supported Extensions
|
||||||
|
|
||||||
@@ -65,7 +104,9 @@ Please first select the extension you want to compile based on the extension lis
|
|||||||
|
|
||||||
> If an extension you need is missing, you can submit an issue.
|
> If an extension you need is missing, you can submit an issue.
|
||||||
|
|
||||||
### GitHub Actions Build
|
Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) .
|
||||||
|
|
||||||
|
### Build Online (using GitHub Actions)
|
||||||
|
|
||||||
Use GitHub Action to easily build a statically compiled PHP,
|
Use GitHub Action to easily build a statically compiled PHP,
|
||||||
and at the same time define the extensions to be compiled by yourself.
|
and at the same time define the extensions to be compiled by yourself.
|
||||||
@@ -77,81 +118,85 @@ and at the same time define the extensions to be compiled by yourself.
|
|||||||
|
|
||||||
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
|
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
|
||||||
|
|
||||||
- When using ubuntu-latest, it will build linux-x86_64 binary.
|
### Build Locally (using SPC binary)
|
||||||
- When using macos-latest, it will build macOS-x86_64 binary.
|
|
||||||
|
|
||||||
### Manual build (using SPC binary)
|
This project provides a binary file of static-php-cli: `spc`.
|
||||||
|
You can use `spc` binary instead of installing any runtime like golang app.
|
||||||
This project provides a binary file of static-php-cli.
|
|
||||||
You can directly download the binary file of the corresponding platform and then use it to build static PHP.
|
|
||||||
Currently, the platforms supported by `spc` binary are Linux and macOS.
|
Currently, the platforms supported by `spc` binary are Linux and macOS.
|
||||||
|
|
||||||
Here's how to download from GitHub Actions:
|
Download from self-hosted nightly builds using commands below:
|
||||||
|
|
||||||
1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml).
|
|
||||||
2. Select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform.
|
|
||||||
3. Unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`.
|
|
||||||
|
|
||||||
You can also download binaries from a self-hosted server: [enter](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/).
|
|
||||||
|
|
||||||
> SPC single-file binary is built by phpmicro and box.
|
|
||||||
|
|
||||||
### Manual build (using source code)
|
|
||||||
|
|
||||||
Clone repo first:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Download from self-hosted nightly builds (sync with main branch)
|
||||||
|
# For Linux x86_64
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
|
||||||
|
# For Linux aarch64
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
|
||||||
|
# macOS x86_64 (Intel)
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
|
||||||
|
# macOS aarch64 (Apple)
|
||||||
|
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
|
||||||
|
# Windows (x86_64, win10 build 17063 or later)
|
||||||
|
curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
|
||||||
|
|
||||||
|
# Add execute perm (Linux and macOS only)
|
||||||
|
chmod +x ./spc
|
||||||
|
|
||||||
|
# Run (Linux and macOS)
|
||||||
|
./spc --version
|
||||||
|
# Run (Windows powershell)
|
||||||
|
.\spc.exe --version
|
||||||
|
```
|
||||||
|
|
||||||
|
Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml).
|
||||||
|
|
||||||
|
### Build Locally (using git source)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# just clone me!
|
||||||
git clone https://github.com/crazywhalecc/static-php-cli.git
|
git clone https://github.com/crazywhalecc/static-php-cli.git
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.).
|
If you have not installed php on your system, we recommend that you use the built-in setup-runtime to install PHP and Composer automatically.
|
||||||
|
|
||||||
And you can also download single-file php binary and composer using command `bin/setup-runtime`.
|
|
||||||
The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd static-php-cli
|
cd static-php-cli
|
||||||
chmod +x bin/setup-runtime
|
chmod +x bin/setup-runtime
|
||||||
# It will download php-cli from self-hosted server and composer from getcomposer.org
|
# it will download static php (from self-hosted server) and composer (from getcomposer)
|
||||||
./bin/setup-runtime
|
bin/setup-runtime
|
||||||
|
# initialize composer deps
|
||||||
# Use this php runtime to run static-php-cli compiler
|
bin/composer install
|
||||||
./bin/php bin/spc
|
# chmod
|
||||||
|
|
||||||
# Use composer
|
|
||||||
./bin/php bin/composer
|
|
||||||
|
|
||||||
# Initialize this project
|
|
||||||
cd static-php-cli
|
|
||||||
composer update
|
|
||||||
chmod +x bin/spc
|
chmod +x bin/spc
|
||||||
|
bin/spc --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use static-php-cli
|
### Start Building PHP
|
||||||
|
|
||||||
Basic usage for building php and micro with some extensions:
|
Basic usage for building php with some extensions:
|
||||||
|
|
||||||
> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands.
|
> If you are using the packaged standalone `spc` binary, you need to replace `bin/spc` with `./spc` or `.\spc.exe` in the following commands.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check system tool dependencies, fix them automatically
|
# Check system tool dependencies, auto-fix them if possible
|
||||||
./bin/spc doctor
|
./bin/spc doctor --auto-fix
|
||||||
|
|
||||||
# fetch all libraries
|
# fetch all libraries
|
||||||
./bin/spc download --all
|
./bin/spc download --all
|
||||||
# only fetch necessary sources by needed extensions
|
# only fetch necessary sources by needed extensions (recommended)
|
||||||
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
|
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
|
||||||
|
# download different PHP version (--with-php=x.y, recommend 7.3 ~ 8.3)
|
||||||
|
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
|
||||||
|
|
||||||
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
|
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
|
||||||
./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro
|
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
||||||
|
# build thread-safe (ZTS) version (--enable-zts)
|
||||||
|
./bin/spc build "curl,phar" --enable-zts --build-cli
|
||||||
|
# build, pack executable with UPX (--with-upx-pack) (reduce binary size for 30~50%)
|
||||||
|
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2:
|
Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more of the following parameters to specify the compiled SAPI:
|
||||||
|
|
||||||
```bash
|
|
||||||
# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro
|
|
||||||
./bin/spc fetch --with-php=8.2 --all
|
|
||||||
```
|
|
||||||
|
|
||||||
Now we support `cli`, `micro`, `fpm`, you can use one or more of the following parameters to specify the compiled SAPI:
|
|
||||||
|
|
||||||
- `--build-cli`: build static cli executable
|
- `--build-cli`: build static cli executable
|
||||||
- `--build-micro`: build static phpmicro self-extracted executable
|
- `--build-micro`: build static phpmicro self-extracted executable
|
||||||
@@ -162,18 +207,10 @@ Now we support `cli`, `micro`, `fpm`, you can use one or more of the following p
|
|||||||
If anything goes wrong, use `--debug` option to display full terminal output:
|
If anything goes wrong, use `--debug` option to display full terminal output:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/spc build openssl,pcntl,mbstring --debug --build-all
|
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
|
||||||
./bin/spc fetch --all --debug
|
./bin/spc download --all --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./bin/spc build openssl,pcntl --build-all --enable-zts
|
|
||||||
```
|
|
||||||
|
|
||||||
Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary.
|
|
||||||
|
|
||||||
## Different SAPI Usage
|
## Different SAPI Usage
|
||||||
|
|
||||||
### Use cli
|
### Use cli
|
||||||
@@ -197,7 +234,7 @@ cd buildroot/bin/
|
|||||||
|
|
||||||
> phpmicro is a SelF-extracted eXecutable SAPI module,
|
> phpmicro is a SelF-extracted eXecutable SAPI module,
|
||||||
> provided by [phpmicro](https://github.com/dixyes/phpmicro) project.
|
> provided by [phpmicro](https://github.com/dixyes/phpmicro) project.
|
||||||
> But this project is using a [fork](https://github.com/crazywhalecc/phpmicro) of phpmicro, because we need to add some features to it.
|
> But this project is using a [fork](https://github.com/static-php/phpmicro) of phpmicro, because we need to add some features to it.
|
||||||
> It can put php runtime and your source code together.
|
> It can put php runtime and your source code together.
|
||||||
|
|
||||||
When using the parameter `--build-all` or `--build-micro`,
|
When using the parameter `--build-all` or `--build-micro`,
|
||||||
@@ -227,7 +264,7 @@ cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app
|
|||||||
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
|
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
|
||||||
```
|
```
|
||||||
|
|
||||||
> In some cases, PHAR files may not run in a micro environment.
|
> In some cases, PHAR files may not run in a micro environment. Overall, micro is not production ready.
|
||||||
|
|
||||||
### Use fpm
|
### Use fpm
|
||||||
|
|
||||||
@@ -235,7 +272,7 @@ When using the parameter `--build-all` or `--build-fpm`,
|
|||||||
the final compilation result will output a file named `./php-fpm`,
|
the final compilation result will output a file named `./php-fpm`,
|
||||||
This file will be located in the path `buildroot/bin/`, simply copy it out for use.
|
This file will be located in the path `buildroot/bin/`, simply copy it out for use.
|
||||||
|
|
||||||
In normal Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm.
|
In common Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm.
|
||||||
Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself.
|
Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself.
|
||||||
|
|
||||||
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
|
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
|
||||||
@@ -257,25 +294,27 @@ For an advanced example of how to use this feature, take a look at [how to use i
|
|||||||
If the extension you need is missing, you can create an issue.
|
If the extension you need is missing, you can create an issue.
|
||||||
If you are familiar with this project, you are also welcome to initiate a pull request.
|
If you are familiar with this project, you are also welcome to initiate a pull request.
|
||||||
|
|
||||||
If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs).
|
If you want to contribute documentation, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs).
|
||||||
|
|
||||||
Part of the English document is written by me, and part is translated by Google,
|
|
||||||
and there may be inaccurate descriptions, strange or offensive expressions.
|
|
||||||
If you are a native English speaker, some corrections to the documentation are welcome.
|
|
||||||
|
|
||||||
|
Now there is a [static-php](https://github.com/static-php) organization, which is used to store the repo related to the project.
|
||||||
|
|
||||||
## Sponsor this project
|
## Sponsor this project
|
||||||
|
|
||||||
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md).
|
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). A portion of your donation will be used to maintain the **static-php.dev** server.
|
||||||
|
|
||||||
## Open-Source License
|
## Open-Source License
|
||||||
|
|
||||||
This project itself is based on MIT License,
|
This project itself is based on MIT License,
|
||||||
some newly added extensions and dependencies may originate from the following projects (including but not limited to),
|
some newly added extensions and dependencies may originate from the the other projects,
|
||||||
and the headers of these code files will also be given additional instructions LICENSE and AUTHOR:
|
and the headers of these code files will also be given additional instructions LICENSE and AUTHOR.
|
||||||
|
|
||||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License)
|
These are similar projects:
|
||||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE)
|
|
||||||
|
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
|
||||||
|
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
|
||||||
|
|
||||||
|
The project uses some code from [dixyes/lwmbs](https://github.com/dixyes/lwmbs), such as windows static build target and libiconv support.
|
||||||
|
lwmbs is licensed under the [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2).
|
||||||
|
|
||||||
Due to the special nature of this project,
|
Due to the special nature of this project,
|
||||||
many other open source projects such as curl and protobuf will be used during the project compilation process,
|
many other open source projects such as curl and protobuf will be used during the project compilation process,
|
||||||
@@ -283,9 +322,3 @@ and they all have their own open source licenses.
|
|||||||
|
|
||||||
Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation,
|
Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation,
|
||||||
and comply with the corresponding project's LICENSE.
|
and comply with the corresponding project's LICENSE.
|
||||||
|
|
||||||
## Advanced
|
|
||||||
|
|
||||||
The refactoring branch of this project is written modularly.
|
|
||||||
If you are interested in this project and want to join the development,
|
|
||||||
you can refer to the [Contribution Guide](https://static-php.dev) of the documentation to contribute code or documentation.
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
|
|||||||
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
|
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
|
||||||
|
|
||||||
# set download dir
|
# set download dir
|
||||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||||
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||||
|
|
||||||
# use china mirror
|
# use china mirror
|
||||||
@@ -35,7 +35,6 @@ while [ $# -gt 0 ]; do
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
--mirror)
|
--mirror)
|
||||||
mirror="$2"
|
mirror="$2"
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
echo "Illegal option $1"
|
echo "Illegal option $1"
|
||||||
@@ -46,8 +45,8 @@ done
|
|||||||
|
|
||||||
case "$mirror" in
|
case "$mirror" in
|
||||||
china)
|
china)
|
||||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||||
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|||||||
115
bin/setup-runtime.ps1
Normal file
115
bin/setup-runtime.ps1
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
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
|
||||||
|
$API = (Invoke-WebRequest -Uri "https://www.php.net/releases/index.php?json&version=8.1") | ConvertFrom-Json
|
||||||
|
|
||||||
|
# php windows download
|
||||||
|
$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/php-" + $API.version + "-Win32-vs16-x64.zip"
|
||||||
|
$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."
|
||||||
9
bin/spc
9
bin/spc
@@ -4,7 +4,13 @@
|
|||||||
use SPC\ConsoleApplication;
|
use SPC\ConsoleApplication;
|
||||||
use SPC\exception\ExceptionHandler;
|
use SPC\exception\ExceptionHandler;
|
||||||
|
|
||||||
require_once __DIR__ . '/../vendor/autoload.php';
|
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
|
||||||
|
// Current: ./bin (git/project mode)
|
||||||
|
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
} else {
|
||||||
|
// Current: ./vendor/crazywhalecc/static-php-cli/bin (composer library mode)
|
||||||
|
require_once dirname(__DIR__, 3) . '/autoload.php';
|
||||||
|
}
|
||||||
|
|
||||||
// 防止 Micro 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?)
|
// 防止 Micro 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?)
|
||||||
if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {
|
if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {
|
||||||
@@ -15,4 +21,5 @@ try {
|
|||||||
(new ConsoleApplication())->run();
|
(new ConsoleApplication())->run();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
ExceptionHandler::getInstance()->handle($e);
|
ExceptionHandler::getInstance()->handle($e);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ RUN apk update; \
|
|||||||
git \
|
git \
|
||||||
jq \
|
jq \
|
||||||
libgcc \
|
libgcc \
|
||||||
|
libtool \
|
||||||
libstdc++ \
|
libstdc++ \
|
||||||
linux-headers \
|
linux-headers \
|
||||||
m4 \
|
m4 \
|
||||||
|
|||||||
11
bin/spc.ps1
Normal file
11
bin/spc.ps1
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
$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
|
||||||
1
box.json
1
box.json
@@ -14,6 +14,5 @@
|
|||||||
"vendor/zhamao"
|
"vendor/zhamao"
|
||||||
],
|
],
|
||||||
"git-commit-short": "git_commit_short",
|
"git-commit-short": "git_commit_short",
|
||||||
"metadata": "ConsoleApplication::VERSION",
|
|
||||||
"output": "spc.phar"
|
"output": "spc.phar"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">= 8.1",
|
"php": ">= 8.1",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-pcntl": "*",
|
|
||||||
"laravel/prompts": "^0.1.12",
|
"laravel/prompts": "^0.1.12",
|
||||||
"symfony/console": "^5.4 || ^6 || ^7",
|
"symfony/console": "^5.4 || ^6 || ^7",
|
||||||
"zhamao/logger": "^1.0"
|
"zhamao/logger": "^1.0"
|
||||||
@@ -20,10 +19,10 @@
|
|||||||
"captainhook/captainhook": "^5.10",
|
"captainhook/captainhook": "^5.10",
|
||||||
"captainhook/plugin-composer": "^5.3",
|
"captainhook/plugin-composer": "^5.3",
|
||||||
"friendsofphp/php-cs-fixer": "^3.25",
|
"friendsofphp/php-cs-fixer": "^3.25",
|
||||||
"humbug/box": "^4.3",
|
"humbug/box": "^4.5",
|
||||||
"nunomaduro/collision": "^7.8",
|
"nunomaduro/collision": "^7.8",
|
||||||
"phpstan/phpstan": "^1.10",
|
"phpstan/phpstan": "^1.10",
|
||||||
"phpunit/phpunit": "^10.3"
|
"phpunit/phpunit": "^10.3 || ^9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
1267
composer.lock
generated
1267
composer.lock
generated
File diff suppressed because it is too large
Load Diff
193
config/ext.json
193
config/ext.json
@@ -1,4 +1,15 @@
|
|||||||
{
|
{
|
||||||
|
"amqp": {
|
||||||
|
"type": "external",
|
||||||
|
"arg-type": "custom",
|
||||||
|
"source": "amqp",
|
||||||
|
"lib-depends": [
|
||||||
|
"librabbitmq"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"openssl"
|
||||||
|
]
|
||||||
|
},
|
||||||
"apcu": {
|
"apcu": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "apcu"
|
"source": "apcu"
|
||||||
@@ -24,6 +35,10 @@
|
|||||||
"arg-type": "with",
|
"arg-type": "with",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"curl"
|
"curl"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"zlib",
|
||||||
|
"openssl"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dba": {
|
"dba": {
|
||||||
@@ -59,8 +74,11 @@
|
|||||||
"ffi": {
|
"ffi": {
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"lib-depends": [
|
"lib-depends-unix": [
|
||||||
"libffi"
|
"libffi"
|
||||||
|
],
|
||||||
|
"lib-depends-windows": [
|
||||||
|
"libffi-win"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fileinfo": {
|
"fileinfo": {
|
||||||
@@ -95,7 +113,7 @@
|
|||||||
},
|
},
|
||||||
"gettext": {
|
"gettext": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with",
|
"arg-type": "with-prefix",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"gettext"
|
"gettext"
|
||||||
]
|
]
|
||||||
@@ -106,7 +124,8 @@
|
|||||||
"source": "ext-glfw",
|
"source": "ext-glfw",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"glfw"
|
"glfw"
|
||||||
]
|
],
|
||||||
|
"lib-depends-windows": []
|
||||||
},
|
},
|
||||||
"gmp": {
|
"gmp": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
@@ -118,10 +137,18 @@
|
|||||||
"iconv": {
|
"iconv": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with-prefix",
|
"arg-type": "with-prefix",
|
||||||
"lib-depends-windows": [
|
"arg-type-windows": "with",
|
||||||
|
"lib-depends-unix": [
|
||||||
"libiconv"
|
"libiconv"
|
||||||
|
],
|
||||||
|
"lib-depends-windows": [
|
||||||
|
"libiconv-win"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"igbinary": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "igbinary"
|
||||||
|
},
|
||||||
"imagick": {
|
"imagick": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "ext-imagick",
|
"source": "ext-imagick",
|
||||||
@@ -132,12 +159,12 @@
|
|||||||
},
|
},
|
||||||
"imap": {
|
"imap": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with",
|
"arg-type": "custom",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"imap"
|
"imap"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-suggests": [
|
||||||
"kerberos"
|
"openssl"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"inotify": {
|
"inotify": {
|
||||||
@@ -169,14 +196,14 @@
|
|||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"mbstring"
|
"mbstring"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"onig"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mbstring": {
|
"mbstring": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom"
|
||||||
"lib-depends": [
|
|
||||||
"onig"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"memcache": {
|
"memcache": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
@@ -228,18 +255,28 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"opcache": {
|
"opcache": {
|
||||||
"type": "builtin"
|
"type": "builtin",
|
||||||
|
"arg-type": "custom"
|
||||||
},
|
},
|
||||||
"openssl": {
|
"openssl": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
|
"arg-type-windows": "with",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"openssl"
|
"openssl",
|
||||||
|
"zlib"
|
||||||
],
|
],
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"password-argon2": {
|
||||||
|
"type": "builtin",
|
||||||
|
"arg-type": "with-prefix",
|
||||||
|
"lib-depends": [
|
||||||
|
"libargon2"
|
||||||
|
]
|
||||||
|
},
|
||||||
"pcntl": {
|
"pcntl": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"unix-only": true
|
"unix-only": true
|
||||||
@@ -298,12 +335,10 @@
|
|||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "protobuf"
|
"source": "protobuf"
|
||||||
},
|
},
|
||||||
"pspell": {
|
"rar": {
|
||||||
"type": "builtin",
|
"type": "external",
|
||||||
"arg-type": "with",
|
"source": "rar",
|
||||||
"lib-depends": [
|
"cpp-extension": true
|
||||||
"aspell"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"readline": {
|
"readline": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
@@ -317,7 +352,12 @@
|
|||||||
"source": "redis",
|
"source": "redis",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"ext-suggests": [
|
"ext-suggests": [
|
||||||
"session"
|
"session",
|
||||||
|
"igbinary"
|
||||||
|
],
|
||||||
|
"lib-suggests": [
|
||||||
|
"zstd",
|
||||||
|
"liblz4"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"session": {
|
"session": {
|
||||||
@@ -329,9 +369,11 @@
|
|||||||
"simplexml": {
|
"simplexml": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"arg-type-windows": "with",
|
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"xml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"snappy": {
|
"snappy": {
|
||||||
@@ -346,18 +388,14 @@
|
|||||||
"apcu"
|
"apcu"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"snmp": {
|
|
||||||
"type": "builtin",
|
|
||||||
"arg-type": "with",
|
|
||||||
"lib-depends": [
|
|
||||||
"net-snmp"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"soap": {
|
"soap": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"xml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sockets": {
|
"sockets": {
|
||||||
@@ -373,16 +411,33 @@
|
|||||||
"sqlite3": {
|
"sqlite3": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with-prefix",
|
"arg-type": "with-prefix",
|
||||||
|
"arg-type-windows": "with",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"sqlite"
|
"sqlite"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"sqlsrv": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "sqlsrv",
|
||||||
|
"lib-depends": [
|
||||||
|
"unixodbc"
|
||||||
|
],
|
||||||
|
"ext-depends-linux": [
|
||||||
|
"pcntl"
|
||||||
|
],
|
||||||
|
"cpp-extension": true
|
||||||
|
},
|
||||||
"ssh2": {
|
"ssh2": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "ext-ssh2",
|
"source": "ext-ssh2",
|
||||||
"arg-type": "with-prefix",
|
"arg-type": "with-prefix",
|
||||||
|
"arg-type-windows": "with",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libssh2"
|
"libssh2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"openssl",
|
||||||
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"swoole": {
|
"swoole": {
|
||||||
@@ -390,17 +445,50 @@
|
|||||||
"source": "swoole",
|
"source": "swoole",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"cpp-extension": true,
|
"cpp-extension": true,
|
||||||
|
"unix-only": true,
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"openssl"
|
"libcares",
|
||||||
|
"brotli",
|
||||||
|
"nghttp2",
|
||||||
|
"zlib"
|
||||||
],
|
],
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"openssl"
|
"openssl",
|
||||||
|
"curl"
|
||||||
],
|
],
|
||||||
"ext-suggests": [
|
"ext-suggests": [
|
||||||
"curl",
|
"swoole-hook-pgsql",
|
||||||
"pgsql"
|
"swoole-hook-mysql",
|
||||||
|
"swoole-hook-sqlite"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"swoole-hook-mysql": {
|
||||||
|
"type": "addon",
|
||||||
|
"arg-type": "custom",
|
||||||
|
"ext-depends": [
|
||||||
|
"mysqlnd",
|
||||||
|
"pdo",
|
||||||
|
"pdo_mysql"
|
||||||
],
|
],
|
||||||
"unix-only": true
|
"ext-suggests": [
|
||||||
|
"mysqli"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"swoole-hook-pgsql": {
|
||||||
|
"type": "addon",
|
||||||
|
"arg-type": "custom",
|
||||||
|
"ext-depends": [
|
||||||
|
"pgsql",
|
||||||
|
"pdo"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"swoole-hook-sqlite": {
|
||||||
|
"type": "addon",
|
||||||
|
"arg-type": "custom",
|
||||||
|
"ext-depends": [
|
||||||
|
"sqlite3",
|
||||||
|
"pdo"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"swow": {
|
"swow": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
@@ -424,12 +512,11 @@
|
|||||||
"unix-only": true
|
"unix-only": true
|
||||||
},
|
},
|
||||||
"sysvshm": {
|
"sysvshm": {
|
||||||
"type": "builtin",
|
"type": "builtin"
|
||||||
"unix-only": true
|
|
||||||
},
|
},
|
||||||
"tidy": {
|
"tidy": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with",
|
"arg-type": "with-prefix",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"tidy"
|
"tidy"
|
||||||
]
|
]
|
||||||
@@ -437,6 +524,32 @@
|
|||||||
"tokenizer": {
|
"tokenizer": {
|
||||||
"type": "builtin"
|
"type": "builtin"
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "ext-uuid",
|
||||||
|
"arg-type": "with-prefix",
|
||||||
|
"lib-depends": [
|
||||||
|
"libuuid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"uv": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "ext-uv",
|
||||||
|
"arg-type": "with-prefix",
|
||||||
|
"lib-depends": [
|
||||||
|
"libuv"
|
||||||
|
],
|
||||||
|
"ext-depends": [
|
||||||
|
"sockets"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"xhprof": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "xhprof",
|
||||||
|
"ext-depends": [
|
||||||
|
"ctype"
|
||||||
|
]
|
||||||
|
},
|
||||||
"xlswriter": {
|
"xlswriter": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "xlswriter",
|
"source": "xlswriter",
|
||||||
@@ -452,6 +565,9 @@
|
|||||||
"arg-type-windows": "with",
|
"arg-type-windows": "with",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"iconv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xmlreader": {
|
"xmlreader": {
|
||||||
@@ -459,6 +575,10 @@
|
|||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"xml",
|
||||||
|
"dom"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xmlwriter": {
|
"xmlwriter": {
|
||||||
@@ -466,6 +586,9 @@
|
|||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
|
],
|
||||||
|
"ext-depends-windows": [
|
||||||
|
"xml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"xsl": {
|
"xsl": {
|
||||||
|
|||||||
192
config/lib.json
192
config/lib.json
@@ -2,14 +2,14 @@
|
|||||||
"brotli": {
|
"brotli": {
|
||||||
"source": "brotli",
|
"source": "brotli",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libbrotlidec-static.a",
|
"libbrotlidec.a",
|
||||||
"libbrotlienc-static.a",
|
"libbrotlienc.a",
|
||||||
"libbrotlicommon-static.a"
|
"libbrotlicommon.a"
|
||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
"brotlicommon-static.lib",
|
"brotlicommon.lib",
|
||||||
"brotlienc-static.lib",
|
"brotlienc.lib",
|
||||||
"brotlidec-static.lib"
|
"brotlidec.lib"
|
||||||
],
|
],
|
||||||
"headers": [
|
"headers": [
|
||||||
"brotli"
|
"brotli"
|
||||||
@@ -45,21 +45,21 @@
|
|||||||
"openssl",
|
"openssl",
|
||||||
"zlib"
|
"zlib"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-depends-windows": [
|
||||||
|
"openssl",
|
||||||
|
"zlib",
|
||||||
|
"libssh2",
|
||||||
|
"nghttp2"
|
||||||
|
],
|
||||||
|
"lib-suggests-unix": [
|
||||||
"libssh2",
|
"libssh2",
|
||||||
"brotli",
|
"brotli",
|
||||||
"nghttp2",
|
"nghttp2",
|
||||||
"zstd"
|
"zstd"
|
||||||
],
|
],
|
||||||
"lib-suggests-windows": [
|
"lib-suggests-windows": [
|
||||||
"zlib",
|
|
||||||
"libssh2",
|
|
||||||
"brotli",
|
"brotli",
|
||||||
"nghttp2",
|
"zstd"
|
||||||
"zstd",
|
|
||||||
"openssl",
|
|
||||||
"idn2",
|
|
||||||
"psl"
|
|
||||||
],
|
],
|
||||||
"frameworks": [
|
"frameworks": [
|
||||||
"CoreFoundation",
|
"CoreFoundation",
|
||||||
@@ -85,6 +85,22 @@
|
|||||||
"brotli"
|
"brotli"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"gettext": {
|
||||||
|
"source": "gettext",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libintl.a"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"libiconv"
|
||||||
|
],
|
||||||
|
"lib-suggests": [
|
||||||
|
"ncurses",
|
||||||
|
"libxml2"
|
||||||
|
],
|
||||||
|
"frameworks": [
|
||||||
|
"CoreFoundation"
|
||||||
|
]
|
||||||
|
},
|
||||||
"glfw": {
|
"glfw": {
|
||||||
"source": "ext-glfw",
|
"source": "ext-glfw",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -131,7 +147,8 @@
|
|||||||
"libpng",
|
"libpng",
|
||||||
"libjpeg",
|
"libjpeg",
|
||||||
"libwebp",
|
"libwebp",
|
||||||
"freetype"
|
"freetype",
|
||||||
|
"libtiff"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-suggests": [
|
||||||
"zstd",
|
"zstd",
|
||||||
@@ -141,24 +158,52 @@
|
|||||||
"libxml2"
|
"libxml2"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"imap": {
|
||||||
|
"source": "imap",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libc-client.a"
|
||||||
|
],
|
||||||
|
"lib-suggests": [
|
||||||
|
"openssl"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ldap": {
|
"ldap": {
|
||||||
"source": "ldap",
|
"source": "ldap",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"liblber.a",
|
"liblber.a",
|
||||||
"libldap.a"
|
"libldap.a"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-depends": [
|
||||||
"openssl",
|
"openssl",
|
||||||
|
"zlib",
|
||||||
"gmp",
|
"gmp",
|
||||||
"libsodium"
|
"libsodium"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libargon2": {
|
||||||
|
"source": "libargon2",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libargon2.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libavif": {
|
"libavif": {
|
||||||
"source": "libavif",
|
"source": "libavif",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libavif.a"
|
"libavif.a"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libcares": {
|
||||||
|
"source": "libcares",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libcares.a"
|
||||||
|
],
|
||||||
|
"headers-unix": [
|
||||||
|
"ares.h",
|
||||||
|
"ares_dns.h",
|
||||||
|
"ares_nameser.h",
|
||||||
|
"ares_rules.h"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libevent": {
|
"libevent": {
|
||||||
"source": "libevent",
|
"source": "libevent",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -189,6 +234,17 @@
|
|||||||
"ffitarget.h"
|
"ffitarget.h"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libffi-win": {
|
||||||
|
"source": "libffi-win",
|
||||||
|
"static-libs-windows": [
|
||||||
|
"libffi.lib"
|
||||||
|
],
|
||||||
|
"headers-windows": [
|
||||||
|
"ffi.h",
|
||||||
|
"ffitarget.h",
|
||||||
|
"fficonfig.h"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libiconv": {
|
"libiconv": {
|
||||||
"source": "libiconv",
|
"source": "libiconv",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -201,6 +257,13 @@
|
|||||||
"localcharset.h"
|
"localcharset.h"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libiconv-win": {
|
||||||
|
"source": "libiconv-win",
|
||||||
|
"static-libs-windows": [
|
||||||
|
"libiconv.lib",
|
||||||
|
"libiconv_a.lib"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libjpeg": {
|
"libjpeg": {
|
||||||
"source": "libjpeg",
|
"source": "libjpeg",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -208,10 +271,10 @@
|
|||||||
"libturbojpeg.a"
|
"libturbojpeg.a"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"libmcrypt": {
|
"liblz4": {
|
||||||
"source": "libmcrypt",
|
"source": "liblz4",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libmcrypt.a"
|
"liblz4.a"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"libmemcached": {
|
"libmemcached": {
|
||||||
@@ -242,6 +305,18 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"librabbitmq": {
|
||||||
|
"source": "librabbitmq",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"librabbitmq.a"
|
||||||
|
],
|
||||||
|
"static-libs-windows": [
|
||||||
|
"rabbitmq.4.lib"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"openssl"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libsodium": {
|
"libsodium": {
|
||||||
"source": "libsodium",
|
"source": "libsodium",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -268,6 +343,24 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libtiff": {
|
||||||
|
"source": "libtiff",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libtiff.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"libuuid": {
|
||||||
|
"source": "libuuid",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libuuid.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"libuv": {
|
||||||
|
"source": "libuv",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libuv.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libwebp": {
|
"libwebp": {
|
||||||
"source": "libwebp",
|
"source": "libwebp",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -284,26 +377,25 @@
|
|||||||
"libxml2.a"
|
"libxml2.a"
|
||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
[
|
|
||||||
"libxml2s.lib",
|
"libxml2s.lib",
|
||||||
"libxml2_a.lib"
|
"libxml2_a.lib"
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"headers": [
|
"headers": [
|
||||||
"libxml2"
|
"libxml2"
|
||||||
],
|
],
|
||||||
"lib-depends": [
|
"lib-depends-unix": [
|
||||||
"libiconv",
|
"libiconv"
|
||||||
|
],
|
||||||
|
"lib-suggests-unix": [
|
||||||
|
"xz",
|
||||||
|
"icu",
|
||||||
"zlib"
|
"zlib"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-depends-windows": [
|
||||||
"xz",
|
"libiconv-win"
|
||||||
"icu"
|
|
||||||
],
|
],
|
||||||
"lib-suggests-windows": [
|
"lib-suggests-windows": [
|
||||||
"icu",
|
"zlib"
|
||||||
"xz",
|
|
||||||
"pthreads4w"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"libxslt": {
|
"libxslt": {
|
||||||
@@ -353,12 +445,6 @@
|
|||||||
"openssl"
|
"openssl"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mcrypt": {
|
|
||||||
"source": "mcrypt",
|
|
||||||
"static-libs-unix": [
|
|
||||||
"libmcrypt.a"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ncurses": {
|
"ncurses": {
|
||||||
"source": "ncurses",
|
"source": "ncurses",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -390,10 +476,8 @@
|
|||||||
"libonig.a"
|
"libonig.a"
|
||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
[
|
|
||||||
"onig.lib",
|
"onig.lib",
|
||||||
"onig_a.lib"
|
"onig_a.lib"
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"headers": [
|
"headers": [
|
||||||
"oniggnu.h",
|
"oniggnu.h",
|
||||||
@@ -441,18 +525,6 @@
|
|||||||
"zstd"
|
"zstd"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"pthreads4w": {
|
|
||||||
"source": "pthreads4w",
|
|
||||||
"static-libs-windows": [
|
|
||||||
"libpthreadVC3.lib"
|
|
||||||
],
|
|
||||||
"headers-windows": [
|
|
||||||
"_ptw32.h",
|
|
||||||
"pthread.h",
|
|
||||||
"sched.h",
|
|
||||||
"semaphore.h"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"readline": {
|
"readline": {
|
||||||
"source": "readline",
|
"source": "readline",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@@ -482,11 +554,31 @@
|
|||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libsqlite3.a"
|
"libsqlite3.a"
|
||||||
],
|
],
|
||||||
"headers-unix": [
|
"static-libs-windows": [
|
||||||
|
"libsqlite3_a.lib"
|
||||||
|
],
|
||||||
|
"headers": [
|
||||||
"sqlite3.h",
|
"sqlite3.h",
|
||||||
"sqlite3ext.h"
|
"sqlite3ext.h"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"tidy": {
|
||||||
|
"source": "tidy",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libtidy.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unixodbc": {
|
||||||
|
"source": "unixodbc",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libodbc.a",
|
||||||
|
"libodbccr.a",
|
||||||
|
"libodbcinst.a"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"libiconv"
|
||||||
|
]
|
||||||
|
},
|
||||||
"xz": {
|
"xz": {
|
||||||
"source": "xz",
|
"source": "xz",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
|
|||||||
46
config/pkg.json
Normal file
46
config/pkg.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"musl-toolchain-aarch64-linux": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
|
||||||
|
},
|
||||||
|
"musl-toolchain-x86_64-linux": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz"
|
||||||
|
},
|
||||||
|
"nasm-x86_64-win": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip",
|
||||||
|
"extract-files": {
|
||||||
|
"nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe",
|
||||||
|
"nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"strawberry-perl-x86_64-win": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
|
||||||
|
},
|
||||||
|
"upx-aarch64-linux": {
|
||||||
|
"type": "ghrel",
|
||||||
|
"repo": "upx/upx",
|
||||||
|
"match": "upx.+-arm64_linux\\.tar\\.xz",
|
||||||
|
"extract-files": {
|
||||||
|
"upx": "{pkg_root_path}/bin/upx"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"upx-x86_64-linux": {
|
||||||
|
"type": "ghrel",
|
||||||
|
"repo": "upx/upx",
|
||||||
|
"match": "upx.+-amd64_linux\\.tar\\.xz",
|
||||||
|
"extract-files": {
|
||||||
|
"upx": "{pkg_root_path}/bin/upx"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"upx-x86_64-win": {
|
||||||
|
"type": "ghrel",
|
||||||
|
"repo": "upx/upx",
|
||||||
|
"match": "upx.+-win64\\.zip",
|
||||||
|
"extract-files": {
|
||||||
|
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"amqp": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/amqp",
|
||||||
|
"path": "php-src/ext/amqp",
|
||||||
|
"filename": "amqp.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apcu": {
|
"apcu": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://pecl.php.net/get/APCu",
|
"url": "https://pecl.php.net/get/APCu",
|
||||||
@@ -100,6 +110,26 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ext-uuid": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/uuid",
|
||||||
|
"path": "php-src/ext/uuid",
|
||||||
|
"filename": "uuid.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ext-uv": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/uv",
|
||||||
|
"path": "php-src/ext/uv",
|
||||||
|
"filename": "uv.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ext-zstd": {
|
"ext-zstd": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"path": "php-src/ext/zstd",
|
"path": "php-src/ext/zstd",
|
||||||
@@ -111,14 +141,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"freetype": {
|
"freetype": {
|
||||||
"type": "filelist",
|
"type": "git",
|
||||||
"url": "https://download-mirror.savannah.gnu.org/releases/freetype/",
|
"rev": "VER-2-13-2",
|
||||||
"regex": "/href=\"(?<file>freetype-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
"url": "https://github.com/freetype/freetype",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE.TXT"
|
"path": "LICENSE.TXT"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"gettext": {
|
||||||
|
"type": "filelist",
|
||||||
|
"url": "https://ftp.gnu.org/pub/gnu/gettext/",
|
||||||
|
"regex": "/href=\"(?<file>gettext-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"gmp": {
|
"gmp": {
|
||||||
"type": "ghtagtar",
|
"type": "ghtagtar",
|
||||||
"repo": "alisw/GMP",
|
"repo": "alisw/GMP",
|
||||||
@@ -136,6 +175,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"igbinary": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/igbinary",
|
||||||
|
"path": "php-src/ext/igbinary",
|
||||||
|
"filename": "igbinary.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"imagemagick": {
|
"imagemagick": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "ImageMagick/ImageMagick",
|
"repo": "ImageMagick/ImageMagick",
|
||||||
@@ -144,6 +193,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"imap": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/static-php/imap.git",
|
||||||
|
"rev": "master",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"inotify": {
|
"inotify": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://pecl.php.net/get/inotify",
|
"url": "https://pecl.php.net/get/inotify",
|
||||||
@@ -163,6 +221,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libargon2": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "master",
|
||||||
|
"url": "https://github.com/mpociot/phc-winner-argon2",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libavif": {
|
"libavif": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "AOMediaCodec/libavif",
|
"repo": "AOMediaCodec/libavif",
|
||||||
@@ -171,6 +238,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libcares": {
|
||||||
|
"type": "filelist",
|
||||||
|
"url": "https://c-ares.org/download/",
|
||||||
|
"regex": "/href=\"\\/download\\/(?<file>c-ares-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libevent": {
|
"libevent": {
|
||||||
"type": "ghrel",
|
"type": "ghrel",
|
||||||
"repo": "libevent/libevent",
|
"repo": "libevent/libevent",
|
||||||
@@ -189,6 +265,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libffi-win": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "master",
|
||||||
|
"url": "https://github.com/static-php/libffi-win.git",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libiconv": {
|
"libiconv": {
|
||||||
"type": "filelist",
|
"type": "filelist",
|
||||||
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
||||||
@@ -198,6 +283,15 @@
|
|||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libiconv-win": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "master",
|
||||||
|
"url": "https://github.com/static-php/libiconv-win.git",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "source/COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libjpeg": {
|
"libjpeg": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "libjpeg-turbo/libjpeg-turbo",
|
"repo": "libjpeg-turbo/libjpeg-turbo",
|
||||||
@@ -206,17 +300,18 @@
|
|||||||
"path": "LICENSE.md"
|
"path": "LICENSE.md"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"libmcrypt": {
|
"liblz4": {
|
||||||
"type": "url",
|
"type": "ghrel",
|
||||||
"url": "https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
|
"repo": "lz4/lz4",
|
||||||
|
"match": "lz4-.+\\.tar\\.gz",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "COPYING"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"libmemcached": {
|
"libmemcached": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/crazywhalecc/libmemcached-macos.git",
|
"url": "https://github.com/static-php/libmemcached-macos.git",
|
||||||
"rev": "master",
|
"rev": "master",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
@@ -225,16 +320,26 @@
|
|||||||
},
|
},
|
||||||
"libpng": {
|
"libpng": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.code.sf.net/p/libpng/code",
|
"url": "https://github.com/glennrp/libpng.git",
|
||||||
"rev": "libpng16",
|
"rev": "libpng16",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"librabbitmq": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/alanxz/rabbitmq-c.git",
|
||||||
|
"rev": "master",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libsodium": {
|
"libsodium": {
|
||||||
"type": "url",
|
"type": "ghrel",
|
||||||
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
|
"repo": "jedisct1/libsodium",
|
||||||
|
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
@@ -249,6 +354,38 @@
|
|||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libtiff": {
|
||||||
|
"type": "filelist",
|
||||||
|
"url": "https://download.osgeo.org/libtiff/",
|
||||||
|
"regex": "/href=\"(?<file>tiff-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libuuid": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/cloudbase/libuuid.git",
|
||||||
|
"rev": "master",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libuv": {
|
||||||
|
"type": "ghtar",
|
||||||
|
"repo": "libuv/libuv",
|
||||||
|
"license": [
|
||||||
|
{
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE-extra"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"libwebp": {
|
"libwebp": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
|
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
|
||||||
@@ -259,7 +396,7 @@
|
|||||||
},
|
},
|
||||||
"libxml2": {
|
"libxml2": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz",
|
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "Copyright"
|
"path": "Copyright"
|
||||||
@@ -292,14 +429,6 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mcrypt": {
|
|
||||||
"type": "url",
|
|
||||||
"url": "https://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz",
|
|
||||||
"license": {
|
|
||||||
"type": "file",
|
|
||||||
"path": "COPYING"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"memcached": {
|
"memcached": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://pecl.php.net/get/memcached",
|
"url": "https://pecl.php.net/get/memcached",
|
||||||
@@ -314,7 +443,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"path": "php-src/sapi/micro",
|
"path": "php-src/sapi/micro",
|
||||||
"rev": "master",
|
"rev": "master",
|
||||||
"url": "https://github.com/crazywhalecc/phpmicro",
|
"url": "https://github.com/static-php/phpmicro",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
@@ -367,9 +496,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pkg-config": {
|
"pkg-config": {
|
||||||
"type": "filelist",
|
"type": "url",
|
||||||
"url": "https://pkgconfig.freedesktop.org/releases/",
|
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
|
||||||
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
@@ -377,7 +505,7 @@
|
|||||||
},
|
},
|
||||||
"postgresql": {
|
"postgresql": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz",
|
"url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "COPYRIGHT"
|
"path": "COPYRIGHT"
|
||||||
@@ -393,10 +521,11 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pthreads4w": {
|
"rar": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"rev": "master",
|
"url": "https://github.com/static-php/php-rar.git",
|
||||||
"url": "https://git.code.sf.net/p/pthreads4w/code",
|
"path": "php-src/ext/rar",
|
||||||
|
"rev": "issue-php82",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
@@ -439,6 +568,16 @@
|
|||||||
"text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give."
|
"text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"sqlsrv": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/sqlsrv",
|
||||||
|
"path": "php-src/ext/sqlsrv",
|
||||||
|
"filename": "sqlsrv.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"swoole": {
|
"swoole": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"path": "php-src/ext/swoole",
|
"path": "php-src/ext/swoole",
|
||||||
@@ -459,6 +598,33 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tidy": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://github.com/htacg/tidy-html5/archive/refs/tags/5.8.0.tar.gz",
|
||||||
|
"filename": "tidy-html5.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "README/LICENSE.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unixodbc": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xhprof": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/xhprof",
|
||||||
|
"path": "php-src/ext/xhprof-src",
|
||||||
|
"filename": "xhprof.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"xlswriter": {
|
"xlswriter": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://pecl.php.net/get/xlswriter",
|
"url": "https://pecl.php.net/get/xlswriter",
|
||||||
@@ -470,9 +636,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xz": {
|
"xz": {
|
||||||
"type": "filelist",
|
"type": "ghrel",
|
||||||
"url": "https://tukaani.org/xz/",
|
"repo": "tukaani-project/xz",
|
||||||
"regex": "/href=\"(?<file>xz-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
"match": "xz-.+\\.tar\\.gz",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
|
|||||||
@@ -8,5 +8,11 @@ parameters:
|
|||||||
- '#Unsafe usage of new static#'
|
- '#Unsafe usage of new static#'
|
||||||
- '#class Fiber#'
|
- '#class Fiber#'
|
||||||
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
||||||
|
- '#Function Swoole\\Coroutine\\run not found.#'
|
||||||
dynamicConstantNames:
|
dynamicConstantNames:
|
||||||
- PHP_OS_FAMILY
|
- PHP_OS_FAMILY
|
||||||
|
excludePaths:
|
||||||
|
analyseAndScan:
|
||||||
|
- ./src/globals/tests/swoole.php
|
||||||
|
- ./src/globals/tests/swoole.phpt
|
||||||
|
- ./src/globals/test-extensions.php
|
||||||
@@ -6,6 +6,7 @@ namespace SPC;
|
|||||||
|
|
||||||
use SPC\command\BuildCliCommand;
|
use SPC\command\BuildCliCommand;
|
||||||
use SPC\command\BuildLibsCommand;
|
use SPC\command\BuildLibsCommand;
|
||||||
|
use SPC\command\DeleteDownloadCommand;
|
||||||
use SPC\command\dev\AllExtCommand;
|
use SPC\command\dev\AllExtCommand;
|
||||||
use SPC\command\dev\PhpVerCommand;
|
use SPC\command\dev\PhpVerCommand;
|
||||||
use SPC\command\dev\SortConfigCommand;
|
use SPC\command\dev\SortConfigCommand;
|
||||||
@@ -13,6 +14,7 @@ use SPC\command\DoctorCommand;
|
|||||||
use SPC\command\DownloadCommand;
|
use SPC\command\DownloadCommand;
|
||||||
use SPC\command\DumpLicenseCommand;
|
use SPC\command\DumpLicenseCommand;
|
||||||
use SPC\command\ExtractCommand;
|
use SPC\command\ExtractCommand;
|
||||||
|
use SPC\command\InstallPkgCommand;
|
||||||
use SPC\command\MicroCombineCommand;
|
use SPC\command\MicroCombineCommand;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Command\HelpCommand;
|
use Symfony\Component\Console\Command\HelpCommand;
|
||||||
@@ -23,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION = '2.0.0-rc8';
|
public const VERSION = '2.1.3';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -35,6 +37,8 @@ final class ConsoleApplication extends Application
|
|||||||
new BuildLibsCommand(),
|
new BuildLibsCommand(),
|
||||||
new DoctorCommand(),
|
new DoctorCommand(),
|
||||||
new DownloadCommand(),
|
new DownloadCommand(),
|
||||||
|
new InstallPkgCommand(),
|
||||||
|
new DeleteDownloadCommand(),
|
||||||
new DumpLicenseCommand(),
|
new DumpLicenseCommand(),
|
||||||
new ExtractCommand(),
|
new ExtractCommand(),
|
||||||
new MicroCombineCommand(),
|
new MicroCombineCommand(),
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder;
|
namespace SPC\builder;
|
||||||
|
|
||||||
|
use SPC\exception\ExceptionHandler;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\SourceManager;
|
||||||
use SPC\store\SourceExtractor;
|
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
use SPC\util\DependencyUtil;
|
|
||||||
|
|
||||||
abstract class BuilderBase
|
abstract class BuilderBase
|
||||||
{
|
{
|
||||||
@@ -30,69 +29,19 @@ abstract class BuilderBase
|
|||||||
/** @var array<string, mixed> compile options */
|
/** @var array<string, mixed> compile options */
|
||||||
protected array $options = [];
|
protected array $options = [];
|
||||||
|
|
||||||
|
/** @var string patch point name */
|
||||||
|
protected string $patch_point = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build libraries
|
* Build libraries
|
||||||
*
|
*
|
||||||
* @param array<string> $libraries Libraries to build
|
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function buildLibs(array $libraries): void
|
abstract public function buildLibs(array $sorted_libraries);
|
||||||
{
|
|
||||||
// search all supported libs
|
|
||||||
$support_lib_list = [];
|
|
||||||
$classes = FileSystem::getClassesPsr4(
|
|
||||||
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
|
|
||||||
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
|
||||||
);
|
|
||||||
foreach ($classes as $class) {
|
|
||||||
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
|
||||||
$support_lib_list[$class::NAME] = $class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no libs specified, compile all supported libs
|
|
||||||
if ($libraries === [] && $this->isLibsOnly()) {
|
|
||||||
$libraries = array_keys($support_lib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
// pkg-config must be compiled first, whether it is specified or not
|
|
||||||
if (!in_array('pkg-config', $libraries)) {
|
|
||||||
array_unshift($libraries, 'pkg-config');
|
|
||||||
}
|
|
||||||
|
|
||||||
// append dependencies
|
|
||||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
|
||||||
|
|
||||||
// add lib object for builder
|
|
||||||
foreach ($libraries as $library) {
|
|
||||||
// if some libs are not supported (but in config "lib.json", throw exception)
|
|
||||||
if (!isset($support_lib_list[$library])) {
|
|
||||||
throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
|
||||||
}
|
|
||||||
$lib = new ($support_lib_list[$library])($this);
|
|
||||||
$this->addLib($lib);
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate and check dependencies
|
|
||||||
foreach ($this->libs as $lib) {
|
|
||||||
$lib->calcDependency();
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract sources
|
|
||||||
SourceExtractor::initSource(libs: $libraries);
|
|
||||||
|
|
||||||
// build all libs
|
|
||||||
foreach ($this->libs as $lib) {
|
|
||||||
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
|
||||||
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
|
||||||
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
|
||||||
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
|
||||||
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add library to build.
|
* Add library to build.
|
||||||
@@ -174,6 +123,8 @@ abstract class BuilderBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set libs only mode.
|
* Set libs only mode.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function setLibsOnly(bool $status = true): void
|
public function setLibsOnly(bool $status = true): void
|
||||||
{
|
{
|
||||||
@@ -187,15 +138,22 @@ abstract class BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function proveExts(array $extensions): void
|
public function proveExts(array $extensions): void
|
||||||
{
|
{
|
||||||
CustomExt::loadCustomExt();
|
CustomExt::loadCustomExt();
|
||||||
SourceExtractor::initSource(sources: ['php-src']);
|
$this->emitPatchPoint('before-php-extract');
|
||||||
|
SourceManager::initSource(sources: ['php-src']);
|
||||||
|
$this->emitPatchPoint('after-php-extract');
|
||||||
if ($this->getPHPVersionID() >= 80000) {
|
if ($this->getPHPVersionID() >= 80000) {
|
||||||
SourceExtractor::initSource(sources: ['micro']);
|
$this->emitPatchPoint('before-micro-extract');
|
||||||
|
SourceManager::initSource(sources: ['micro']);
|
||||||
|
$this->emitPatchPoint('after-micro-extract');
|
||||||
}
|
}
|
||||||
SourceExtractor::initSource(exts: $extensions);
|
$this->emitPatchPoint('before-exts-extract');
|
||||||
|
SourceManager::initSource(exts: $extensions);
|
||||||
|
$this->emitPatchPoint('after-exts-extract');
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
$class = CustomExt::getExtClass($extension);
|
$class = CustomExt::getExtClass($extension);
|
||||||
$ext = new $class($extension, $this);
|
$ext = new $class($extension, $this);
|
||||||
@@ -225,9 +183,10 @@ abstract class BuilderBase
|
|||||||
{
|
{
|
||||||
$ret = [];
|
$ret = [];
|
||||||
foreach ($this->exts as $ext) {
|
foreach ($this->exts as $ext) {
|
||||||
|
logger()->info($ext->getName() . ' is using ' . $ext->getConfigureArg());
|
||||||
$ret[] = trim($ext->getConfigureArg());
|
$ret[] = trim($ext->getConfigureArg());
|
||||||
}
|
}
|
||||||
logger()->info('Using configure: ' . implode(' ', $ret));
|
logger()->debug('Using configure: ' . implode(' ', $ret));
|
||||||
return implode(' ', $ret);
|
return implode(' ', $ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +218,43 @@ abstract class BuilderBase
|
|||||||
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPHPVersion(): string
|
||||||
|
{
|
||||||
|
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
|
||||||
|
throw new WrongUsageException('PHP source files are not available, you need to download them first');
|
||||||
|
}
|
||||||
|
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
|
||||||
|
if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) {
|
||||||
|
return $match[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PHP version from archive file name.
|
||||||
|
*
|
||||||
|
* @param null|string $file php-*.*.*.tar.gz filename, read from lockfile if empty
|
||||||
|
*/
|
||||||
|
public function getPHPVersionFromArchive(?string $file = null): false|string
|
||||||
|
{
|
||||||
|
if ($file === null) {
|
||||||
|
$lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false;
|
||||||
|
if ($lock === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$lock = json_decode($lock, true);
|
||||||
|
$file = $lock['php-src']['filename'] ?? null;
|
||||||
|
if ($file === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) {
|
||||||
|
return $match[1];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get build type name string to display.
|
* Get build type name string to display.
|
||||||
*
|
*
|
||||||
@@ -331,6 +327,39 @@ abstract class BuilderBase
|
|||||||
return implode(' ', $env);
|
return implode(' ', $env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get builder patch point name.
|
||||||
|
*/
|
||||||
|
public function getPatchPoint(): string
|
||||||
|
{
|
||||||
|
return $this->patch_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function emitPatchPoint(string $point_name): void
|
||||||
|
{
|
||||||
|
$this->patch_point = $point_name;
|
||||||
|
if (($patches = $this->getOption('with-added-patch', [])) === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($patches as $patch) {
|
||||||
|
try {
|
||||||
|
if (!file_exists($patch)) {
|
||||||
|
throw new RuntimeException("Additional patch script file {$patch} not found!");
|
||||||
|
}
|
||||||
|
logger()->debug('Running additional patch script: ' . $patch);
|
||||||
|
require $patch;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
||||||
|
if ($this->getOption('debug')) {
|
||||||
|
ExceptionHandler::getInstance()->handle($e);
|
||||||
|
} else {
|
||||||
|
logger()->critical('Please check with --debug option to see more details.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all libs are downloaded.
|
* Check if all libs are downloaded.
|
||||||
* If not, throw exception.
|
* If not, throw exception.
|
||||||
@@ -354,4 +383,22 @@ abstract class BuilderBase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate micro extension test php code.
|
||||||
|
*/
|
||||||
|
protected function generateMicroExtTests(): string
|
||||||
|
{
|
||||||
|
$php = "<?php\n\necho '[micro-test-start]' . PHP_EOL;\n";
|
||||||
|
|
||||||
|
foreach ($this->getExts() as $ext) {
|
||||||
|
$ext_name = $ext->getDistName();
|
||||||
|
if (!empty($ext_name)) {
|
||||||
|
$php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n";
|
||||||
|
$php .= "assert(extension_loaded('{$ext_name}'));\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$php .= "echo '[micro-test-end]';\n";
|
||||||
|
return $php;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace SPC\builder;
|
|||||||
use SPC\builder\freebsd\BSDBuilder;
|
use SPC\builder\freebsd\BSDBuilder;
|
||||||
use SPC\builder\linux\LinuxBuilder;
|
use SPC\builder\linux\LinuxBuilder;
|
||||||
use SPC\builder\macos\MacOSBuilder;
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
|
use SPC\builder\windows\WindowsBuilder;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
@@ -17,6 +18,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
*/
|
*/
|
||||||
class BuilderProvider
|
class BuilderProvider
|
||||||
{
|
{
|
||||||
|
private static ?BuilderBase $builder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
@@ -24,16 +27,24 @@ class BuilderProvider
|
|||||||
*/
|
*/
|
||||||
public static function makeBuilderByInput(InputInterface $input): BuilderBase
|
public static function makeBuilderByInput(InputInterface $input): BuilderBase
|
||||||
{
|
{
|
||||||
return match (PHP_OS_FAMILY) {
|
self::$builder = match (PHP_OS_FAMILY) {
|
||||||
// 'Windows' => new WindowsBuilder(
|
'Windows' => new WindowsBuilder($input->getOptions()),
|
||||||
// binary_sdk_dir: $input->getOption('with-sdk-binary-dir'),
|
|
||||||
// vs_ver: $input->getOption('vs-ver'),
|
|
||||||
// arch: $input->getOption('arch'),
|
|
||||||
// ),
|
|
||||||
'Darwin' => new MacOSBuilder($input->getOptions()),
|
'Darwin' => new MacOSBuilder($input->getOptions()),
|
||||||
'Linux' => new LinuxBuilder($input->getOptions()),
|
'Linux' => new LinuxBuilder($input->getOptions()),
|
||||||
'BSD' => new BSDBuilder($input->getOptions()),
|
'BSD' => new BSDBuilder($input->getOptions()),
|
||||||
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
|
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
|
||||||
};
|
};
|
||||||
|
return self::$builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
*/
|
||||||
|
public static function getBuilder(): BuilderBase
|
||||||
|
{
|
||||||
|
if (self::$builder === null) {
|
||||||
|
throw new WrongUsageException('Builder has not been initialized');
|
||||||
|
}
|
||||||
|
return self::$builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use SPC\exception\FileSystemException;
|
|||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
class Extension
|
class Extension
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,7 @@ class Extension
|
|||||||
$arg = $this->getEnableArg();
|
$arg = $this->getEnableArg();
|
||||||
switch (PHP_OS_FAMILY) {
|
switch (PHP_OS_FAMILY) {
|
||||||
case 'Windows':
|
case 'Windows':
|
||||||
$arg = $this->getWindowsConfigureArg();
|
$arg .= $this->getWindowsConfigureArg();
|
||||||
break;
|
break;
|
||||||
case 'Darwin':
|
case 'Darwin':
|
||||||
case 'Linux':
|
case 'Linux':
|
||||||
@@ -163,6 +164,65 @@ class Extension
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
// Run compile check if build target is cli
|
||||||
|
// If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
|
||||||
|
// If check failed, throw RuntimeException
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')) {
|
||||||
|
// Trim additional content & escape special characters to allow inline usage
|
||||||
|
$test = str_replace(
|
||||||
|
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
||||||
|
['', '', '', '\"', '\$'],
|
||||||
|
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')
|
||||||
|
);
|
||||||
|
|
||||||
|
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
||||||
|
if ($ret !== 0) {
|
||||||
|
if ($this->builder->getOption('debug')) {
|
||||||
|
var_dump($out);
|
||||||
|
}
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function runCliCheckWindows(): void
|
||||||
|
{
|
||||||
|
// Run compile check if build target is cli
|
||||||
|
// If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
|
||||||
|
// If check failed, throw RuntimeException
|
||||||
|
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))) {
|
||||||
|
// Trim additional content & escape special characters to allow inline usage
|
||||||
|
$test = str_replace(
|
||||||
|
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
||||||
|
['', '', '', '\"', '$'],
|
||||||
|
file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))
|
||||||
|
);
|
||||||
|
|
||||||
|
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"');
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ abstract class LibraryBase
|
|||||||
if (!$this->patched && $this->patchBeforeBuild()) {
|
if (!$this->patched && $this->patchBeforeBuild()) {
|
||||||
file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!');
|
file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!');
|
||||||
}
|
}
|
||||||
|
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-build');
|
||||||
$this->build();
|
$this->build();
|
||||||
|
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-build');
|
||||||
return BUILD_STATUS_OK;
|
return BUILD_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
src/SPC/builder/extension/amqp.php
Normal file
35
src/SPC/builder/extension/amqp.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('amqp')]
|
||||||
|
class amqp extends Extension
|
||||||
|
{
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
|
||||||
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
|
||||||
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_ssl_socket.h', '/^#warning.*/m', '');
|
||||||
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWindowsConfigureArg(): string
|
||||||
|
{
|
||||||
|
return '--with-amqp';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
@@ -34,4 +35,16 @@ class event extends Extension
|
|||||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
// Prevent event extension compile error on macOS
|
||||||
|
if ($this->builder instanceof MacOSBuilder) {
|
||||||
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,9 @@ class ffi extends Extension
|
|||||||
{
|
{
|
||||||
return '--with-ffi --enable-zend-signals';
|
return '--with-ffi --enable-zend-signals';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWindowsConfigureArg(): string
|
||||||
|
{
|
||||||
|
return '--with-ffi';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/SPC/builder/extension/gettext.php
Normal file
40
src/SPC/builder/extension/gettext.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('gettext')]
|
||||||
|
class gettext extends Extension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
if ($this->builder instanceof MacOSBuilder) {
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeConfigure(): bool
|
||||||
|
{
|
||||||
|
if ($this->builder instanceof MacOSBuilder) {
|
||||||
|
$frameworks = ' ' . $this->builder->getFrameworks(true) . ' ';
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,12 +17,26 @@ class glfw extends Extension
|
|||||||
*/
|
*/
|
||||||
public function patchBeforeBuildconf(): bool
|
public function patchBeforeBuildconf(): bool
|
||||||
{
|
{
|
||||||
|
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
|
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchBeforeConfigure(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
|
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWindowsConfigureArg(): string
|
||||||
|
{
|
||||||
|
return '--enable-glfw=static';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\builder\linux\LinuxBuilder;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('imagick')]
|
#[CustomExt('imagick')]
|
||||||
@@ -14,7 +15,9 @@ class imagick extends Extension
|
|||||||
{
|
{
|
||||||
// imagick may call omp_pause_all which requires -lgomp
|
// imagick may call omp_pause_all which requires -lgomp
|
||||||
$extra_libs = $this->builder->getOption('extra-libs', '');
|
$extra_libs = $this->builder->getOption('extra-libs', '');
|
||||||
|
if ($this->builder instanceof LinuxBuilder) {
|
||||||
$extra_libs .= ' -lgomp ';
|
$extra_libs .= ' -lgomp ';
|
||||||
|
}
|
||||||
$this->builder->setOption('extra-libs', $extra_libs);
|
$this->builder->setOption('extra-libs', $extra_libs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/SPC/builder/extension/imap.php
Normal file
28
src/SPC/builder/extension/imap.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('imap')]
|
||||||
|
class imap extends Extension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
*/
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
if ($this->builder->getOption('enable-zts')) {
|
||||||
|
throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds');
|
||||||
|
}
|
||||||
|
$arg = '--with-imap=' . BUILD_ROOT_PATH;
|
||||||
|
if ($this->builder->getLib('openssl') !== null) {
|
||||||
|
$arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH;
|
||||||
|
}
|
||||||
|
return $arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/SPC/builder/extension/ldap.php
Normal file
23
src/SPC/builder/extension/ldap.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('ldap')]
|
||||||
|
class ldap extends Extension
|
||||||
|
{
|
||||||
|
public function patchBeforeConfigure(): bool
|
||||||
|
{
|
||||||
|
$output = shell()->execWithResult('$PKG_CONFIG --libs-only-l --static ldap');
|
||||||
|
if (!empty($output[1][0])) {
|
||||||
|
$libs = $output[1][0];
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lldap ', $libs . ' ');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('mbregex')]
|
#[CustomExt('mbregex')]
|
||||||
@@ -19,4 +20,27 @@ class mbregex extends Extension
|
|||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbregex is not an extension, we need to overwrite the default check.
|
||||||
|
*/
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runCliCheckWindows(): void
|
||||||
|
{
|
||||||
|
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
|
||||||
|
}
|
||||||
|
$out = implode("\n", $out);
|
||||||
|
if (!str_contains($out, 'regex')) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ use SPC\util\CustomExt;
|
|||||||
#[CustomExt('mbstring')]
|
#[CustomExt('mbstring')]
|
||||||
class mbstring extends Extension
|
class mbstring extends Extension
|
||||||
{
|
{
|
||||||
public function getUnixConfigureArg(): string
|
public function getConfigureArg(): string
|
||||||
{
|
{
|
||||||
$arg = '--enable-mbstring';
|
$arg = '--enable-mbstring';
|
||||||
if ($this->builder->getExt('mbregex') === null) {
|
if ($this->builder->getExt('mbregex') === null) {
|
||||||
$arg .= ' --disable-mbregex';
|
$arg .= ' --disable-mbregex';
|
||||||
|
} else {
|
||||||
|
$arg .= ' --enable-mbregex';
|
||||||
}
|
}
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,20 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('mongodb')]
|
#[CustomExt('mongodb')]
|
||||||
class mongodb extends Extension
|
class mongodb extends Extension
|
||||||
{
|
{
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'if test -z "$PHP_CONFIG"; then', 'if false; then');
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version`', 'PHP_MONGODB_PHP_VERSION=' . $this->builder->getPHPVersion());
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION_ID=`${PHP_CONFIG} --vernum`', 'PHP_MONGODB_PHP_VERSION_ID=' . $this->builder->getPHPVersionID());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
$arg = ' --enable-mongodb ';
|
$arg = ' --enable-mongodb ';
|
||||||
|
|||||||
@@ -5,11 +5,25 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('opcache')]
|
#[CustomExt('opcache')]
|
||||||
class opcache extends Extension
|
class opcache extends Extension
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
if ($this->builder->getPHPVersionID() < 80000) {
|
||||||
|
throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !');
|
||||||
|
}
|
||||||
|
return '--enable-opcache';
|
||||||
|
}
|
||||||
|
|
||||||
public function getDistName(): string
|
public function getDistName(): string
|
||||||
{
|
{
|
||||||
return 'Zend Opcache';
|
return 'Zend Opcache';
|
||||||
|
|||||||
21
src/SPC/builder/extension/password_argon2.php
Normal file
21
src/SPC/builder/extension/password_argon2.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('password-argon2')]
|
||||||
|
class password_argon2 extends Extension
|
||||||
|
{
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,14 +13,14 @@ class redis extends Extension
|
|||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
$arg = '--enable-redis';
|
$arg = '--enable-redis';
|
||||||
if (!$this->builder->getExt('session')) {
|
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
|
||||||
$arg .= ' --disable-redis-session';
|
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
|
||||||
} else {
|
|
||||||
$arg .= ' --enable-redis-session';
|
|
||||||
}
|
|
||||||
if ($this->builder->getLib('zstd')) {
|
if ($this->builder->getLib('zstd')) {
|
||||||
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
|
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
|
||||||
}
|
}
|
||||||
|
if ($this->builder->getLib('liblz4')) {
|
||||||
|
$arg .= ' --enable-redis-lz4 --with-liblz4="' . BUILD_ROOT_PATH . '"';
|
||||||
|
}
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/SPC/builder/extension/sodium.php
Normal file
35
src/SPC/builder/extension/sodium.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('sodium')]
|
||||||
|
class sodium extends Extension
|
||||||
|
{
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
// bypass error: unknown warning option '-Wno-logical-op' for macOS
|
||||||
|
return $this->removeLineContainingString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function removeLineContainingString(): bool
|
||||||
|
{
|
||||||
|
$path = SOURCE_PATH . '/php-src/ext/sodium/config.m4';
|
||||||
|
$search = '-Wno-logical-op';
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$content = file_get_contents($path);
|
||||||
|
$lines = preg_split('/\r\n|\n/', $content);
|
||||||
|
$filteredLines = array_filter($lines, function ($line) use ($search) {
|
||||||
|
return strpos($line, $search) === false;
|
||||||
|
});
|
||||||
|
$newContent = implode("\n", $filteredLines);
|
||||||
|
file_put_contents($path, $newContent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,12 +12,31 @@ class swoole extends Extension
|
|||||||
{
|
{
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
|
// enable swoole
|
||||||
$arg = '--enable-swoole';
|
$arg = '--enable-swoole';
|
||||||
$arg .= $this->builder->getExt('pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql';
|
|
||||||
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl';
|
// commonly-used feature: coroutine-time, thread-context
|
||||||
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
$arg .= ' --enable-swoole-coro-time --enable-thread-context';
|
||||||
// curl hook is buggy for static php
|
|
||||||
$arg .= ' --disable-swoole-curl';
|
// required feature: curl, openssl (but curl hook is buggy for php 8.0)
|
||||||
|
$arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
|
||||||
|
$arg .= ' --enable-openssl';
|
||||||
|
|
||||||
|
// additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature)
|
||||||
|
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
|
||||||
|
$arg .= $this->builder->getLib('brotli') ? (' --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
||||||
|
$arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
|
||||||
|
|
||||||
|
// additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc.
|
||||||
|
// so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support)
|
||||||
|
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql';
|
||||||
|
|
||||||
|
// enable this feature , need remove pdo_sqlite
|
||||||
|
// more info : https://wenda.swoole.com/detail/109023
|
||||||
|
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite';
|
||||||
|
|
||||||
|
// enable this feature , need stop pdo_*
|
||||||
|
// $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' ';
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
src/SPC/builder/extension/swoole_hook_mysql.php
Normal file
41
src/SPC/builder/extension/swoole_hook_mysql.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('swoole-hook-mysql')]
|
||||||
|
class swoole_hook_mysql extends Extension
|
||||||
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
// pdo_mysql doesn't need to be disabled
|
||||||
|
// enable swoole-hook-mysql will enable mysqli, pdo, pdo_mysql, we don't need to add any additional options
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
// skip if not enable swoole
|
||||||
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false);
|
||||||
|
$out = implode('', $out);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
if (!str_contains($out, 'mysqlnd')) {
|
||||||
|
throw new RuntimeException('swoole mysql hook is not enabled correctly.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/SPC/builder/extension/swoole_hook_pgsql.php
Normal file
45
src/SPC/builder/extension/swoole_hook_pgsql.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('swoole-hook-pgsql')]
|
||||||
|
class swoole_hook_pgsql extends Extension
|
||||||
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
// pdo_pgsql need to be disabled
|
||||||
|
if ($this->builder->getExt('pdo_pgsql') !== null) {
|
||||||
|
throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.');
|
||||||
|
}
|
||||||
|
// enable swoole pgsql hook
|
||||||
|
return '--enable-swoole-pgsql';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
// skip if not enable swoole
|
||||||
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false);
|
||||||
|
$out = implode('', $out);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
if (!str_contains($out, 'coroutine_pgsql')) {
|
||||||
|
throw new RuntimeException('swoole pgsql hook is not enabled correctly.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/SPC/builder/extension/swoole_hook_sqlite.php
Normal file
45
src/SPC/builder/extension/swoole_hook_sqlite.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('swoole-hook-sqlite')]
|
||||||
|
class swoole_hook_sqlite extends Extension
|
||||||
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUnixConfigureArg(): string
|
||||||
|
{
|
||||||
|
// pdo_pgsql need to be disabled
|
||||||
|
if ($this->builder->getExt('pdo_sqlite') !== null) {
|
||||||
|
throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.');
|
||||||
|
}
|
||||||
|
// enable swoole pgsql hook
|
||||||
|
return '--enable-swoole-sqlite';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runCliCheckUnix(): void
|
||||||
|
{
|
||||||
|
// skip if not enable swoole
|
||||||
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false);
|
||||||
|
$out = implode('', $out);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
if (!str_contains($out, 'coroutine_sqlite')) {
|
||||||
|
throw new RuntimeException('swoole sqlite hook is not enabled correctly.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/SPC/builder/extension/xhprof.php
Normal file
33
src/SPC/builder/extension/xhprof.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('xhprof')]
|
||||||
|
class xhprof extends Extension
|
||||||
|
{
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
if (!is_link(SOURCE_PATH . '/php-src/ext/xhprof')) {
|
||||||
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
|
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D xhprof xhprof-src\extension');
|
||||||
|
} else {
|
||||||
|
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s xhprof-src/extension xhprof');
|
||||||
|
}
|
||||||
|
|
||||||
|
// patch config.m4
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
SOURCE_PATH . '/php-src/ext/xhprof/config.m4',
|
||||||
|
'if test -f $phpincludedir/ext/pcre/php_pcre.h; then',
|
||||||
|
'if test -f $abs_srcdir/ext/pcre/php_pcre.h; then'
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
|
|||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('xml')]
|
#[CustomExt('xml')]
|
||||||
@@ -33,4 +34,25 @@ class xml extends Extension
|
|||||||
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
|
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/win32/build/config.w32', 'dllmain.c ', '');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWindowsConfigureArg(): string
|
||||||
|
{
|
||||||
|
$arg = match ($this->name) {
|
||||||
|
'xml' => '--with-xml',
|
||||||
|
'soap' => '--enable-soap',
|
||||||
|
'xmlreader' => '--enable-xmlreader',
|
||||||
|
'xmlwriter' => '--enable-xmlwriter',
|
||||||
|
'dom' => '--with-dom',
|
||||||
|
'simplexml' => '--with-simplexml',
|
||||||
|
default => throw new RuntimeException('Not accept non-xml extension'),
|
||||||
|
};
|
||||||
|
$arg .= ' --with-libxml';
|
||||||
|
return $arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\freebsd;
|
namespace SPC\builder\freebsd;
|
||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\unix\UnixBuilderBase;
|
||||||
use SPC\builder\traits\UnixBuilderTrait;
|
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
|
|
||||||
class BSDBuilder extends BuilderBase
|
class BSDBuilder extends UnixBuilderBase
|
||||||
{
|
{
|
||||||
/** Unix compatible builder methods */
|
|
||||||
use UnixBuilderTrait;
|
|
||||||
|
|
||||||
/** @var bool Micro patch phar flag */
|
/** @var bool Micro patch phar flag */
|
||||||
private bool $phar_patched = false;
|
private bool $phar_patched = false;
|
||||||
|
|
||||||
@@ -81,10 +77,12 @@ class BSDBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
$this->setOption('extra-libs', $extra_libs);
|
$this->setOption('extra-libs', $extra_libs);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-buildconf');
|
||||||
SourcePatcher::patchBeforeBuildconf($this);
|
SourcePatcher::patchBeforeBuildconf($this);
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-configure');
|
||||||
SourcePatcher::patchBeforeConfigure($this);
|
SourcePatcher::patchBeforeConfigure($this);
|
||||||
|
|
||||||
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
|
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
|
||||||
@@ -115,6 +113,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
$this->makeExtensionArgs()
|
$this->makeExtensionArgs()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-make');
|
||||||
SourcePatcher::patchBeforeMake($this);
|
SourcePatcher::patchBeforeMake($this);
|
||||||
|
|
||||||
$this->cleanMake();
|
$this->cleanMake();
|
||||||
@@ -140,6 +139,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (php_uname('m') === $this->getOption('arch')) {
|
if (php_uname('m') === $this->getOption('arch')) {
|
||||||
|
$this->emitPatchPoint('before-sanity-check');
|
||||||
$this->sanityCheck($build_target);
|
$this->sanityCheck($build_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildCli(): void
|
protected function buildCli(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString([
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||||
@@ -173,7 +173,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
*/
|
*/
|
||||||
public function buildMicro(): void
|
protected function buildMicro(): void
|
||||||
{
|
{
|
||||||
if ($this->getPHPVersionID() < 80000) {
|
if ($this->getPHPVersionID() < 80000) {
|
||||||
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
||||||
@@ -211,7 +211,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildFpm(): void
|
protected function buildFpm(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString([
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||||
@@ -231,7 +231,7 @@ class BSDBuilder extends BuilderBase
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function buildEmbed(): void
|
protected function buildEmbed(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString([
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||||
|
|||||||
@@ -4,20 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\linux;
|
namespace SPC\builder\linux;
|
||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
|
||||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||||
use SPC\builder\traits\UnixBuilderTrait;
|
use SPC\builder\unix\UnixBuilderBase;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
|
|
||||||
class LinuxBuilder extends BuilderBase
|
class LinuxBuilder extends UnixBuilderBase
|
||||||
{
|
{
|
||||||
/** Unix compatible builder methods */
|
|
||||||
use UnixBuilderTrait;
|
|
||||||
|
|
||||||
/** @var array Tune cflags */
|
/** @var array Tune cflags */
|
||||||
public array $tune_c_flags;
|
public array $tune_c_flags;
|
||||||
|
|
||||||
@@ -138,19 +134,22 @@ class LinuxBuilder extends BuilderBase
|
|||||||
// add libstdc++, some extensions or libraries need it
|
// add libstdc++, some extensions or libraries need it
|
||||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
||||||
$this->setOption('extra-libs', $extra_libs);
|
$this->setOption('extra-libs', $extra_libs);
|
||||||
|
|
||||||
$cflags = $this->arch_c_flags;
|
$cflags = $this->arch_c_flags;
|
||||||
|
|
||||||
// prepare build php envs
|
// prepare build php envs
|
||||||
$envs_build_php = SystemUtil::makeEnvVarString([
|
$envs_build_php = SystemUtil::makeEnvVarString([
|
||||||
'CFLAGS' => $cflags,
|
'CFLAGS' => $cflags,
|
||||||
|
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
|
||||||
|
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
|
||||||
'LIBS' => '-ldl -lpthread',
|
'LIBS' => '-ldl -lpthread',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-buildconf');
|
||||||
SourcePatcher::patchBeforeBuildconf($this);
|
SourcePatcher::patchBeforeBuildconf($this);
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-configure');
|
||||||
SourcePatcher::patchBeforeConfigure($this);
|
SourcePatcher::patchBeforeConfigure($this);
|
||||||
|
|
||||||
$phpVersionID = $this->getPHPVersionID();
|
$phpVersionID = $this->getPHPVersionID();
|
||||||
@@ -170,6 +169,27 @@ class LinuxBuilder extends BuilderBase
|
|||||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||||
|
|
||||||
|
// upx pack and strip for micro
|
||||||
|
if ($this->getOption('with-upx-pack', false)) {
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||||
|
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||||
|
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . $this->getOption('upx-exec') . ' --best \$(SAPI_MICRO_PATH)',
|
||||||
|
);
|
||||||
|
} elseif (!$this->getOption('no-strip', false)) {
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||||
|
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||||
|
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||||
|
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||||
|
'POST_MICRO_BUILD_COMMANDS=true',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec(
|
->exec(
|
||||||
"{$this->getOption('ld_library_path')} " .
|
"{$this->getOption('ld_library_path')} " .
|
||||||
@@ -189,10 +209,11 @@ class LinuxBuilder extends BuilderBase
|
|||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$maxExecutionTimers .
|
$maxExecutionTimers .
|
||||||
$this->makeExtensionArgs() . ' ' .
|
$this->makeExtensionArgs() .
|
||||||
$envs_build_php
|
' ' . $envs_build_php . ' '
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-make');
|
||||||
SourcePatcher::patchBeforeMake($this);
|
SourcePatcher::patchBeforeMake($this);
|
||||||
|
|
||||||
$this->cleanMake();
|
$this->cleanMake();
|
||||||
@@ -218,6 +239,7 @@ class LinuxBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (php_uname('m') === $this->getOption('arch')) {
|
if (php_uname('m') === $this->getOption('arch')) {
|
||||||
|
$this->emitPatchPoint('before-sanity-check');
|
||||||
$this->sanityCheck($build_target);
|
$this->sanityCheck($build_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,14 +250,18 @@ class LinuxBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildCli(): void
|
protected function buildCli(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
->exec("make -j{$this->concurrency} {$vars} cli");
|
->exec("make -j{$this->concurrency} {$vars} cli");
|
||||||
|
|
||||||
if (!$this->getOption('no-strip', false)) {
|
if ($this->getOption('with-upx-pack')) {
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
|
||||||
|
->exec('strip --strip-all php')
|
||||||
|
->exec($this->getOption('upx-exec') . ' --best php');
|
||||||
|
} elseif (!$this->getOption('no-strip', false)) {
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +275,7 @@ class LinuxBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
*/
|
*/
|
||||||
public function buildMicro(): void
|
protected function buildMicro(): void
|
||||||
{
|
{
|
||||||
if ($this->getPHPVersionID() < 80000) {
|
if ($this->getPHPVersionID() < 80000) {
|
||||||
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
||||||
@@ -266,10 +292,6 @@ class LinuxBuilder extends BuilderBase
|
|||||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
->exec("make -j{$this->concurrency} {$vars} micro");
|
->exec("make -j{$this->concurrency} {$vars} micro");
|
||||||
|
|
||||||
if (!$this->getOption('no-strip', false)) {
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||||
|
|
||||||
if ($this->phar_patched) {
|
if ($this->phar_patched) {
|
||||||
@@ -283,17 +305,20 @@ class LinuxBuilder extends BuilderBase
|
|||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function buildFpm(): void
|
protected function buildFpm(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
->exec("make -j{$this->concurrency} {$vars} fpm");
|
->exec("make -j{$this->concurrency} {$vars} fpm");
|
||||||
|
|
||||||
if (!$this->getOption('no-strip', false)) {
|
if ($this->getOption('with-upx-pack')) {
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
|
||||||
|
->exec('strip --strip-all php-fpm')
|
||||||
|
->exec($this->getOption('upx-exec') . ' --best php-fpm');
|
||||||
|
} elseif (!$this->getOption('no-strip', false)) {
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->deployBinary(BUILD_TARGET_FPM);
|
$this->deployBinary(BUILD_TARGET_FPM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +327,7 @@ class LinuxBuilder extends BuilderBase
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function buildEmbed(): void
|
protected function buildEmbed(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
|
|
||||||
@@ -322,10 +347,11 @@ class LinuxBuilder extends BuilderBase
|
|||||||
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
|
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
|
||||||
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
|
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
|
||||||
$ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : '';
|
$ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : '';
|
||||||
|
$tune_c_flags = implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags));
|
||||||
return [
|
return [
|
||||||
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags,
|
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE {$tune_c_flags}{$cflags}",
|
||||||
'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs,
|
'EXTRA_LIBS' => "{$this->getOption('extra-libs', '')} {$libs}",
|
||||||
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags,
|
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static{$ldflags}",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,11 +110,7 @@ class SystemUtil
|
|||||||
public static function getTuneCFlags(string $arch): array
|
public static function getTuneCFlags(string $arch): array
|
||||||
{
|
{
|
||||||
return match ($arch) {
|
return match ($arch) {
|
||||||
'x86_64' => [
|
'x86_64', 'arm64', 'aarch64' => [],
|
||||||
'-march=corei7',
|
|
||||||
'-mtune=core-avx2',
|
|
||||||
],
|
|
||||||
'arm64', 'aarch64' => [],
|
|
||||||
default => throw new RuntimeException('unsupported arch: ' . $arch),
|
default => throw new RuntimeException('unsupported arch: ' . $arch),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -209,4 +205,21 @@ class SystemUtil
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fully-supported linux distros.
|
||||||
|
*
|
||||||
|
* @return string[] List of supported Linux distro name for doctor
|
||||||
|
*/
|
||||||
|
public static function getSupportedDistros(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// debian-like
|
||||||
|
'debian', 'ubuntu', 'Deepin',
|
||||||
|
// rhel-like
|
||||||
|
'redhat',
|
||||||
|
// alpine
|
||||||
|
'alpine',
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/linux/library/gettext.php
Normal file
12
src/SPC/builder/linux/library/gettext.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class gettext extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\gettext;
|
||||||
|
|
||||||
|
public const NAME = 'gettext';
|
||||||
|
}
|
||||||
67
src/SPC/builder/linux/library/imap.php
Normal file
67
src/SPC/builder/linux/library/imap.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
class imap extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
public const NAME = 'imap';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
$cc = getenv('CC') ?: 'gcc';
|
||||||
|
// FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', '');
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}");
|
||||||
|
/* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto');
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz');
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
$this->source_dir . '/src/osdep/unix/ssl_unix.c',
|
||||||
|
"#include <x509v3.h>\n#include <ssl.h>",
|
||||||
|
"#include <ssl.h>\n#include <x509v3.h>"
|
||||||
|
);
|
||||||
|
// SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir);
|
||||||
|
SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH);
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
if ($this->builder->getLib('openssl')) {
|
||||||
|
$ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH;
|
||||||
|
} else {
|
||||||
|
$ssl_options = 'SSLTYPE=none';
|
||||||
|
}
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec('touch ip6')
|
||||||
|
->exec('chmod +x tools/an')
|
||||||
|
->exec('chmod +x tools/ua')
|
||||||
|
->exec('chmod +x src/osdep/unix/drivers')
|
||||||
|
->exec('chmod +x src/osdep/unix/mkauths')
|
||||||
|
->exec(
|
||||||
|
"yes | make slx {$ssl_options}"
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
shell()
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a')
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/')
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/')
|
||||||
|
->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/');
|
||||||
|
} catch (\Throwable) {
|
||||||
|
// last command throws an exception, no idea why since it works
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/SPC/builder/linux/library/libargon2.php
Normal file
25
src/SPC/builder/linux/library/libargon2.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
class libargon2 extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libargon2;
|
||||||
|
|
||||||
|
public const NAME = 'libargon2';
|
||||||
|
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
// detect libsodium (The libargon2 conflicts with the libsodium library.)
|
||||||
|
if ($this->builder->getLib('libsodium') !== null) {
|
||||||
|
throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !');
|
||||||
|
}
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/libcares.php
Normal file
12
src/SPC/builder/linux/library/libcares.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libcares extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libcares;
|
||||||
|
|
||||||
|
public const NAME = 'libcares';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/liblz4.php
Normal file
12
src/SPC/builder/linux/library/liblz4.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class liblz4 extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\liblz4;
|
||||||
|
|
||||||
|
public const NAME = 'liblz4';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/librabbitmq.php
Normal file
12
src/SPC/builder/linux/library/librabbitmq.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class librabbitmq extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\librabbitmq;
|
||||||
|
|
||||||
|
public const NAME = 'librabbitmq';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/libtiff.php
Normal file
12
src/SPC/builder/linux/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libtiff extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libtiff;
|
||||||
|
|
||||||
|
public const NAME = 'libtiff';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/libuuid.php
Normal file
12
src/SPC/builder/linux/library/libuuid.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libuuid extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libuuid;
|
||||||
|
|
||||||
|
public const NAME = 'libuuid';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/libuv.php
Normal file
12
src/SPC/builder/linux/library/libuv.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libuv extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libuv;
|
||||||
|
|
||||||
|
public const NAME = 'libuv';
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ class libxml2 extends LinuxLibraryBase
|
|||||||
*/
|
*/
|
||||||
public function build(): void
|
public function build(): void
|
||||||
{
|
{
|
||||||
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||||
|
|
||||||
@@ -26,7 +26,9 @@ class libxml2 extends LinuxLibraryBase
|
|||||||
shell()->cd($this->source_dir . '/build')
|
shell()->cd($this->source_dir . '/build')
|
||||||
->exec(
|
->exec(
|
||||||
'cmake ' .
|
'cmake ' .
|
||||||
"{$this->builder->makeCmakeArgs()} " .
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||||
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||||
@@ -39,7 +41,7 @@ class libxml2 extends LinuxLibraryBase
|
|||||||
'..'
|
'..'
|
||||||
)
|
)
|
||||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install');
|
||||||
|
|
||||||
FileSystem::replaceFileStr(
|
FileSystem::replaceFileStr(
|
||||||
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
||||||
|
|||||||
@@ -1,72 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
|
||||||
*
|
|
||||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
|
||||||
* software according to the terms and conditions of the
|
|
||||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
*
|
|
||||||
* http://license.coscl.org.cn/MulanPSL2
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* See the Mulan PSL v2 for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SPC\builder\linux\library;
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
use SPC\exception\FileSystemException;
|
|
||||||
use SPC\exception\RuntimeException;
|
|
||||||
use SPC\exception\WrongUsageException;
|
|
||||||
|
|
||||||
class nghttp2 extends LinuxLibraryBase
|
class nghttp2 extends LinuxLibraryBase
|
||||||
{
|
{
|
||||||
|
use \SPC\builder\unix\library\nghttp2;
|
||||||
|
|
||||||
public const NAME = 'nghttp2';
|
public const NAME = 'nghttp2';
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FileSystemException
|
|
||||||
* @throws RuntimeException
|
|
||||||
* @throws WrongUsageException
|
|
||||||
*/
|
|
||||||
public function build(): void
|
|
||||||
{
|
|
||||||
$args = $this->builder->makeAutoconfArgs(static::NAME, [
|
|
||||||
'zlib' => null,
|
|
||||||
'openssl' => null,
|
|
||||||
'libxml2' => null,
|
|
||||||
'libev' => null,
|
|
||||||
'libcares' => null,
|
|
||||||
'libngtcp2' => null,
|
|
||||||
'libnghttp3' => null,
|
|
||||||
'libbpf' => null,
|
|
||||||
'libevent-openssl' => null,
|
|
||||||
'jansson' => null,
|
|
||||||
'jemalloc' => null,
|
|
||||||
'systemd' => null,
|
|
||||||
'cunit' => null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
[,,$destdir] = SEPARATED_PATH;
|
|
||||||
|
|
||||||
shell()->cd($this->source_dir)
|
|
||||||
->exec(
|
|
||||||
'./configure ' .
|
|
||||||
'--enable-static ' .
|
|
||||||
'--disable-shared ' .
|
|
||||||
"--host={$this->builder->getOption('gnu-arch')}-unknown-linux " .
|
|
||||||
'--enable-lib-only ' .
|
|
||||||
'--with-boost=no ' .
|
|
||||||
$args . ' ' .
|
|
||||||
'--prefix='
|
|
||||||
)
|
|
||||||
->exec('make clean')
|
|
||||||
->exec("make -j{$this->builder->concurrency}")
|
|
||||||
->exec("make install DESTDIR={$destdir}");
|
|
||||||
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/linux/library/tidy.php
Normal file
12
src/SPC/builder/linux/library/tidy.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class tidy extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\tidy;
|
||||||
|
|
||||||
|
public const NAME = 'tidy';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/unixodbc.php
Normal file
12
src/SPC/builder/linux/library/unixodbc.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class unixodbc extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\unixodbc;
|
||||||
|
|
||||||
|
public const NAME = 'unixodbc';
|
||||||
|
}
|
||||||
@@ -4,20 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\macos;
|
namespace SPC\builder\macos;
|
||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
|
||||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||||
use SPC\builder\traits\UnixBuilderTrait;
|
use SPC\builder\unix\UnixBuilderBase;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
|
|
||||||
class MacOSBuilder extends BuilderBase
|
class MacOSBuilder extends UnixBuilderBase
|
||||||
{
|
{
|
||||||
/** Unix compatible builder methods */
|
|
||||||
use UnixBuilderTrait;
|
|
||||||
|
|
||||||
/** @var bool Micro patch phar flag */
|
/** @var bool Micro patch phar flag */
|
||||||
private bool $phar_patched = false;
|
private bool $phar_patched = false;
|
||||||
|
|
||||||
@@ -141,10 +137,12 @@ class MacOSBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
$this->setOption('extra-libs', $extra_libs);
|
$this->setOption('extra-libs', $extra_libs);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-buildconf');
|
||||||
SourcePatcher::patchBeforeBuildconf($this);
|
SourcePatcher::patchBeforeBuildconf($this);
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-configure');
|
||||||
SourcePatcher::patchBeforeConfigure($this);
|
SourcePatcher::patchBeforeConfigure($this);
|
||||||
|
|
||||||
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
|
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
|
||||||
@@ -155,6 +153,21 @@ class MacOSBuilder extends BuilderBase
|
|||||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||||
|
|
||||||
|
// prepare build php envs
|
||||||
|
$envs_build_php = SystemUtil::makeEnvVarString([
|
||||||
|
'CFLAGS' => " {$this->arch_c_flags} -Werror=unknown-warning-option ",
|
||||||
|
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
|
||||||
|
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($this->getLib('postgresql')) {
|
||||||
|
shell()
|
||||||
|
->cd(SOURCE_PATH . '/php-src')
|
||||||
|
->exec(
|
||||||
|
'sed -i.backup "s/ac_cv_func_explicit_bzero\" = xyes/ac_cv_func_explicit_bzero\" = x_fake_yes/" ./configure'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec(
|
->exec(
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
@@ -162,7 +175,6 @@ class MacOSBuilder extends BuilderBase
|
|||||||
'--with-valgrind=no ' . // Not detect memory leak
|
'--with-valgrind=no ' . // Not detect memory leak
|
||||||
'--enable-shared=no ' .
|
'--enable-shared=no ' .
|
||||||
'--enable-static=yes ' .
|
'--enable-static=yes ' .
|
||||||
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
|
|
||||||
'--disable-all ' .
|
'--disable-all ' .
|
||||||
'--disable-cgi ' .
|
'--disable-cgi ' .
|
||||||
'--disable-phpdbg ' .
|
'--disable-phpdbg ' .
|
||||||
@@ -172,9 +184,11 @@ class MacOSBuilder extends BuilderBase
|
|||||||
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$this->makeExtensionArgs()
|
$this->makeExtensionArgs() . ' ' .
|
||||||
|
$envs_build_php
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('before-php-make');
|
||||||
SourcePatcher::patchBeforeMake($this);
|
SourcePatcher::patchBeforeMake($this);
|
||||||
|
|
||||||
$this->cleanMake();
|
$this->cleanMake();
|
||||||
@@ -200,6 +214,7 @@ class MacOSBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (php_uname('m') === $this->getOption('arch')) {
|
if (php_uname('m') === $this->getOption('arch')) {
|
||||||
|
$this->emitPatchPoint('before-sanity-check');
|
||||||
$this->sanityCheck($build_target);
|
$this->sanityCheck($build_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,12 +225,9 @@ class MacOSBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildCli(): void
|
protected function buildCli(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
|
||||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
|
||||||
]);
|
|
||||||
|
|
||||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||||
$shell->exec("make -j{$this->concurrency} {$vars} cli");
|
$shell->exec("make -j{$this->concurrency} {$vars} cli");
|
||||||
@@ -232,7 +244,7 @@ class MacOSBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
*/
|
*/
|
||||||
public function buildMicro(): void
|
protected function buildMicro(): void
|
||||||
{
|
{
|
||||||
if ($this->getPHPVersionID() < 80000) {
|
if ($this->getPHPVersionID() < 80000) {
|
||||||
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
|
||||||
@@ -246,9 +258,8 @@ class MacOSBuilder extends BuilderBase
|
|||||||
$vars = [
|
$vars = [
|
||||||
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
|
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
|
||||||
'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli,
|
'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli,
|
||||||
// link resolv library (macOS needs it)
|
|
||||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv",
|
|
||||||
];
|
];
|
||||||
|
$vars = $this->getBuildVars($vars);
|
||||||
if (!$this->getOption('no-strip', false)) {
|
if (!$this->getOption('no-strip', false)) {
|
||||||
$vars['STRIP'] = 'dsymutil -f ';
|
$vars['STRIP'] = 'dsymutil -f ';
|
||||||
}
|
}
|
||||||
@@ -269,12 +280,9 @@ class MacOSBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildFpm(): void
|
protected function buildFpm(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
|
||||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
|
||||||
]);
|
|
||||||
|
|
||||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||||
$shell->exec("make -j{$this->concurrency} {$vars} fpm");
|
$shell->exec("make -j{$this->concurrency} {$vars} fpm");
|
||||||
@@ -289,12 +297,9 @@ class MacOSBuilder extends BuilderBase
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function buildEmbed(): void
|
protected function buildEmbed(): void
|
||||||
{
|
{
|
||||||
$vars = SystemUtil::makeEnvVarString([
|
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
|
||||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
|
||||||
]);
|
|
||||||
|
|
||||||
shell()
|
shell()
|
||||||
->cd(SOURCE_PATH . '/php-src')
|
->cd(SOURCE_PATH . '/php-src')
|
||||||
@@ -308,4 +313,15 @@ class MacOSBuilder extends BuilderBase
|
|||||||
->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o')
|
->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o')
|
||||||
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
|
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getBuildVars($input = []): array
|
||||||
|
{
|
||||||
|
$optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os';
|
||||||
|
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
|
||||||
|
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
|
||||||
|
return [
|
||||||
|
'EXTRA_CFLAGS' => "{$optimization} {$cflags} " . $this->getOption('x-extra-cflags'),
|
||||||
|
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv {$libs} " . $this->getOption('x-extra-libs'),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/macos/library/gettext.php
Normal file
12
src/SPC/builder/macos/library/gettext.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class gettext extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\gettext;
|
||||||
|
|
||||||
|
public const NAME = 'gettext';
|
||||||
|
}
|
||||||
70
src/SPC/builder/macos/library/imap.php
Normal file
70
src/SPC/builder/macos/library/imap.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\store\SourcePatcher;
|
||||||
|
|
||||||
|
class imap extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
public const NAME = 'imap';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
$cc = getenv('CC') ?: 'clang';
|
||||||
|
SourcePatcher::patchFile('0001_imap_macos.patch', $this->source_dir);
|
||||||
|
// FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', '');
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}");
|
||||||
|
/* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto');
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz');
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
$this->source_dir . '/src/osdep/unix/ssl_unix.c',
|
||||||
|
"#include <x509v3.h>\n#include <ssl.h>",
|
||||||
|
"#include <ssl.h>\n#include <x509v3.h>"
|
||||||
|
);
|
||||||
|
// SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir);
|
||||||
|
SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH);
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
if ($this->builder->getLib('openssl')) {
|
||||||
|
$ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH;
|
||||||
|
} else {
|
||||||
|
$ssl_options = 'SSLTYPE=none';
|
||||||
|
}
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec('touch ip6')
|
||||||
|
->exec('chmod +x tools/an')
|
||||||
|
->exec('chmod +x tools/ua')
|
||||||
|
->exec('chmod +x src/osdep/unix/drivers')
|
||||||
|
->exec('chmod +x src/osdep/unix/mkauths')
|
||||||
|
->exec(
|
||||||
|
"yes | EXTRACFLAGS='-Wimplicit-function-declaration -include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h' make osx {$ssl_options}"
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
shell()
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a')
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/')
|
||||||
|
->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/')
|
||||||
|
->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/');
|
||||||
|
} catch (\Throwable) {
|
||||||
|
// last command throws an exception, no idea why since it works
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libargon2.php
Normal file
12
src/SPC/builder/macos/library/libargon2.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libargon2 extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libargon2;
|
||||||
|
|
||||||
|
public const NAME = 'libargon2';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libcares.php
Normal file
12
src/SPC/builder/macos/library/libcares.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libcares extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libcares;
|
||||||
|
|
||||||
|
public const NAME = 'libcares';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/liblz4.php
Normal file
12
src/SPC/builder/macos/library/liblz4.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class liblz4 extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\liblz4;
|
||||||
|
|
||||||
|
public const NAME = 'liblz4';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/librabbitmq.php
Normal file
12
src/SPC/builder/macos/library/librabbitmq.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class librabbitmq extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\librabbitmq;
|
||||||
|
|
||||||
|
public const NAME = 'librabbitmq';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libtiff.php
Normal file
12
src/SPC/builder/macos/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libtiff extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libtiff;
|
||||||
|
|
||||||
|
public const NAME = 'libtiff';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libuuid.php
Normal file
12
src/SPC/builder/macos/library/libuuid.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libuuid extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libuuid;
|
||||||
|
|
||||||
|
public const NAME = 'libuuid';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libuv.php
Normal file
12
src/SPC/builder/macos/library/libuv.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libuv extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libuv;
|
||||||
|
|
||||||
|
public const NAME = 'libuv';
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ class libxml2 extends MacOSLibraryBase
|
|||||||
*/
|
*/
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||||
|
|
||||||
@@ -27,7 +27,9 @@ class libxml2 extends MacOSLibraryBase
|
|||||||
->exec(
|
->exec(
|
||||||
'cmake ' .
|
'cmake ' .
|
||||||
// '--debug-find ' .
|
// '--debug-find ' .
|
||||||
"{$this->builder->makeCmakeArgs()} " .
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||||
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||||
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
||||||
@@ -39,6 +41,6 @@ class libxml2 extends MacOSLibraryBase
|
|||||||
'..'
|
'..'
|
||||||
)
|
)
|
||||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,51 +20,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\macos\library;
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
use SPC\exception\FileSystemException;
|
|
||||||
use SPC\exception\RuntimeException;
|
|
||||||
|
|
||||||
class nghttp2 extends MacOSLibraryBase
|
class nghttp2 extends MacOSLibraryBase
|
||||||
{
|
{
|
||||||
|
use \SPC\builder\unix\library\nghttp2;
|
||||||
|
|
||||||
public const NAME = 'nghttp2';
|
public const NAME = 'nghttp2';
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FileSystemException
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
protected function build(): void
|
|
||||||
{
|
|
||||||
$args = $this->builder->makeAutoconfArgs(static::NAME, [
|
|
||||||
'zlib' => null,
|
|
||||||
'openssl' => null,
|
|
||||||
'libxml2' => null,
|
|
||||||
'libev' => null,
|
|
||||||
'libcares' => null,
|
|
||||||
'libngtcp2' => null,
|
|
||||||
'libnghttp3' => null,
|
|
||||||
'libbpf' => null,
|
|
||||||
'libevent-openssl' => null,
|
|
||||||
'jansson' => null,
|
|
||||||
'jemalloc' => null,
|
|
||||||
'systemd' => null,
|
|
||||||
'cunit' => null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
[,,$destdir] = SEPARATED_PATH;
|
|
||||||
|
|
||||||
shell()->cd($this->source_dir)
|
|
||||||
->exec(
|
|
||||||
'./configure ' .
|
|
||||||
'--enable-static ' .
|
|
||||||
'--disable-shared ' .
|
|
||||||
"--host={$this->builder->getOption('gnu-arch')}-apple-darwin " .
|
|
||||||
'--enable-lib-only ' .
|
|
||||||
'--with-boost=no ' .
|
|
||||||
$args . ' ' .
|
|
||||||
'--prefix='
|
|
||||||
)
|
|
||||||
->exec('make clean')
|
|
||||||
->exec("make -j{$this->builder->concurrency}")
|
|
||||||
->exec("make install DESTDIR={$destdir}");
|
|
||||||
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/macos/library/tidy.php
Normal file
12
src/SPC/builder/macos/library/tidy.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class tidy extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\tidy;
|
||||||
|
|
||||||
|
public const NAME = 'tidy';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/unixodbc.php
Normal file
12
src/SPC/builder/macos/library/unixodbc.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class unixodbc extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\unixodbc;
|
||||||
|
|
||||||
|
public const NAME = 'unixodbc';
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace SPC\builder\traits;
|
|
||||||
|
|
||||||
trait LibraryTrait {}
|
|
||||||
@@ -12,8 +12,6 @@ use SPC\store\FileSystem;
|
|||||||
|
|
||||||
trait UnixLibraryTrait
|
trait UnixLibraryTrait
|
||||||
{
|
{
|
||||||
use LibraryTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
|
|||||||
@@ -2,15 +2,19 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SPC\builder\traits;
|
namespace SPC\builder\unix;
|
||||||
|
|
||||||
|
use SPC\builder\BuilderBase;
|
||||||
use SPC\builder\linux\LinuxBuilder;
|
use SPC\builder\linux\LinuxBuilder;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\store\SourceManager;
|
||||||
|
use SPC\util\DependencyUtil;
|
||||||
|
|
||||||
trait UnixBuilderTrait
|
abstract class UnixBuilderBase extends BuilderBase
|
||||||
{
|
{
|
||||||
/** @var string cflags */
|
/** @var string cflags */
|
||||||
public string $arch_c_flags;
|
public string $arch_c_flags;
|
||||||
@@ -49,94 +53,6 @@ trait UnixBuilderTrait
|
|||||||
return array_map(fn ($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles);
|
return array_map(fn ($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sanity check after build complete
|
|
||||||
*
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
public function sanityCheck(int $build_target): void
|
|
||||||
{
|
|
||||||
// sanity check for php-cli
|
|
||||||
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
|
||||||
logger()->info('running cli sanity check');
|
|
||||||
[$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "echo \"hello\";"');
|
|
||||||
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
|
||||||
throw new RuntimeException('cli failed sanity check');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->exts as $ext) {
|
|
||||||
logger()->debug('testing ext: ' . $ext->getName());
|
|
||||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $ext->getDistName() . '"', false);
|
|
||||||
if ($ret !== 0) {
|
|
||||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) {
|
|
||||||
// Trim additional content & escape special characters to allow inline usage
|
|
||||||
$test = str_replace(
|
|
||||||
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
|
||||||
['', '', '', '\"', '\$'],
|
|
||||||
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')
|
|
||||||
);
|
|
||||||
|
|
||||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
|
||||||
if ($ret !== 0) {
|
|
||||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sanity check for phpmicro
|
|
||||||
if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
|
|
||||||
if (file_exists(SOURCE_PATH . '/hello.exe')) {
|
|
||||||
@unlink(SOURCE_PATH . '/hello.exe');
|
|
||||||
}
|
|
||||||
file_put_contents(
|
|
||||||
SOURCE_PATH . '/hello.exe',
|
|
||||||
file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') .
|
|
||||||
'<?php echo "hello";'
|
|
||||||
);
|
|
||||||
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
|
||||||
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
|
||||||
if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') {
|
|
||||||
throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将编译好的二进制文件发布到 buildroot
|
|
||||||
*
|
|
||||||
* @param int $type 发布类型
|
|
||||||
* @throws RuntimeException
|
|
||||||
* @throws FileSystemException
|
|
||||||
*/
|
|
||||||
public function deployBinary(int $type): bool
|
|
||||||
{
|
|
||||||
$src = match ($type) {
|
|
||||||
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
|
||||||
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
|
||||||
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
|
|
||||||
default => throw new RuntimeException('Deployment does not accept type ' . $type),
|
|
||||||
};
|
|
||||||
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
|
||||||
FileSystem::createDir(BUILD_ROOT_PATH . '/bin');
|
|
||||||
shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '/bin/'));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run php clean
|
|
||||||
*
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
public function cleanMake(): void
|
|
||||||
{
|
|
||||||
logger()->info('cleaning up');
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return generic cmake options when configuring cmake projects
|
* Return generic cmake options when configuring cmake projects
|
||||||
*/
|
*/
|
||||||
@@ -173,4 +89,139 @@ trait UnixBuilderTrait
|
|||||||
}
|
}
|
||||||
return $extra;
|
return $extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function buildLibs(array $sorted_libraries): void
|
||||||
|
{
|
||||||
|
// search all supported libs
|
||||||
|
$support_lib_list = [];
|
||||||
|
$classes = FileSystem::getClassesPsr4(
|
||||||
|
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
|
||||||
|
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
||||||
|
);
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
||||||
|
$support_lib_list[$class::NAME] = $class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no libs specified, compile all supported libs
|
||||||
|
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
||||||
|
$libraries = array_keys($support_lib_list);
|
||||||
|
$sorted_libraries = DependencyUtil::getLibs($libraries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// pkg-config must be compiled first, whether it is specified or not
|
||||||
|
if (!in_array('pkg-config', $sorted_libraries)) {
|
||||||
|
array_unshift($sorted_libraries, 'pkg-config');
|
||||||
|
}
|
||||||
|
|
||||||
|
// add lib object for builder
|
||||||
|
foreach ($sorted_libraries as $library) {
|
||||||
|
// if some libs are not supported (but in config "lib.json", throw exception)
|
||||||
|
if (!isset($support_lib_list[$library])) {
|
||||||
|
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||||
|
}
|
||||||
|
$lib = new ($support_lib_list[$library])($this);
|
||||||
|
$this->addLib($lib);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate and check dependencies
|
||||||
|
foreach ($this->libs as $lib) {
|
||||||
|
$lib->calcDependency();
|
||||||
|
}
|
||||||
|
|
||||||
|
// patch point
|
||||||
|
$this->emitPatchPoint('before-libs-extract');
|
||||||
|
|
||||||
|
// extract sources
|
||||||
|
SourceManager::initSource(libs: $sorted_libraries);
|
||||||
|
|
||||||
|
$this->emitPatchPoint('after-libs-extract');
|
||||||
|
|
||||||
|
// build all libs
|
||||||
|
foreach ($this->libs as $lib) {
|
||||||
|
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
||||||
|
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
||||||
|
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
||||||
|
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
||||||
|
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanity check after build complete
|
||||||
|
*
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function sanityCheck(int $build_target): void
|
||||||
|
{
|
||||||
|
// sanity check for php-cli
|
||||||
|
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
||||||
|
logger()->info('running cli sanity check');
|
||||||
|
[$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "echo \"hello\";"');
|
||||||
|
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
||||||
|
throw new RuntimeException('cli failed sanity check');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->exts as $ext) {
|
||||||
|
logger()->debug('testing ext: ' . $ext->getName());
|
||||||
|
$ext->runCliCheckUnix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sanity check for phpmicro
|
||||||
|
if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
|
||||||
|
if (file_exists(SOURCE_PATH . '/hello.exe')) {
|
||||||
|
@unlink(SOURCE_PATH . '/hello.exe');
|
||||||
|
}
|
||||||
|
file_put_contents(
|
||||||
|
SOURCE_PATH . '/hello.exe',
|
||||||
|
file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') .
|
||||||
|
($this->getOption('without-micro-ext-test') ? '<?php echo "[micro-test-start][micro-test-end]";' : $this->generateMicroExtTests())
|
||||||
|
);
|
||||||
|
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
||||||
|
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
||||||
|
$raw_out = trim(implode('', $output2));
|
||||||
|
$condition[0] = $ret === 0;
|
||||||
|
$condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]');
|
||||||
|
foreach ($condition as $k => $v) {
|
||||||
|
if (!$v) {
|
||||||
|
throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将编译好的二进制文件发布到 buildroot
|
||||||
|
*
|
||||||
|
* @param int $type 发布类型
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
protected function deployBinary(int $type): bool
|
||||||
|
{
|
||||||
|
$src = match ($type) {
|
||||||
|
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
||||||
|
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
||||||
|
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
|
||||||
|
default => throw new RuntimeException('Deployment does not accept type ' . $type),
|
||||||
|
};
|
||||||
|
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
||||||
|
FileSystem::createDir(BUILD_ROOT_PATH . '/bin');
|
||||||
|
shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '/bin/'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run php clean
|
||||||
|
*
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function cleanMake(): void
|
||||||
|
{
|
||||||
|
logger()->info('cleaning up');
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,7 @@ trait brotli
|
|||||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
||||||
shell()->cd(BUILD_ROOT_PATH . '/lib')
|
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
||||||
->exec('ln -s libbrotlicommon.a libbrotlicommon-static.a')
|
|
||||||
->exec('ln -s libbrotlidec.a libbrotlidec-static.a')
|
|
||||||
->exec('ln -s libbrotlienc.a libbrotlienc-static.a');
|
|
||||||
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ trait curl
|
|||||||
// compile!
|
// compile!
|
||||||
shell()->cd($this->source_dir . '/build')
|
shell()->cd($this->source_dir . '/build')
|
||||||
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
||||||
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..")
|
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
||||||
->exec("make -j{$this->builder->concurrency}")
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
// patch pkgconf
|
// patch pkgconf
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ trait freetype
|
|||||||
$suggested .= ' ';
|
$suggested .= ' ';
|
||||||
|
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('sh autogen.sh')
|
||||||
->exec(
|
->exec(
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
|
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
|
||||||
|
|||||||
28
src/SPC/builder/unix/library/gettext.php
Normal file
28
src/SPC/builder/unix/library/gettext.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
trait gettext
|
||||||
|
{
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
$extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : '';
|
||||||
|
$extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : '';
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec(
|
||||||
|
'./configure ' .
|
||||||
|
'--enable-static ' .
|
||||||
|
'--disable-shared ' .
|
||||||
|
'--disable-java ' .
|
||||||
|
'--disable-c+ ' .
|
||||||
|
$extra .
|
||||||
|
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||||
|
'--prefix=' . BUILD_ROOT_PATH
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec('make install');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||||
|
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
@@ -39,8 +40,12 @@ trait imagemagick
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : '';
|
$ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : '';
|
||||||
|
|
||||||
|
// libxml iconv patch
|
||||||
|
$required_libs .= $this instanceof MacOSLibraryBase ? (' -liconv') : '';
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->exec(
|
->exec(
|
||||||
|
'PKG_CONFIG="$PKG_CONFIG --static" ' .
|
||||||
$ldflags .
|
$ldflags .
|
||||||
"LIBS='{$required_libs}' " .
|
"LIBS='{$required_libs}' " .
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
|
|||||||
@@ -4,17 +4,27 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
trait ldap
|
trait ldap
|
||||||
{
|
{
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
$alt = '';
|
$alt = '';
|
||||||
// openssl support
|
// openssl support
|
||||||
$alt .= $this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : '';
|
$alt .= $this->builder->getLib('openssl') ? '--with-tls=openssl ' : '';
|
||||||
// gmp support
|
// gmp support
|
||||||
$alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : '';
|
$alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : '';
|
||||||
// libsodium support
|
// libsodium support
|
||||||
$alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '';
|
$alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '--enable-argon2=no ';
|
||||||
|
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||||
|
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->exec(
|
->exec(
|
||||||
$this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) .
|
$this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) .
|
||||||
@@ -22,7 +32,6 @@ trait ldap
|
|||||||
'--enable-static ' .
|
'--enable-static ' .
|
||||||
'--disable-shared ' .
|
'--disable-shared ' .
|
||||||
'--disable-slapd ' .
|
'--disable-slapd ' .
|
||||||
'--disable-slurpd ' .
|
|
||||||
'--without-systemd ' .
|
'--without-systemd ' .
|
||||||
'--without-cyrus-sasl ' .
|
'--without-cyrus-sasl ' .
|
||||||
$alt .
|
$alt .
|
||||||
|
|||||||
26
src/SPC/builder/unix/library/libargon2.php
Normal file
26
src/SPC/builder/unix/library/libargon2.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait libargon2
|
||||||
|
{
|
||||||
|
protected function build()
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec("make PREFIX='' clean")
|
||||||
|
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||||
|
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
|
$this->patchPkgconfPrefix(['libargon2.pc']);
|
||||||
|
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/SPC/builder/unix/library/libcares.php
Normal file
21
src/SPC/builder/unix/library/libcares.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
|
||||||
|
trait libcares
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('./configure --prefix=' . BUILD_ROOT_PATH . ' --enable-static --disable-shared --disable-tests')
|
||||||
|
->exec("make -j {$this->builder->concurrency}")
|
||||||
|
->exec('make install');
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/SPC/builder/unix/library/liblz4.php
Normal file
26
src/SPC/builder/unix/library/liblz4.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait liblz4
|
||||||
|
{
|
||||||
|
protected function build()
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec("make PREFIX='' clean")
|
||||||
|
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||||
|
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
|
$this->patchPkgconfPrefix(['liblz4.pc']);
|
||||||
|
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/SPC/builder/unix/library/librabbitmq.php
Normal file
35
src/SPC/builder/unix/library/librabbitmq.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait librabbitmq
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
// CMake needs a clean build directory
|
||||||
|
FileSystem::resetDir($this->source_dir . '/build');
|
||||||
|
// Start build
|
||||||
|
shell()->cd($this->source_dir . '/build')
|
||||||
|
->exec(
|
||||||
|
'cmake ' .
|
||||||
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||||
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||||
|
'-DBUILD_STATIC_LIBS=ON ' .
|
||||||
|
'..'
|
||||||
|
)
|
||||||
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
|
->exec('make install');
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/SPC/builder/unix/library/libtiff.php
Normal file
30
src/SPC/builder/unix/library/libtiff.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
|
||||||
|
trait libtiff
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec(
|
||||||
|
'./configure ' .
|
||||||
|
'--enable-static --disable-shared ' .
|
||||||
|
'--disable-cxx ' .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/SPC/builder/unix/library/libuuid.php
Normal file
38
src/SPC/builder/unix/library/libuuid.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait libuuid
|
||||||
|
{
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/configure', '-${am__api_version}', '');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('chmod +x configure')
|
||||||
|
->exec('chmod +x install-sh')
|
||||||
|
->exec(
|
||||||
|
'./configure ' .
|
||||||
|
'--enable-static --disable-shared ' .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
$this->patchPkgconfPrefix(['uuid.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/SPC/builder/unix/library/libuv.php
Normal file
29
src/SPC/builder/unix/library/libuv.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait libuv
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
// CMake needs a clean build directory
|
||||||
|
FileSystem::resetDir($this->source_dir . '/build');
|
||||||
|
// Start build
|
||||||
|
shell()->cd($this->source_dir . '/build')
|
||||||
|
->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..")
|
||||||
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
// patch pkgconfig
|
||||||
|
$this->patchPkgconfPrefix(['libuv-static.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/SPC/builder/unix/library/nghttp2.php
Normal file
53
src/SPC/builder/unix/library/nghttp2.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
|
||||||
|
trait nghttp2
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws WrongUsageException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
$args = $this->builder->makeAutoconfArgs(static::NAME, [
|
||||||
|
'zlib' => null,
|
||||||
|
'openssl' => null,
|
||||||
|
'libxml2' => null,
|
||||||
|
'libev' => null,
|
||||||
|
'libcares' => null,
|
||||||
|
'libngtcp2' => null,
|
||||||
|
'libnghttp3' => null,
|
||||||
|
'libbpf' => null,
|
||||||
|
'libevent-openssl' => null,
|
||||||
|
'jansson' => null,
|
||||||
|
'jemalloc' => null,
|
||||||
|
'systemd' => null,
|
||||||
|
'cunit' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
[,,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec(
|
||||||
|
'./configure ' .
|
||||||
|
'--enable-static ' .
|
||||||
|
'--disable-shared ' .
|
||||||
|
'--enable-lib-only ' .
|
||||||
|
'--with-boost=no ' .
|
||||||
|
$args . ' ' .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec("make install DESTDIR={$destdir}");
|
||||||
|
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ trait pkgconfig
|
|||||||
'--disable-shared ' .
|
'--disable-shared ' .
|
||||||
'--enable-static ' .
|
'--enable-static ' .
|
||||||
'--with-internal-glib ' .
|
'--with-internal-glib ' .
|
||||||
|
'--disable-host-tool ' .
|
||||||
|
'--with-pic ' .
|
||||||
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||||
'--without-sysroot ' .
|
'--without-sysroot ' .
|
||||||
'--without-system-include-path ' .
|
'--without-system-include-path ' .
|
||||||
@@ -29,6 +31,7 @@ trait pkgconfig
|
|||||||
)
|
)
|
||||||
->exec('make clean')
|
->exec('make clean')
|
||||||
->exec("make -j{$this->builder->concurrency}")
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
->exec('make install');
|
->exec('make install-exec');
|
||||||
|
shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user