mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
165 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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'
|
||||
type: choice
|
||||
options:
|
||||
- '8.3'
|
||||
- '8.2'
|
||||
- '8.1'
|
||||
- '8.0'
|
||||
@@ -51,7 +52,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -67,7 +68,7 @@ jobs:
|
||||
|
||||
# If there's no dependencies cache, fetch sources, with or without debug
|
||||
- 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: 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'
|
||||
type: choice
|
||||
options:
|
||||
- '8.3'
|
||||
- '8.2'
|
||||
- '8.1'
|
||||
- '8.0'
|
||||
@@ -56,7 +57,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -72,7 +73,7 @@ jobs:
|
||||
|
||||
# If there's no dependencies cache, fetch sources, with or without debug
|
||||
- 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: ./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-macos-x86_64.yml
vendored
5
.github/workflows/build-macos-x86_64.yml
vendored
@@ -9,6 +9,7 @@ on:
|
||||
default: '8.2'
|
||||
type: choice
|
||||
options:
|
||||
- '8.3'
|
||||
- '8.2'
|
||||
- '8.1'
|
||||
- '8.0'
|
||||
@@ -61,7 +62,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -77,7 +78,7 @@ jobs:
|
||||
|
||||
# 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 }} --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: ./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/
|
||||
73
.github/workflows/release-build.yml
vendored
73
.github/workflows/release-build.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Upload SPC Binary (Release)
|
||||
name: Build SPC Binary
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
@@ -8,10 +10,14 @@ on:
|
||||
|
||||
jobs:
|
||||
build-release-artifacts:
|
||||
name: "Upload SPC Binary (Release)"
|
||||
name: "Build SPC Binary"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "8.1"
|
||||
micro-version:
|
||||
- "8.1.26"
|
||||
operating-system:
|
||||
- "linux-x86_64"
|
||||
- "macos-x86_64"
|
||||
@@ -21,18 +27,57 @@ jobs:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
- name: Reuse static-php-cli-hosted artifacts
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
- if: inputs.debug == true
|
||||
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
|
||||
|
||||
- name: "Install PHP for official runners"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
repo: crazywhalecc/static-php-cli-hosted
|
||||
branch: master
|
||||
workflow: build-spc-release.yml
|
||||
name: "spc-${{ matrix.operating-system }}"
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
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: |
|
||||
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
|
||||
|
||||
- name: "Generate Executable"
|
||||
run: |
|
||||
cat micro.sfx spc.phar > spc
|
||||
chmod +x spc
|
||||
|
||||
- name: "Archive Executable"
|
||||
run: |
|
||||
tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
|
||||
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
|
||||
|
||||
- name: "Copy file"
|
||||
run: "mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS"
|
||||
|
||||
- name: upload binaries to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
@@ -40,6 +85,18 @@ jobs:
|
||||
with:
|
||||
files: ${{ 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"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
||||
214
.github/workflows/tests.yml
vendored
214
.github/workflows/tests.yml
vendored
@@ -1,98 +1,156 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/globals/test-extensions.php'
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
tools: pecl, composer, php-cs-fixer
|
||||
- name: "Setup PHP"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
tools: pecl, composer, php-cs-fixer
|
||||
|
||||
- name: Run PHP-CS-Fixer fix
|
||||
run: php-cs-fixer fix --dry-run --diff --ansi
|
||||
- name: Run PHP-CS-Fixer fix
|
||||
run: php-cs-fixer fix --dry-run --diff --ansi
|
||||
|
||||
phpstan:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
phpstan:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
tools: composer
|
||||
- name: "Setup PHP"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
tools: composer
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-phpstan-
|
||||
- name: "Cache Composer packages"
|
||||
id: composer-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-phpstan-
|
||||
|
||||
- name: Install Dependencies
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
- name: "Install Dependencies"
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
|
||||
- name: Run phpstan
|
||||
run: vendor/bin/phpstan analyse
|
||||
- name: "Run phpstan"
|
||||
run: vendor/bin/phpstan analyse
|
||||
|
||||
phpunit:
|
||||
name: PHPUnit (PHP ${{ matrix.php }})
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- php: '8.1'
|
||||
- php: '8.2'
|
||||
fail-fast: false
|
||||
phpunit:
|
||||
name: "PHPUnit (PHP ${{ matrix.php }})"
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- php: '8.1'
|
||||
- php: '8.2'
|
||||
- php: '8.3'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "${{ matrix.php }}"
|
||||
tools: pecl, composer
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
- name: "Setup PHP"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "${{ matrix.php }}"
|
||||
tools: pecl, composer
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
|
||||
- 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-
|
||||
- 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-
|
||||
|
||||
- name: Install Dependencies
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
- name: "Install Dependencies"
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
|
||||
- name: Run PHPUnit tests
|
||||
run: |
|
||||
vendor/bin/phpunit tests/ --no-coverage
|
||||
- name: "Run PHPUnit Tests"
|
||||
run: |
|
||||
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
|
||||
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: "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)"
|
||||
run: 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 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
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -22,9 +22,12 @@ docker/source/
|
||||
|
||||
# exclude self-runtime
|
||||
/bin/*
|
||||
!/bin/spc
|
||||
!/bin/setup-runtime
|
||||
!/bin/spc*
|
||||
!/bin/setup-runtime*
|
||||
!/bin/spc-alpine-docker
|
||||
|
||||
# exclude windows build tools
|
||||
/php-sdk-binary-tools/
|
||||
|
||||
# default test directory
|
||||
/tests/var/
|
||||
|
||||
@@ -63,6 +63,7 @@ return (new PhpCsFixer\Config())
|
||||
'phpdoc_summary' => false,
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
'phpdoc_var_without_name' => false,
|
||||
'fully_qualified_strict_types' => false,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC'])
|
||||
|
||||
19
README-zh.md
19
README-zh.md
@@ -12,13 +12,12 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
||||
|
||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||
|
||||
> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。
|
||||
> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/static-php/phpmicro)。
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[]()
|
||||
[]()
|
||||
|
||||
> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎
|
||||
@@ -29,9 +28,11 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
||||
|
||||
## 自托管直接下载
|
||||
|
||||
如果你不想自行编译 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 左右。
|
||||
|
||||
## 使用 static-php-cli 构建 PHP
|
||||
|
||||
@@ -131,7 +132,7 @@ chmod +x bin/spc
|
||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
||||
```
|
||||
|
||||
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.2:
|
||||
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3:
|
||||
|
||||
```bash
|
||||
# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建
|
||||
@@ -232,7 +233,7 @@ 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) 贡献。
|
||||
|
||||
## 赞助本项目
|
||||
|
||||
|
||||
72
README.md
72
README.md
@@ -4,6 +4,8 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
||||
|
||||
🌐 **[中文](README-zh.md)** | **[English](README.md)**
|
||||
|
||||
> 2.0 Release is coming soon, windows support will be added in v2.1.
|
||||
|
||||
The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎
|
||||
|
||||
Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI)
|
||||
@@ -14,26 +16,29 @@ You can also use the micro binary file to combine php binary and php source code
|
||||
|
||||
<img width="600" alt="2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||
|
||||
> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
|
||||
> This SAPI feature is from the [Fork](https://github.com/static-php/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html))
|
||||
[]()
|
||||
|
||||
## Docs
|
||||
## Documentation
|
||||
|
||||
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
|
||||
|
||||
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 compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.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.
|
||||
|
||||
- [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.
|
||||
|
||||
## Use static-php-cli to build PHP
|
||||
|
||||
@@ -65,6 +70,8 @@ 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.
|
||||
|
||||
Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) .
|
||||
|
||||
### GitHub Actions Build
|
||||
|
||||
Use GitHub Action to easily build a statically compiled PHP,
|
||||
@@ -88,13 +95,12 @@ Currently, the platforms supported by `spc` binary are Linux and macOS.
|
||||
|
||||
Here's how to download from GitHub Actions:
|
||||
|
||||
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`.
|
||||
1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml) or [self-hosted nightly builds](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/).
|
||||
2. If you download from GHA, select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform.
|
||||
3. If you download from GHA, unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`.
|
||||
4. If you download from self-hosted server, download `spc-$os-$arch` file and just use it (don't forget `chmod +x`).
|
||||
|
||||
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.
|
||||
> SPC single-file binary is built by phpmicro and box, and it doesn't need to install PHP. Just treat `spc` as a standalone executable.
|
||||
|
||||
### Manual build (using source code)
|
||||
|
||||
@@ -134,7 +140,7 @@ Basic usage for building php and micro with some extensions:
|
||||
> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands.
|
||||
|
||||
```bash
|
||||
# Check system tool dependencies, fix them automatically
|
||||
# Check system tool dependencies, fix them if possible
|
||||
./bin/spc doctor
|
||||
# fetch all libraries
|
||||
./bin/spc download --all
|
||||
@@ -144,7 +150,7 @@ Basic usage for building php and micro with some extensions:
|
||||
./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro
|
||||
```
|
||||
|
||||
You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2:
|
||||
You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.3:
|
||||
|
||||
```bash
|
||||
# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro
|
||||
@@ -166,7 +172,7 @@ If anything goes wrong, use `--debug` option to display full terminal output:
|
||||
./bin/spc fetch --all --debug
|
||||
```
|
||||
|
||||
In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option.
|
||||
In addition, we build NTS (non-thread-safe) 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
|
||||
@@ -197,7 +203,7 @@ cd buildroot/bin/
|
||||
|
||||
> phpmicro is a SelF-extracted eXecutable SAPI module,
|
||||
> 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.
|
||||
|
||||
When using the parameter `--build-all` or `--build-micro`,
|
||||
@@ -227,7 +233,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
|
||||
```
|
||||
|
||||
> 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
|
||||
|
||||
@@ -235,7 +241,7 @@ When using the parameter `--build-all` or `--build-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.
|
||||
|
||||
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.
|
||||
|
||||
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
|
||||
@@ -257,12 +263,9 @@ 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 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).
|
||||
|
||||
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.
|
||||
If you want to contribute documentation, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs).
|
||||
|
||||
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
|
||||
|
||||
@@ -271,11 +274,13 @@ You can sponsor my project on [this page](https://github.com/crazywhalecc/crazyw
|
||||
## Open-Source 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),
|
||||
and the headers of these code files will also be given additional instructions LICENSE and AUTHOR:
|
||||
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.
|
||||
|
||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License)
|
||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE)
|
||||
These are similar projects:
|
||||
|
||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
|
||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
|
||||
|
||||
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,
|
||||
@@ -284,8 +289,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,
|
||||
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)
|
||||
|
||||
# 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"
|
||||
|
||||
# use china mirror
|
||||
@@ -35,7 +35,6 @@ while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--mirror)
|
||||
mirror="$2"
|
||||
shift
|
||||
;;
|
||||
--*)
|
||||
echo "Illegal option $1"
|
||||
@@ -46,8 +45,8 @@ done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
||||
__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.tencent.com/composer/composer.phar"
|
||||
;;
|
||||
|
||||
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)
|
||||
Start-Process ($WorkingDir + "\php.exe") ($WorkingDir + "\composer.phar " + $args) -NoNewWindow -Wait
|
||||
'
|
||||
$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."
|
||||
8
bin/spc
8
bin/spc
@@ -4,7 +4,13 @@
|
||||
use SPC\ConsoleApplication;
|
||||
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 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?)
|
||||
if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {
|
||||
|
||||
@@ -73,6 +73,7 @@ RUN apk update; \
|
||||
git \
|
||||
jq \
|
||||
libgcc \
|
||||
libtool \
|
||||
libstdc++ \
|
||||
linux-headers \
|
||||
m4 \
|
||||
|
||||
12
bin/spc.ps1
Normal file
12
bin/spc.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
$PHP_Exec = "runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
if (-not $PHP_Exec) {
|
||||
Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$phpArgs = "bin\spc " + $args
|
||||
Start-Process $PHP_Exec -ArgumentList $phpArgs -NoNewWindow -Wait
|
||||
@@ -11,7 +11,6 @@
|
||||
"require": {
|
||||
"php": ">= 8.1",
|
||||
"ext-mbstring": "*",
|
||||
"ext-pcntl": "*",
|
||||
"laravel/prompts": "^0.1.12",
|
||||
"symfony/console": "^5.4 || ^6 || ^7",
|
||||
"zhamao/logger": "^1.0"
|
||||
|
||||
545
composer.lock
generated
545
composer.lock
generated
File diff suppressed because it is too large
Load Diff
117
config/ext.json
117
config/ext.json
@@ -118,10 +118,14 @@
|
||||
"iconv": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends-windows": [
|
||||
"lib-depends": [
|
||||
"libiconv"
|
||||
]
|
||||
},
|
||||
"igbinary": {
|
||||
"type": "external",
|
||||
"source": "igbinary"
|
||||
},
|
||||
"imagick": {
|
||||
"type": "external",
|
||||
"source": "ext-imagick",
|
||||
@@ -132,12 +136,12 @@
|
||||
},
|
||||
"imap": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"imap"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"kerberos"
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"inotify": {
|
||||
@@ -169,14 +173,14 @@
|
||||
"arg-type": "custom",
|
||||
"ext-depends": [
|
||||
"mbstring"
|
||||
],
|
||||
"lib-depends": [
|
||||
"onig"
|
||||
]
|
||||
},
|
||||
"mbstring": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"onig"
|
||||
]
|
||||
"arg-type": "custom"
|
||||
},
|
||||
"memcache": {
|
||||
"type": "external",
|
||||
@@ -228,18 +232,27 @@
|
||||
]
|
||||
},
|
||||
"opcache": {
|
||||
"type": "builtin"
|
||||
"type": "builtin",
|
||||
"arg-type": "custom"
|
||||
},
|
||||
"openssl": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
"openssl",
|
||||
"zlib"
|
||||
],
|
||||
"ext-depends": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"password-argon2": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"libargon2"
|
||||
]
|
||||
},
|
||||
"pcntl": {
|
||||
"type": "builtin",
|
||||
"unix-only": true
|
||||
@@ -305,6 +318,11 @@
|
||||
"aspell"
|
||||
]
|
||||
},
|
||||
"rar": {
|
||||
"type": "external",
|
||||
"source": "rar",
|
||||
"cpp-extension": true
|
||||
},
|
||||
"readline": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
@@ -317,7 +335,12 @@
|
||||
"source": "redis",
|
||||
"arg-type": "custom",
|
||||
"ext-suggests": [
|
||||
"session"
|
||||
"session",
|
||||
"igbinary"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd",
|
||||
"liblz4"
|
||||
]
|
||||
},
|
||||
"session": {
|
||||
@@ -377,6 +400,17 @@
|
||||
"sqlite"
|
||||
]
|
||||
},
|
||||
"sqlsrv": {
|
||||
"type": "external",
|
||||
"source": "sqlsrv",
|
||||
"lib-depends": [
|
||||
"unixodbc"
|
||||
],
|
||||
"ext-depends-linux": [
|
||||
"pcntl"
|
||||
],
|
||||
"cpp-extension": true
|
||||
},
|
||||
"ssh2": {
|
||||
"type": "external",
|
||||
"source": "ext-ssh2",
|
||||
@@ -390,17 +424,50 @@
|
||||
"source": "swoole",
|
||||
"arg-type": "custom",
|
||||
"cpp-extension": true,
|
||||
"unix-only": true,
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
"libcares",
|
||||
"brotli",
|
||||
"nghttp2",
|
||||
"zlib"
|
||||
],
|
||||
"ext-depends": [
|
||||
"openssl"
|
||||
"openssl",
|
||||
"curl"
|
||||
],
|
||||
"ext-suggests": [
|
||||
"curl",
|
||||
"pgsql"
|
||||
"swoole-hook-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": {
|
||||
"type": "external",
|
||||
@@ -429,7 +496,7 @@
|
||||
},
|
||||
"tidy": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"tidy"
|
||||
]
|
||||
@@ -437,6 +504,24 @@
|
||||
"tokenizer": {
|
||||
"type": "builtin"
|
||||
},
|
||||
"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": {
|
||||
"type": "external",
|
||||
"source": "xlswriter",
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
"brotli": {
|
||||
"source": "brotli",
|
||||
"static-libs-unix": [
|
||||
"libbrotlidec-static.a",
|
||||
"libbrotlienc-static.a",
|
||||
"libbrotlicommon-static.a"
|
||||
"libbrotlidec.a",
|
||||
"libbrotlienc.a",
|
||||
"libbrotlicommon.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"brotlicommon-static.lib",
|
||||
"brotlienc-static.lib",
|
||||
"brotlidec-static.lib"
|
||||
"brotlicommon.lib",
|
||||
"brotlienc.lib",
|
||||
"brotlidec.lib"
|
||||
],
|
||||
"headers": [
|
||||
"brotli"
|
||||
@@ -141,24 +141,52 @@
|
||||
"libxml2"
|
||||
]
|
||||
},
|
||||
"imap": {
|
||||
"source": "imap",
|
||||
"static-libs-unix": [
|
||||
"libc-client.a"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"ldap": {
|
||||
"source": "ldap",
|
||||
"static-libs-unix": [
|
||||
"liblber.a",
|
||||
"libldap.a"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"lib-depends": [
|
||||
"openssl",
|
||||
"zlib",
|
||||
"gmp",
|
||||
"libsodium"
|
||||
]
|
||||
},
|
||||
"libargon2": {
|
||||
"source": "libargon2",
|
||||
"static-libs-unix": [
|
||||
"libargon2.a"
|
||||
]
|
||||
},
|
||||
"libavif": {
|
||||
"source": "libavif",
|
||||
"static-libs-unix": [
|
||||
"libavif.a"
|
||||
]
|
||||
},
|
||||
"libcares": {
|
||||
"source": "libcares",
|
||||
"static-libs-unix": [
|
||||
"libcares.a"
|
||||
],
|
||||
"headers-unix": [
|
||||
"ares.h",
|
||||
"ares_dns.h",
|
||||
"ares_nameser.h",
|
||||
"ares_rules.h"
|
||||
]
|
||||
},
|
||||
"libevent": {
|
||||
"source": "libevent",
|
||||
"static-libs-unix": [
|
||||
@@ -208,10 +236,10 @@
|
||||
"libturbojpeg.a"
|
||||
]
|
||||
},
|
||||
"libmcrypt": {
|
||||
"source": "libmcrypt",
|
||||
"liblz4": {
|
||||
"source": "liblz4",
|
||||
"static-libs-unix": [
|
||||
"libmcrypt.a"
|
||||
"liblz4.a"
|
||||
]
|
||||
},
|
||||
"libmemcached": {
|
||||
@@ -268,6 +296,12 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"libuv": {
|
||||
"source": "libuv",
|
||||
"static-libs-unix": [
|
||||
"libuv.a"
|
||||
]
|
||||
},
|
||||
"libwebp": {
|
||||
"source": "libwebp",
|
||||
"static-libs-unix": [
|
||||
@@ -293,17 +327,12 @@
|
||||
"libxml2"
|
||||
],
|
||||
"lib-depends": [
|
||||
"libiconv",
|
||||
"zlib"
|
||||
"libiconv"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"xz",
|
||||
"icu"
|
||||
],
|
||||
"lib-suggests-windows": [
|
||||
"icu",
|
||||
"xz",
|
||||
"pthreads4w"
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"libxslt": {
|
||||
@@ -353,12 +382,6 @@
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"mcrypt": {
|
||||
"source": "mcrypt",
|
||||
"static-libs-unix": [
|
||||
"libmcrypt.a"
|
||||
]
|
||||
},
|
||||
"ncurses": {
|
||||
"source": "ncurses",
|
||||
"static-libs-unix": [
|
||||
@@ -441,18 +464,6 @@
|
||||
"zstd"
|
||||
]
|
||||
},
|
||||
"pthreads4w": {
|
||||
"source": "pthreads4w",
|
||||
"static-libs-windows": [
|
||||
"libpthreadVC3.lib"
|
||||
],
|
||||
"headers-windows": [
|
||||
"_ptw32.h",
|
||||
"pthread.h",
|
||||
"sched.h",
|
||||
"semaphore.h"
|
||||
]
|
||||
},
|
||||
"readline": {
|
||||
"source": "readline",
|
||||
"static-libs-unix": [
|
||||
@@ -487,6 +498,23 @@
|
||||
"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": {
|
||||
"source": "xz",
|
||||
"static-libs-unix": [
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"license": {
|
||||
"type": "text",
|
||||
"text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement."
|
||||
"text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved. \n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement."
|
||||
}
|
||||
},
|
||||
"curl": {
|
||||
@@ -100,6 +100,16 @@
|
||||
"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": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/zstd",
|
||||
@@ -111,9 +121,9 @@
|
||||
}
|
||||
},
|
||||
"freetype": {
|
||||
"type": "filelist",
|
||||
"url": "https://download-mirror.savannah.gnu.org/releases/freetype/",
|
||||
"regex": "/href=\"(?<file>freetype-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||
"type": "git",
|
||||
"rev": "VER-2-13-2",
|
||||
"url": "https://github.com/freetype/freetype",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE.TXT"
|
||||
@@ -136,6 +146,16 @@
|
||||
"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": {
|
||||
"type": "ghtar",
|
||||
"repo": "ImageMagick/ImageMagick",
|
||||
@@ -144,6 +164,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"imap": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/static-php/imap.git",
|
||||
"rev": "master",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"inotify": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/inotify",
|
||||
@@ -163,6 +192,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libargon2": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/mpociot/phc-winner-argon2",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libavif": {
|
||||
"type": "ghtar",
|
||||
"repo": "AOMediaCodec/libavif",
|
||||
@@ -171,6 +209,15 @@
|
||||
"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": {
|
||||
"type": "ghrel",
|
||||
"repo": "libevent/libevent",
|
||||
@@ -206,17 +253,18 @@
|
||||
"path": "LICENSE.md"
|
||||
}
|
||||
},
|
||||
"libmcrypt": {
|
||||
"type": "url",
|
||||
"url": "https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
|
||||
"liblz4": {
|
||||
"type": "ghrel",
|
||||
"repo": "lz4/lz4",
|
||||
"match": "lz4-.+\\.tar\\.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libmemcached": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/crazywhalecc/libmemcached-macos.git",
|
||||
"url": "https://github.com/static-php/libmemcached-macos.git",
|
||||
"rev": "master",
|
||||
"license": {
|
||||
"type": "file",
|
||||
@@ -225,7 +273,7 @@
|
||||
},
|
||||
"libpng": {
|
||||
"type": "git",
|
||||
"url": "https://git.code.sf.net/p/libpng/code",
|
||||
"url": "https://github.com/glennrp/libpng.git",
|
||||
"rev": "libpng16",
|
||||
"license": {
|
||||
"type": "file",
|
||||
@@ -233,8 +281,9 @@
|
||||
}
|
||||
},
|
||||
"libsodium": {
|
||||
"type": "url",
|
||||
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
|
||||
"type": "ghrel",
|
||||
"repo": "jedisct1/libsodium",
|
||||
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
@@ -249,6 +298,20 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libuv": {
|
||||
"type": "ghtar",
|
||||
"repo": "libuv/libuv",
|
||||
"license": [
|
||||
{
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"path": "LICENSE-extra"
|
||||
}
|
||||
]
|
||||
},
|
||||
"libwebp": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
|
||||
@@ -292,14 +355,6 @@
|
||||
"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": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/memcached",
|
||||
@@ -314,7 +369,7 @@
|
||||
"type": "git",
|
||||
"path": "php-src/sapi/micro",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/crazywhalecc/phpmicro",
|
||||
"url": "https://github.com/static-php/phpmicro",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
@@ -367,9 +422,8 @@
|
||||
}
|
||||
},
|
||||
"pkg-config": {
|
||||
"type": "filelist",
|
||||
"url": "https://pkgconfig.freedesktop.org/releases/",
|
||||
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
@@ -377,7 +431,7 @@
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "url",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYRIGHT"
|
||||
@@ -393,10 +447,11 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"pthreads4w": {
|
||||
"rar": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://git.code.sf.net/p/pthreads4w/code",
|
||||
"url": "https://github.com/static-php/php-rar.git",
|
||||
"path": "php-src/ext/rar",
|
||||
"rev": "issue-php82",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
@@ -439,6 +494,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."
|
||||
}
|
||||
},
|
||||
"sqlsrv": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/sqlsrv",
|
||||
"path": "php-src/ext/sqlsrv",
|
||||
"filename": "sqlsrv.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"swoole": {
|
||||
"type": "ghtar",
|
||||
"path": "php-src/ext/swoole",
|
||||
@@ -459,6 +524,33 @@
|
||||
"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": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/xlswriter",
|
||||
@@ -470,9 +562,9 @@
|
||||
}
|
||||
},
|
||||
"xz": {
|
||||
"type": "filelist",
|
||||
"url": "https://tukaani.org/xz/",
|
||||
"regex": "/href=\"(?<file>xz-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||
"type": "ghrel",
|
||||
"repo": "tukaani-project/xz",
|
||||
"match": "xz-.+\\.tar\\.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
|
||||
@@ -8,5 +8,10 @@ parameters:
|
||||
- '#Unsafe usage of new static#'
|
||||
- '#class Fiber#'
|
||||
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
||||
- '#Function Swoole\\Coroutine\\run not found.#'
|
||||
dynamicConstantNames:
|
||||
- PHP_OS_FAMILY
|
||||
- PHP_OS_FAMILY
|
||||
excludePaths:
|
||||
analyseAndScan:
|
||||
- ./src/globals/tests/swoole.php
|
||||
- ./src/globals/tests/swoole.phpt
|
||||
@@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.0.0-rc8';
|
||||
public const VERSION = '2.0.0';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -33,12 +33,12 @@ abstract class BuilderBase
|
||||
/**
|
||||
* 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 RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function buildLibs(array $libraries): void
|
||||
public function buildLibs(array $sorted_libraries): void
|
||||
{
|
||||
// search all supported libs
|
||||
$support_lib_list = [];
|
||||
@@ -53,23 +53,21 @@ abstract class BuilderBase
|
||||
}
|
||||
|
||||
// if no libs specified, compile all supported libs
|
||||
if ($libraries === [] && $this->isLibsOnly()) {
|
||||
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
||||
$libraries = array_keys($support_lib_list);
|
||||
$sorted_libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
}
|
||||
|
||||
// pkg-config must be compiled first, whether it is specified or not
|
||||
if (!in_array('pkg-config', $libraries)) {
|
||||
array_unshift($libraries, 'pkg-config');
|
||||
if (!in_array('pkg-config', $sorted_libraries)) {
|
||||
array_unshift($sorted_libraries, 'pkg-config');
|
||||
}
|
||||
|
||||
// append dependencies
|
||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
|
||||
// add lib object for builder
|
||||
foreach ($libraries as $library) {
|
||||
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 RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||
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);
|
||||
@@ -81,7 +79,7 @@ abstract class BuilderBase
|
||||
}
|
||||
|
||||
// extract sources
|
||||
SourceExtractor::initSource(libs: $libraries);
|
||||
SourceExtractor::initSource(libs: $sorted_libraries);
|
||||
|
||||
// build all libs
|
||||
foreach ($this->libs as $lib) {
|
||||
@@ -227,7 +225,7 @@ abstract class BuilderBase
|
||||
foreach ($this->exts as $ext) {
|
||||
$ret[] = trim($ext->getConfigureArg());
|
||||
}
|
||||
logger()->info('Using configure: ' . implode(' ', $ret));
|
||||
logger()->debug('Using configure: ' . implode(' ', $ret));
|
||||
return implode(' ', $ret);
|
||||
}
|
||||
|
||||
@@ -259,6 +257,19 @@ abstract class BuilderBase
|
||||
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 build type name string to display.
|
||||
*
|
||||
|
||||
@@ -163,6 +163,35 @@ class Extension
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function runCliCheck(): void
|
||||
{
|
||||
[$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] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
|
||||
@@ -17,10 +17,19 @@ class glfw extends Extension
|
||||
*/
|
||||
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');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
@@ -14,7 +15,9 @@ class imagick extends Extension
|
||||
{
|
||||
// imagick may call omp_pause_all which requires -lgomp
|
||||
$extra_libs = $this->builder->getOption('extra-libs', '');
|
||||
$extra_libs .= ' -lgomp ';
|
||||
if ($this->builder instanceof LinuxBuilder) {
|
||||
$extra_libs .= ' -lgomp ';
|
||||
}
|
||||
$this->builder->setOption('extra-libs', $extra_libs);
|
||||
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,18 +5,25 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('mbregex')]
|
||||
class mbregex extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'mbstring';
|
||||
}
|
||||
|
||||
public function getConfigureArg(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* mbregex is not an extension, we need to overwrite the default check.
|
||||
*/
|
||||
public function runCliCheck(): 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 !');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,20 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('mongodb')]
|
||||
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
|
||||
{
|
||||
$arg = ' --enable-mongodb ';
|
||||
|
||||
@@ -5,11 +5,25 @@ 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('opcache')]
|
||||
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
|
||||
{
|
||||
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 runCliCheck(): 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
|
||||
{
|
||||
$arg = '--enable-redis';
|
||||
if (!$this->builder->getExt('session')) {
|
||||
$arg .= ' --disable-redis-session';
|
||||
} else {
|
||||
$arg .= ' --enable-redis-session';
|
||||
}
|
||||
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
|
||||
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
|
||||
if ($this->builder->getLib('zstd')) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// 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';
|
||||
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
||||
// curl hook is buggy for static php
|
||||
$arg .= ' --disable-swoole-curl';
|
||||
|
||||
// commonly-used feature: coroutine-time, thread-context
|
||||
$arg .= ' --enable-swoole-coro-time --enable-thread-context';
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
36
src/SPC/builder/extension/swoole_hook_mysql.php
Normal file
36
src/SPC/builder/extension/swoole_hook_mysql.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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 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 runCliCheck(): 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/SPC/builder/extension/swoole_hook_pgsql.php
Normal file
40
src/SPC/builder/extension/swoole_hook_pgsql.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 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 runCliCheck(): 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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/SPC/builder/extension/swoole_hook_sqlite.php
Normal file
40
src/SPC/builder/extension/swoole_hook_sqlite.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 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 runCliCheck(): 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;
|
||||
}
|
||||
}
|
||||
@@ -138,15 +138,15 @@ class LinuxBuilder extends BuilderBase
|
||||
// add libstdc++, some extensions or libraries need it
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
||||
$this->setOption('extra-libs', $extra_libs);
|
||||
|
||||
$cflags = $this->arch_c_flags;
|
||||
|
||||
// prepare build php envs
|
||||
$envs_build_php = SystemUtil::makeEnvVarString([
|
||||
'CFLAGS' => $cflags,
|
||||
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
|
||||
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
|
||||
'LIBS' => '-ldl -lpthread',
|
||||
]);
|
||||
|
||||
SourcePatcher::patchBeforeBuildconf($this);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||
@@ -189,8 +189,8 @@ class LinuxBuilder extends BuilderBase
|
||||
$json_74 .
|
||||
$zts .
|
||||
$maxExecutionTimers .
|
||||
$this->makeExtensionArgs() . ' ' .
|
||||
$envs_build_php
|
||||
$this->makeExtensionArgs() .
|
||||
' ' . $envs_build_php . ' '
|
||||
);
|
||||
|
||||
SourcePatcher::patchBeforeMake($this);
|
||||
@@ -322,10 +322,11 @@ class LinuxBuilder extends BuilderBase
|
||||
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
|
||||
$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']}" : '';
|
||||
$tune_c_flags = implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags));
|
||||
return [
|
||||
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags,
|
||||
'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs,
|
||||
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags,
|
||||
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE {$tune_c_flags}{$cflags}",
|
||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs', '')} {$libs}",
|
||||
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static{$ldflags}",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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/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';
|
||||
}
|
||||
@@ -26,7 +26,9 @@ class libxml2 extends LinuxLibraryBase
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'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 ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
@@ -39,7 +41,7 @@ class libxml2 extends LinuxLibraryBase
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
|
||||
FileSystem::replaceFileStr(
|
||||
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
||||
|
||||
@@ -1,72 +1,12 @@
|
||||
<?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);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
|
||||
class nghttp2 extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\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';
|
||||
}
|
||||
@@ -155,6 +155,21 @@ class MacOSBuilder extends BuilderBase
|
||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||
$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')
|
||||
->exec(
|
||||
'./configure ' .
|
||||
@@ -162,7 +177,6 @@ class MacOSBuilder extends BuilderBase
|
||||
'--with-valgrind=no ' . // Not detect memory leak
|
||||
'--enable-shared=no ' .
|
||||
'--enable-static=yes ' .
|
||||
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--disable-phpdbg ' .
|
||||
@@ -172,7 +186,8 @@ class MacOSBuilder extends BuilderBase
|
||||
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||
$json_74 .
|
||||
$zts .
|
||||
$this->makeExtensionArgs()
|
||||
$this->makeExtensionArgs() . ' ' .
|
||||
$envs_build_php
|
||||
);
|
||||
|
||||
SourcePatcher::patchBeforeMake($this);
|
||||
@@ -212,10 +227,7 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildCli(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString([
|
||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
||||
]);
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} {$vars} cli");
|
||||
@@ -246,9 +258,8 @@ class MacOSBuilder extends BuilderBase
|
||||
$vars = [
|
||||
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
|
||||
'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)) {
|
||||
$vars['STRIP'] = 'dsymutil -f ';
|
||||
}
|
||||
@@ -271,10 +282,7 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildFpm(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString([
|
||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
||||
]);
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} {$vars} fpm");
|
||||
@@ -291,10 +299,7 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildEmbed(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString([
|
||||
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
|
||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
|
||||
]);
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
|
||||
shell()
|
||||
->cd(SOURCE_PATH . '/php-src')
|
||||
@@ -308,4 +313,15 @@ class MacOSBuilder extends BuilderBase
|
||||
->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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/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';
|
||||
}
|
||||
@@ -27,7 +27,9 @@ class libxml2 extends MacOSLibraryBase
|
||||
->exec(
|
||||
'cmake ' .
|
||||
// '--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 ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
||||
@@ -39,6 +41,6 @@ class libxml2 extends MacOSLibraryBase
|
||||
'..'
|
||||
)
|
||||
->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;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class nghttp2 extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\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';
|
||||
}
|
||||
@@ -66,24 +66,7 @@ trait UnixBuilderTrait
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
$ext->runCliCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,7 @@ trait brotli
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
||||
shell()->cd(BUILD_ROOT_PATH . '/lib')
|
||||
->exec('ln -s libbrotlicommon.a libbrotlicommon-static.a')
|
||||
->exec('ln -s libbrotlidec.a libbrotlidec-static.a')
|
||||
->exec('ln -s libbrotlienc.a libbrotlienc-static.a');
|
||||
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
||||
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'))) {
|
||||
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||
|
||||
@@ -26,6 +26,7 @@ trait freetype
|
||||
$suggested .= ' ';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('sh autogen.sh')
|
||||
->exec(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
@@ -39,8 +40,12 @@ trait imagemagick
|
||||
}
|
||||
|
||||
$ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : '';
|
||||
|
||||
// libxml iconv patch
|
||||
$required_libs .= $this instanceof MacOSLibraryBase ? (' -liconv') : '';
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
'PKG_CONFIG="$PKG_CONFIG --static" ' .
|
||||
$ldflags .
|
||||
"LIBS='{$required_libs}' " .
|
||||
'./configure ' .
|
||||
|
||||
@@ -4,17 +4,27 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait ldap
|
||||
{
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz');
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$alt = '';
|
||||
// openssl support
|
||||
$alt .= $this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : '';
|
||||
$alt .= $this->builder->getLib('openssl') ? '--with-tls=openssl ' : '';
|
||||
// gmp support
|
||||
$alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : '';
|
||||
// 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)
|
||||
->exec(
|
||||
$this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) .
|
||||
@@ -22,7 +32,6 @@ trait ldap
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--disable-slapd ' .
|
||||
'--disable-slurpd ' .
|
||||
'--without-systemd ' .
|
||||
'--without-cyrus-sasl ' .
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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']);
|
||||
}
|
||||
}
|
||||
@@ -20,17 +20,19 @@ trait postgresql
|
||||
{
|
||||
$builddir = BUILD_ROOT_PATH;
|
||||
$envs = '';
|
||||
$packages = 'openssl zlib readline libxml-2.0 zlib';
|
||||
$packages = 'zlib openssl readline libxml-2.0';
|
||||
$optional_packages = [
|
||||
'zstd' => 'libzstd',
|
||||
'ldap' => 'ldap',
|
||||
'libpam' => 'libpam',
|
||||
// 'ldap' => 'ldap',
|
||||
'libxslt' => 'libxslt',
|
||||
'icu' => 'icu-i18n',
|
||||
];
|
||||
|
||||
foreach ($optional_packages as $lib => $pkg) {
|
||||
if ($this->getBuilder()->getLib($lib)) {
|
||||
$packages .= ' ' . $pkg;
|
||||
$output = shell()->execWithResult("pkg-config --static {$pkg}");
|
||||
logger()->info(var_export($output[1], true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +61,8 @@ trait postgresql
|
||||
# 有静态链接配置 参考文件: src/interfaces/libpq/Makefile
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile')
|
||||
->exec('sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib')
|
||||
->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib');
|
||||
->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib')
|
||||
->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib');
|
||||
|
||||
// configure
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
@@ -73,25 +75,24 @@ trait postgresql
|
||||
'--with-readline ' .
|
||||
'--with-libxml ' .
|
||||
($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') .
|
||||
($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') .
|
||||
($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') .
|
||||
'--without-ldap ' .
|
||||
($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') .
|
||||
($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') .
|
||||
'--without-lz4 ' .
|
||||
'--without-perl ' .
|
||||
'--without-python ' .
|
||||
'--without-pam ' .
|
||||
'--without-bonjour ' .
|
||||
'--without-tcl '
|
||||
);
|
||||
// ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') .
|
||||
|
||||
// build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec($envs . ' make -C src/bin/pg_config install')
|
||||
->exec($envs . ' make -C src/include install')
|
||||
->exec($envs . ' make -C src/common install')
|
||||
->exec($envs . ' make -C src/backend/port install')
|
||||
->exec($envs . ' make -C src/port install')
|
||||
->exec($envs . ' make -C src/backend/libpq install')
|
||||
->exec($envs . ' make -C src/interfaces/libpq install');
|
||||
|
||||
// remove dynamic libs
|
||||
|
||||
32
src/SPC/builder/unix/library/tidy.php
Normal file
32
src/SPC/builder/unix/library/tidy.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait tidy
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
FileSystem::resetDir($this->source_dir . '/build-dir');
|
||||
shell()->cd($this->source_dir . '/build-dir')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DBUILD_SHARED_LIB=OFF ' .
|
||||
'-DSUPPORT_CONSOLE_APP=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['tidy.pc']);
|
||||
}
|
||||
}
|
||||
35
src/SPC/builder/unix/library/unixodbc.php
Normal file
35
src/SPC/builder/unix/library/unixodbc.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;
|
||||
|
||||
trait unixodbc
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--disable-debug ' .
|
||||
'--disable-dependency-tracking ' .
|
||||
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--with-included-ltdl ' .
|
||||
'--enable-gui=no ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']);
|
||||
$this->cleanLaFiles();
|
||||
}
|
||||
}
|
||||
26
src/SPC/builder/windows/SystemUtil.php
Normal file
26
src/SPC/builder/windows/SystemUtil.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows;
|
||||
|
||||
class SystemUtil
|
||||
{
|
||||
/**
|
||||
* @param string $name 命令名称
|
||||
* @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH)
|
||||
* @return null|string 找到了返回命令路径,找不到返回 null
|
||||
*/
|
||||
public static function findCommand(string $name, array $paths = []): ?string
|
||||
{
|
||||
if (!$paths) {
|
||||
$paths = explode(PATH_SEPARATOR, getenv('Path'));
|
||||
}
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $name)) {
|
||||
return $path . DIRECTORY_SEPARATOR . $name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\command;
|
||||
|
||||
use Laravel\Prompts\ConfirmPrompt;
|
||||
use Laravel\Prompts\Prompt;
|
||||
use Psr\Log\LogLevel;
|
||||
use SPC\ConsoleApplication;
|
||||
use SPC\exception\ExceptionHandler;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
|
||||
abstract class BaseCommand extends Command
|
||||
@@ -78,6 +82,15 @@ abstract class BaseCommand extends Command
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
// windows fallback
|
||||
Prompt::fallbackWhen(PHP_OS_FAMILY === 'Windows');
|
||||
ConfirmPrompt::fallbackUsing(function (ConfirmPrompt $prompt) use ($input, $output) {
|
||||
$helper = new QuestionHelper();
|
||||
$case = $prompt->default ? ' [Y/n] ' : ' [y/N] ';
|
||||
$question = new ConfirmationQuestion($prompt->label . $case, $prompt->default);
|
||||
return $helper->ask($input, $output, $question);
|
||||
});
|
||||
if ($this->shouldExecute()) {
|
||||
try {
|
||||
return $this->handle();
|
||||
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use ZM\Logger\ConsoleColor;
|
||||
|
||||
#[AsCommand('build', 'build CLI binary')]
|
||||
#[AsCommand('build', 'build PHP')]
|
||||
class BuildCliCommand extends BuildCommand
|
||||
{
|
||||
public function configure(): void
|
||||
@@ -33,6 +33,8 @@ class BuildCliCommand extends BuildCommand
|
||||
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
||||
$this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI');
|
||||
$this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli');
|
||||
$this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs');
|
||||
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
@@ -42,12 +44,9 @@ class BuildCliCommand extends BuildCommand
|
||||
// transform string to array
|
||||
$extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions'))));
|
||||
|
||||
$rule = BUILD_TARGET_NONE;
|
||||
$rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
||||
// parse rule with options
|
||||
$rule = $this->parseRules();
|
||||
|
||||
if ($rule === BUILD_TARGET_NONE) {
|
||||
$this->output->writeln('<error>Please add at least one build target!</error>');
|
||||
$this->output->writeln("<comment>\t--build-cli\tBuild php-cli SAPI</comment>");
|
||||
@@ -62,16 +61,27 @@ class BuildCliCommand extends BuildCommand
|
||||
$builder = BuilderProvider::makeBuilderByInput($this->input);
|
||||
// calculate dependencies
|
||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries);
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info('Build target: ' . ConsoleColor::yellow($builder->getBuildTypeName($rule)));
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info('Enabled extensions: ' . ConsoleColor::yellow(implode(', ', $extensions)));
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info('Required libraries: ' . ConsoleColor::yellow(implode(', ', $libraries)));
|
||||
if (!empty($not_included)) {
|
||||
logger()->warning('some extensions will be enabled due to dependencies: ' . implode(',', $not_included));
|
||||
|
||||
// print info
|
||||
$indent_texts = [
|
||||
'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')',
|
||||
'Build SAPI' => $builder->getBuildTypeName($rule),
|
||||
'Extensions (' . count($extensions) . ')' => implode(', ', $extensions),
|
||||
'Libraries (' . count($libraries) . ')' => implode(', ', $libraries),
|
||||
'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes',
|
||||
'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no',
|
||||
];
|
||||
if (!empty($this->input->getOption('with-hardcoded-ini'))) {
|
||||
$indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini');
|
||||
}
|
||||
$this->printFormatInfo($indent_texts);
|
||||
|
||||
if (!empty($not_included)) {
|
||||
logger()->warning('Some extensions will be enabled due to dependencies: ' . implode(',', $not_included));
|
||||
}
|
||||
logger()->info('Build will start after 2s ...');
|
||||
sleep(2);
|
||||
|
||||
if ($this->input->getOption('with-clean')) {
|
||||
logger()->info('Cleaning source dir...');
|
||||
FileSystem::removeDir(SOURCE_PATH);
|
||||
@@ -140,4 +150,41 @@ class BuildCliCommand extends BuildCommand
|
||||
return static::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse build options to rule int.
|
||||
*/
|
||||
private function parseRules(): int
|
||||
{
|
||||
$rule = BUILD_TARGET_NONE;
|
||||
$rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE);
|
||||
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
||||
return $rule;
|
||||
}
|
||||
|
||||
private function printFormatInfo(array $indent_texts): void
|
||||
{
|
||||
// calculate space count for every line
|
||||
$maxlen = 0;
|
||||
foreach ($indent_texts as $k => $v) {
|
||||
$maxlen = max(strlen($k), $maxlen);
|
||||
}
|
||||
foreach ($indent_texts as $k => $v) {
|
||||
if (is_string($v)) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($v));
|
||||
} elseif (is_array($v) && !is_assoc_array($v)) {
|
||||
$first = array_shift($v);
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($first));
|
||||
foreach ($v as $vs) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info(str_pad('', $maxlen + 2) . ConsoleColor::yellow($vs));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace SPC\command;
|
||||
use SPC\builder\BuilderProvider;
|
||||
use SPC\exception\ExceptionHandler;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\DependencyUtil;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@@ -59,6 +60,7 @@ class BuildLibsCommand extends BuildCommand
|
||||
// 只编译 library 的情况下,标记
|
||||
$builder->setLibsOnly();
|
||||
// 编译和检查库完整
|
||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
$builder->buildLibs($libraries);
|
||||
|
||||
$time = round(microtime(true) - START_TIME, 3);
|
||||
|
||||
@@ -75,8 +75,9 @@ class DoctorCommand extends BaseCommand
|
||||
} catch (\Throwable $e) {
|
||||
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||
|
||||
pcntl_signal(SIGINT, SIG_IGN);
|
||||
|
||||
if (extension_loaded('pcntl')) {
|
||||
pcntl_signal(SIGINT, SIG_IGN);
|
||||
}
|
||||
return static::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use SPC\store\Config;
|
||||
use SPC\util\DependencyUtil;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function Laravel\Prompts\table;
|
||||
@@ -22,6 +23,13 @@ class AllExtCommand extends BaseCommand
|
||||
public function configure(): void
|
||||
{
|
||||
$this->addArgument('extensions', InputArgument::OPTIONAL, 'List of extensions that will be displayed, comma separated');
|
||||
$this->addOption(
|
||||
'columns',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'List of columns that will be displayed, comma separated (lib-depends, lib-suggests, ext-depends, ext-suggests, unix-only)',
|
||||
'lib-depends,lib-suggests,ext-depends,ext-suggests,unix-only'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,6 +40,16 @@ class AllExtCommand extends BaseCommand
|
||||
public function handle(): int
|
||||
{
|
||||
$extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions') ?? '')));
|
||||
$columns = array_map('trim', array_filter(explode(',', $this->getOption('columns'))));
|
||||
|
||||
foreach ($columns as $column) {
|
||||
if (!in_array($column, ['lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only', 'type'])) {
|
||||
$this->output->writeln('<error>Column name [' . $column . '] is not valid.</error>');
|
||||
$this->output->writeln('<error>Available column name: lib-depends, lib-suggests, ext-depends, ext-suggests, unix-only, type</error>');
|
||||
return static::FAILURE;
|
||||
}
|
||||
}
|
||||
array_unshift($columns, 'name');
|
||||
|
||||
$style = new SymfonyStyle($this->input, $this->output);
|
||||
$style->writeln($extensions ? 'Available extensions:' : 'Extensions:');
|
||||
@@ -51,23 +69,26 @@ class AllExtCommand extends BaseCommand
|
||||
$lib_suggests = Config::getExt($extension, 'lib-suggests', []);
|
||||
$ext_suggests = Config::getExt($extension, 'ext-suggests', []);
|
||||
|
||||
$data[] = [
|
||||
$extension,
|
||||
implode(', ', $libraries),
|
||||
implode(', ', $lib_suggests),
|
||||
implode(',', $not_included),
|
||||
implode(', ', $ext_suggests),
|
||||
Config::getExt($extension, 'unix-only', false) ? 'true' : 'false',
|
||||
];
|
||||
$row = [];
|
||||
foreach ($columns as $column) {
|
||||
$row[] = match ($column) {
|
||||
'name' => $extension,
|
||||
'type' => Config::getExt($extension, 'type'),
|
||||
'lib-depends' => implode(', ', $libraries),
|
||||
'lib-suggests' => implode(', ', $lib_suggests),
|
||||
'ext-depends' => implode(',', $not_included),
|
||||
'ext-suggests' => implode(', ', $ext_suggests),
|
||||
'unix-only' => Config::getExt($extension, 'unix-only', false) ? 'true' : 'false',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
if ($data === []) {
|
||||
$style->warning('Unknown extension selected: ' . implode(',', $extensions));
|
||||
} else {
|
||||
table(
|
||||
['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'],
|
||||
$data
|
||||
);
|
||||
table($columns, $data);
|
||||
}
|
||||
|
||||
return static::SUCCESS;
|
||||
|
||||
@@ -34,12 +34,23 @@ final class CheckListHandler
|
||||
*/
|
||||
public function emitFix(OutputInterface $output, CheckResult $result): void
|
||||
{
|
||||
pcntl_signal(SIGINT, function () use ($output) {
|
||||
$output->writeln('<error>You cancelled fix</error>');
|
||||
});
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
sapi_windows_set_ctrl_handler(function () use ($output) {
|
||||
$output->writeln('<error>You cancelled fix</error>');
|
||||
});
|
||||
} elseif (extension_loaded('pcntl')) {
|
||||
pcntl_signal(SIGINT, function () use ($output) {
|
||||
$output->writeln('<error>You cancelled fix</error>');
|
||||
});
|
||||
}
|
||||
|
||||
$fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams());
|
||||
pcntl_signal(SIGINT, SIG_IGN);
|
||||
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
sapi_windows_set_ctrl_handler(null);
|
||||
} elseif (extension_loaded('pcntl')) {
|
||||
pcntl_signal(SIGINT, SIG_IGN);
|
||||
}
|
||||
|
||||
if ($fix_result) {
|
||||
$output->writeln('<info>Fix done</info>');
|
||||
|
||||
@@ -21,6 +21,7 @@ class LinuxToolCheckList
|
||||
'tar', 'unzip', 'gzip',
|
||||
'bzip2', 'cmake', 'gcc',
|
||||
'g++', 'patch', 'binutils-gold',
|
||||
'libtoolize',
|
||||
];
|
||||
|
||||
public const TOOLS_DEBIAN = [
|
||||
@@ -28,7 +29,7 @@ class LinuxToolCheckList
|
||||
'git', 'autoconf', 'automake',
|
||||
'tar', 'unzip', 'gzip',
|
||||
'bzip2', 'cmake', 'patch',
|
||||
'xz',
|
||||
'xz', 'libtoolize',
|
||||
];
|
||||
|
||||
public const TOOLS_RHEL = [
|
||||
@@ -36,7 +37,7 @@ class LinuxToolCheckList
|
||||
'git', 'autoconf', 'automake',
|
||||
'tar', 'unzip', 'gzip', 'gcc',
|
||||
'bzip2', 'cmake', 'patch',
|
||||
'xz', 'wget', // to get musl
|
||||
'xz',
|
||||
];
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
@@ -47,8 +48,7 @@ class LinuxToolCheckList
|
||||
|
||||
$required = match ($distro['dist']) {
|
||||
'alpine' => self::TOOLS_ALPINE,
|
||||
'almalinux' => self::TOOLS_RHEL,
|
||||
'rhel' => self::TOOLS_RHEL,
|
||||
'redhat' => self::TOOLS_RHEL,
|
||||
default => self::TOOLS_DEBIAN,
|
||||
};
|
||||
$missing = [];
|
||||
@@ -61,8 +61,7 @@ class LinuxToolCheckList
|
||||
return match ($distro['dist']) {
|
||||
'ubuntu',
|
||||
'alpine',
|
||||
'rhel',
|
||||
'almalinux',
|
||||
'redhat',
|
||||
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
||||
default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'),
|
||||
};
|
||||
@@ -74,11 +73,10 @@ class LinuxToolCheckList
|
||||
#[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')]
|
||||
public function checkSystemOSPackages(): ?CheckResult
|
||||
{
|
||||
$distro = SystemUtil::getOSRelease();
|
||||
if ($distro['dist'] === 'alpine') {
|
||||
if (SystemUtil::isMuslDist()) {
|
||||
// check linux-headers installation
|
||||
if (!file_exists('/usr/include/linux/mman.h')) {
|
||||
return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [$distro, ['linux-headers']]);
|
||||
return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [SystemUtil::getOSRelease(), ['linux-headers']]);
|
||||
}
|
||||
}
|
||||
return CheckResult::ok();
|
||||
@@ -94,8 +92,7 @@ class LinuxToolCheckList
|
||||
$install_cmd = match ($distro['dist']) {
|
||||
'ubuntu', 'debian' => 'apt-get install -y',
|
||||
'alpine' => 'apk add',
|
||||
'rhel' => 'dnf install -y',
|
||||
'almalinux' => 'dnf install -y',
|
||||
'redhat' => 'dnf install -y',
|
||||
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
||||
};
|
||||
$prefix = '';
|
||||
@@ -104,8 +101,10 @@ class LinuxToolCheckList
|
||||
logger()->warning('Current user is not root, using sudo for running command');
|
||||
}
|
||||
try {
|
||||
$is_rhel = in_array($distro['dist'], ['rhel', 'almalinux']);
|
||||
$to_install = $is_rhel ? $missing : str_replace('xz', 'xz-utils', $missing);
|
||||
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu']);
|
||||
$to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing;
|
||||
// debian, alpine libtool -> libtoolize
|
||||
$to_install = str_replace('libtoolize', 'libtool', $to_install);
|
||||
shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install));
|
||||
} catch (RuntimeException) {
|
||||
return false;
|
||||
|
||||
@@ -25,6 +25,7 @@ class MacOSToolCheckList
|
||||
'autoconf',
|
||||
'automake',
|
||||
'tar',
|
||||
'libtool',
|
||||
'unzip',
|
||||
'xz',
|
||||
'gzip',
|
||||
|
||||
@@ -16,8 +16,8 @@ class OSCheckList
|
||||
#[AsCheckItem('if current OS are supported', level: 999)]
|
||||
public function checkOS(): ?CheckResult
|
||||
{
|
||||
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) {
|
||||
return CheckResult::fail('Current OS is not supported');
|
||||
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) {
|
||||
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
||||
}
|
||||
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
||||
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
|
||||
|
||||
44
src/SPC/doctor/item/WindowsToolCheckList.php
Normal file
44
src/SPC/doctor/item/WindowsToolCheckList.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\doctor\item;
|
||||
|
||||
use SPC\builder\windows\SystemUtil;
|
||||
use SPC\doctor\AsCheckItem;
|
||||
use SPC\doctor\AsFixItem;
|
||||
use SPC\doctor\CheckResult;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class WindowsToolCheckList
|
||||
{
|
||||
#[AsCheckItem('if git are installed', limit_os: 'Windows', level: 999)]
|
||||
public function checkGit(): ?CheckResult
|
||||
{
|
||||
if (SystemUtil::findCommand('git.exe') === null) {
|
||||
return CheckResult::fail('Git not installed, please install git for windows manually, see: https://git-scm.com/download/win');
|
||||
// return CheckResult::fail('Git not installed, see https://static-php.dev/en/guide/windows-setup.html');
|
||||
}
|
||||
return CheckResult::ok();
|
||||
}
|
||||
|
||||
#[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 998)]
|
||||
public function checkSDK(): ?CheckResult
|
||||
{
|
||||
if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) {
|
||||
return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk');
|
||||
}
|
||||
return CheckResult::ok(PHP_SDK_PATH);
|
||||
}
|
||||
|
||||
#[AsFixItem('install-php-sdk')]
|
||||
public function installPhpSdk(): bool
|
||||
{
|
||||
try {
|
||||
cmd(true)->exec('git clone https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH);
|
||||
} catch (RuntimeException) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,7 @@ class FileSystem
|
||||
throw new FileSystemException("unknown archive format: {$filename}");
|
||||
}
|
||||
}
|
||||
self::emitSourceExtractHook($name);
|
||||
} catch (RuntimeException $e) {
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
f_passthru('rmdir /s /q ' . SOURCE_PATH . "/{$name}");
|
||||
|
||||
@@ -16,6 +16,7 @@ class SourcePatcher
|
||||
// FileSystem::addSourceExtractHook('swow', [SourcePatcher::class, 'patchSwow']);
|
||||
FileSystem::addSourceExtractHook('micro', [SourcePatcher::class, 'patchMicro']);
|
||||
FileSystem::addSourceExtractHook('openssl', [SourcePatcher::class, 'patchOpenssl11Darwin']);
|
||||
FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +135,12 @@ class SourcePatcher
|
||||
$patch_file = ROOT_DIR . "/src/globals/patch/{$patch_name}";
|
||||
$patch_str = str_replace('/', DIRECTORY_SEPARATOR, $patch_file);
|
||||
|
||||
// copy patch from phar
|
||||
if (\Phar::running() !== '') {
|
||||
file_put_contents(SOURCE_PATH . '/' . $patch_name, file_get_contents($patch_file));
|
||||
$patch_str = str_replace('/', DIRECTORY_SEPARATOR, SOURCE_PATH . '/' . $patch_name);
|
||||
}
|
||||
|
||||
f_passthru(
|
||||
'cd ' . $cwd . ' && ' .
|
||||
(PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patch_str . ' | patch -p1 ' . ($reverse ? '-R' : '')
|
||||
@@ -153,6 +160,17 @@ class SourcePatcher
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function patchSwoole(): bool
|
||||
{
|
||||
// swoole hook needs pdo/pdo.h
|
||||
FileSystem::replaceFileStr(
|
||||
SOURCE_PATH . '/php-src/ext/swoole/config.m4',
|
||||
'PHP_ADD_INCLUDE([$ext_srcdir])',
|
||||
"PHP_ADD_INCLUDE( [\$ext_srcdir] )\n PHP_ADD_INCLUDE([\$abs_srcdir/ext])"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,9 @@ class UnixShell
|
||||
|
||||
public function __construct(?bool $debug = null)
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
throw new RuntimeException('Windows cannot use UnixShell');
|
||||
}
|
||||
$this->debug = $debug ?? defined('DEBUG_MODE');
|
||||
}
|
||||
|
||||
|
||||
90
src/SPC/util/WindowsCmd.php
Normal file
90
src/SPC/util/WindowsCmd.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\util;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use ZM\Logger\ConsoleColor;
|
||||
|
||||
class WindowsCmd
|
||||
{
|
||||
private ?string $cd = null;
|
||||
|
||||
private bool $debug;
|
||||
|
||||
private array $env = [];
|
||||
|
||||
public function __construct(?bool $debug = null)
|
||||
{
|
||||
if (PHP_OS_FAMILY !== 'Windows') {
|
||||
throw new RuntimeException('Only windows can use WindowsCmd');
|
||||
}
|
||||
$this->debug = $debug ?? defined('DEBUG_MODE');
|
||||
}
|
||||
|
||||
public function cd(string $dir): WindowsCmd
|
||||
{
|
||||
logger()->info('Entering dir: ' . $dir);
|
||||
$c = clone $this;
|
||||
$c->cd = $dir;
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function exec(string $cmd): WindowsCmd
|
||||
{
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd));
|
||||
if ($this->cd !== null) {
|
||||
$cmd = 'cd /d ' . escapeshellarg($this->cd) . ' && ' . $cmd;
|
||||
}
|
||||
if (!$this->debug) {
|
||||
$cmd .= ' >nul 2>&1';
|
||||
}
|
||||
echo $cmd . PHP_EOL;
|
||||
|
||||
f_passthru($cmd);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execWithResult(string $cmd, bool $with_log = true): array
|
||||
{
|
||||
if ($with_log) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd));
|
||||
} else {
|
||||
logger()->debug('Running command with result: ' . $cmd);
|
||||
}
|
||||
exec($cmd, $out, $code);
|
||||
return [$code, $out];
|
||||
}
|
||||
|
||||
public function setEnv(array $env): WindowsCmd
|
||||
{
|
||||
$this->env = array_merge($this->env, $env);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function execWithEnv(string $cmd): WindowsCmd
|
||||
{
|
||||
if ($this->getEnvString() !== '') {
|
||||
return $this->exec($this->getEnvString() . "call {$cmd}");
|
||||
}
|
||||
return $this->exec($cmd);
|
||||
}
|
||||
|
||||
private function getEnvString(): string
|
||||
{
|
||||
$str = '';
|
||||
foreach ($this->env as $k => $v) {
|
||||
$str .= 'set ' . $k . '=' . $v . ' && ';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
|
||||
define('WORKING_DIR', getcwd());
|
||||
const ROOT_DIR = __DIR__ . '/../..';
|
||||
define('ROOT_DIR', dirname(__DIR__, 2));
|
||||
|
||||
// CLI start time
|
||||
define('START_TIME', microtime(true));
|
||||
@@ -22,6 +22,10 @@ define('SEPARATED_PATH', [
|
||||
BUILD_ROOT_PATH,
|
||||
]);
|
||||
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
define('PHP_SDK_PATH', is_string($a = getenv('PHP_SDK_PATH')) ? $a : (WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools'));
|
||||
}
|
||||
|
||||
// dangerous command
|
||||
const DANGER_CMD = [
|
||||
'rm',
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\UnixShell;
|
||||
use SPC\util\WindowsCmd;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
|
||||
/**
|
||||
@@ -68,7 +70,7 @@ function osfamily2dir(): string
|
||||
/**
|
||||
* Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown
|
||||
*
|
||||
* @throws \SPC\exception\RuntimeException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function f_passthru(string $cmd): ?bool
|
||||
{
|
||||
@@ -86,7 +88,7 @@ function f_passthru(string $cmd): ?bool
|
||||
}
|
||||
$ret = passthru($cmd, $code);
|
||||
if ($code !== 0) {
|
||||
throw new \SPC\exception\RuntimeException('Command run failed with code[' . $code . ']: ' . $cmd, $code);
|
||||
throw new RuntimeException('Command run failed with code[' . $code . ']: ' . $cmd, $code);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -120,3 +122,8 @@ function shell(?bool $debug = null): UnixShell
|
||||
{
|
||||
return new UnixShell($debug);
|
||||
}
|
||||
|
||||
function cmd(?bool $debug = null): WindowsCmd
|
||||
{
|
||||
return new WindowsCmd($debug);
|
||||
}
|
||||
|
||||
220
src/globals/patch/0001_imap_macos.patch
Normal file
220
src/globals/patch/0001_imap_macos.patch
Normal file
@@ -0,0 +1,220 @@
|
||||
From 5ab3bd7fa858eec0626a9dd0117ca3b050ef4660 Mon Sep 17 00:00:00 2001
|
||||
From: crazywhalecc <jesse2061@outlook.com>
|
||||
Date: Mon, 13 Nov 2023 00:00:52 +0800
|
||||
Subject: [PATCH] make macOS static compile happy
|
||||
|
||||
---
|
||||
src/c-client/netmsg.c | 1 +
|
||||
src/c-client/nntp.c | 1 +
|
||||
src/osdep/amiga/dummy.c | 1 +
|
||||
src/osdep/amiga/mbx.c | 1 +
|
||||
src/osdep/amiga/mh.c | 1 +
|
||||
src/osdep/amiga/mtx.c | 1 +
|
||||
src/osdep/amiga/unix.c | 1 +
|
||||
src/osdep/unix/dummy.c | 1 +
|
||||
src/osdep/unix/mbx.c | 1 +
|
||||
src/osdep/unix/mh.c | 1 +
|
||||
src/osdep/unix/mmdf.c | 1 +
|
||||
src/osdep/unix/mtx.c | 1 +
|
||||
src/osdep/unix/mx.c | 1 +
|
||||
src/osdep/unix/tcp_unix.c | 1 +
|
||||
src/osdep/unix/tenex.c | 2 ++
|
||||
src/osdep/unix/unix.c | 1 +
|
||||
16 files changed, 17 insertions(+)
|
||||
|
||||
diff --git a/src/c-client/netmsg.c b/src/c-client/netmsg.c
|
||||
index 187e4eb..f316d0b 100644
|
||||
--- a/src/c-client/netmsg.c
|
||||
+++ b/src/c-client/netmsg.c
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
+#include <time.h>
|
||||
extern int errno; /* just in case */
|
||||
#include "c-client.h"
|
||||
#include "netmsg.h"
|
||||
diff --git a/src/c-client/nntp.c b/src/c-client/nntp.c
|
||||
index fe90edb..b2f7536 100644
|
||||
--- a/src/c-client/nntp.c
|
||||
+++ b/src/c-client/nntp.c
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
+#include <time.h>
|
||||
#include "c-client.h"
|
||||
#include "newsrc.h"
|
||||
#include "netmsg.h"
|
||||
diff --git a/src/osdep/amiga/dummy.c b/src/osdep/amiga/dummy.c
|
||||
index b003a0b..2c65824 100644
|
||||
--- a/src/osdep/amiga/dummy.c
|
||||
+++ b/src/osdep/amiga/dummy.c
|
||||
@@ -35,6 +35,7 @@ extern int errno; /* just in case */
|
||||
#include "osdep.h"
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <time.h>
|
||||
#include "dummy.h"
|
||||
#include "misc.h"
|
||||
|
||||
diff --git a/src/osdep/amiga/mbx.c b/src/osdep/amiga/mbx.c
|
||||
index 1ece5d8..2495965 100644
|
||||
--- a/src/osdep/amiga/mbx.c
|
||||
+++ b/src/osdep/amiga/mbx.c
|
||||
@@ -43,6 +43,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/amiga/mh.c b/src/osdep/amiga/mh.c
|
||||
index 0226b7a..e7c907a 100644
|
||||
--- a/src/osdep/amiga/mh.c
|
||||
+++ b/src/osdep/amiga/mh.c
|
||||
@@ -36,6 +36,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/amiga/mtx.c b/src/osdep/amiga/mtx.c
|
||||
index 8e6f76e..ca7b368 100644
|
||||
--- a/src/osdep/amiga/mtx.c
|
||||
+++ b/src/osdep/amiga/mtx.c
|
||||
@@ -43,6 +43,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/amiga/unix.c b/src/osdep/amiga/unix.c
|
||||
index be3c437..c755fe7 100644
|
||||
--- a/src/osdep/amiga/unix.c
|
||||
+++ b/src/osdep/amiga/unix.c
|
||||
@@ -46,6 +46,7 @@ extern int errno; /* just in case */
|
||||
#include "osdep.h"
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <utime.h>
|
||||
#include "unix.h"
|
||||
#include "pseudo.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/unix/dummy.c b/src/osdep/unix/dummy.c
|
||||
index b003a0b..2c65824 100644
|
||||
--- a/src/osdep/unix/dummy.c
|
||||
+++ b/src/osdep/unix/dummy.c
|
||||
@@ -35,6 +35,7 @@ extern int errno; /* just in case */
|
||||
#include "osdep.h"
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <time.h>
|
||||
#include "dummy.h"
|
||||
#include "misc.h"
|
||||
|
||||
diff --git a/src/osdep/unix/mbx.c b/src/osdep/unix/mbx.c
|
||||
index 1ece5d8..2495965 100644
|
||||
--- a/src/osdep/unix/mbx.c
|
||||
+++ b/src/osdep/unix/mbx.c
|
||||
@@ -43,6 +43,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/unix/mh.c b/src/osdep/unix/mh.c
|
||||
index 0226b7a..e7c907a 100644
|
||||
--- a/src/osdep/unix/mh.c
|
||||
+++ b/src/osdep/unix/mh.c
|
||||
@@ -36,6 +36,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/unix/mmdf.c b/src/osdep/unix/mmdf.c
|
||||
index e962434..8cc9fae 100644
|
||||
--- a/src/osdep/unix/mmdf.c
|
||||
+++ b/src/osdep/unix/mmdf.c
|
||||
@@ -34,6 +34,7 @@ extern int errno; /* just in case */
|
||||
#include "osdep.h"
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <utime.h>
|
||||
#include "pseudo.h"
|
||||
#include "fdstring.h"
|
||||
#include "misc.h"
|
||||
diff --git a/src/osdep/unix/mtx.c b/src/osdep/unix/mtx.c
|
||||
index 8e6f76e..ca7b368 100644
|
||||
--- a/src/osdep/unix/mtx.c
|
||||
+++ b/src/osdep/unix/mtx.c
|
||||
@@ -43,6 +43,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/unix/mx.c b/src/osdep/unix/mx.c
|
||||
index 4549527..9d444c9 100644
|
||||
--- a/src/osdep/unix/mx.c
|
||||
+++ b/src/osdep/unix/mx.c
|
||||
@@ -36,6 +36,7 @@ extern int errno; /* just in case */
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
#include "fdstring.h"
|
||||
diff --git a/src/osdep/unix/tcp_unix.c b/src/osdep/unix/tcp_unix.c
|
||||
index 5bad706..5d6cd03 100644
|
||||
--- a/src/osdep/unix/tcp_unix.c
|
||||
+++ b/src/osdep/unix/tcp_unix.c
|
||||
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "ip_unix.c"
|
||||
+#include <poll.h>
|
||||
|
||||
#undef write /* don't use redefined write() */
|
||||
|
||||
diff --git a/src/osdep/unix/tenex.c b/src/osdep/unix/tenex.c
|
||||
index eee61fb..61760f0 100644
|
||||
--- a/src/osdep/unix/tenex.c
|
||||
+++ b/src/osdep/unix/tenex.c
|
||||
@@ -46,6 +46,8 @@ extern int errno; /* just in case */
|
||||
#include "mail.h"
|
||||
#include "osdep.h"
|
||||
#include <sys/stat.h>
|
||||
+#include <time.h>
|
||||
+#include <utime.h>
|
||||
#include "misc.h"
|
||||
#include "dummy.h"
|
||||
|
||||
diff --git a/src/osdep/unix/unix.c b/src/osdep/unix/unix.c
|
||||
index be3c437..c755fe7 100644
|
||||
--- a/src/osdep/unix/unix.c
|
||||
+++ b/src/osdep/unix/unix.c
|
||||
@@ -46,6 +46,7 @@ extern int errno; /* just in case */
|
||||
#include "osdep.h"
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <utime.h>
|
||||
#include "unix.h"
|
||||
#include "pseudo.h"
|
||||
#include "fdstring.h"
|
||||
--
|
||||
2.39.3 (Apple Git-145)
|
||||
|
||||
56
src/globals/test-extensions.php
Normal file
56
src/globals/test-extensions.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This is GitHub Actions automatic test extension args generator.
|
||||
* You can edit $extensions, $with_libs and $base_combination.
|
||||
*/
|
||||
|
||||
// --------------------------------- edit area ---------------------------------
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = 'ldap';
|
||||
|
||||
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
||||
$with_libs = '';
|
||||
|
||||
// Please change your test base combination. We recommend testing with `common`.
|
||||
// You can use `common`, `bulk`, `minimal` or `none`.
|
||||
$base_combination = 'minimal';
|
||||
|
||||
// -------------------------- code area, do not modify --------------------------
|
||||
|
||||
/**
|
||||
* get combination for tests, do not modify it if not necessary.
|
||||
*/
|
||||
function _getCombination(string $type = 'common'): string
|
||||
{
|
||||
return match ($type) {
|
||||
'common' => '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',
|
||||
'bulk' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,' .
|
||||
'intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,' .
|
||||
'posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,' .
|
||||
'sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib',
|
||||
'minimal' => 'pcntl,posix,mbstring,tokenizer,phar',
|
||||
default => '', // none
|
||||
};
|
||||
}
|
||||
|
||||
if (!isset($argv[1])) {
|
||||
exit("Please use 'extensions', 'cmd' or 'libs' as output type");
|
||||
}
|
||||
|
||||
$trim_value = "\r\n \t,";
|
||||
|
||||
$final_extensions = trim(trim($extensions, $trim_value) . ',' . _getCombination($base_combination), $trim_value);
|
||||
$final_libs = trim($with_libs, $trim_value);
|
||||
|
||||
echo match ($argv[1]) {
|
||||
'extensions' => $final_extensions,
|
||||
'libs' => $final_libs,
|
||||
'cmd' => $final_extensions . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
|
||||
default => '',
|
||||
};
|
||||
12
src/globals/tests/swoole.php
Normal file
12
src/globals/tests/swoole.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
assert(function_exists('swoole_cpu_num'));
|
||||
assert(function_exists('swoole_string'));
|
||||
assert(class_exists('Swoole\Coroutine'));
|
||||
assert(class_exists('Swoole\Coroutine\Http2\Client'));
|
||||
assert(class_exists('Swoole\Coroutine\Redis'));
|
||||
assert(class_exists('Swoole\Coroutine\WaitGroup'));
|
||||
assert(class_exists('Swoole\Http2\Request'));
|
||||
assert(constant('SWOOLE_VERSION'));
|
||||
Reference in New Issue
Block a user