mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
138 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fcb7ebf03 | ||
|
|
7416b8079b | ||
|
|
bde18054e5 | ||
|
|
954f8f4ddc | ||
|
|
0fee628842 | ||
|
|
69e6d82e83 | ||
|
|
e1e6270d86 | ||
|
|
30af182aff | ||
|
|
3ecc603770 | ||
|
|
15c2935d48 | ||
|
|
7a8e0a7e67 | ||
|
|
d98d6aeffb | ||
|
|
aaa4510f25 | ||
|
|
b14894fab7 | ||
|
|
1a87ce4194 | ||
|
|
6b96feb538 | ||
|
|
21dbb8af46 | ||
|
|
4d227ca7ef | ||
|
|
3a2683bb0c | ||
|
|
bd8f91d466 | ||
|
|
254844b5ec | ||
|
|
4cb1764439 | ||
|
|
847535721c | ||
|
|
e3c542d9df | ||
|
|
b4ed4ea956 | ||
|
|
99aadd3e73 | ||
|
|
c77dc1af6c | ||
|
|
9fd56987ef | ||
|
|
1e494a2213 | ||
|
|
da6d9ffb4b | ||
|
|
d3a001d808 | ||
|
|
d445668d9f | ||
|
|
32f14e16c8 | ||
|
|
46984b6df1 | ||
|
|
96c3e6b935 | ||
|
|
8092f1e481 | ||
|
|
632f904f30 | ||
|
|
8358a985b3 | ||
|
|
e21b5676e7 | ||
|
|
94b3afe6bc | ||
|
|
e4d8e5e4d2 | ||
|
|
88796bc017 | ||
|
|
e23daaa355 | ||
|
|
71017361b5 | ||
|
|
d202de3f50 | ||
|
|
03510073c6 | ||
|
|
8e58592a6e | ||
|
|
96dd5ba87b | ||
|
|
d4c0290195 | ||
|
|
f5d1df5407 | ||
|
|
9664709f21 | ||
|
|
b46655ecfe | ||
|
|
842e0add29 | ||
|
|
254764761d | ||
|
|
5f6c1a0f40 | ||
|
|
d5dcd193cf | ||
|
|
5012da96be | ||
|
|
df0e37cd0f | ||
|
|
4ab7b6bfdc | ||
|
|
f498250001 | ||
|
|
3945ac037b | ||
|
|
b0d8b00fcc | ||
|
|
62b0bf8af0 | ||
|
|
905e080770 | ||
|
|
097ecd3fb0 | ||
|
|
b9359759dd | ||
|
|
50fe366c42 | ||
|
|
9dd89e6b02 | ||
|
|
c03220d1ee | ||
|
|
9db843ab66 | ||
|
|
304973d9bc | ||
|
|
ab386f820c | ||
|
|
4adf1f5e2e | ||
|
|
b4ae87585c | ||
|
|
ae3298472d | ||
|
|
d241cb993e | ||
|
|
8376122634 | ||
|
|
a30e054d7d | ||
|
|
78f4317660 | ||
|
|
3ac3dab6c8 | ||
|
|
1a7e436ee1 | ||
|
|
f11b36ab3c | ||
|
|
e2ef195a84 | ||
|
|
645e2a9fc2 | ||
|
|
d59b8457c6 | ||
|
|
a2d1262cbf | ||
|
|
2f9a1e8601 | ||
|
|
b239f60fe4 | ||
|
|
983521e225 | ||
|
|
aeed04a5ec | ||
|
|
faed569e8a | ||
|
|
49ddb3ec13 | ||
|
|
71c0387ab0 | ||
|
|
e5d2d5e689 | ||
|
|
be2394b39b | ||
|
|
158298b96c | ||
|
|
ffa84f8b91 | ||
|
|
0954ddcc96 | ||
|
|
d9bd96af71 | ||
|
|
2649dcd05c | ||
|
|
939db75268 | ||
|
|
227bf73870 | ||
|
|
05e3898e7a | ||
|
|
9777c9aa93 | ||
|
|
b8d8461e61 | ||
|
|
b977543c72 | ||
|
|
4d87cd11cc | ||
|
|
957daf0547 | ||
|
|
3dae904122 | ||
|
|
e835196972 | ||
|
|
52ed0e2cee | ||
|
|
1e898d271d | ||
|
|
39754cde59 | ||
|
|
a6f7b938e1 | ||
|
|
0ad501af9a | ||
|
|
73035067e3 | ||
|
|
421b3830b6 | ||
|
|
59dcb905fe | ||
|
|
d222190fc7 | ||
|
|
06e9864d19 | ||
|
|
0b1a321615 | ||
|
|
9ee7d7769a | ||
|
|
2440a65d8e | ||
|
|
839931d65f | ||
|
|
2591b48abe | ||
|
|
2549597871 | ||
|
|
2064172bed | ||
|
|
dc19d0c61d | ||
|
|
05c6dc6dab | ||
|
|
4b653bc293 | ||
|
|
1c3476b8e9 | ||
|
|
61ca501c2a | ||
|
|
d916feec62 | ||
|
|
0dcecf6ca4 | ||
|
|
a04deb458f | ||
|
|
34f810571e | ||
|
|
5ab4d140d5 | ||
|
|
104778d17a |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -10,4 +10,6 @@ liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
# noinspection YAMLSchemaValidation
|
||||
buy_me_a_coffee: crazywhalecc
|
||||
custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
|
||||
32
.github/workflows/build-linux-arm.yml
vendored
32
.github/workflows/build-linux-arm.yml
vendored
@@ -45,14 +45,30 @@ jobs:
|
||||
name: build ${{ inputs.version }} on ${{ inputs.operating-system }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
|
||||
# If there's no Composer cache, install dependencies
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev --classmap-authoritative
|
||||
|
||||
- name: Generate hashed key for download cache
|
||||
run: |
|
||||
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
|
||||
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
key: php-${{ env.INPUT_HASH }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -75,31 +91,31 @@ jobs:
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-${{ inputs.version }}-linux-${{ inputs.operating-system }}
|
||||
path: buildroot/bin/php
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: micro-${{ inputs.version }}-linux-${{ inputs.operating-system }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload fpm executable
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
|
||||
23
.github/workflows/build-linux-x86_64.yml
vendored
23
.github/workflows/build-linux-x86_64.yml
vendored
@@ -39,11 +39,11 @@ jobs:
|
||||
name: build ${{ inputs.version }} on Linux x86_64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
@@ -52,12 +52,17 @@ jobs:
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev --classmap-authoritative
|
||||
|
||||
- name: Generate hashed key for download cache
|
||||
run: |
|
||||
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
|
||||
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
key: php-${{ env.INPUT_HASH }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -80,31 +85,31 @@ jobs:
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload fpm executable
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
|
||||
132
.github/workflows/build-macos-aarch64.yml
vendored
Normal file
132
.github/workflows/build-macos-aarch64.yml
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
name: CI on arm64 macOS
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: php version to compile
|
||||
default: '8.2'
|
||||
type: choice
|
||||
options:
|
||||
- '8.3'
|
||||
- '8.2'
|
||||
- '8.1'
|
||||
- '8.0'
|
||||
- '7.4'
|
||||
build-cli:
|
||||
description: build cli binary
|
||||
default: true
|
||||
type: boolean
|
||||
build-micro:
|
||||
description: build phpmicro binary
|
||||
type: boolean
|
||||
build-fpm:
|
||||
description: build fpm binary
|
||||
type: boolean
|
||||
extensions:
|
||||
description: extensions to compile (comma separated)
|
||||
required: true
|
||||
type: string
|
||||
debug:
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build ${{ inputs.version }} on macOS arm64
|
||||
runs-on: macos-14
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Install macOS missing packages and mark os suffix
|
||||
- run: |
|
||||
brew install automake gzip
|
||||
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
|
||||
|
||||
|
||||
- name: "Setup PHP"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
tools: pecl, composer
|
||||
extensions: curl, openssl, mbstring, tokenizer
|
||||
ini-values: memory_limit=-1
|
||||
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
|
||||
# If there's no Composer cache, install dependencies
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev --classmap-authoritative
|
||||
|
||||
- name: Generate hashed key for download cache
|
||||
run: |
|
||||
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
|
||||
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ env.INPUT_HASH }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
|
||||
|
||||
# With target select: cli, micro or both
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
|
||||
|
||||
# If there's no dependencies cache, fetch sources, with or without debug
|
||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }}
|
||||
|
||||
# Run build command
|
||||
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload fpm executable
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
buildroot/build-extensions.json
|
||||
buildroot/build-libraries.json
|
||||
33
.github/workflows/build-macos-x86_64.yml
vendored
33
.github/workflows/build-macos-x86_64.yml
vendored
@@ -37,18 +37,26 @@ env:
|
||||
jobs:
|
||||
build:
|
||||
name: build ${{ inputs.version }} on macOS x86_64
|
||||
runs-on: macos-latest
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Install macOS missing packages and mark os suffix
|
||||
- run: |
|
||||
brew install automake gzip
|
||||
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
|
||||
|
||||
- name: "Setup PHP"
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
tools: pecl, composer
|
||||
extensions: curl, openssl, mbstring, tokenizer
|
||||
ini-values: memory_limit=-1
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
@@ -57,12 +65,17 @@ jobs:
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev --classmap-authoritative
|
||||
|
||||
- name: Generate hashed key for download cache
|
||||
run: |
|
||||
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
|
||||
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
|
||||
key: php-${{ env.INPUT_HASH }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
@@ -85,31 +98,31 @@ jobs:
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload fpm executable
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
|
||||
108
.github/workflows/build-windows-x86_64.yml
vendored
Normal file
108
.github/workflows/build-windows-x86_64.yml
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
name: CI on x86_64 Windows
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: php version to compile
|
||||
default: '8.2'
|
||||
type: choice
|
||||
options:
|
||||
- '8.3'
|
||||
- '8.2'
|
||||
- '8.1'
|
||||
- '8.0'
|
||||
- '7.4'
|
||||
build-cli:
|
||||
description: build cli binary
|
||||
default: true
|
||||
type: boolean
|
||||
build-micro:
|
||||
description: build phpmicro binary
|
||||
type: boolean
|
||||
extensions:
|
||||
description: extensions to compile (comma separated)
|
||||
required: true
|
||||
type: string
|
||||
debug:
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build ${{ inputs.version }} on Windows x86_64
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
|
||||
# If there's no Composer cache, install dependencies
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev --classmap-authoritative
|
||||
|
||||
- name: Generate hashed key for download cache
|
||||
shell: bash
|
||||
run: |
|
||||
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
|
||||
echo "INPUT_HASH=${INPUT_HASH}" >> "$GITHUB_ENV"
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ env.INPUT_HASH }}
|
||||
|
||||
# With or without debug
|
||||
- if: inputs.debug == true
|
||||
run: echo "SPC_BUILD_DEBUG=--debug" >> $env:GITHUB_ENV
|
||||
|
||||
# With target select: cli, micro or both
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
run: echo "SPC_BUILD_CLI=--build-cli" >> $env:GITHUB_ENV
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
run: echo "SPC_BUILD_MICRO=--build-micro" >> $env:GITHUB_ENV
|
||||
|
||||
- run: ./bin/spc doctor
|
||||
|
||||
# If there's no dependencies cache, fetch sources, with or without debug
|
||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||
run: ./bin/spc download --with-php="${{ inputs.version }}" --for-extensions="${{ inputs.extensions }}" ${{ env.SPC_BUILD_DEBUG }}
|
||||
|
||||
# Run build command
|
||||
- run: ./bin/spc build "${{ inputs.extensions }}" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: php-${{ inputs.version }}
|
||||
path: buildroot/bin/php.exe
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: micro-${{ inputs.version }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
buildroot/build-extensions.json
|
||||
buildroot/build-libraries.json
|
||||
53
.github/workflows/release-build.yml
vendored
53
.github/workflows/release-build.yml
vendored
@@ -15,14 +15,15 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
micro-version:
|
||||
- "8.1.26"
|
||||
- "8.2.18"
|
||||
operating-system:
|
||||
- "linux-x86_64"
|
||||
- "macos-x86_64"
|
||||
- "linux-aarch64"
|
||||
- "macos-aarch64"
|
||||
- "windows-x64"
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v4"
|
||||
@@ -59,31 +60,51 @@ jobs:
|
||||
|
||||
- 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
|
||||
|
||||
if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
|
||||
curl https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ matrix.micro-version }}-micro-win.zip -o tmp.zip
|
||||
unzip tmp.zip
|
||||
else
|
||||
curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz
|
||||
tar -zxvf tmp.tgz
|
||||
fi
|
||||
|
||||
- name: "Generate Executable"
|
||||
run: |
|
||||
cat micro.sfx spc.phar > spc
|
||||
chmod +x spc
|
||||
bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G"
|
||||
if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then
|
||||
mv spc spc.exe
|
||||
else
|
||||
chmod +x spc
|
||||
fi
|
||||
|
||||
- name: "Archive Executable"
|
||||
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
|
||||
if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
|
||||
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
|
||||
else
|
||||
echo "filename=spc-${{ matrix.operating-system }}.exe" >> $GITHUB_ENV
|
||||
echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: "Copy file"
|
||||
run: "mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS"
|
||||
run: |
|
||||
if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then
|
||||
mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS
|
||||
else
|
||||
mkdir dist/ && cp spc.exe dist/${{ env.filename }}
|
||||
echo "SUFFIX=.exe" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: upload binaries to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: ${{ env.filename }}
|
||||
files: dist/${{ env.filename }}
|
||||
|
||||
- name: "Deploy to Self-Hosted Server"
|
||||
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||
@@ -100,5 +121,5 @@ jobs:
|
||||
- name: "Upload Artifact"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: spc
|
||||
name: spc-${{ matrix.operating-system }}
|
||||
path: spc${{ env.SUFFIX }}
|
||||
name: spc-${{ matrix.operating-system }}${{ env.SUFFIX }}
|
||||
|
||||
19
.github/workflows/tests.yml
vendored
19
.github/workflows/tests.yml
vendored
@@ -114,6 +114,8 @@ jobs:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
- macos-14
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
@@ -127,6 +129,13 @@ jobs:
|
||||
extensions: curl, openssl, mbstring
|
||||
ini-values: memory_limit=-1
|
||||
|
||||
- name: "Use test token if exists"
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then
|
||||
echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: "Cache Composer packages"
|
||||
id: composer-cache
|
||||
uses: actions/cache@v3
|
||||
@@ -150,7 +159,13 @@ jobs:
|
||||
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
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
timeout_minutes: 10
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: |
|
||||
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3
|
||||
|
||||
- name: "Run Build Tests (build)"
|
||||
run: bin/spc build $(php src/globals/test-extensions.php cmd) --build-cli --build-micro --build-fpm --debug
|
||||
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,6 +16,9 @@ docker/source/
|
||||
# default source build root directory
|
||||
/buildroot/
|
||||
|
||||
# default package root directory
|
||||
/pkgroot/
|
||||
|
||||
# tools cache files
|
||||
.php-cs-fixer.cache
|
||||
.phpunit.result.cache
|
||||
|
||||
80
README-zh.md
80
README-zh.md
@@ -1,10 +1,11 @@
|
||||
# static-php-cli
|
||||
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[]()
|
||||
[]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html))
|
||||
[](https://discord.gg/RNpegEYW)
|
||||
[](README.md)
|
||||
[](README-zh.md)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/releases)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
|
||||
[](https://static-php.dev/zh/guide/extensions.html)
|
||||
|
||||
**static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。
|
||||
|
||||
@@ -12,9 +13,6 @@
|
||||
|
||||
**static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。
|
||||
|
||||
- [README - English](./README.md)
|
||||
- [README - 中文](./README-zh.md)
|
||||
|
||||
## 特性
|
||||
|
||||
static-php-cli(简称 `spc`)有许多特性:
|
||||
@@ -22,11 +20,12 @@ static-php-cli(简称 `spc`)有许多特性:
|
||||
- :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖
|
||||
- :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件)
|
||||
- :pill: 提供一键检查和修复编译环境的 Doctor 模块
|
||||
- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、[`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301)
|
||||
- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、`Windows`
|
||||
- :wrench: 高度自定义的代码 patch 功能
|
||||
- :books: 自带编译依赖管理
|
||||
- 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建)
|
||||
- :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html)
|
||||
- :floppy_disk: 整合 UPX 工具(减小二进制文件体积)
|
||||
|
||||
**静态 php-cli:**
|
||||
|
||||
@@ -48,27 +47,45 @@ static-php-cli(简称 `spc`)有许多特性:
|
||||
- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。
|
||||
- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。
|
||||
|
||||
对于 Windows 系统,目前支持的扩展较少,故仅提供 SPC 自身运行的最小扩展组合的 `cli` 和 `micro`:[扩展组合 - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/)。
|
||||
|
||||
## 使用 static-php-cli 构建 PHP
|
||||
|
||||
### 编译环境需求
|
||||
|
||||
- PHP >= 8.1(spc 自身是用 PHP 写的)
|
||||
- 扩展:`mbstring,pcntl,posix,tokenizer,phar`
|
||||
- PHP >= 8.1(这是 spc 自身需要的版本,不是支持的构建版本)
|
||||
- 扩展:`mbstring,tokenizer,phar`
|
||||
- 系统安装了 `curl` 和 `git`
|
||||
|
||||
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
|
||||
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。
|
||||
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含上面提到的扩展和 PHP 版本大于等于 8.1 即可。
|
||||
|
||||
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
|
||||
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|----------------------|----------------------|
|
||||
| macOS | :octocat: :computer: | :computer: |
|
||||
| macOS | :octocat: :computer: | :octocat: :computer: |
|
||||
| Linux | :octocat: :computer: | :octocat: :computer: |
|
||||
| Windows | | |
|
||||
| Windows | :octocat: :computer: | |
|
||||
| FreeBSD | :computer: | :computer: |
|
||||
|
||||
目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。
|
||||
当前支持编译的 PHP 版本:
|
||||
|
||||
> :warning: 支持,但可能不再提供修复
|
||||
>
|
||||
> :heavy_check_mark: 支持
|
||||
>
|
||||
> :x: 不支持
|
||||
|
||||
| PHP Version | Status | Comment |
|
||||
|-------------|--------------------|------------------------------|
|
||||
| 7.2 | :x: | |
|
||||
| 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
|
||||
| 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
|
||||
| 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 |
|
||||
| 8.1 | :heavy_check_mark: | |
|
||||
| 8.2 | :heavy_check_mark: | |
|
||||
| 8.3 | :heavy_check_mark: | |
|
||||
|
||||
### 支持的扩展
|
||||
|
||||
@@ -108,10 +125,16 @@ curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-a
|
||||
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
|
||||
# macOS aarch64 (Apple)
|
||||
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
|
||||
# Windows (x86_64, win10 build 17063 or later)
|
||||
curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
|
||||
|
||||
# add x perm
|
||||
# Add execute perm (Linux and macOS only)
|
||||
chmod +x ./spc
|
||||
|
||||
# Run (Linux and macOS)
|
||||
./spc --version
|
||||
# Run (Windows powershell)
|
||||
.\spc.exe --version
|
||||
```
|
||||
|
||||
自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
|
||||
@@ -150,14 +173,16 @@ bin/spc --version
|
||||
# 拉取所有依赖库
|
||||
./bin/spc download --all
|
||||
# 只拉取编译指定扩展需要的所有依赖(推荐)
|
||||
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
|
||||
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
|
||||
# 下载编译不同版本的 PHP (--with-php=x.y,推荐 7.3 ~ 8.3)
|
||||
./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1
|
||||
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
|
||||
|
||||
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
|
||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
||||
# 编译线程安全版本 (--enable-zts)
|
||||
./bin/spc build curl,phar --enable-zts --build-cli
|
||||
./bin/spc build "curl,phar" --enable-zts --build-cli
|
||||
# 编译后使用 UPX 减小可执行文件体积 (--with-upx-pack) (至少压缩至原来的 30~50%)
|
||||
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
|
||||
```
|
||||
|
||||
其中,目前支持构建 cli,micro,fpm 和 embed,使用以下参数的一个或多个来指定编译的 SAPI:
|
||||
@@ -171,7 +196,7 @@ bin/spc --version
|
||||
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
|
||||
|
||||
```bash
|
||||
./bin/spc build openssl,pcntl,mbstring --debug --build-all
|
||||
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
|
||||
./bin/spc download --all --debug
|
||||
```
|
||||
|
||||
@@ -250,18 +275,17 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys
|
||||
|
||||
## 赞助本项目
|
||||
|
||||
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。
|
||||
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。你捐赠的一部分将会被用于维护 **static-php.dev** 服务器。
|
||||
|
||||
## 开源协议
|
||||
|
||||
本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目:
|
||||
本项目采用 MIT License 许可开源,下面是类似的项目:
|
||||
|
||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证)
|
||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE)
|
||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
|
||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
|
||||
|
||||
该项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 中的一些代码,例如 Windows 静态构建目标和 libiconv 库支持。
|
||||
lwmbs 使用 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可进行分发。对应文件有关于作者和许可的特殊说明,除此之外,均使用 MIT 授权许可。
|
||||
|
||||
因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
|
||||
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
|
||||
|
||||
## 进阶
|
||||
|
||||
本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。
|
||||
|
||||
79
README.md
79
README.md
@@ -1,10 +1,11 @@
|
||||
# static-php-cli
|
||||
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[]()
|
||||
[]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html))
|
||||
[](https://discord.gg/RNpegEYW)
|
||||
[](README-zh.md)
|
||||
[](README.md)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/releases)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
|
||||
[](https://static-php.dev/en/guide/extensions.html)
|
||||
|
||||
**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime
|
||||
with popular extensions.
|
||||
@@ -14,9 +15,6 @@ Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro
|
||||
**static-php-cli** also has the ability to package PHP projects
|
||||
along with the PHP interpreter into one single executable file.
|
||||
|
||||
- [README - English](./README.md)
|
||||
- [README - 中文](./README-zh.md)
|
||||
|
||||
## Features
|
||||
|
||||
static-php-cli (you can call it `spc`) has a lot of features:
|
||||
@@ -24,11 +22,12 @@ static-php-cli (you can call it `spc`) has a lot of features:
|
||||
- :handbag: Build single-file php executable, without any dependencies
|
||||
- :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file)
|
||||
- :pill: Automatic build environment checker (Doctor module)
|
||||
- :zap: `Linux`, `macOS`, `FreeBSD`, [`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301) support
|
||||
- :zap: `Linux`, `macOS`, `FreeBSD`, `Windows` support
|
||||
- :wrench: Configurable source code patches
|
||||
- :books: Build dependency management
|
||||
- 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box))
|
||||
- :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html)
|
||||
- :floppy_disk: UPX integration (significantly reduces binary size)
|
||||
|
||||
**Single-file standalone php-cli:**
|
||||
|
||||
@@ -54,28 +53,47 @@ which can be downloaded directly according to your needs.
|
||||
- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size.
|
||||
- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size.
|
||||
|
||||
For Windows systems, there are currently fewer extensions supported,
|
||||
so only `cli` and `micro` that run the minimum extension combination of SPC itself are provided: [Extension-Combination - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/).
|
||||
|
||||
## Build
|
||||
|
||||
### Compilation Requirements
|
||||
|
||||
- PHP >= 8.1 (static-php-cli is written in PHP)
|
||||
- Extension: `mbstring,pcntl,posix,tokenizer,phar`
|
||||
- Supported OS with `curl` and `git` installed
|
||||
|
||||
You can say I made a PHP builder written in PHP, pretty funny.
|
||||
But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension.
|
||||
But static-php-cli runtime only requires an environment above PHP 8.1 and extensions mentioned below.
|
||||
|
||||
- PHP >= 8.1 (This is the version required by spc itself, not the build version)
|
||||
- Extension: `mbstring,tokenizer,phar`
|
||||
- Supported OS with `curl` and `git` installed
|
||||
|
||||
Here is the supported OS and arch, where :octocat: represents support for GitHub Action builds,
|
||||
:computer: represents support for local manual builds, and blank represents not currently supported.
|
||||
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|----------------------|----------------------|
|
||||
| macOS | :octocat: :computer: | :computer: |
|
||||
| macOS | :octocat: :computer: | :octocat: :computer: |
|
||||
| Linux | :octocat: :computer: | :octocat: :computer: |
|
||||
| Windows | | |
|
||||
| Windows | :octocat: :computer: | |
|
||||
| FreeBSD | :computer: | :computer: |
|
||||
|
||||
Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`.
|
||||
Currently supported PHP versions for compilation:
|
||||
|
||||
> :warning: supported but not maintained
|
||||
>
|
||||
> :heavy_check_mark: supported
|
||||
>
|
||||
> :x: not supported
|
||||
|
||||
| PHP Version | Status | Comment |
|
||||
|-------------|--------------------|---------------------------------------------------|
|
||||
| 7.2 | :x: | |
|
||||
| 7.3 | :warning: | phpmicro and some extensions not supported on 7.x |
|
||||
| 7.4 | :warning: | phpmicro and some extensions not supported on 7.x |
|
||||
| 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 |
|
||||
| 8.1 | :heavy_check_mark: | |
|
||||
| 8.2 | :heavy_check_mark: | |
|
||||
| 8.3 | :heavy_check_mark: | |
|
||||
|
||||
### Supported Extensions
|
||||
|
||||
@@ -118,10 +136,16 @@ curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-a
|
||||
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
|
||||
# macOS aarch64 (Apple)
|
||||
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
|
||||
# Windows (x86_64, win10 build 17063 or later)
|
||||
curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
|
||||
|
||||
# add x perm
|
||||
# Add execute perm (Linux and macOS only)
|
||||
chmod +x ./spc
|
||||
|
||||
# Run (Linux and macOS)
|
||||
./spc --version
|
||||
# Run (Windows powershell)
|
||||
.\spc.exe --version
|
||||
```
|
||||
|
||||
Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml).
|
||||
@@ -151,7 +175,7 @@ bin/spc --version
|
||||
|
||||
Basic usage for building php with some extensions:
|
||||
|
||||
> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands.
|
||||
> If you are using the packaged standalone `spc` binary, you need to replace `bin/spc` with `./spc` or `.\spc.exe` in the following commands.
|
||||
|
||||
```bash
|
||||
# Check system tool dependencies, auto-fix them if possible
|
||||
@@ -160,14 +184,16 @@ Basic usage for building php with some extensions:
|
||||
# fetch all libraries
|
||||
./bin/spc download --all
|
||||
# only fetch necessary sources by needed extensions (recommended)
|
||||
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
|
||||
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
|
||||
# download different PHP version (--with-php=x.y, recommend 7.3 ~ 8.3)
|
||||
./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1
|
||||
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
|
||||
|
||||
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
|
||||
./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro
|
||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
|
||||
# build thread-safe (ZTS) version (--enable-zts)
|
||||
./bin/spc build curl,phar --enable-zts --build-cli
|
||||
./bin/spc build "curl,phar" --enable-zts --build-cli
|
||||
# build, pack executable with UPX (--with-upx-pack) (reduce binary size for 30~50%)
|
||||
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
|
||||
```
|
||||
|
||||
Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more of the following parameters to specify the compiled SAPI:
|
||||
@@ -181,7 +207,7 @@ Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more o
|
||||
If anything goes wrong, use `--debug` option to display full terminal output:
|
||||
|
||||
```bash
|
||||
./bin/spc build openssl,pcntl,mbstring --debug --build-all
|
||||
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
|
||||
./bin/spc download --all --debug
|
||||
```
|
||||
|
||||
@@ -274,7 +300,7 @@ Now there is a [static-php](https://github.com/static-php) organization, which i
|
||||
|
||||
## Sponsor this project
|
||||
|
||||
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md).
|
||||
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). A portion of your donation will be used to maintain the **static-php.dev** server.
|
||||
|
||||
## Open-Source License
|
||||
|
||||
@@ -287,6 +313,9 @@ These are similar projects:
|
||||
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
|
||||
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
|
||||
|
||||
The project uses some code from [dixyes/lwmbs](https://github.com/dixyes/lwmbs), such as windows static build target and libiconv support.
|
||||
lwmbs is licensed under the [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2).
|
||||
|
||||
Due to the special nature of this project,
|
||||
many other open source projects such as curl and protobuf will be used during the project compilation process,
|
||||
and they all have their own open source licenses.
|
||||
|
||||
@@ -28,7 +28,7 @@ function RemoveFromPath {
|
||||
$currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
|
||||
if ($currentPath -like "*$pathToRemove*") {
|
||||
$newPath = $currentPath -replace [regex]::Escape($pathToRemove), ''
|
||||
$newPath = $currentPath -replace [regex]::Escape(';' + $pathToRemove), ''
|
||||
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
|
||||
Write-Host "Removed Path '$pathToRemove'"
|
||||
} else {
|
||||
@@ -92,7 +92,7 @@ if (-not(Test-Path "runtime\composer.phar"))
|
||||
# create runtime\composer.ps1
|
||||
$ComposerContent = '
|
||||
$WorkingDir = (Split-Path -Parent $MyInvocation.MyCommand.Definition)
|
||||
Start-Process ($WorkingDir + "\php.exe") ($WorkingDir + "\composer.phar " + $args) -NoNewWindow -Wait
|
||||
& ($WorkingDir + "\php.exe") (Join-Path $WorkingDir "\composer.phar") @args
|
||||
'
|
||||
$ComposerContent | Set-Content -Path 'runtime\composer.ps1' -Encoding UTF8
|
||||
|
||||
|
||||
1
bin/spc
1
bin/spc
@@ -21,4 +21,5 @@ try {
|
||||
(new ConsoleApplication())->run();
|
||||
} catch (Exception $e) {
|
||||
ExceptionHandler::getInstance()->handle($e);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$PHP_Exec = "runtime\php.exe"
|
||||
$PHP_Exec = ".\runtime\php.exe"
|
||||
|
||||
if (-not(Test-Path $PHP_Exec)) {
|
||||
$PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
|
||||
@@ -8,5 +8,5 @@ if (-not(Test-Path $PHP_Exec)) {
|
||||
}
|
||||
}
|
||||
|
||||
$phpArgs = "bin\spc " + $args
|
||||
Start-Process $PHP_Exec -ArgumentList $phpArgs -NoNewWindow -Wait
|
||||
& "$PHP_Exec" ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
|
||||
1
box.json
1
box.json
@@ -14,6 +14,5 @@
|
||||
"vendor/zhamao"
|
||||
],
|
||||
"git-commit-short": "git_commit_short",
|
||||
"metadata": "ConsoleApplication::VERSION",
|
||||
"output": "spc.phar"
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"friendsofphp/php-cs-fixer": "^3.25",
|
||||
"humbug/box": "^4.3",
|
||||
"humbug/box": "^4.5",
|
||||
"nunomaduro/collision": "^7.8",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^10.3"
|
||||
"phpunit/phpunit": "^10.3 || ^9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -54,5 +54,11 @@
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
}
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "other",
|
||||
"url": "https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
940
composer.lock
generated
940
composer.lock
generated
File diff suppressed because it is too large
Load Diff
114
config/ext.json
114
config/ext.json
@@ -1,4 +1,15 @@
|
||||
{
|
||||
"amqp": {
|
||||
"type": "external",
|
||||
"arg-type": "custom",
|
||||
"source": "amqp",
|
||||
"lib-depends": [
|
||||
"librabbitmq"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"apcu": {
|
||||
"type": "external",
|
||||
"source": "apcu"
|
||||
@@ -24,11 +35,18 @@
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"curl"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"zlib",
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"dba": {
|
||||
"type": "builtin",
|
||||
"arg-type-windows": "with"
|
||||
"arg-type": "custom",
|
||||
"lib-suggests": [
|
||||
"qdbm"
|
||||
]
|
||||
},
|
||||
"dom": {
|
||||
"type": "builtin",
|
||||
@@ -37,8 +55,15 @@
|
||||
"lib-depends": [
|
||||
"libxml2",
|
||||
"zlib"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml"
|
||||
]
|
||||
},
|
||||
"ds": {
|
||||
"type": "external",
|
||||
"source": "ext-ds"
|
||||
},
|
||||
"event": {
|
||||
"type": "external",
|
||||
"source": "ext-event",
|
||||
@@ -59,8 +84,11 @@
|
||||
"ffi": {
|
||||
"arg-type": "custom",
|
||||
"type": "builtin",
|
||||
"lib-depends": [
|
||||
"lib-depends-unix": [
|
||||
"libffi"
|
||||
],
|
||||
"lib-depends-windows": [
|
||||
"libffi-win"
|
||||
]
|
||||
},
|
||||
"fileinfo": {
|
||||
@@ -95,7 +123,7 @@
|
||||
},
|
||||
"gettext": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"gettext"
|
||||
]
|
||||
@@ -106,7 +134,8 @@
|
||||
"source": "ext-glfw",
|
||||
"lib-depends": [
|
||||
"glfw"
|
||||
]
|
||||
],
|
||||
"lib-depends-windows": []
|
||||
},
|
||||
"gmp": {
|
||||
"type": "builtin",
|
||||
@@ -118,8 +147,12 @@
|
||||
"iconv": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends-unix": [
|
||||
"libiconv"
|
||||
],
|
||||
"lib-depends-windows": [
|
||||
"libiconv-win"
|
||||
]
|
||||
},
|
||||
"igbinary": {
|
||||
@@ -238,6 +271,7 @@
|
||||
"openssl": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends": [
|
||||
"openssl",
|
||||
"zlib"
|
||||
@@ -290,6 +324,15 @@
|
||||
"sqlite"
|
||||
]
|
||||
},
|
||||
"pdo_sqlsrv": {
|
||||
"type": "external",
|
||||
"source": "pdo_sqlsrv",
|
||||
"arg-type": "with",
|
||||
"ext-depends": [
|
||||
"pdo",
|
||||
"sqlsrv"
|
||||
]
|
||||
},
|
||||
"pgsql": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
@@ -311,13 +354,6 @@
|
||||
"type": "external",
|
||||
"source": "protobuf"
|
||||
},
|
||||
"pspell": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"aspell"
|
||||
]
|
||||
},
|
||||
"rar": {
|
||||
"type": "external",
|
||||
"source": "rar",
|
||||
@@ -349,12 +385,19 @@
|
||||
"shmop": {
|
||||
"type": "builtin"
|
||||
},
|
||||
"simdjson": {
|
||||
"type": "external",
|
||||
"source": "ext-simdjson",
|
||||
"cpp-extension": true
|
||||
},
|
||||
"simplexml": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends": [
|
||||
"libxml2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml"
|
||||
]
|
||||
},
|
||||
"snappy": {
|
||||
@@ -369,18 +412,14 @@
|
||||
"apcu"
|
||||
]
|
||||
},
|
||||
"snmp": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"net-snmp"
|
||||
]
|
||||
},
|
||||
"soap": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"libxml2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml"
|
||||
]
|
||||
},
|
||||
"sockets": {
|
||||
@@ -396,6 +435,7 @@
|
||||
"sqlite3": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends": [
|
||||
"sqlite"
|
||||
]
|
||||
@@ -415,8 +455,13 @@
|
||||
"type": "external",
|
||||
"source": "ext-ssh2",
|
||||
"arg-type": "with-prefix",
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends": [
|
||||
"libssh2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"openssl",
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"swoole": {
|
||||
@@ -491,8 +536,7 @@
|
||||
"unix-only": true
|
||||
},
|
||||
"sysvshm": {
|
||||
"type": "builtin",
|
||||
"unix-only": true
|
||||
"type": "builtin"
|
||||
},
|
||||
"tidy": {
|
||||
"type": "builtin",
|
||||
@@ -504,6 +548,14 @@
|
||||
"tokenizer": {
|
||||
"type": "builtin"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "external",
|
||||
"source": "ext-uuid",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"libuuid"
|
||||
]
|
||||
},
|
||||
"uv": {
|
||||
"type": "external",
|
||||
"source": "ext-uv",
|
||||
@@ -537,6 +589,9 @@
|
||||
"arg-type-windows": "with",
|
||||
"lib-depends": [
|
||||
"libxml2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"iconv"
|
||||
]
|
||||
},
|
||||
"xmlreader": {
|
||||
@@ -544,6 +599,10 @@
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"libxml2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"xmlwriter": {
|
||||
@@ -551,6 +610,9 @@
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"libxml2"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml"
|
||||
]
|
||||
},
|
||||
"xsl": {
|
||||
@@ -564,6 +626,14 @@
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"yac": {
|
||||
"type": "external",
|
||||
"source": "yac",
|
||||
"arg-type-unix": "custom",
|
||||
"ext-depends-unix": [
|
||||
"igbinary"
|
||||
]
|
||||
},
|
||||
"yaml": {
|
||||
"type": "external",
|
||||
"source": "yaml",
|
||||
|
||||
121
config/lib.json
121
config/lib.json
@@ -36,7 +36,7 @@
|
||||
"libcurl.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"libcurl.lib"
|
||||
"libcurl_a.lib"
|
||||
],
|
||||
"headers": [
|
||||
"curl"
|
||||
@@ -45,21 +45,21 @@
|
||||
"openssl",
|
||||
"zlib"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"lib-depends-windows": [
|
||||
"openssl",
|
||||
"zlib",
|
||||
"libssh2",
|
||||
"nghttp2"
|
||||
],
|
||||
"lib-suggests-unix": [
|
||||
"libssh2",
|
||||
"brotli",
|
||||
"nghttp2",
|
||||
"zstd"
|
||||
],
|
||||
"lib-suggests-windows": [
|
||||
"zlib",
|
||||
"libssh2",
|
||||
"brotli",
|
||||
"nghttp2",
|
||||
"zstd",
|
||||
"openssl",
|
||||
"idn2",
|
||||
"psl"
|
||||
"zstd"
|
||||
],
|
||||
"frameworks": [
|
||||
"CoreFoundation",
|
||||
@@ -85,6 +85,22 @@
|
||||
"brotli"
|
||||
]
|
||||
},
|
||||
"gettext": {
|
||||
"source": "gettext",
|
||||
"static-libs-unix": [
|
||||
"libintl.a"
|
||||
],
|
||||
"lib-depends": [
|
||||
"libiconv"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"ncurses",
|
||||
"libxml2"
|
||||
],
|
||||
"frameworks": [
|
||||
"CoreFoundation"
|
||||
]
|
||||
},
|
||||
"glfw": {
|
||||
"source": "ext-glfw",
|
||||
"static-libs-unix": [
|
||||
@@ -131,7 +147,8 @@
|
||||
"libpng",
|
||||
"libjpeg",
|
||||
"libwebp",
|
||||
"freetype"
|
||||
"freetype",
|
||||
"libtiff"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd",
|
||||
@@ -217,6 +234,17 @@
|
||||
"ffitarget.h"
|
||||
]
|
||||
},
|
||||
"libffi-win": {
|
||||
"source": "libffi-win",
|
||||
"static-libs-windows": [
|
||||
"libffi.lib"
|
||||
],
|
||||
"headers-windows": [
|
||||
"ffi.h",
|
||||
"ffitarget.h",
|
||||
"fficonfig.h"
|
||||
]
|
||||
},
|
||||
"libiconv": {
|
||||
"source": "libiconv",
|
||||
"static-libs-unix": [
|
||||
@@ -229,6 +257,13 @@
|
||||
"localcharset.h"
|
||||
]
|
||||
},
|
||||
"libiconv-win": {
|
||||
"source": "libiconv-win",
|
||||
"static-libs-windows": [
|
||||
"libiconv.lib",
|
||||
"libiconv_a.lib"
|
||||
]
|
||||
},
|
||||
"libjpeg": {
|
||||
"source": "libjpeg",
|
||||
"static-libs-unix": [
|
||||
@@ -270,6 +305,18 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"librabbitmq": {
|
||||
"source": "librabbitmq",
|
||||
"static-libs-unix": [
|
||||
"librabbitmq.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"rabbitmq.4.lib"
|
||||
],
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"libsodium": {
|
||||
"source": "libsodium",
|
||||
"static-libs-unix": [
|
||||
@@ -296,6 +343,21 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"libtiff": {
|
||||
"source": "libtiff",
|
||||
"static-libs-unix": [
|
||||
"libtiff.a"
|
||||
]
|
||||
},
|
||||
"libuuid": {
|
||||
"source": "libuuid",
|
||||
"static-libs-unix": [
|
||||
"libuuid.a"
|
||||
],
|
||||
"headers": [
|
||||
"uuid/uuid.h"
|
||||
]
|
||||
},
|
||||
"libuv": {
|
||||
"source": "libuv",
|
||||
"static-libs-unix": [
|
||||
@@ -318,21 +380,25 @@
|
||||
"libxml2.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
[
|
||||
"libxml2s.lib",
|
||||
"libxml2_a.lib"
|
||||
]
|
||||
"libxml2s.lib",
|
||||
"libxml2_a.lib"
|
||||
],
|
||||
"headers": [
|
||||
"libxml2"
|
||||
],
|
||||
"lib-depends": [
|
||||
"lib-depends-unix": [
|
||||
"libiconv"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"lib-suggests-unix": [
|
||||
"xz",
|
||||
"icu",
|
||||
"zlib"
|
||||
],
|
||||
"lib-depends-windows": [
|
||||
"libiconv-win"
|
||||
],
|
||||
"lib-suggests-windows": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"libxslt": {
|
||||
@@ -413,10 +479,8 @@
|
||||
"libonig.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
[
|
||||
"onig.lib",
|
||||
"onig_a.lib"
|
||||
]
|
||||
"onig.lib",
|
||||
"onig_a.lib"
|
||||
],
|
||||
"headers": [
|
||||
"oniggnu.h",
|
||||
@@ -464,6 +528,18 @@
|
||||
"zstd"
|
||||
]
|
||||
},
|
||||
"qdbm": {
|
||||
"source": "qdbm",
|
||||
"static-libs-unix": [
|
||||
"libqdbm.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"qdbm_a.lib"
|
||||
],
|
||||
"headers-windows": [
|
||||
"depot.h"
|
||||
]
|
||||
},
|
||||
"readline": {
|
||||
"source": "readline",
|
||||
"static-libs-unix": [
|
||||
@@ -493,7 +569,10 @@
|
||||
"static-libs-unix": [
|
||||
"libsqlite3.a"
|
||||
],
|
||||
"headers-unix": [
|
||||
"static-libs-windows": [
|
||||
"libsqlite3_a.lib"
|
||||
],
|
||||
"headers": [
|
||||
"sqlite3.h",
|
||||
"sqlite3ext.h"
|
||||
]
|
||||
|
||||
46
config/pkg.json
Normal file
46
config/pkg.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"musl-toolchain-aarch64-linux": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
|
||||
},
|
||||
"musl-toolchain-x86_64-linux": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz"
|
||||
},
|
||||
"nasm-x86_64-win": {
|
||||
"type": "url",
|
||||
"url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip",
|
||||
"extract-files": {
|
||||
"nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe",
|
||||
"nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
|
||||
}
|
||||
},
|
||||
"strawberry-perl-x86_64-win": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
|
||||
},
|
||||
"upx-aarch64-linux": {
|
||||
"type": "ghrel",
|
||||
"repo": "upx/upx",
|
||||
"match": "upx.+-arm64_linux\\.tar\\.xz",
|
||||
"extract-files": {
|
||||
"upx": "{pkg_root_path}/bin/upx"
|
||||
}
|
||||
},
|
||||
"upx-x86_64-linux": {
|
||||
"type": "ghrel",
|
||||
"repo": "upx/upx",
|
||||
"match": "upx.+-amd64_linux\\.tar\\.xz",
|
||||
"extract-files": {
|
||||
"upx": "{pkg_root_path}/bin/upx"
|
||||
}
|
||||
},
|
||||
"upx-x86_64-win": {
|
||||
"type": "ghrel",
|
||||
"repo": "upx/upx",
|
||||
"match": "upx.+-win64\\.zip",
|
||||
"extract-files": {
|
||||
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,16 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"amqp": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/amqp",
|
||||
"path": "php-src/ext/amqp",
|
||||
"filename": "amqp.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"apcu": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/APCu",
|
||||
@@ -42,6 +52,16 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"ext-ds": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/ds",
|
||||
"path": "php-src/ext/ds",
|
||||
"filename": "ds.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-event": {
|
||||
"type": "url",
|
||||
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
|
||||
@@ -80,6 +100,16 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-simdjson": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/simdjson",
|
||||
"path": "php-src/ext/simdjson",
|
||||
"filename": "simdjson.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-snappy": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/snappy",
|
||||
@@ -100,6 +130,16 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-uuid": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/uuid",
|
||||
"path": "php-src/ext/uuid",
|
||||
"filename": "uuid.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-uv": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/uv",
|
||||
@@ -129,6 +169,15 @@
|
||||
"path": "LICENSE.TXT"
|
||||
}
|
||||
},
|
||||
"gettext": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/pub/gnu/gettext/",
|
||||
"regex": "/href=\"(?<file>gettext-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"gmp": {
|
||||
"type": "ghtagtar",
|
||||
"repo": "alisw/GMP",
|
||||
@@ -195,7 +244,7 @@
|
||||
"libargon2": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/mpociot/phc-winner-argon2",
|
||||
"url": "https://github.com/static-php/phc-winner-argon2",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
@@ -236,6 +285,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libffi-win": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/static-php/libffi-win.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libiconv": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
||||
@@ -245,6 +303,15 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libiconv-win": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/static-php/libiconv-win.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "source/COPYING"
|
||||
}
|
||||
},
|
||||
"libjpeg": {
|
||||
"type": "ghtar",
|
||||
"repo": "libjpeg-turbo/libjpeg-turbo",
|
||||
@@ -280,6 +347,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"librabbitmq": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/alanxz/rabbitmq-c.git",
|
||||
"rev": "master",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libsodium": {
|
||||
"type": "ghrel",
|
||||
"repo": "jedisct1/libsodium",
|
||||
@@ -298,6 +374,24 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libtiff": {
|
||||
"type": "filelist",
|
||||
"url": "https://download.osgeo.org/libtiff/",
|
||||
"regex": "/href=\"(?<file>tiff-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE.md"
|
||||
}
|
||||
},
|
||||
"libuuid": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/static-php/libuuid.git",
|
||||
"rev": "master",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libuv": {
|
||||
"type": "ghtar",
|
||||
"repo": "libuv/libuv",
|
||||
@@ -322,7 +416,7 @@
|
||||
},
|
||||
"libxml2": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz",
|
||||
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "Copyright"
|
||||
@@ -421,6 +515,16 @@
|
||||
"path": "LICENSE.txt"
|
||||
}
|
||||
},
|
||||
"pdo_sqlsrv": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/pdo_sqlsrv",
|
||||
"path": "php-src/ext/pdo_sqlsrv",
|
||||
"filename": "pdo_sqlsrv.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"pkg-config": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
|
||||
@@ -431,7 +535,7 @@
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "url",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYRIGHT"
|
||||
@@ -447,6 +551,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"qdbm": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/static-php/qdbm.git",
|
||||
"rev": "main",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"rar": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/static-php/php-rar.git",
|
||||
@@ -562,14 +675,23 @@
|
||||
}
|
||||
},
|
||||
"xz": {
|
||||
"type": "ghrel",
|
||||
"repo": "tukaani-project/xz",
|
||||
"match": "xz-.+\\.tar\\.gz",
|
||||
"type": "url",
|
||||
"url": "https://fossies.org/linux/misc/xz-5.4.6.tar.xz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"yac": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/yac",
|
||||
"path": "php-src/ext/yac",
|
||||
"filename": "yac.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"yaml": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/yaml",
|
||||
|
||||
@@ -14,4 +14,5 @@ parameters:
|
||||
excludePaths:
|
||||
analyseAndScan:
|
||||
- ./src/globals/tests/swoole.php
|
||||
- ./src/globals/tests/swoole.phpt
|
||||
- ./src/globals/tests/swoole.phpt
|
||||
- ./src/globals/test-extensions.php
|
||||
@@ -6,6 +6,7 @@ namespace SPC;
|
||||
|
||||
use SPC\command\BuildCliCommand;
|
||||
use SPC\command\BuildLibsCommand;
|
||||
use SPC\command\DeleteDownloadCommand;
|
||||
use SPC\command\dev\AllExtCommand;
|
||||
use SPC\command\dev\PhpVerCommand;
|
||||
use SPC\command\dev\SortConfigCommand;
|
||||
@@ -13,6 +14,7 @@ use SPC\command\DoctorCommand;
|
||||
use SPC\command\DownloadCommand;
|
||||
use SPC\command\DumpLicenseCommand;
|
||||
use SPC\command\ExtractCommand;
|
||||
use SPC\command\InstallPkgCommand;
|
||||
use SPC\command\MicroCombineCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\HelpCommand;
|
||||
@@ -23,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.0.1';
|
||||
public const VERSION = '2.2.0';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -31,10 +33,13 @@ final class ConsoleApplication extends Application
|
||||
|
||||
$this->addCommands(
|
||||
[
|
||||
// Common commands
|
||||
new BuildCliCommand(),
|
||||
new BuildLibsCommand(),
|
||||
new DoctorCommand(),
|
||||
new DownloadCommand(),
|
||||
new InstallPkgCommand(),
|
||||
new DeleteDownloadCommand(),
|
||||
new DumpLicenseCommand(),
|
||||
new ExtractCommand(),
|
||||
new MicroCombineCommand(),
|
||||
|
||||
@@ -9,10 +9,8 @@ use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourceExtractor;
|
||||
use SPC\store\SourceManager;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\DependencyUtil;
|
||||
|
||||
abstract class BuilderBase
|
||||
{
|
||||
@@ -43,64 +41,7 @@ abstract class BuilderBase
|
||||
* @throws WrongUsageException
|
||||
* @internal
|
||||
*/
|
||||
public function buildLibs(array $sorted_libraries): void
|
||||
{
|
||||
// search all supported libs
|
||||
$support_lib_list = [];
|
||||
$classes = FileSystem::getClassesPsr4(
|
||||
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
|
||||
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
||||
);
|
||||
foreach ($classes as $class) {
|
||||
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
||||
$support_lib_list[$class::NAME] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
// if no libs specified, compile all supported libs
|
||||
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
||||
$libraries = array_keys($support_lib_list);
|
||||
$sorted_libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
}
|
||||
|
||||
// pkg-config must be compiled first, whether it is specified or not
|
||||
if (!in_array('pkg-config', $sorted_libraries)) {
|
||||
array_unshift($sorted_libraries, 'pkg-config');
|
||||
}
|
||||
|
||||
// add lib object for builder
|
||||
foreach ($sorted_libraries as $library) {
|
||||
// if some libs are not supported (but in config "lib.json", throw exception)
|
||||
if (!isset($support_lib_list[$library])) {
|
||||
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||
}
|
||||
$lib = new ($support_lib_list[$library])($this);
|
||||
$this->addLib($lib);
|
||||
}
|
||||
|
||||
// calculate and check dependencies
|
||||
foreach ($this->libs as $lib) {
|
||||
$lib->calcDependency();
|
||||
}
|
||||
|
||||
// patch point
|
||||
$this->emitPatchPoint('before-libs-extract');
|
||||
|
||||
// extract sources
|
||||
SourceExtractor::initSource(libs: $sorted_libraries);
|
||||
|
||||
$this->emitPatchPoint('after-libs-extract');
|
||||
|
||||
// build all libs
|
||||
foreach ($this->libs as $lib) {
|
||||
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
||||
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
||||
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
||||
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
||||
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
||||
};
|
||||
}
|
||||
}
|
||||
abstract public function buildLibs(array $sorted_libraries);
|
||||
|
||||
/**
|
||||
* Add library to build.
|
||||
@@ -203,15 +144,15 @@ abstract class BuilderBase
|
||||
{
|
||||
CustomExt::loadCustomExt();
|
||||
$this->emitPatchPoint('before-php-extract');
|
||||
SourceExtractor::initSource(sources: ['php-src']);
|
||||
SourceManager::initSource(sources: ['php-src']);
|
||||
$this->emitPatchPoint('after-php-extract');
|
||||
if ($this->getPHPVersionID() >= 80000) {
|
||||
$this->emitPatchPoint('before-micro-extract');
|
||||
SourceExtractor::initSource(sources: ['micro']);
|
||||
SourceManager::initSource(sources: ['micro']);
|
||||
$this->emitPatchPoint('after-micro-extract');
|
||||
}
|
||||
$this->emitPatchPoint('before-exts-extract');
|
||||
SourceExtractor::initSource(exts: $extensions);
|
||||
SourceManager::initSource(exts: $extensions);
|
||||
$this->emitPatchPoint('after-exts-extract');
|
||||
foreach ($extensions as $extension) {
|
||||
$class = CustomExt::getExtClass($extension);
|
||||
@@ -242,6 +183,7 @@ abstract class BuilderBase
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($this->exts as $ext) {
|
||||
logger()->info($ext->getName() . ' is using ' . $ext->getConfigureArg());
|
||||
$ret[] = trim($ext->getConfigureArg());
|
||||
}
|
||||
logger()->debug('Using configure: ' . implode(' ', $ret));
|
||||
@@ -289,6 +231,30 @@ abstract class BuilderBase
|
||||
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHP version from archive file name.
|
||||
*
|
||||
* @param null|string $file php-*.*.*.tar.gz filename, read from lockfile if empty
|
||||
*/
|
||||
public function getPHPVersionFromArchive(?string $file = null): false|string
|
||||
{
|
||||
if ($file === null) {
|
||||
$lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false;
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
$lock = json_decode($lock, true);
|
||||
$file = $lock['php-src']['filename'] ?? null;
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) {
|
||||
return $match[1];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get build type name string to display.
|
||||
*
|
||||
@@ -417,4 +383,22 @@ abstract class BuilderBase
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate micro extension test php code.
|
||||
*/
|
||||
protected function generateMicroExtTests(): string
|
||||
{
|
||||
$php = "<?php\n\necho '[micro-test-start]' . PHP_EOL;\n";
|
||||
|
||||
foreach ($this->getExts() as $ext) {
|
||||
$ext_name = $ext->getDistName();
|
||||
if (!empty($ext_name)) {
|
||||
$php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n";
|
||||
$php .= "assert(extension_loaded('{$ext_name}'));\n\n";
|
||||
}
|
||||
}
|
||||
$php .= "echo '[micro-test-end]';\n";
|
||||
return $php;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace SPC\builder;
|
||||
use SPC\builder\freebsd\BSDBuilder;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
@@ -27,11 +28,7 @@ class BuilderProvider
|
||||
public static function makeBuilderByInput(InputInterface $input): BuilderBase
|
||||
{
|
||||
self::$builder = match (PHP_OS_FAMILY) {
|
||||
// 'Windows' => new WindowsBuilder(
|
||||
// binary_sdk_dir: $input->getOption('with-sdk-binary-dir'),
|
||||
// vs_ver: $input->getOption('vs-ver'),
|
||||
// arch: $input->getOption('arch'),
|
||||
// ),
|
||||
'Windows' => new WindowsBuilder($input->getOptions()),
|
||||
'Darwin' => new MacOSBuilder($input->getOptions()),
|
||||
'Linux' => new LinuxBuilder($input->getOptions()),
|
||||
'BSD' => new BSDBuilder($input->getOptions()),
|
||||
|
||||
@@ -8,6 +8,7 @@ use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class Extension
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class Extension
|
||||
$arg = $this->getEnableArg();
|
||||
switch (PHP_OS_FAMILY) {
|
||||
case 'Windows':
|
||||
$arg = $this->getWindowsConfigureArg();
|
||||
$arg .= $this->getWindowsConfigureArg();
|
||||
break;
|
||||
case 'Darwin':
|
||||
case 'Linux':
|
||||
@@ -164,14 +165,13 @@ class Extension
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// Run compile check if build target is cli
|
||||
// If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
|
||||
// If check failed, throw RuntimeException
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
@@ -185,7 +185,38 @@ class Extension
|
||||
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')
|
||||
);
|
||||
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
if ($this->builder->getOption('debug')) {
|
||||
var_dump($out);
|
||||
}
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function runCliCheckWindows(): void
|
||||
{
|
||||
// Run compile check if build target is cli
|
||||
// If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
|
||||
// If check failed, throw RuntimeException
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
}
|
||||
|
||||
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))) {
|
||||
// Trim additional content & escape special characters to allow inline usage
|
||||
$test = str_replace(
|
||||
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
||||
['', '', '', '\"', '$'],
|
||||
file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))
|
||||
);
|
||||
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
}
|
||||
|
||||
@@ -206,4 +206,9 @@ abstract class LibraryBase
|
||||
}
|
||||
logger()->debug('enabling ' . static::NAME . " without {$name}");
|
||||
}
|
||||
|
||||
protected function getSnakeCaseName(): string
|
||||
{
|
||||
return str_replace('-', '_', static::NAME);
|
||||
}
|
||||
}
|
||||
|
||||
35
src/SPC/builder/extension/amqp.php
Normal file
35
src/SPC/builder/extension/amqp.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('amqp')]
|
||||
class amqp extends Extension
|
||||
{
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
|
||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
|
||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_ssl_socket.h', '/^#warning.*/m', '');
|
||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
return '--with-amqp';
|
||||
}
|
||||
}
|
||||
24
src/SPC/builder/extension/dba.php
Normal file
24
src/SPC/builder/extension/dba.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('dba')]
|
||||
class dba extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
|
||||
return '--enable-dba' . $qdbm;
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
$qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : '';
|
||||
return '--with-dba' . $qdbm;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
@@ -34,4 +35,16 @@ class event extends Extension
|
||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// Prevent event extension compile error on macOS
|
||||
if ($this->builder instanceof MacOSBuilder) {
|
||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,9 @@ class ffi extends Extension
|
||||
{
|
||||
return '--with-ffi --enable-zend-signals';
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
return '--with-ffi';
|
||||
}
|
||||
}
|
||||
|
||||
40
src/SPC/builder/extension/gettext.php
Normal file
40
src/SPC/builder/extension/gettext.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('gettext')]
|
||||
class gettext extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if ($this->builder instanceof MacOSBuilder) {
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
if ($this->builder instanceof MacOSBuilder) {
|
||||
$frameworks = ' ' . $this->builder->getFrameworks(true) . ' ';
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,9 @@ class glfw extends Extension
|
||||
{
|
||||
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
return '--enable-glfw=static';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ class imagick extends Extension
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// imagick may call omp_pause_all which requires -lgomp
|
||||
$extra_libs = $this->builder->getOption('extra-libs', '');
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
if ($this->builder instanceof LinuxBuilder) {
|
||||
$extra_libs .= ' -lgomp ';
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp ';
|
||||
}
|
||||
$this->builder->setOption('extra-libs', $extra_libs);
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
26
src/SPC/builder/extension/intl.php
Normal file
26
src/SPC/builder/extension/intl.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('intl')]
|
||||
class intl extends Extension
|
||||
{
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
// TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17');
|
||||
// Also need to use clang++ -std=c++17 to force override the default C++ standard
|
||||
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) {
|
||||
f_putenv('CXX=' . $env . ' -std=c++17');
|
||||
} else {
|
||||
f_putenv('CXX=clang++ -std=c++17');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,11 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('mbregex')]
|
||||
class mbregex extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'mbstring';
|
||||
}
|
||||
|
||||
public function getConfigureArg(): string
|
||||
{
|
||||
return '';
|
||||
@@ -19,11 +24,23 @@ class mbregex extends Extension
|
||||
/**
|
||||
* mbregex is not an extension, we need to overwrite the default check.
|
||||
*/
|
||||
public function runCliCheck(): void
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||
}
|
||||
}
|
||||
|
||||
public function runCliCheckWindows(): void
|
||||
{
|
||||
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
|
||||
}
|
||||
$out = implode("\n", $out);
|
||||
if (!str_contains($out, 'regex')) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('mbstring')]
|
||||
class mbstring extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
public function getConfigureArg(): string
|
||||
{
|
||||
$arg = '--enable-mbstring';
|
||||
if ($this->builder->getExt('mbregex') === null) {
|
||||
$arg .= ' --disable-mbregex';
|
||||
} else {
|
||||
$arg .= ' --enable-mbregex';
|
||||
}
|
||||
return $arg;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,12 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('password-argon2')]
|
||||
class password_argon2 extends Extension
|
||||
{
|
||||
public function runCliCheck(): void
|
||||
public function getDistName(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
|
||||
if ($ret !== 0) {
|
||||
|
||||
34
src/SPC/builder/extension/simdjson.php
Normal file
34
src/SPC/builder/extension/simdjson.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('simdjson')]
|
||||
class simdjson extends Extension
|
||||
{
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
$php_ver = $this->builder->getPHPVersionID();
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
|
||||
'/php_version=(`.*`)$/m',
|
||||
'php_version=' . strval($php_ver)
|
||||
);
|
||||
FileSystem::replaceFileStr(
|
||||
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
|
||||
'if test -z "$PHP_CONFIG"; then',
|
||||
'if false; then'
|
||||
);
|
||||
FileSystem::replaceFileStr(
|
||||
SOURCE_PATH . '/php-src/ext/simdjson/config.w32',
|
||||
"'yes',",
|
||||
'PHP_SIMDJSON_SHARED,'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ class swoole extends Extension
|
||||
// enable swoole
|
||||
$arg = '--enable-swoole';
|
||||
|
||||
// commonly-used feature: coroutine-time, thread-context
|
||||
$arg .= ' --enable-swoole-coro-time --enable-thread-context';
|
||||
// commonly-used feature: coroutine-time, disable-thread-context
|
||||
$arg .= ' --enable-swoole-coro-time --disable-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';
|
||||
|
||||
@@ -11,6 +11,11 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('swoole-hook-mysql')]
|
||||
class swoole_hook_mysql extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'swoole';
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
// pdo_mysql doesn't need to be disabled
|
||||
@@ -18,7 +23,7 @@ class swoole_hook_mysql extends Extension
|
||||
return '';
|
||||
}
|
||||
|
||||
public function runCliCheck(): void
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
|
||||
@@ -12,6 +12,11 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('swoole-hook-pgsql')]
|
||||
class swoole_hook_pgsql extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'swoole';
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
// pdo_pgsql need to be disabled
|
||||
@@ -22,7 +27,7 @@ class swoole_hook_pgsql extends Extension
|
||||
return '--enable-swoole-pgsql';
|
||||
}
|
||||
|
||||
public function runCliCheck(): void
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
|
||||
@@ -12,6 +12,11 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('swoole-hook-sqlite')]
|
||||
class swoole_hook_sqlite extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'swoole';
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
// pdo_pgsql need to be disabled
|
||||
@@ -22,7 +27,7 @@ class swoole_hook_sqlite extends Extension
|
||||
return '--enable-swoole-sqlite';
|
||||
}
|
||||
|
||||
public function runCliCheck(): void
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('xml')]
|
||||
@@ -33,4 +34,25 @@ class xml extends Extension
|
||||
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
|
||||
return $arg;
|
||||
}
|
||||
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/win32/build/config.w32', 'dllmain.c ', '');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
$arg = match ($this->name) {
|
||||
'xml' => '--with-xml',
|
||||
'soap' => '--enable-soap',
|
||||
'xmlreader' => '--enable-xmlreader',
|
||||
'xmlwriter' => '--enable-xmlwriter',
|
||||
'dom' => '--with-dom',
|
||||
'simplexml' => '--with-simplexml',
|
||||
default => throw new RuntimeException('Not accept non-xml extension'),
|
||||
};
|
||||
$arg .= ' --with-libxml';
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
26
src/SPC/builder/extension/yac.php
Normal file
26
src/SPC/builder/extension/yac.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('yac')]
|
||||
class yac extends Extension
|
||||
{
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/yac/storage/allocator/yac_allocator.h', 'defined(HAVE_SHM_MMAP_ANON)', 'defined(YAC_ALLOCATOR_H)');
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/yac/serializer/igbinary.c', '#ifdef YAC_ENABLE_IGBINARY', '#if 1');
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/yac/serializer/json.c', '#if YAC_ENABLE_JSON', '#if 1');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--enable-yac --enable-igbinary --enable-json';
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\freebsd;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\traits\UnixBuilderTrait;
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
class BSDBuilder extends BuilderBase
|
||||
class BSDBuilder extends UnixBuilderBase
|
||||
{
|
||||
/** Unix compatible builder methods */
|
||||
use UnixBuilderTrait;
|
||||
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
|
||||
@@ -4,79 +4,50 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||
use SPC\builder\traits\UnixBuilderTrait;
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
|
||||
class LinuxBuilder extends BuilderBase
|
||||
class LinuxBuilder extends UnixBuilderBase
|
||||
{
|
||||
/** Unix compatible builder methods */
|
||||
use UnixBuilderTrait;
|
||||
|
||||
/** @var array Tune cflags */
|
||||
public array $tune_c_flags;
|
||||
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
// ---------- set necessary options ----------
|
||||
// set C/C++ compilers (default: alpine: gcc, others: musl-cross-make)
|
||||
if (SystemUtil::isMuslDist()) {
|
||||
f_putenv("CC={$this->getOption('cc', 'gcc')}");
|
||||
f_putenv("CXX={$this->getOption('cxx', 'g++')}");
|
||||
f_putenv("AR={$this->getOption('ar', 'ar')}");
|
||||
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
|
||||
} else {
|
||||
$arch = arch2gnu(php_uname('m'));
|
||||
f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}");
|
||||
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
|
||||
f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}");
|
||||
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
|
||||
f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
|
||||
// check musl-cross make installed if we use musl-cross-make
|
||||
$arch = arch2gnu(php_uname('m'));
|
||||
|
||||
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
|
||||
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
|
||||
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
|
||||
// check musl-cross make installed if we use musl-cross-make
|
||||
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) {
|
||||
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
|
||||
}
|
||||
GlobalEnvManager::init($this);
|
||||
|
||||
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) {
|
||||
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
|
||||
}
|
||||
|
||||
// set PKG_CONFIG
|
||||
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||
// set PKG_CONFIG_PATH
|
||||
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
|
||||
|
||||
// set arch (default: current)
|
||||
$this->setOptionIfNotExist('arch', php_uname('m'));
|
||||
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
|
||||
|
||||
// concurrency
|
||||
$this->concurrency = SystemUtil::getCpuCount();
|
||||
$this->concurrency = intval(getenv('SPC_CONCURRENCY'));
|
||||
// cflags
|
||||
$this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch'));
|
||||
$this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch'));
|
||||
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC'));
|
||||
$this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS');
|
||||
$this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS');
|
||||
// cmake toolchain
|
||||
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(
|
||||
'Linux',
|
||||
$this->getOption('arch'),
|
||||
$arch,
|
||||
$this->arch_c_flags,
|
||||
getenv('CC'),
|
||||
getenv('CXX'),
|
||||
@@ -128,8 +99,8 @@ class LinuxBuilder extends BuilderBase
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
// ---------- Update extra-libs ----------
|
||||
$extra_libs = $this->getOption('extra-libs', '');
|
||||
// non-bloat linking
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
// bloat means force-load all static libraries, even if they are not used
|
||||
if (!$this->getOption('bloat', false)) {
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
|
||||
} else {
|
||||
@@ -137,21 +108,13 @@ 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);
|
||||
f_putenv('SPC_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',
|
||||
]);
|
||||
|
||||
$this->emitPatchPoint('before-php-buildconf');
|
||||
SourcePatcher::patchBeforeBuildconf($this);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_BUILDCONF'));
|
||||
|
||||
$this->emitPatchPoint('before-php-configure');
|
||||
SourcePatcher::patchBeforeConfigure($this);
|
||||
@@ -173,17 +136,53 @@ class LinuxBuilder 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' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
|
||||
'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'),
|
||||
'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'),
|
||||
'LIBS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'),
|
||||
]);
|
||||
|
||||
// upx pack and strip for micro
|
||||
// but always restore Makefile.frag.bak first
|
||||
if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak')) {
|
||||
copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag');
|
||||
}
|
||||
if ($this->getOption('with-upx-pack', false)) {
|
||||
// judge $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` count
|
||||
// if 2, replace src/globals/extra/micro-triple-Makefile.frag file content
|
||||
if (substr_count(FileSystem::readFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'), '$(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)`') === 2) {
|
||||
// bak first
|
||||
copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak');
|
||||
// replace Makefile.frag content
|
||||
FileSystem::writeFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', FileSystem::readFile(ROOT_DIR . '/src/globals/extra/micro-triple-Makefile.frag'));
|
||||
}
|
||||
// with upx pack always need strip
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . getenv('UPX_EXEC') . ' --best \$(SAPI_MICRO_PATH)',
|
||||
);
|
||||
} elseif (!$this->getOption('no-strip', false)) {
|
||||
// not-no-strip means strip (default behavior)
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)',
|
||||
);
|
||||
} else {
|
||||
// just no strip
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
|
||||
'/POST_MICRO_BUILD_COMMANDS=.*/',
|
||||
'POST_MICRO_BUILD_COMMANDS=true',
|
||||
);
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec(
|
||||
"{$this->getOption('ld_library_path')} " .
|
||||
'./configure ' .
|
||||
'--prefix= ' .
|
||||
'--with-valgrind=no ' .
|
||||
'--enable-shared=no ' .
|
||||
'--enable-static=yes ' .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--disable-phpdbg ' .
|
||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
||||
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
||||
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
|
||||
@@ -235,12 +234,16 @@ class LinuxBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildCli(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||
->exec("make -j{$this->concurrency} {$vars} cli");
|
||||
->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli");
|
||||
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
if ($this->getOption('with-upx-pack')) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
|
||||
->exec('strip --strip-all php')
|
||||
->exec(getenv('UPX_EXEC') . ' --best php');
|
||||
} elseif (!$this->getOption('no-strip', false)) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
||||
}
|
||||
|
||||
@@ -264,16 +267,16 @@ class LinuxBuilder extends BuilderBase
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars([
|
||||
'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '',
|
||||
]));
|
||||
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
|
||||
$vars = $this->getMakeExtraVars();
|
||||
|
||||
// patch fake cli for micro
|
||||
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
|
||||
$vars = SystemUtil::makeEnvVarString($vars);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||
->exec("make -j{$this->concurrency} {$vars} micro");
|
||||
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx');
|
||||
}
|
||||
->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro");
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||
|
||||
@@ -290,15 +293,18 @@ class LinuxBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildFpm(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||
->exec("make -j{$this->concurrency} {$vars} fpm");
|
||||
->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm");
|
||||
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
if ($this->getOption('with-upx-pack')) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
|
||||
->exec('strip --strip-all php-fpm')
|
||||
->exec(getenv('UPX_EXEC') . ' --best php-fpm');
|
||||
} elseif (!$this->getOption('no-strip', false)) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
|
||||
}
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_FPM);
|
||||
}
|
||||
|
||||
@@ -309,29 +315,19 @@ class LinuxBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildEmbed(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
|
||||
shell()
|
||||
->cd(SOURCE_PATH . '/php-src')
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||
->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install");
|
||||
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install");
|
||||
}
|
||||
|
||||
private function getBuildVars($input = []): array
|
||||
private function getMakeExtraVars(): array
|
||||
{
|
||||
$use_lld = '';
|
||||
if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) {
|
||||
$use_lld = '-Xcompiler -fuse-ld=lld';
|
||||
}
|
||||
$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']}" : '';
|
||||
$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 {$tune_c_flags}{$cflags}",
|
||||
'EXTRA_LIBS' => "{$this->getOption('extra-libs', '')} {$libs}",
|
||||
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static{$ldflags}",
|
||||
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
||||
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
|
||||
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +110,7 @@ class SystemUtil
|
||||
public static function getTuneCFlags(string $arch): array
|
||||
{
|
||||
return match ($arch) {
|
||||
'x86_64' => [
|
||||
'-march=corei7',
|
||||
'-mtune=core-avx2',
|
||||
],
|
||||
'arm64', 'aarch64' => [],
|
||||
'x86_64', 'arm64', 'aarch64' => [],
|
||||
default => throw new RuntimeException('unsupported arch: ' . $arch),
|
||||
};
|
||||
}
|
||||
@@ -224,6 +220,8 @@ class SystemUtil
|
||||
'redhat',
|
||||
// alpine
|
||||
'alpine',
|
||||
// arch
|
||||
'arch', 'manjaro',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/gettext.php
Normal file
12
src/SPC/builder/linux/library/gettext.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class gettext extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\gettext;
|
||||
|
||||
public const NAME = 'gettext';
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class icu extends LinuxLibraryBase
|
||||
protected function build(): void
|
||||
{
|
||||
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
|
||||
$cxxflags = 'CXXFLAGS="-std=c++11"';
|
||||
$cxxflags = 'CXXFLAGS="-std=c++17"';
|
||||
$ldflags = 'LDFLAGS="-static"';
|
||||
shell()->cd($this->source_dir . '/source')
|
||||
->exec(
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libargon2 extends LinuxLibraryBase
|
||||
@@ -15,10 +14,6 @@ class libargon2 extends LinuxLibraryBase
|
||||
|
||||
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/librabbitmq.php
Normal file
12
src/SPC/builder/linux/library/librabbitmq.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class librabbitmq extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\librabbitmq;
|
||||
|
||||
public const NAME = 'librabbitmq';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/libtiff.php
Normal file
12
src/SPC/builder/linux/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libtiff extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libtiff;
|
||||
|
||||
public const NAME = 'libtiff';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/libuuid.php
Normal file
12
src/SPC/builder/linux/library/libuuid.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libuuid extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libuuid;
|
||||
|
||||
public const NAME = 'libuuid';
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class libxml2 extends LinuxLibraryBase
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||
|
||||
@@ -28,6 +28,7 @@ class libxml2 extends LinuxLibraryBase
|
||||
'cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
|
||||
@@ -24,6 +24,7 @@ use SPC\builder\linux\SystemUtil;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class openssl extends LinuxLibraryBase
|
||||
{
|
||||
@@ -41,8 +42,7 @@ class openssl extends LinuxLibraryBase
|
||||
$extra = '';
|
||||
$ex_lib = '-ldl -pthread';
|
||||
|
||||
$env = "CFLAGS='{$this->builder->arch_c_flags}'";
|
||||
$env .= " CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH .
|
||||
$env = "CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH .
|
||||
' -idirafter /usr/include/ ' .
|
||||
' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' .
|
||||
"' ";
|
||||
@@ -63,7 +63,8 @@ class openssl extends LinuxLibraryBase
|
||||
$clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : '';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
"{$env} ./Configure no-shared {$extra} " .
|
||||
'--prefix=/ ' .
|
||||
'--libdir=lib ' .
|
||||
@@ -73,8 +74,18 @@ class openssl extends LinuxLibraryBase
|
||||
"linux-{$this->builder->getOption('arch')}{$clang_postfix}"
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->exec("make install_sw DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||
// patch for openssl 3.3.0+
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/qdbm.php
Normal file
12
src/SPC/builder/linux/library/qdbm.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class qdbm extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\qdbm;
|
||||
|
||||
public const NAME = 'qdbm';
|
||||
}
|
||||
@@ -4,20 +4,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\builder\traits\UnixBuilderTrait;
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
|
||||
class MacOSBuilder extends BuilderBase
|
||||
class MacOSBuilder extends UnixBuilderBase
|
||||
{
|
||||
/** Unix compatible builder methods */
|
||||
use UnixBuilderTrait;
|
||||
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
@@ -30,28 +27,15 @@ class MacOSBuilder extends BuilderBase
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
// ---------- set necessary options ----------
|
||||
// set C Compiler (default: clang)
|
||||
f_putenv('CC=' . $this->getOption('cc', 'clang'));
|
||||
// set C++ Composer (default: clang++)
|
||||
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
|
||||
// set PATH
|
||||
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
|
||||
// set PKG_CONFIG
|
||||
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||
// set PKG_CONFIG_PATH
|
||||
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
|
||||
// apply global environment variables
|
||||
GlobalEnvManager::init($this);
|
||||
|
||||
// set arch (default: current)
|
||||
$this->setOptionIfNotExist('arch', php_uname('m'));
|
||||
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
|
||||
|
||||
// ---------- set necessary compile environments ----------
|
||||
// ---------- set necessary compile vars ----------
|
||||
// concurrency
|
||||
$this->concurrency = SystemUtil::getCpuCount();
|
||||
$this->concurrency = intval(getenv('SPC_CONCURRENCY'));
|
||||
// cflags
|
||||
$this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
|
||||
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
|
||||
$this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS');
|
||||
$this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS');
|
||||
// cmake toolchain
|
||||
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags);
|
||||
|
||||
@@ -127,24 +111,25 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
// ---------- Update extra-libs ----------
|
||||
$extra_libs = $this->getOption('extra-libs', '');
|
||||
// add macOS frameworks
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true);
|
||||
// add libc++, some extensions or libraries need it (C++ cannot be linked statically)
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : '');
|
||||
// bloat means force-load all static libraries, even if they are not used
|
||||
if (!$this->getOption('bloat', false)) {
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
|
||||
} else {
|
||||
logger()->info('bloat linking');
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles())));
|
||||
}
|
||||
$this->setOption('extra-libs', $extra_libs);
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
|
||||
$this->emitPatchPoint('before-php-buildconf');
|
||||
SourcePatcher::patchBeforeBuildconf($this);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_BUILDCONF'));
|
||||
|
||||
$this->emitPatchPoint('before-php-configure');
|
||||
SourcePatcher::patchBeforeConfigure($this);
|
||||
@@ -159,9 +144,9 @@ class MacOSBuilder extends BuilderBase
|
||||
|
||||
// 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,
|
||||
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
|
||||
'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'),
|
||||
'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'),
|
||||
]);
|
||||
|
||||
if ($this->getLib('postgresql')) {
|
||||
@@ -174,14 +159,7 @@ class MacOSBuilder extends BuilderBase
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec(
|
||||
'./configure ' .
|
||||
'--prefix= ' .
|
||||
'--with-valgrind=no ' . // Not detect memory leak
|
||||
'--enable-shared=no ' .
|
||||
'--enable-static=yes ' .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--disable-phpdbg ' .
|
||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
||||
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
||||
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
|
||||
@@ -231,10 +209,10 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildCli(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} {$vars} cli");
|
||||
$shell->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli");
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
$shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php');
|
||||
}
|
||||
@@ -259,18 +237,17 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
|
||||
$vars = [
|
||||
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
|
||||
'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli,
|
||||
];
|
||||
$vars = $this->getBuildVars($vars);
|
||||
$vars = $this->getMakeExtraVars();
|
||||
|
||||
// patch fake cli for micro
|
||||
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
$vars['STRIP'] = 'dsymutil -f ';
|
||||
}
|
||||
$vars = SystemUtil::makeEnvVarString($vars);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec("make -j{$this->concurrency} {$vars} micro");
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} micro");
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||
|
||||
if ($this->phar_patched) {
|
||||
@@ -286,10 +263,10 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildFpm(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} {$vars} fpm");
|
||||
$shell->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} fpm");
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
$shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip sapi/fpm/php-fpm');
|
||||
}
|
||||
@@ -303,11 +280,10 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
protected function buildEmbed(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
|
||||
shell()
|
||||
->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install")
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install")
|
||||
// Workaround for https://github.com/php/php-src/issues/12082
|
||||
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o')
|
||||
->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o')
|
||||
@@ -318,14 +294,11 @@ class MacOSBuilder extends BuilderBase
|
||||
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
|
||||
}
|
||||
|
||||
private function getBuildVars($input = []): array
|
||||
private function getMakeExtraVars(): 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'),
|
||||
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
||||
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/macos/library/gettext.php
Normal file
12
src/SPC/builder/macos/library/gettext.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class gettext extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\gettext;
|
||||
|
||||
public const NAME = 'gettext';
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class libpng extends MacOSLibraryBase
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$optimizations = match ($this->builder->getOption('arch')) {
|
||||
$optimizations = match (php_uname('m')) {
|
||||
'x86_64' => '--enable-intel-sse ',
|
||||
'arm64' => '--enable-arm-neon ',
|
||||
default => '',
|
||||
@@ -45,7 +45,7 @@ class libpng extends MacOSLibraryBase
|
||||
->exec('chmod +x ./install-sh')
|
||||
->exec(
|
||||
'./configure ' .
|
||||
"--host={$this->builder->getOption('gnu-arch')}-apple-darwin " .
|
||||
'--host=' . arch2gnu(php_uname('m')) . '-apple-darwin ' .
|
||||
'--disable-shared ' .
|
||||
'--enable-static ' .
|
||||
'--enable-hardware-optimizations ' .
|
||||
|
||||
12
src/SPC/builder/macos/library/librabbitmq.php
Normal file
12
src/SPC/builder/macos/library/librabbitmq.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class librabbitmq extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\librabbitmq;
|
||||
|
||||
public const NAME = 'librabbitmq';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/libtiff.php
Normal file
12
src/SPC/builder/macos/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libtiff extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libtiff;
|
||||
|
||||
public const NAME = 'libtiff';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/libuuid.php
Normal file
12
src/SPC/builder/macos/library/libuuid.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libuuid extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libuuid;
|
||||
|
||||
public const NAME = 'libuuid';
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class libxml2 extends MacOSLibraryBase
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||
|
||||
@@ -29,6 +29,7 @@ class libxml2 extends MacOSLibraryBase
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SPC\builder\macos\library;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class openssl extends MacOSLibraryBase
|
||||
{
|
||||
@@ -47,6 +48,7 @@ class openssl extends MacOSLibraryBase
|
||||
}
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->exec(
|
||||
"./Configure no-shared {$extra} " .
|
||||
'--prefix=/ ' . // use prefix=/
|
||||
@@ -55,8 +57,18 @@ class openssl extends MacOSLibraryBase
|
||||
"darwin64-{$this->builder->getOption('arch')}-cc"
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->exec("make install_sw DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||
// patch for openssl 3.3.0+
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/macos/library/qdbm.php
Normal file
12
src/SPC/builder/macos/library/qdbm.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class qdbm extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\qdbm;
|
||||
|
||||
public const NAME = 'qdbm';
|
||||
}
|
||||
@@ -1,20 +1,4 @@
|
||||
<?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);
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
trait LibraryTrait {}
|
||||
@@ -12,8 +12,6 @@ use SPC\store\FileSystem;
|
||||
|
||||
trait UnixLibraryTrait
|
||||
{
|
||||
use LibraryTrait;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
@@ -50,7 +48,7 @@ trait UnixLibraryTrait
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function makeAutoconfEnv(string $prefix = null): string
|
||||
public function makeAutoconfEnv(?string $prefix = null): string
|
||||
{
|
||||
if ($prefix === null) {
|
||||
$prefix = str_replace('-', '_', strtoupper(static::NAME));
|
||||
@@ -101,4 +99,19 @@ trait UnixLibraryTrait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getLibExtraCFlags(): string
|
||||
{
|
||||
return getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';
|
||||
}
|
||||
|
||||
public function getLibExtraLdFlags(): string
|
||||
{
|
||||
return getenv($this->getSnakeCaseName() . '_LDFLAGS') ?: '';
|
||||
}
|
||||
|
||||
public function getLibExtraLibs(): string
|
||||
{
|
||||
return getenv($this->getSnakeCaseName() . '_LIBS') ?: '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
namespace SPC\builder\unix;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourceManager;
|
||||
use SPC\util\DependencyUtil;
|
||||
|
||||
trait UnixBuilderTrait
|
||||
abstract class UnixBuilderBase extends BuilderBase
|
||||
{
|
||||
/** @var string cflags */
|
||||
public string $arch_c_flags;
|
||||
@@ -86,6 +90,65 @@ trait UnixBuilderTrait
|
||||
return $extra;
|
||||
}
|
||||
|
||||
public function buildLibs(array $sorted_libraries): void
|
||||
{
|
||||
// search all supported libs
|
||||
$support_lib_list = [];
|
||||
$classes = FileSystem::getClassesPsr4(
|
||||
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
|
||||
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
||||
);
|
||||
foreach ($classes as $class) {
|
||||
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
||||
$support_lib_list[$class::NAME] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
// if no libs specified, compile all supported libs
|
||||
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
||||
$libraries = array_keys($support_lib_list);
|
||||
$sorted_libraries = DependencyUtil::getLibs($libraries);
|
||||
}
|
||||
|
||||
// pkg-config must be compiled first, whether it is specified or not
|
||||
if (!in_array('pkg-config', $sorted_libraries)) {
|
||||
array_unshift($sorted_libraries, 'pkg-config');
|
||||
}
|
||||
|
||||
// add lib object for builder
|
||||
foreach ($sorted_libraries as $library) {
|
||||
// if some libs are not supported (but in config "lib.json", throw exception)
|
||||
if (!isset($support_lib_list[$library])) {
|
||||
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||
}
|
||||
$lib = new ($support_lib_list[$library])($this);
|
||||
$this->addLib($lib);
|
||||
}
|
||||
|
||||
// calculate and check dependencies
|
||||
foreach ($this->libs as $lib) {
|
||||
$lib->calcDependency();
|
||||
}
|
||||
|
||||
// patch point
|
||||
$this->emitPatchPoint('before-libs-extract');
|
||||
|
||||
// extract sources
|
||||
SourceManager::initSource(libs: $sorted_libraries);
|
||||
|
||||
$this->emitPatchPoint('after-libs-extract');
|
||||
|
||||
// build all libs
|
||||
foreach ($this->libs as $lib) {
|
||||
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
||||
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
||||
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
||||
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
||||
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanity check after build complete
|
||||
*
|
||||
@@ -103,7 +166,7 @@ trait UnixBuilderTrait
|
||||
|
||||
foreach ($this->exts as $ext) {
|
||||
logger()->debug('testing ext: ' . $ext->getName());
|
||||
$ext->runCliCheck();
|
||||
$ext->runCliCheckUnix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,12 +178,17 @@ trait UnixBuilderTrait
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/hello.exe',
|
||||
file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') .
|
||||
'<?php echo "hello";'
|
||||
($this->getOption('without-micro-ext-test') ? '<?php echo "[micro-test-start][micro-test-end]";' : $this->generateMicroExtTests())
|
||||
);
|
||||
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
||||
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
||||
if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') {
|
||||
throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']');
|
||||
$raw_out = trim(implode('', $output2));
|
||||
$condition[0] = $ret === 0;
|
||||
$condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]');
|
||||
foreach ($condition as $k => $v) {
|
||||
if (!$v) {
|
||||
throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,15 @@ trait brotli
|
||||
{
|
||||
FileSystem::resetDir($this->source_dir . '/build-dir');
|
||||
shell()->cd($this->source_dir . '/build-dir')
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
||||
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
||||
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||
|
||||
@@ -9,8 +9,9 @@ trait bzip2
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->execWithEnv("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ trait curl
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// compile!
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
||||
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..")
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
// patch pkgconf
|
||||
$this->patchPkgconfPrefix(['libcurl.pc']);
|
||||
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
|
||||
|
||||
@@ -26,15 +26,16 @@ trait freetype
|
||||
$suggested .= ' ';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->exec('sh autogen.sh')
|
||||
->exec(
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
|
||||
$suggested
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['freetype2.pc']);
|
||||
FileSystem::replaceFileStr(
|
||||
BUILD_ROOT_PATH . '/lib/pkgconfig/freetype2.pc',
|
||||
|
||||
29
src/SPC/builder/unix/library/gettext.php
Normal file
29
src/SPC/builder/unix/library/gettext.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
trait gettext
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
$extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : '';
|
||||
$extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : '';
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--disable-java ' .
|
||||
'--disable-c+ ' .
|
||||
$extra .
|
||||
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--prefix=' . BUILD_ROOT_PATH
|
||||
)
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install');
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,14 @@ trait gmp
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['gmp.pc']);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ trait imagemagick
|
||||
protected function build(): void
|
||||
{
|
||||
// TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future
|
||||
$extra = '--without-jxl --without-x --disable-openmp --without-bzlib ';
|
||||
$extra = '--without-jxl --without-x --enable-openmp --without-bzlib ';
|
||||
$required_libs = '';
|
||||
$optional_libs = [
|
||||
'libzip' => 'zip',
|
||||
@@ -39,15 +39,18 @@ trait imagemagick
|
||||
}
|
||||
}
|
||||
|
||||
$ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : '';
|
||||
$ldflags = $this instanceof LinuxLibraryBase ? ('-static') : '';
|
||||
|
||||
// libxml iconv patch
|
||||
$required_libs .= $this instanceof MacOSLibraryBase ? (' -liconv') : '';
|
||||
$required_libs .= $this instanceof MacOSLibraryBase ? ('-liconv') : '';
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
'PKG_CONFIG="$PKG_CONFIG --static" ' .
|
||||
$ldflags .
|
||||
"LIBS='{$required_libs}' " .
|
||||
->setEnv([
|
||||
'CFLAGS' => $this->getLibExtraCFlags(),
|
||||
'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags,
|
||||
'LIBS' => $this->getLibExtraLibs() ?: $required_libs,
|
||||
'PKG_CONFIG' => '$PKG_CONFIG --static',
|
||||
])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
$extra .
|
||||
|
||||
@@ -25,9 +25,15 @@ trait ldap
|
||||
$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');
|
||||
$ldflags = '-L' . BUILD_LIB_PATH;
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
$this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) .
|
||||
->setEnv([
|
||||
'CFLAGS' => $this->getLibExtraCFlags(),
|
||||
'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags,
|
||||
'LIBS' => $this->getLibExtraLibs(),
|
||||
])
|
||||
->execWithEnv(
|
||||
$this->builder->makeAutoconfFlags(AUTOCONF_CPPFLAGS) .
|
||||
' ./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
|
||||
@@ -11,9 +11,10 @@ trait libargon2
|
||||
protected function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->exec("make PREFIX='' clean")
|
||||
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||
->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''")
|
||||
->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||
|
||||
$this->patchPkgconfPrefix(['libargon2.pc']);
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ trait libavif
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// Start build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..")
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libavif.pc']);
|
||||
$this->cleanLaFiles();
|
||||
|
||||
@@ -14,8 +14,9 @@ trait libcares
|
||||
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}")
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv('./configure --prefix=' . BUILD_ROOT_PATH . ' --enable-static --disable-shared --disable-tests')
|
||||
->execWithEnv("make -j {$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ trait libevent
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// Start build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'cmake ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
@@ -33,7 +34,7 @@ trait libevent
|
||||
'-DEVENT__DISABLE_SAMPLES=ON ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
}
|
||||
}
|
||||
|
||||
35
src/SPC/builder/unix/library/librabbitmq.php
Normal file
35
src/SPC/builder/unix/library/librabbitmq.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait librabbitmq
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
// CMake needs a clean build directory
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// Start build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
}
|
||||
}
|
||||
30
src/SPC/builder/unix/library/libtiff.php
Normal file
30
src/SPC/builder/unix/library/libtiff.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
trait libtiff
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--disable-cxx ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
||||
}
|
||||
}
|
||||
46
src/SPC/builder/unix/library/libuuid.php
Normal file
46
src/SPC/builder/unix/library/libuuid.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait libuuid
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}");
|
||||
copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a');
|
||||
FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid');
|
||||
copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h');
|
||||
$pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in');
|
||||
$pc = str_replace([
|
||||
'@prefix@',
|
||||
'@exec_prefix@',
|
||||
'@libdir@',
|
||||
'@includedir@',
|
||||
'@LIBUUID_VERSION@',
|
||||
], [
|
||||
BUILD_ROOT_PATH,
|
||||
'${prefix}',
|
||||
'${prefix}/lib',
|
||||
'${prefix}/include',
|
||||
'1.0.3',
|
||||
], $pc);
|
||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/uuid.pc', $pc);
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,13 @@ trait ncurses
|
||||
'--with-curses-h ' .
|
||||
'--enable-pc-files ' .
|
||||
'--enable-echo ' .
|
||||
// '--enable-widec ' .
|
||||
'--disable-widec ' .
|
||||
'--with-normal ' .
|
||||
'--with-ticlib ' .
|
||||
'--without-tests ' .
|
||||
'--without-dlsym ' .
|
||||
'--without-debug ' .
|
||||
'-enable-symlinks' .
|
||||
'-enable-symlinks ' .
|
||||
'--bindir=' . BUILD_ROOT_PATH . '/bin ' .
|
||||
'--includedir=' . BUILD_ROOT_PATH . '/include ' .
|
||||
'--libdir=' . BUILD_ROOT_PATH . '/lib ' .
|
||||
|
||||
@@ -8,19 +8,18 @@ trait pkgconfig
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
$macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' ";
|
||||
$linux_env = 'LDFLAGS=--static ';
|
||||
$cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : '';
|
||||
$ldflags = PHP_OS_FAMILY !== 'Linux' ? '' : '--static';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
match (PHP_OS_FAMILY) {
|
||||
'Darwin' => $macos_env,
|
||||
default => $linux_env,
|
||||
} .
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--disable-shared ' .
|
||||
'--enable-static ' .
|
||||
'--with-internal-glib ' .
|
||||
'--disable-host-tool ' .
|
||||
'--with-pic ' .
|
||||
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--without-sysroot ' .
|
||||
'--without-system-include-path ' .
|
||||
@@ -28,7 +27,8 @@ trait pkgconfig
|
||||
'--without-pc-path'
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install-exec');
|
||||
shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,26 +27,31 @@ trait postgresql
|
||||
'libxslt' => 'libxslt',
|
||||
'icu' => 'icu-i18n',
|
||||
];
|
||||
$error_exec_cnt = 0;
|
||||
|
||||
foreach ($optional_packages as $lib => $pkg) {
|
||||
if ($this->getBuilder()->getLib($lib)) {
|
||||
$packages .= ' ' . $pkg;
|
||||
$output = shell()->execWithResult("pkg-config --static {$pkg}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
logger()->info(var_export($output[1], true));
|
||||
}
|
||||
}
|
||||
|
||||
$output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
if (!empty($output[1][0])) {
|
||||
$cppflags = $output[1][0];
|
||||
$envs .= " CPPFLAGS=\"{$cppflags}\"";
|
||||
}
|
||||
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
if (!empty($output[1][0])) {
|
||||
$ldflags = $output[1][0];
|
||||
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
||||
}
|
||||
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
if (!empty($output[1][0])) {
|
||||
$libs = $output[1][0];
|
||||
$libcpp = '';
|
||||
@@ -55,14 +60,23 @@ trait postgresql
|
||||
}
|
||||
$envs .= " LIBS=\"{$libs}{$libcpp}\" ";
|
||||
}
|
||||
if ($error_exec_cnt > 0) {
|
||||
throw new RuntimeException('Failed to get pkg-config information!');
|
||||
}
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
|
||||
# 有静态链接配置 参考文件: 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 "278 s/^/# /" ../src/Makefile.shlib')
|
||||
->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib');
|
||||
$version = $this->getVersion();
|
||||
// 16.1 workaround
|
||||
if (version_compare($version, '16.1') >= 0) {
|
||||
# 有静态链接配置 参考文件: 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 "278 s/^/# /" ../src/Makefile.shlib')
|
||||
->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib');
|
||||
} else {
|
||||
throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !');
|
||||
}
|
||||
|
||||
// configure
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
@@ -101,4 +115,17 @@ trait postgresql
|
||||
->exec("rm -rf {$builddir}/lib/*.so")
|
||||
->exec("rm -rf {$builddir}/lib/*.dylib");
|
||||
}
|
||||
|
||||
private function getVersion(): string
|
||||
{
|
||||
try {
|
||||
$file = FileSystem::readFile($this->source_dir . '/meson.build');
|
||||
if (preg_match("/^\\s+version:\\s?'(.*)'/m", $file, $match)) {
|
||||
return $match[1];
|
||||
}
|
||||
return 'unknown';
|
||||
} catch (FileSystemException) {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
src/SPC/builder/unix/library/qdbm.php
Normal file
33
src/SPC/builder/unix/library/qdbm.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait qdbm
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean');
|
||||
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/MYLIBS = libqdbm.a.*/m', 'MYLIBS = libqdbm.a');
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make -j{$this->builder->concurrency}" . ($this instanceof MacOSLibraryBase ? ' mac' : ''))
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['qdbm.pc']);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ trait xz
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->getOption('gnu-arch')}-unknown-linux " .
|
||||
'--disable-scripts ' .
|
||||
'--disable-doc ' .
|
||||
'--with-libiconv ' .
|
||||
|
||||
@@ -4,17 +4,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class SystemUtil
|
||||
{
|
||||
/**
|
||||
* @param string $name 命令名称
|
||||
* @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH)
|
||||
* @return null|string 找到了返回命令路径,找不到返回 null
|
||||
* Find windows program using executable name.
|
||||
*
|
||||
* @param string $name command name (xxx.exe)
|
||||
* @param array $paths search path (default use env path)
|
||||
* @return null|string null if not found, string is absolute path
|
||||
*/
|
||||
public static function findCommand(string $name, array $paths = []): ?string
|
||||
public static function findCommand(string $name, array $paths = [], bool $include_sdk_bin = false): ?string
|
||||
{
|
||||
if (!$paths) {
|
||||
$paths = explode(PATH_SEPARATOR, getenv('Path'));
|
||||
if ($include_sdk_bin) {
|
||||
$paths[] = PHP_SDK_PATH . '\bin';
|
||||
}
|
||||
}
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $name)) {
|
||||
@@ -23,4 +31,74 @@ class SystemUtil
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Visual Studio installation.
|
||||
*
|
||||
* @return array<string, string>|false False if not installed, array contains 'version' and 'dir'
|
||||
*/
|
||||
public static function findVisualStudio(): array|false
|
||||
{
|
||||
$check_path = [
|
||||
'C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe' => 'vs17',
|
||||
'C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe' => 'vs17',
|
||||
'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe' => 'vs17',
|
||||
'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe' => 'vs16',
|
||||
'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' => 'vs16',
|
||||
'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe' => 'vs16',
|
||||
];
|
||||
foreach ($check_path as $path => $vs_version) {
|
||||
if (file_exists($path)) {
|
||||
$vs_ver = $vs_version;
|
||||
$d_dir = dirname($path, 4);
|
||||
return [
|
||||
'version' => $vs_ver,
|
||||
'dir' => $d_dir,
|
||||
];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CPU count for concurrency.
|
||||
*/
|
||||
public static function getCpuCount(): int
|
||||
{
|
||||
$result = f_exec('echo %NUMBER_OF_PROCESSORS%', $out, $code);
|
||||
if ($code !== 0 || !$result) {
|
||||
return 1;
|
||||
}
|
||||
return intval($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CMake toolchain file.
|
||||
*
|
||||
* @param null|string $cflags CFLAGS for cmake, default use '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP='
|
||||
* @param null|string $ldflags LDFLAGS for cmake, default use '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt'
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function makeCmakeToolchainFile(?string $cflags = null, ?string $ldflags = null): string
|
||||
{
|
||||
if ($cflags === null) {
|
||||
$cflags = '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP=';
|
||||
}
|
||||
if ($ldflags === null) {
|
||||
$ldflags = '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt';
|
||||
}
|
||||
$buildroot = str_replace('\\', '\\\\', BUILD_ROOT_PATH);
|
||||
$toolchain = <<<CMAKE
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
SET(CMAKE_C_FLAGS "{$cflags}")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "{$cflags}")
|
||||
SET(CMAKE_CXX_FLAGS "{$cflags}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "{$cflags}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "{$ldflags}")
|
||||
SET(CMAKE_FIND_ROOT_PATH "{$buildroot}")
|
||||
SET(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
|
||||
CMAKE;
|
||||
FileSystem::writeFile(SOURCE_PATH . '\toolchain.cmake', $toolchain);
|
||||
return realpath(SOURCE_PATH . '\toolchain.cmake');
|
||||
}
|
||||
}
|
||||
|
||||
381
src/SPC/builder/windows/WindowsBuilder.php
Normal file
381
src/SPC/builder/windows/WindowsBuilder.php
Normal file
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourceManager;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\DependencyUtil;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
|
||||
class WindowsBuilder extends BuilderBase
|
||||
{
|
||||
/** @var string cmake toolchain file */
|
||||
public string $cmake_toolchain_file;
|
||||
|
||||
public string $sdk_prefix;
|
||||
|
||||
private bool $zts;
|
||||
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
GlobalEnvManager::init($this);
|
||||
|
||||
// ---------- set necessary options ----------
|
||||
// set sdk (require visual studio 16 or 17)
|
||||
$vs = SystemUtil::findVisualStudio()['version'];
|
||||
$this->sdk_prefix = PHP_SDK_PATH . "\\phpsdk-{$vs}-x64.bat -t";
|
||||
|
||||
// set zts
|
||||
$this->zts = $this->getOption('enable-zts', false);
|
||||
|
||||
// set concurrency
|
||||
$this->concurrency = intval(getenv('SPC_CONCURRENCY'));
|
||||
|
||||
// make cmake toolchain
|
||||
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile();
|
||||
|
||||
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
|
||||
f_mkdir(BUILD_LIB_PATH, recursive: true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
// ---------- Update extra-libs ----------
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
|
||||
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
|
||||
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
|
||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||
|
||||
SourcePatcher::patchBeforeBuildconf($this);
|
||||
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} buildconf.bat");
|
||||
|
||||
SourcePatcher::patchBeforeConfigure($this);
|
||||
|
||||
$zts = $this->zts ? '--enable-zts=yes ' : '--enable-zts=no ';
|
||||
|
||||
// with-upx-pack for phpmicro
|
||||
$makefile = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.w32');
|
||||
if ($this->getOption('with-upx-pack', false)) {
|
||||
if (!file_exists($makefile . '.originfile')) {
|
||||
copy($makefile, $makefile . '.originfile');
|
||||
FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', '_MICRO_UPX = ' . getenv('UPX_EXEC') . " --best $(MICRO_SFX)\n$(MICRO_SFX):");
|
||||
FileSystem::replaceFileStr($makefile, '@$(_MICRO_MT)', "@$(_MICRO_MT)\n\t@$(_MICRO_UPX)");
|
||||
}
|
||||
} elseif (file_exists($makefile . '.originfile')) {
|
||||
copy($makefile . '.originfile', $makefile);
|
||||
unlink($makefile . '.originfile');
|
||||
}
|
||||
|
||||
if (($logo = $this->getOption('with-micro-logo')) !== null) {
|
||||
// realpath
|
||||
$logo = realpath($logo);
|
||||
$micro_logo = '--enable-micro-logo=' . $logo . ' ';
|
||||
} else {
|
||||
$micro_logo = '';
|
||||
}
|
||||
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')
|
||||
->exec(
|
||||
"{$this->sdk_prefix} configure.bat --task-args \"" .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--with-php-build=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' .
|
||||
'--with-extra-libs=' . BUILD_LIB_PATH . ' ' .
|
||||
($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') .
|
||||
($enableMicro ? ('--enable-micro=yes ' . $micro_logo) : '--enable-micro=no ') .
|
||||
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
|
||||
"{$this->makeExtensionArgs()} " .
|
||||
$zts .
|
||||
'"'
|
||||
);
|
||||
|
||||
SourcePatcher::patchBeforeMake($this);
|
||||
|
||||
$this->cleanMake();
|
||||
|
||||
if ($enableCli) {
|
||||
logger()->info('building cli');
|
||||
$this->buildCli();
|
||||
}
|
||||
if ($enableFpm) {
|
||||
logger()->warning('Windows does not support fpm SAPI, I will skip it.');
|
||||
}
|
||||
if ($enableMicro) {
|
||||
logger()->info('building micro');
|
||||
$this->buildMicro();
|
||||
}
|
||||
if ($enableEmbed) {
|
||||
logger()->warning('Windows does not currently support embed SAPI.');
|
||||
// logger()->info('building embed');
|
||||
$this->buildEmbed();
|
||||
}
|
||||
|
||||
$this->sanityCheck($build_target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function buildCli(): void
|
||||
{
|
||||
SourcePatcher::patchWindowsCLITarget();
|
||||
|
||||
// add nmake wrapper
|
||||
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" EXTRA_LD_FLAGS_PROGRAM= %*");
|
||||
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_cli_wrapper.bat --task-args php.exe");
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_CLI);
|
||||
}
|
||||
|
||||
public function buildEmbed(): void
|
||||
{
|
||||
// TODO: add embed support for windows
|
||||
/*
|
||||
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_embed_wrapper.bat', 'nmake /nologo %*');
|
||||
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')
|
||||
->exec("{$this->sdk_prefix} nmake_embed_wrapper.bat --task-args php8embed.lib");
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function buildMicro(): void
|
||||
{
|
||||
// workaround for fiber (originally from https://github.com/dixyes/lwmbs/blob/master/windows/MicroBuild.php)
|
||||
$makefile = FileSystem::readFile(SOURCE_PATH . '\php-src\Makefile');
|
||||
if ($this->getPHPVersionID() >= 80200 && str_contains($makefile, 'FIBER_ASM_ARCH')) {
|
||||
$makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ARCH)_ms_pe_masm.obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ARCH)_ms_pe_masm.obj' . "\r\n\r\n";
|
||||
} elseif ($this->getPHPVersionID() >= 80400 && str_contains($makefile, 'FIBER_ASM_ABI')) {
|
||||
$makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ABI).obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ABI).obj' . "\r\n\r\n";
|
||||
}
|
||||
FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile);
|
||||
|
||||
// add nmake wrapper
|
||||
$fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' /DPHP_MICRO_FAKE_CLI" ' : '';
|
||||
$wrapper = "nmake /nologo LIBS_MICRO=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*";
|
||||
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_micro_wrapper.bat', $wrapper);
|
||||
|
||||
// phar patch for micro
|
||||
if ($this->getExt('phar')) {
|
||||
$this->phar_patched = true;
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
try {
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro");
|
||||
} finally {
|
||||
if ($this->phar_patched) {
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||
}
|
||||
|
||||
public function buildLibs(array $sorted_libraries): void
|
||||
{
|
||||
// search all supported libs
|
||||
$support_lib_list = [];
|
||||
$classes = FileSystem::getClassesPsr4(
|
||||
ROOT_DIR . '\src\SPC\builder\\' . osfamily2dir() . '\\library',
|
||||
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
||||
);
|
||||
foreach ($classes as $class) {
|
||||
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
||||
$support_lib_list[$class::NAME] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
// if no libs specified, compile all supported libs
|
||||
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
||||
$libraries = array_keys($support_lib_list);
|
||||
$sorted_libraries = DependencyUtil::getLibs($libraries);
|
||||
}
|
||||
|
||||
// add lib object for builder
|
||||
foreach ($sorted_libraries as $library) {
|
||||
// if some libs are not supported (but in config "lib.json", throw exception)
|
||||
if (!isset($support_lib_list[$library])) {
|
||||
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||
}
|
||||
$lib = new ($support_lib_list[$library])($this);
|
||||
$this->addLib($lib);
|
||||
}
|
||||
|
||||
// calculate and check dependencies
|
||||
foreach ($this->libs as $lib) {
|
||||
$lib->calcDependency();
|
||||
}
|
||||
|
||||
// extract sources
|
||||
SourceManager::initSource(libs: $sorted_libraries);
|
||||
|
||||
// build all libs
|
||||
foreach ($this->libs as $lib) {
|
||||
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
||||
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
||||
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
||||
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
||||
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function cleanMake(): void
|
||||
{
|
||||
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_clean_wrapper.bat', 'nmake /nologo %*');
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_clean_wrapper.bat --task-args \"clean\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run extension and PHP cli and micro check
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function sanityCheck(mixed $build_target): void
|
||||
{
|
||||
// sanity check for php-cli
|
||||
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
||||
logger()->info('running cli sanity check');
|
||||
[$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -r "echo \"hello\";"');
|
||||
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
||||
throw new RuntimeException('cli failed sanity check');
|
||||
}
|
||||
|
||||
foreach ($this->exts as $ext) {
|
||||
logger()->debug('testing ext: ' . $ext->getName());
|
||||
$ext->runCliCheckWindows();
|
||||
}
|
||||
}
|
||||
|
||||
// sanity check for phpmicro
|
||||
if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
|
||||
if (file_exists(SOURCE_PATH . '\hello.exe')) {
|
||||
@unlink(SOURCE_PATH . '\hello.exe');
|
||||
}
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '\hello.exe',
|
||||
file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') .
|
||||
($this->getOption('without-micro-ext-test') ? '<?php echo "[micro-test-start][micro-test-end]";' : $this->generateMicroExtTests())
|
||||
);
|
||||
chmod(SOURCE_PATH . '\hello.exe', 0755);
|
||||
[$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe');
|
||||
$raw_out = trim(implode('', $output2));
|
||||
$condition[0] = $ret === 0;
|
||||
$condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]');
|
||||
foreach ($condition as $k => $v) {
|
||||
if (!$v) {
|
||||
throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编译好的二进制文件发布到 buildroot
|
||||
*
|
||||
* @param int $type 发布类型
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function deployBinary(int $type): bool
|
||||
{
|
||||
$ts = $this->zts ? '_TS' : '';
|
||||
$src = match ($type) {
|
||||
BUILD_TARGET_CLI => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\php.exe",
|
||||
BUILD_TARGET_MICRO => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\micro.sfx",
|
||||
default => throw new RuntimeException('Deployment does not accept type ' . $type),
|
||||
};
|
||||
|
||||
// with-upx-pack for cli
|
||||
if ($this->getOption('with-upx-pack', false) && $type === BUILD_TARGET_CLI) {
|
||||
cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($src));
|
||||
}
|
||||
|
||||
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
||||
FileSystem::createDir(BUILD_ROOT_PATH . '\bin');
|
||||
|
||||
cmd()->exec('copy ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '\bin\\'));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function getAllStaticLibFiles(): array
|
||||
{
|
||||
$libs = [];
|
||||
|
||||
// reorder libs
|
||||
foreach ($this->libs as $lib) {
|
||||
foreach ($lib->getDependencies() as $dep) {
|
||||
$libs[] = $dep;
|
||||
}
|
||||
$libs[] = $lib;
|
||||
}
|
||||
|
||||
$libFiles = [];
|
||||
$libNames = [];
|
||||
// merge libs
|
||||
foreach ($libs as $lib) {
|
||||
if (!in_array($lib::NAME, $libNames, true)) {
|
||||
$libNames[] = $lib::NAME;
|
||||
array_unshift($libFiles, ...$lib->getStaticLibs());
|
||||
}
|
||||
}
|
||||
return $libFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate command wrapper prefix for php-sdk internal commands.
|
||||
*
|
||||
* @param string $internal_cmd command in php-sdk-tools\bin
|
||||
* @return string Example: C:\php-sdk-tools\phpsdk-vs17-x64.bat -t source\cmake_wrapper.bat --task-args
|
||||
*/
|
||||
public function makeSimpleWrapper(string $internal_cmd): string
|
||||
{
|
||||
$wrapper_bat = SOURCE_PATH . '\\' . crc32($internal_cmd) . '_wrapper.bat';
|
||||
if (!file_exists($wrapper_bat)) {
|
||||
file_put_contents($wrapper_bat, $internal_cmd . ' %*');
|
||||
}
|
||||
return "{$this->sdk_prefix} {$wrapper_bat} --task-args";
|
||||
}
|
||||
}
|
||||
72
src/SPC/builder/windows/library/WindowsLibraryBase.php
Normal file
72
src/SPC/builder/windows/library/WindowsLibraryBase.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\LibraryBase;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
abstract class WindowsLibraryBase extends LibraryBase
|
||||
{
|
||||
public function __construct(protected WindowsBuilder $builder)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getBuilder(): BuilderBase
|
||||
{
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string
|
||||
{
|
||||
$libs = [$this];
|
||||
if ($recursive) {
|
||||
array_unshift($libs, ...array_values($this->getDependencies(recursive: true)));
|
||||
}
|
||||
|
||||
$sep = match ($style) {
|
||||
'autoconf' => ' ',
|
||||
'cmake' => ';',
|
||||
default => throw new RuntimeException('style only support autoconf and cmake'),
|
||||
};
|
||||
$ret = [];
|
||||
foreach ($libs as $lib) {
|
||||
$libFiles = [];
|
||||
foreach ($lib->getStaticLibs() as $name) {
|
||||
$name = str_replace(' ', '\ ', FileSystem::convertPath(BUILD_LIB_PATH . "/{$name}"));
|
||||
$name = str_replace('"', '\"', $name);
|
||||
$libFiles[] = $name;
|
||||
}
|
||||
array_unshift($ret, implode($sep, $libFiles));
|
||||
}
|
||||
return implode($sep, $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a nmake wrapper file.
|
||||
*
|
||||
* @param string $content nmake wrapper content
|
||||
* @param string $default_filename default nmake wrapper filename
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function makeNmakeWrapper(string $content, string $default_filename = ''): string
|
||||
{
|
||||
if ($default_filename === '') {
|
||||
$default_filename = $this->source_dir . '\nmake_wrapper.bat';
|
||||
}
|
||||
FileSystem::writeFile($default_filename, $content);
|
||||
return 'nmake_wrapper.bat';
|
||||
}
|
||||
}
|
||||
24
src/SPC/builder/windows/library/curl.php
Normal file
24
src/SPC/builder/windows/library/curl.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class curl extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'curl';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
cmd()->cd($this->source_dir . '\winbuild')
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('nmake'),
|
||||
'/f Makefile.vc WITH_DEVEL=' . BUILD_ROOT_PATH . ' ' .
|
||||
'WITH_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'mode=static RTLIBCFG=static WITH_SSL=static WITH_NGHTTP2=static WITH_SSH2=static ENABLE_IPV6=yes WITH_ZLIB=static MACHINE=x64 DEBUG=no'
|
||||
);
|
||||
FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl');
|
||||
}
|
||||
}
|
||||
46
src/SPC/builder/windows/library/libffi_win.php
Normal file
46
src/SPC/builder/windows/library/libffi_win.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\builder\windows\SystemUtil;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libffi_win extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libffi-win';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$vs_ver_dir = match (SystemUtil::findVisualStudio()['version']) {
|
||||
'vs17' => '/win32/vs17_x64',
|
||||
'vs16' => '/win32/vs16_x64',
|
||||
default => throw new RuntimeException('Current VS version is not supported yet!'),
|
||||
};
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir . $vs_ver_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('msbuild'),
|
||||
'libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64'
|
||||
);
|
||||
FileSystem::createDir(BUILD_LIB_PATH);
|
||||
FileSystem::createDir(BUILD_INCLUDE_PATH);
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.lib', BUILD_LIB_PATH . '\libffi.lib');
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.pdb', BUILD_LIB_PATH . '\libffi.pdb');
|
||||
copy($this->source_dir . '\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h');
|
||||
|
||||
FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '#define LIBFFI_H', "#define LIBFFI_H\n#define FFI_BUILDING");
|
||||
copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h');
|
||||
copy($this->source_dir . '\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h');
|
||||
|
||||
// copy($this->source_dir . '\msvc_build\out\static-Release\X64\libffi.lib', BUILD_LIB_PATH . '\libffi.lib');
|
||||
// copy($this->source_dir . '\msvc_build\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h');
|
||||
// copy($this->source_dir . '\msvc_build\include\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h');
|
||||
// copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h');
|
||||
|
||||
// FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '..\..\src\x86\ffitarget.h', 'ffitarget.h');
|
||||
}
|
||||
}
|
||||
35
src/SPC/builder/windows/library/libiconv_win.php
Normal file
35
src/SPC/builder/windows/library/libiconv_win.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\builder\windows\SystemUtil;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libiconv_win extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libiconv-win';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$vs_ver_dir = match (SystemUtil::findVisualStudio()['version']) {
|
||||
'vs17' => '/MSVC17',
|
||||
'vs16' => '/MSVC16',
|
||||
default => throw new RuntimeException('Current VS version is not supported yet!'),
|
||||
};
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir . $vs_ver_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('msbuild'),
|
||||
'libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64'
|
||||
);
|
||||
FileSystem::createDir(BUILD_LIB_PATH);
|
||||
FileSystem::createDir(BUILD_INCLUDE_PATH);
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv.lib', BUILD_LIB_PATH . '\libiconv.lib');
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv_a.lib', BUILD_LIB_PATH . '\libiconv_a.lib');
|
||||
copy($this->source_dir . '\source\include\iconv.h', BUILD_INCLUDE_PATH . '\iconv.h');
|
||||
}
|
||||
}
|
||||
36
src/SPC/builder/windows/library/librabbitmq.php
Normal file
36
src/SPC/builder/windows/library/librabbitmq.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class librabbitmq extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'librabbitmq';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\build');
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
'-B build ' .
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build build --config Release --target install -j{$this->builder->concurrency}"
|
||||
);
|
||||
rename(BUILD_LIB_PATH . '\librabbitmq.4.lib', BUILD_LIB_PATH . '\rabbitmq.4.lib');
|
||||
}
|
||||
}
|
||||
38
src/SPC/builder/windows/library/libssh2.php
Normal file
38
src/SPC/builder/windows/library/libssh2.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libssh2 extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libssh2';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\build');
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
'-B build ' .
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
"-DENABLE_ZLIB_COMPRESSION={$zlib} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build build --config Release --target install -j{$this->builder->concurrency}"
|
||||
);
|
||||
}
|
||||
}
|
||||
44
src/SPC/builder/windows/library/libxml2.php
Normal file
44
src/SPC/builder/windows/library/libxml2.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libxml2 extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libxml2';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\build');
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
'-B build ' .
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
"-DLIBXML2_WITH_ZLIB={$zlib} " .
|
||||
'-DLIBXML2_WITH_PYTHON=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
'-DIconv_LIBRARY=' . BUILD_LIB_PATH . ' ' .
|
||||
'-DIconv_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ' .
|
||||
'-DLIBXML2_WITH_LZMA=OFF ' . // xz not supported yet
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
|
||||
'-DLIBXML2_WITH_TESTS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build build --config Release --target install -j{$this->builder->concurrency}"
|
||||
);
|
||||
copy(BUILD_LIB_PATH . '\libxml2s.lib', BUILD_LIB_PATH . '\libxml2_a.lib');
|
||||
}
|
||||
}
|
||||
39
src/SPC/builder/windows/library/nghttp2.php
Normal file
39
src/SPC/builder/windows/library/nghttp2.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class nghttp2 extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'nghttp2';
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\build');
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
'-B build ' .
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DENABLE_SHARED_LIB=OFF ' .
|
||||
'-DENABLE_STATIC_LIB=ON ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DENABLE_STATIC_CRT=ON ' .
|
||||
'-DENABLE_LIB_ONLY=ON ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build build --config Release --target install -j{$this->builder->concurrency}"
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user