mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
63 Commits
2.0.0-beta
...
2.0-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9b47c392e | ||
|
|
4a9b171bb4 | ||
|
|
1b6d0e35ea | ||
|
|
6d638f3721 | ||
|
|
125556b73b | ||
|
|
db3728bc00 | ||
|
|
f002c8021c | ||
|
|
e47bd8ae3c | ||
|
|
0b3aefaefe | ||
|
|
f281d5eeb7 | ||
|
|
89ad11ebb6 | ||
|
|
2e50ee37a9 | ||
|
|
a4204347c1 | ||
|
|
afe81c4306 | ||
|
|
f0e431dd63 | ||
|
|
09f1574264 | ||
|
|
b7f64e46c2 | ||
|
|
a329445701 | ||
|
|
7527f9f099 | ||
|
|
9daa10e939 | ||
|
|
a59e338438 | ||
|
|
a714482cfb | ||
|
|
0138ab3934 | ||
|
|
a294671cf1 | ||
|
|
a8825c1f22 | ||
|
|
9abf696725 | ||
|
|
a1f34a7df9 | ||
|
|
c83e8eb787 | ||
|
|
4ec9f9b6cd | ||
|
|
0a1f200c69 | ||
|
|
67e9cba399 | ||
|
|
8065b30ba0 | ||
|
|
6af1ba6284 | ||
|
|
a0d817803e | ||
|
|
669c7b188b | ||
|
|
1c2343f740 | ||
|
|
280284e4c2 | ||
|
|
85ac553ded | ||
|
|
5bda711500 | ||
|
|
399835e7d1 | ||
|
|
75bb66776c | ||
|
|
7f952804d0 | ||
|
|
289645caa0 | ||
|
|
b280c0abd8 | ||
|
|
2d597ed690 | ||
|
|
b3296842b7 | ||
|
|
d73cefc280 | ||
|
|
6f4aebfc4c | ||
|
|
cac3ffc7d7 | ||
|
|
893fa5bfd6 | ||
|
|
40102a661d | ||
|
|
d7305c434e | ||
|
|
0bed76da11 | ||
|
|
117cd93e8f | ||
|
|
0bd62b0d5f | ||
|
|
8df4ade754 | ||
|
|
ea055afd3c | ||
|
|
9e92b1844a | ||
|
|
297b3a61a0 | ||
|
|
4b7b2291aa | ||
|
|
65d66c6073 | ||
|
|
7df46be6eb | ||
|
|
5ce9229e7d |
106
.github/workflows/build-linux-arm.yml
vendored
Normal file
106
.github/workflows/build-linux-arm.yml
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
name: CI on arm linux
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
operating-system:
|
||||
required: true
|
||||
description: Compile target arch (Linux only)
|
||||
type: choice
|
||||
options:
|
||||
- aarch64
|
||||
version:
|
||||
required: true
|
||||
description: php version to compile
|
||||
default: '8.2'
|
||||
type: choice
|
||||
options:
|
||||
- '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 ${{ inputs.operating-system }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies
|
||||
|
||||
# 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: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
|
||||
|
||||
# Run build command
|
||||
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
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
|
||||
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
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
buildroot/build-extensions.json
|
||||
buildroot/build-libraries.json
|
||||
@@ -1,15 +1,8 @@
|
||||
name: CI
|
||||
name: CI on x86_64 linux
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
operating-system:
|
||||
required: true
|
||||
description: Compile target OS
|
||||
type: choice
|
||||
options:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
version:
|
||||
required: true
|
||||
description: php version to compile
|
||||
@@ -42,20 +35,13 @@ env:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build ${{ inputs.version }} on ${{ inputs.operating-system }}
|
||||
runs-on: ${{ inputs.operating-system }}
|
||||
name: build ${{ inputs.version }} on Linux x86_64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Install macOS missing packages and mark os suffix
|
||||
- if: ${{ inputs.operating-system == 'macos-latest' }}
|
||||
run: |
|
||||
brew install automake gzip
|
||||
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
|
||||
|
||||
# Install Ubuntu missing packages and mark os suffix
|
||||
- if: ${{ inputs.operating-system == 'ubuntu-latest' }}
|
||||
run: |
|
||||
- run: |
|
||||
sudo apt install musl-tools -y
|
||||
echo "SPC_BUILD_OS=linux" >> $GITHUB_ENV
|
||||
|
||||
@@ -90,7 +76,8 @@ jobs:
|
||||
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
|
||||
|
||||
# If there's no dependencies cache, fetch sources, with or without debug
|
||||
- run: CACHE_API_EXEC=yes ./bin/spc fetch --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
|
||||
- if: steps.cache-download.outputs.cache-hit != 'true'
|
||||
run: CACHE_API_EXEC=yes ./bin/spc download --with-php=${{ inputs.version }} --all ${{ 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 }}
|
||||
@@ -127,3 +114,9 @@ jobs:
|
||||
path: |
|
||||
buildroot/build-extensions.json
|
||||
buildroot/build-libraries.json
|
||||
|
||||
# Upload downloaded files
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: download-files
|
||||
path: downloads/
|
||||
122
.github/workflows/build-macos-x86_64.yml
vendored
Normal file
122
.github/workflows/build-macos-x86_64.yml
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
name: CI on x86_64 macOS
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: php version to compile
|
||||
default: '8.2'
|
||||
type: choice
|
||||
options:
|
||||
- '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 x86_64
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Install macOS missing packages and mark os suffix
|
||||
- run: |
|
||||
brew install automake gzip
|
||||
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
|
||||
|
||||
# Cache composer dependencies
|
||||
- id: cache-composer-deps
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: vendor
|
||||
key: composer-dependencies
|
||||
|
||||
# If there's no Composer cache, install dependencies
|
||||
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
|
||||
run: composer update --no-dev
|
||||
|
||||
# Cache downloaded source
|
||||
- id: cache-download
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: downloads
|
||||
key: php-${{ inputs.version }}-dependencies
|
||||
|
||||
# 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 }} --all ${{ env.SPC_BUILD_DEBUG }}
|
||||
|
||||
# Run build command
|
||||
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
|
||||
|
||||
# Upload cli executable
|
||||
- if: ${{ inputs.build-cli == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php
|
||||
|
||||
# Upload micro self-extracted executable
|
||||
- if: ${{ inputs.build-micro == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/micro.sfx
|
||||
|
||||
# Upload fpm executable
|
||||
- if: ${{ inputs.build-fpm == true }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
|
||||
path: buildroot/bin/php-fpm
|
||||
|
||||
# Upload extensions metadata
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: license-files
|
||||
path: buildroot/license/
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-meta
|
||||
path: |
|
||||
buildroot/build-extensions.json
|
||||
buildroot/build-libraries.json
|
||||
|
||||
# Upload downloaded files
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: download-files
|
||||
path: downloads/
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,3 +24,4 @@ composer.lock
|
||||
/bin/*
|
||||
!/bin/spc
|
||||
!/bin/setup-runtime
|
||||
!/bin/spc-alpine-docker
|
||||
|
||||
35
README-en.md
35
README-en.md
@@ -2,16 +2,23 @@
|
||||
|
||||
Compile A Statically Linked PHP With Swoole and other Extensions.
|
||||
|
||||
Compile a purely static PHP binary file with various extensions to make PHP-cli applications more portable!
|
||||
Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI)
|
||||
|
||||
You can also use the micro binary file to package PHP source code and binary files into one for distribution!
|
||||
This function is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
|
||||
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
|
||||
|
||||
You can also use the micro binary file to combine php binary and php source code into one for distribution!
|
||||
This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). (micro SAPI)
|
||||
|
||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||
|
||||
> This branch is new version, if you are looking for old bash version of static-php-cli, see [bash-version](https://github.com/crazywhalecc/static-php-cli/tree/bash-version).
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
|
||||
[]()
|
||||
[]()
|
||||
|
||||
## Compilation Requirements
|
||||
@@ -22,13 +29,13 @@ But static-php-cli runtime only requires an environment above PHP 8.0 and `token
|
||||
Here is the architecture support status, where `CI` represents support for GitHub Action builds,
|
||||
`Local` represents support for local builds, and blank represents not currently supported.
|
||||
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|-----------|---------|
|
||||
| macOS | CI, Local | Local |
|
||||
| Linux | CI, Local | Local |
|
||||
| Windows | | |
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|-----------|-----------|
|
||||
| macOS | CI, Local | Local |
|
||||
| Linux | CI, Local | CI, Local |
|
||||
| Windows | | |
|
||||
|
||||
> linux-aarch64 and macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine.
|
||||
> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine.
|
||||
|
||||
Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`.
|
||||
|
||||
@@ -36,6 +43,12 @@ Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`
|
||||
|
||||
Please first select the extension you want to compile based on the extension list below.
|
||||
|
||||
### Direct Download
|
||||
|
||||
If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.zhamao.xin/static-php-cli/)
|
||||
|
||||
> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
||||
|
||||
### Supported Extensions
|
||||
|
||||
[Supported Extension List](/ext-support.md)
|
||||
|
||||
32
README.md
32
README.md
@@ -4,15 +4,21 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
|
||||
|
||||
If you are using English, see [English README](README-en.md).
|
||||
|
||||
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!
|
||||
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI)
|
||||
|
||||
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(由 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 提供支持)
|
||||
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
|
||||
|
||||
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(由 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 提供支持)(micro SAPI)
|
||||
|
||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||
|
||||
> 此分支为重构的新版,如果你在找纯 Bash 编写的旧版本,请到 [bash-version 分支](https://github.com/crazywhalecc/static-php-cli/tree/bash-version)。
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[]()
|
||||
[]()
|
||||
|
||||
## 编译环境需求
|
||||
@@ -22,13 +28,13 @@ If you are using English, see [English README](README-en.md).
|
||||
|
||||
下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。
|
||||
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|-----------|---------|
|
||||
| macOS | CI, Local | Local |
|
||||
| Linux | CI, Local | Local |
|
||||
| Windows | | |
|
||||
| | x86_64 | aarch64 |
|
||||
|---------|-----------|-----------|
|
||||
| macOS | CI, Local | Local |
|
||||
| Linux | CI, Local | CI, Local |
|
||||
| Windows | | |
|
||||
|
||||
> linux-aarch64 and macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。
|
||||
> macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。
|
||||
|
||||
目前支持编译的 PHP 版本为:`7.4`,`8.0`,`8.1`,`8.2`。
|
||||
|
||||
@@ -36,6 +42,12 @@ If you are using English, see [English README](README-en.md).
|
||||
|
||||
请先根据下方扩展列表选择你要编译的扩展。
|
||||
|
||||
### 自托管直接下载
|
||||
|
||||
如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.zhamao.xin/static-php-cli/)
|
||||
|
||||
> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
||||
|
||||
### 支持的扩展情况
|
||||
|
||||
[扩展支持列表](/ext-support.md)
|
||||
|
||||
@@ -8,8 +8,8 @@ __OS__=$(uname -s)
|
||||
__ARCH__=$(uname -m)
|
||||
# format arch name
|
||||
case $__ARCH__ in
|
||||
arm64 | aarch64) __ARCH__=arm64 ;;
|
||||
x86_64|x64) __ARCH__=x64 ;;
|
||||
arm64 | aarch64) __ARCH__=aarch64 ;;
|
||||
x86_64|x64) __ARCH__=x86_64 ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
@@ -25,14 +25,37 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
|
||||
__PROJECT__=$(cd ${__DIR__}/../ && pwd)
|
||||
|
||||
# set download dir
|
||||
__PHP_RUNTIME_URL__="https://github.com/swoole/swoole-src/releases/download/v4.8.13/swoole-cli-v4.8.13-${__OS_FIXED__}-${__ARCH__}.tar.xz"
|
||||
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.5-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||
|
||||
# download static-php binary (currently using swoole-cli temporarily)
|
||||
# use china mirror
|
||||
# bash bin/setup-runtime --mirror china
|
||||
mirror=''
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--mirror)
|
||||
mirror="$2"
|
||||
shift
|
||||
;;
|
||||
--*)
|
||||
echo "Illegal option $1"
|
||||
;;
|
||||
esac
|
||||
shift $(($# > 0 ? 1 : 0))
|
||||
done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.5-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
test -d ${__PROJECT__}/downloads || mkdir ${__PROJECT__}/downloads
|
||||
# download static php binary
|
||||
test -f ${__PROJECT__}/downloads/runtime.tar.xz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o ${__PROJECT__}/downloads/runtime.tar.xz "$__PHP_RUNTIME_URL__" ; }
|
||||
test -f ${__DIR__}/php || { tar -xf ${__PROJECT__}/downloads/runtime.tar.xz -C ${__DIR__}/ && mv ${__DIR__}/swoole-cli ${__DIR__}/php && rm ${__DIR__}/LICENSE ; } # (TODO: temporarily use swoole-cli as php)
|
||||
test -f ${__PROJECT__}/downloads/runtime.tar.gz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o ${__PROJECT__}/downloads/runtime.tar.gz "$__PHP_RUNTIME_URL__" ; }
|
||||
test -f ${__DIR__}/php || { tar -xf ${__PROJECT__}/downloads/runtime.tar.gz -C ${__DIR__}/ ; }
|
||||
chmod +x ${__DIR__}/php
|
||||
# download composer
|
||||
test -f ${__DIR__}/composer || curl -#fSL -o ${__DIR__}/composer "$__COMPOSER_URL__"
|
||||
|
||||
82
bin/spc-alpine-docker
Executable file
82
bin/spc-alpine-docker
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# This file is using docker to run commands
|
||||
|
||||
self_dir=$(cd "$(dirname "$0")";pwd)
|
||||
|
||||
# Detect docker can run
|
||||
if ! which docker >/dev/null; then
|
||||
echo "Docker is not installed, please install docker first !"
|
||||
exit 1
|
||||
fi
|
||||
DOCKER_EXECUTABLE="docker"
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
if [ "$SPC_USE_SUDO" != "yes" ]; then
|
||||
echo "Docker command requires sudo"
|
||||
echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again'
|
||||
exit 1
|
||||
fi
|
||||
DOCKER_EXECUTABLE="sudo docker"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# to check if qemu-docker run
|
||||
if [ "$SPC_USE_ARCH" = "" ]; then
|
||||
SPC_USE_ARCH=x86_64
|
||||
fi
|
||||
case $SPC_USE_ARCH in
|
||||
x86_64)
|
||||
ALPINE_FROM=alpine:edge
|
||||
;;
|
||||
aarch64)
|
||||
ALPINE_FROM=multiarch/alpine:aarch64-edge
|
||||
echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m"
|
||||
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
|
||||
;;
|
||||
*)
|
||||
echo "Current arch is not supported to run in docker: $SPC_USE_ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$SPC_USE_MIRROR" = "yes" ]; then
|
||||
SPC_USE_MIRROR="RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories"
|
||||
else
|
||||
SPC_USE_MIRROR="RUN echo 'Using original repo'"
|
||||
fi
|
||||
|
||||
# Detect docker env is setup
|
||||
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH; then
|
||||
echo "Docker container does not exist. Building docker image ..."
|
||||
ALPINE_DOCKERFILE=$(cat << EOF
|
||||
FROM $ALPINE_FROM
|
||||
$SPC_USE_MIRROR
|
||||
RUN apk update
|
||||
RUN apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils bison flex pkgconfig automake curl
|
||||
RUN apk add build-base xz php81 php81-common php81-pcntl php81-tokenizer php81-phar php81-posix php81-xml composer
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
ADD ./src /app/src
|
||||
ADD ./composer.json /app/composer.json
|
||||
ADD ./bin /app/bin
|
||||
RUN composer update --no-dev
|
||||
EOF
|
||||
)
|
||||
echo "$ALPINE_DOCKERFILE" > $(pwd)/Dockerfile
|
||||
|
||||
$DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH .
|
||||
rm $(pwd)/Dockerfile
|
||||
fi
|
||||
|
||||
# Check if in ci (local terminal can execute with -it)
|
||||
if [ -t 0 ]; then
|
||||
INTERACT=-it
|
||||
else
|
||||
INTERACT=''
|
||||
fi
|
||||
|
||||
# Run docker
|
||||
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT=$(pwd) -v $(pwd)/config:/app/config -v $(pwd)/src:/app/src -v $(pwd)/buildroot:/app/buildroot -v $(pwd)/source:/app/source -v $(pwd)/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@
|
||||
@@ -15,7 +15,8 @@
|
||||
"symfony/console": "^6 || ^5 || ^4",
|
||||
"zhamao/logger": "^1.0",
|
||||
"crazywhalecc/cli-helper": "^0.1.0",
|
||||
"nunomaduro/collision": "*"
|
||||
"nunomaduro/collision": "*",
|
||||
"ext-pcntl": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"apcu": {
|
||||
"type": "external",
|
||||
"source": "apcu"
|
||||
},
|
||||
"bcmath": {
|
||||
"type": "builtin"
|
||||
},
|
||||
@@ -17,7 +21,7 @@
|
||||
},
|
||||
"curl": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"curl"
|
||||
]
|
||||
@@ -35,6 +39,20 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"event": {
|
||||
"type": "external",
|
||||
"source": "ext-event",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"libevent"
|
||||
],
|
||||
"ext-depends": [
|
||||
"openssl"
|
||||
],
|
||||
"ext-suggests": [
|
||||
"sockets"
|
||||
]
|
||||
},
|
||||
"exif": {
|
||||
"type": "builtin"
|
||||
},
|
||||
@@ -69,25 +87,10 @@
|
||||
"zlib"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"gd",
|
||||
"libavif",
|
||||
"libwebp",
|
||||
"libjpeg",
|
||||
"xpm",
|
||||
"freetype"
|
||||
],
|
||||
"lib-depends-windows": [
|
||||
"libiconv",
|
||||
"freetype",
|
||||
"libjpeg",
|
||||
"zlib",
|
||||
"libpng",
|
||||
"xpm"
|
||||
],
|
||||
"lib-suggests-windows": [
|
||||
"gd",
|
||||
"libavif",
|
||||
"libwebp"
|
||||
]
|
||||
},
|
||||
"gettext": {
|
||||
@@ -111,6 +114,14 @@
|
||||
"libiconv"
|
||||
]
|
||||
},
|
||||
"imagick": {
|
||||
"type": "external",
|
||||
"source": "ext-imagick",
|
||||
"arg-type": "custom",
|
||||
"lib-depends": [
|
||||
"imagemagick"
|
||||
]
|
||||
},
|
||||
"imap": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
@@ -121,6 +132,10 @@
|
||||
"kerberos"
|
||||
]
|
||||
},
|
||||
"inotify": {
|
||||
"type": "external",
|
||||
"source": "inotify"
|
||||
},
|
||||
"intl": {
|
||||
"type": "builtin",
|
||||
"lib-depends": [
|
||||
@@ -149,7 +164,8 @@
|
||||
},
|
||||
"mongodb": {
|
||||
"type": "external",
|
||||
"source": "mongodb"
|
||||
"source": "mongodb",
|
||||
"arg-type": "custom"
|
||||
},
|
||||
"mysqli": {
|
||||
"type": "builtin",
|
||||
@@ -167,7 +183,7 @@
|
||||
},
|
||||
"openssl": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
]
|
||||
@@ -231,13 +247,9 @@
|
||||
},
|
||||
"readline": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"readline"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"libedit",
|
||||
"ncurses"
|
||||
]
|
||||
},
|
||||
"redis": {
|
||||
@@ -280,16 +292,24 @@
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"lib-depends": [
|
||||
"sodium"
|
||||
"libsodium"
|
||||
]
|
||||
},
|
||||
"sqlite3": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"sqlite"
|
||||
]
|
||||
},
|
||||
"ssh2": {
|
||||
"type": "external",
|
||||
"source": "ext-ssh2",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"libssh2"
|
||||
]
|
||||
},
|
||||
"swoole": {
|
||||
"type": "external",
|
||||
"source": "swoole",
|
||||
@@ -305,10 +325,6 @@
|
||||
],
|
||||
"unix-only": true
|
||||
},
|
||||
"inotify": {
|
||||
"type": "external",
|
||||
"source": "inotify"
|
||||
},
|
||||
"swow": {
|
||||
"type": "external",
|
||||
"source": "swow",
|
||||
@@ -383,7 +399,7 @@
|
||||
},
|
||||
"zip": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "with-prefix",
|
||||
"arg-type-windows": "enable",
|
||||
"lib-depends": [
|
||||
"libzip"
|
||||
|
||||
116
config/lib.json
116
config/lib.json
@@ -66,12 +66,6 @@
|
||||
"SystemConfiguration"
|
||||
]
|
||||
},
|
||||
"postgresql": {
|
||||
"source": "postgresql",
|
||||
"static-libs-unix": [
|
||||
"libpg.a"
|
||||
]
|
||||
},
|
||||
"freetype": {
|
||||
"source": "freetype",
|
||||
"static-libs-unix": [
|
||||
@@ -80,6 +74,14 @@
|
||||
"headers-unix": [
|
||||
"freetype2/freetype/freetype.h",
|
||||
"freetype2/ft2build.h"
|
||||
],
|
||||
"lib-depends": [
|
||||
"zlib"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"libpng",
|
||||
"bzip2",
|
||||
"brotli"
|
||||
]
|
||||
},
|
||||
"gmp": {
|
||||
@@ -94,6 +96,46 @@
|
||||
"gmp.h"
|
||||
]
|
||||
},
|
||||
"imagemagick": {
|
||||
"source": "imagemagick",
|
||||
"static-libs-unix": [
|
||||
"libMagick++-7.Q16HDRI.a",
|
||||
"libMagickCore-7.Q16HDRI.a",
|
||||
"libMagickWand-7.Q16HDRI.a"
|
||||
],
|
||||
"lib-depends": [
|
||||
"zlib",
|
||||
"libpng",
|
||||
"libjpeg",
|
||||
"bzip2",
|
||||
"libwebp",
|
||||
"freetype"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd",
|
||||
"xz",
|
||||
"libzip",
|
||||
"libxml2"
|
||||
]
|
||||
},
|
||||
"libavif": {
|
||||
"source": "libavif",
|
||||
"static-libs-unix": [
|
||||
"libavif.a"
|
||||
]
|
||||
},
|
||||
"libevent": {
|
||||
"source": "libevent",
|
||||
"static-libs-unix": [
|
||||
"libevent.a",
|
||||
"libevent_core.a",
|
||||
"libevent_extra.a",
|
||||
"libevent_openssl.a"
|
||||
],
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"libffi": {
|
||||
"source": "libffi",
|
||||
"static-libs-unix": [
|
||||
@@ -115,7 +157,8 @@
|
||||
"libiconv": {
|
||||
"source": "libiconv",
|
||||
"static-libs-unix": [
|
||||
"libiconv.a"
|
||||
"libiconv.a",
|
||||
"libcharset.a"
|
||||
],
|
||||
"headers": [
|
||||
"iconv.h",
|
||||
@@ -123,6 +166,13 @@
|
||||
"localcharset.h"
|
||||
]
|
||||
},
|
||||
"libjpeg": {
|
||||
"source": "libjpeg",
|
||||
"static-libs-unix": [
|
||||
"libjpeg.a",
|
||||
"libturbojpeg.a"
|
||||
]
|
||||
},
|
||||
"libmcrypt": {
|
||||
"source": "libmcrypt",
|
||||
"static-libs-unix": [
|
||||
@@ -170,6 +220,16 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"libwebp": {
|
||||
"source": "libwebp",
|
||||
"static-libs-unix": [
|
||||
"libwebp.a",
|
||||
"libwebpdecoder.a",
|
||||
"libwebpdemux.a",
|
||||
"libwebpmux.a",
|
||||
"libsharpyuv.a"
|
||||
]
|
||||
},
|
||||
"libxml2": {
|
||||
"source": "libxml2",
|
||||
"static-libs-unix": [
|
||||
@@ -241,6 +301,12 @@
|
||||
"libmcrypt.a"
|
||||
]
|
||||
},
|
||||
"ncurses": {
|
||||
"source": "ncurses",
|
||||
"static-libs-unix": [
|
||||
"libncurses.a"
|
||||
]
|
||||
},
|
||||
"nghttp2": {
|
||||
"source": "nghttp2",
|
||||
"static-libs-unix": [
|
||||
@@ -257,17 +323,7 @@
|
||||
"openssl"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"libxml2",
|
||||
"libev",
|
||||
"libcares",
|
||||
"libngtcp2",
|
||||
"libnghttp3",
|
||||
"libbpf",
|
||||
"libevent-openssl",
|
||||
"jansson",
|
||||
"jemalloc",
|
||||
"systemd",
|
||||
"cunit"
|
||||
"libxml2"
|
||||
]
|
||||
},
|
||||
"onig": {
|
||||
@@ -303,6 +359,15 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"pkg-config": {
|
||||
"source": "pkg-config"
|
||||
},
|
||||
"postgresql": {
|
||||
"source": "postgresql",
|
||||
"static-libs-unix": [
|
||||
"libpg.a"
|
||||
]
|
||||
},
|
||||
"pthreads4w": {
|
||||
"source": "pthreads4w",
|
||||
"static-libs-windows": [
|
||||
@@ -315,6 +380,15 @@
|
||||
"semaphore.h"
|
||||
]
|
||||
},
|
||||
"readline": {
|
||||
"source": "readline",
|
||||
"static-libs-unix": [
|
||||
"libreadline.a"
|
||||
],
|
||||
"lib-depends": [
|
||||
"ncurses"
|
||||
]
|
||||
},
|
||||
"sqlite": {
|
||||
"source": "sqlite",
|
||||
"static-libs-unix": [
|
||||
@@ -380,5 +454,11 @@
|
||||
"zstd.h",
|
||||
"zstd_errors.h"
|
||||
]
|
||||
},
|
||||
"libsodium": {
|
||||
"source": "libsodium",
|
||||
"static-libs-unix": [
|
||||
"libsodium.a"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,21 @@
|
||||
{
|
||||
"php-src": {
|
||||
"type": "custom",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"apcu": {
|
||||
"type": "url",
|
||||
"url": "http://pecl.php.net/get/APCu",
|
||||
"path": "php-src/ext/apcu",
|
||||
"filename": "apcu.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"brotli": {
|
||||
"type": "ghtar",
|
||||
"repo": "google/brotli",
|
||||
@@ -25,6 +42,35 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"ext-event": {
|
||||
"type": "url",
|
||||
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
|
||||
"path": "php-src/ext/event",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-imagick": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/imagick",
|
||||
"path": "php-src/ext/imagick",
|
||||
"filename": "imagick.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-ssh2": {
|
||||
"type": "url",
|
||||
"url": "http://pecl.php.net/get/ssh2",
|
||||
"path": "php-src/ext/ssh2",
|
||||
"filename": "ssh2.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-zstd": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/zstd",
|
||||
@@ -44,13 +90,6 @@
|
||||
"path": "LICENSE.TXT"
|
||||
}
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "custom",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYRIGHT"
|
||||
}
|
||||
},
|
||||
"gmp": {
|
||||
"type": "filelist",
|
||||
"url": "https://gmplib.org/download/gmp/",
|
||||
@@ -60,6 +99,41 @@
|
||||
"text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs."
|
||||
}
|
||||
},
|
||||
"imagemagick": {
|
||||
"type": "ghtar",
|
||||
"repo": "ImageMagick/ImageMagick",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"inotify": {
|
||||
"type": "url",
|
||||
"url": "http://pecl.php.net/get/inotify",
|
||||
"path": "php-src/ext/inotify",
|
||||
"filename": "inotify.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libavif": {
|
||||
"type": "ghtar",
|
||||
"repo": "AOMediaCodec/libavif",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libevent": {
|
||||
"type": "ghrel",
|
||||
"repo": "libevent/libevent",
|
||||
"match": "libevent.+\\.tar\\.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libffi": {
|
||||
"type": "ghrel",
|
||||
"repo": "libffi/libffi",
|
||||
@@ -78,6 +152,14 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libjpeg": {
|
||||
"type": "ghtar",
|
||||
"repo": "libjpeg-turbo/libjpeg-turbo",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE.md"
|
||||
}
|
||||
},
|
||||
"libmcrypt": {
|
||||
"type": "url",
|
||||
"url": "https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
|
||||
@@ -113,12 +195,12 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libuv": {
|
||||
"type": "ghtar",
|
||||
"repo": "libuv/libuv",
|
||||
"libwebp": {
|
||||
"type": "ghtagtar",
|
||||
"repo": "webmproject/libwebp",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"libxml2": {
|
||||
@@ -159,7 +241,7 @@
|
||||
"type": "git",
|
||||
"path": "php-src/sapi/micro",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/dixyes/phpmicro",
|
||||
"url": "https://github.com/crazywhalecc/phpmicro",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
@@ -175,6 +257,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ncurses": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/pub/gnu/ncurses/",
|
||||
"regex": "/href=\"(?<file>ncurses-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"nghttp2": {
|
||||
"type": "ghrel",
|
||||
"repo": "nghttp2/nghttp2",
|
||||
@@ -202,6 +293,22 @@
|
||||
"path": "LICENSE.txt"
|
||||
}
|
||||
},
|
||||
"pkg-config": {
|
||||
"type": "filelist",
|
||||
"url": "https://pkgconfig.freedesktop.org/releases/",
|
||||
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "custom",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYRIGHT"
|
||||
}
|
||||
},
|
||||
"protobuf": {
|
||||
"type": "url",
|
||||
"url": "http://pecl.php.net/get/protobuf",
|
||||
@@ -212,16 +319,6 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"inotify": {
|
||||
"type": "url",
|
||||
"url": "http://pecl.php.net/get/inotify",
|
||||
"path": "php-src/ext/inotify",
|
||||
"filename": "inotify.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"pthreads4w": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
@@ -231,11 +328,13 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"php-src": {
|
||||
"type": "custom",
|
||||
"readline": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/pub/gnu/readline/",
|
||||
"regex": "/href=\"(?<file>readline-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"redis": {
|
||||
@@ -312,5 +411,13 @@
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libsodium": {
|
||||
"type": "url",
|
||||
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
}
|
||||
}
|
||||
138
ext-support.md
138
ext-support.md
@@ -6,57 +6,63 @@
|
||||
> - no with issue link: not supported yet due to issue
|
||||
> - partial with issue link: supported but not perfect due to issue
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
|------------|--------------------------------------------------------------------|---------------------------------------------------------------------|---------|
|
||||
| bcmath | yes | yes | |
|
||||
| bz2 | yes | yes | |
|
||||
| calendar | yes | yes | |
|
||||
| ctype | yes | yes | |
|
||||
| curl | yes | yes | |
|
||||
| date | yes | yes | |
|
||||
| dba | yes | yes | |
|
||||
| dom | yes | yes | |
|
||||
| enchant | | | |
|
||||
| event | | | |
|
||||
| exif | yes | yes | |
|
||||
| filter | yes | yes | |
|
||||
| fileinfo | yes | | |
|
||||
| ftp | yes | yes | |
|
||||
| gd | yes, untested | yes | |
|
||||
| gettext | | | |
|
||||
| gmp | yes, untested | yes, untested | |
|
||||
| iconv | yes | | |
|
||||
| inotify | yes | yes | |
|
||||
| mbstring | yes | yes | |
|
||||
| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||
| mongodb | yes, untested | | |
|
||||
| mysqli | | | |
|
||||
| mysqlnd | yes | yes | |
|
||||
| openssl | yes | yes | |
|
||||
| pcntl | yes, untested | yes | |
|
||||
| pdo | yes | yes | |
|
||||
| pdo_mysql | yes | yes | |
|
||||
| pdo_sqlite | yes | yes | |
|
||||
| pdo_pgsql | | | |
|
||||
| phar | yes | yes | |
|
||||
| posix | yes | yes | |
|
||||
| protobuf | yes, untested | | |
|
||||
| readline | | | |
|
||||
| redis | yes | yes | |
|
||||
| session | yes | yes | |
|
||||
| shmop | yes, untested | | |
|
||||
| simplexml | yes, untested | yes, untested | |
|
||||
| soap | yes, untested | | |
|
||||
| sockets | yes | yes | |
|
||||
| sqlite3 | yes, untested | yes, untested | |
|
||||
| swow | yes | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||
| swoole | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | [partial](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||
| tokenizer | yes | yes | |
|
||||
| xml | yes | yes | |
|
||||
| xmlreader | yes, untested | yes, untested | |
|
||||
| xmlwriter | yes, untested | yes, untested | |
|
||||
| zip | yes, untested | yes | |
|
||||
| zlib | yes | yes | |
|
||||
| | Linux | macOS | Windows |
|
||||
|------------|---------------------------------------------------------------------|----------------------------------------------------------------|---------|
|
||||
| apcu | yes, untested | yes, untested | |
|
||||
| bcmath | yes | yes | |
|
||||
| bz2 | yes | yes | |
|
||||
| calendar | yes | yes | |
|
||||
| ctype | yes | yes | |
|
||||
| curl | yes | yes | |
|
||||
| dba | yes | yes | |
|
||||
| dom | yes | yes | |
|
||||
| enchant | | | |
|
||||
| event | yes | yes | |
|
||||
| exif | yes | yes | |
|
||||
| ffi | | yes, [docs]() | |
|
||||
| filter | yes | yes | |
|
||||
| fileinfo | yes | yes | |
|
||||
| ftp | yes | yes | |
|
||||
| gd | yes | yes | |
|
||||
| gettext | | | |
|
||||
| gmp | yes | yes | |
|
||||
| iconv | yes | yes | |
|
||||
| imagick | yes | yes | |
|
||||
| inotify | yes | yes | |
|
||||
| mbstring | yes | yes | |
|
||||
| mbregex | yes | yes | |
|
||||
| mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||
| mongodb | yes | yes | |
|
||||
| mysqli | yes | yes | |
|
||||
| mysqlnd | yes | yes | |
|
||||
| openssl | yes | yes | |
|
||||
| pcntl | yes | yes | |
|
||||
| pdo | yes | yes | |
|
||||
| pdo_mysql | yes | yes | |
|
||||
| pdo_sqlite | yes | yes | |
|
||||
| pdo_pgsql | | | |
|
||||
| phar | yes | yes | |
|
||||
| posix | yes | yes | |
|
||||
| protobuf | yes | yes | |
|
||||
| readline | yes, untested | yes, untested | |
|
||||
| redis | yes | yes | |
|
||||
| session | yes | yes | |
|
||||
| shmop | yes | yes | |
|
||||
| simplexml | yes | yes | |
|
||||
| soap | yes | yes | |
|
||||
| sockets | yes | yes | |
|
||||
| sodium | yes | yes | |
|
||||
| sqlite3 | yes | yes | |
|
||||
| ssh2 | yes, untested | yes, untested | |
|
||||
| swow | yes | yes | |
|
||||
| swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | |
|
||||
| tokenizer | yes | yes | |
|
||||
| xml | yes | yes | |
|
||||
| xmlreader | yes, untested | yes, untested | |
|
||||
| xmlwriter | yes, untested | yes, untested | |
|
||||
| zip | yes, untested | yes, untested | |
|
||||
| zlib | yes | yes | |
|
||||
| zstd | yes | yes | |
|
||||
|
||||
## Additional Requirements
|
||||
|
||||
@@ -64,11 +70,39 @@
|
||||
- swoole >= 5.0 requires PHP >= 8.0
|
||||
- swow requires PHP >= 8.0
|
||||
|
||||
## Typical Extension List Example
|
||||
|
||||
Here are some extension list example for different use.
|
||||
|
||||
- For general use: `"bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,ftp,filter,gd,iconv,xml,mbstring,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip"`
|
||||
- For static-php-cli self: `"posix,pcntl,phar,tokenizer,iconv,zlib"`
|
||||
- For static-php-cli self (with dev dependencies): `"posix,pcntl,phar,tokenizer,iconv,zlib,xml,dom,xmlwriter,xmlreader,fileinfo"`
|
||||
- Minimum, with no extension: `""`
|
||||
|
||||
Compile with all supported extensions (exclude `swow`, `swoole` due to c++ extension):
|
||||
|
||||
```bash
|
||||
bin/spc build --build-all bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,mbregex,mbstring,mongodb,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,protobuf,redis,session,shmop,simplexml,soap,sockets,sqlite3,tokenizer,xml,xmlreader,xmlwriter,yaml,zip,zlib,zstd --with-libs=libjpeg,freetype,libwebp,libavif --debug
|
||||
```
|
||||
|
||||
## Additional Libraries
|
||||
|
||||
Some extensions have soft dependencies, you can enable extra features by adding these libs using `--with-libs`.
|
||||
|
||||
For example, to compile with gd extension, with `libwebp, libgif, libavif, libjpeg, freetype` extra features:
|
||||
|
||||
```bash
|
||||
bin/spc build gd --with-libs=libjpeg,freetype,libwebp,libavif --build-cli
|
||||
```
|
||||
|
||||
> If you don't add them, your compilation will not enable these features.
|
||||
|
||||
## Limitations
|
||||
|
||||
- swow and swoole cannot be compiled at the same time.
|
||||
- openssl needs manual configuration for ssl certificate. (TODO: I will write a wiki about it)
|
||||
- some extensions need system configuration, e.g. `curl` and `openssl` will search ssl certificate on your system.
|
||||
|
||||
## Bugs
|
||||
## Bugs and TODOs
|
||||
|
||||
See [#32](https://github.com/crazywhalecc/static-php-cli/issues/32).
|
||||
|
||||
@@ -5,10 +5,34 @@ __DIR__=$(
|
||||
cd "$(dirname "$0")"
|
||||
pwd
|
||||
)
|
||||
cd ${__DIR__}
|
||||
|
||||
|
||||
# use china mirror
|
||||
# bash quickstart/linux/x86_64/alpine-3.16-init.sh --mirror china
|
||||
mirror=''
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--mirror)
|
||||
mirror="$2"
|
||||
shift
|
||||
;;
|
||||
--*)
|
||||
echo "Illegal option $1"
|
||||
;;
|
||||
esac
|
||||
shift $(( $# > 0 ? 1 : 0 ))
|
||||
done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
|
||||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
|
||||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||
|
||||
apk update
|
||||
|
||||
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils
|
||||
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils
|
||||
|
||||
@@ -8,4 +8,4 @@ __DIR__=$(
|
||||
|
||||
cd ${__DIR__}
|
||||
|
||||
docker exec -it static-php-cli-dev-1 bash
|
||||
docker exec -it static-php-cli-dev-1 sh
|
||||
|
||||
@@ -5,14 +5,38 @@ __DIR__=$(
|
||||
cd "$(dirname "$0")"
|
||||
pwd
|
||||
)
|
||||
cd ${__DIR__}
|
||||
|
||||
# use china mirror
|
||||
# bash quickstart/linux/x86_64/debian-11-init.sh --mirror china
|
||||
mirror=''
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--mirror)
|
||||
mirror="$2"
|
||||
shift
|
||||
;;
|
||||
--*)
|
||||
echo "Illegal option $1"
|
||||
;;
|
||||
esac
|
||||
shift $(( $# > 0 ? 1 : 0 ))
|
||||
done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save
|
||||
sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list && \
|
||||
sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list && \
|
||||
sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
|
||||
|
||||
apt update -y
|
||||
apt install -y git curl wget ca-certificates
|
||||
apt install -y xz-utils autoconf automake libclang-13-dev clang lld libtool cmake bison re2c gettext coreutils lzip zip unzip
|
||||
apt install -y pkg-config bzip2 flex
|
||||
apt install -y git curl wget ca-certificates
|
||||
apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext coreutils lzip zip unzip
|
||||
apt install -y pkg-config bzip2 flex
|
||||
apt install -y musl-tools g++
|
||||
apt install -y clang
|
||||
|
||||
|
||||
# apt install build-essential linux-headers-$(uname -r)
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
||||
*/
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.0-beta2';
|
||||
public const VERSION = '2.0-rc1';
|
||||
|
||||
/**
|
||||
* @throws \ReflectionException
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace SPC\builder;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
@@ -37,11 +38,15 @@ abstract class BuilderBase
|
||||
/** @var bool 本次编译是否只编译 libs,不编译 PHP */
|
||||
protected bool $libs_only = false;
|
||||
|
||||
/** @var bool 是否 strip 最终的二进制 */
|
||||
protected bool $strip = true;
|
||||
|
||||
/**
|
||||
* 构建指定列表的 libs
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function buildLibs(array $libraries): void
|
||||
{
|
||||
@@ -61,16 +66,13 @@ abstract class BuilderBase
|
||||
if ($libraries === [] && $this->isLibsOnly()) {
|
||||
$libraries = array_keys($support_lib_list);
|
||||
}
|
||||
if (!in_array('pkg-config', $libraries)) {
|
||||
array_unshift($libraries, 'pkg-config');
|
||||
}
|
||||
|
||||
// 排序 libs,根据依赖计算一个新的列表出来
|
||||
$libraries = DependencyUtil::getLibsByDeps($libraries);
|
||||
|
||||
// 这里筛选 libraries,比如纯静态模式排除掉ffi
|
||||
if (defined('BUILD_ALL_STATIC') && BUILD_ALL_STATIC) {
|
||||
$k = array_search('libffi', $libraries, true);
|
||||
$k !== false && array_splice($libraries, $k, 1);
|
||||
}
|
||||
|
||||
// 过滤不支持的库后添加
|
||||
foreach ($libraries as $library) {
|
||||
if (!isset($support_lib_list[$library])) {
|
||||
@@ -80,13 +82,14 @@ abstract class BuilderBase
|
||||
$this->addLib($lib);
|
||||
}
|
||||
|
||||
// 统计还没 fetch 到本地的库
|
||||
$this->checkLibsSource();
|
||||
|
||||
// 计算依赖,经过这里的遍历,如果没有抛出异常,说明依赖符合要求,可以继续下面的
|
||||
foreach ($this->libs as $lib) {
|
||||
$lib->calcDependency();
|
||||
}
|
||||
|
||||
$this->initSource(libs: $libraries);
|
||||
|
||||
// 构建库
|
||||
foreach ($this->libs as $lib) {
|
||||
match ($lib->tryBuild()) {
|
||||
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
||||
@@ -154,6 +157,11 @@ abstract class BuilderBase
|
||||
public function proveExts(array $extensions): void
|
||||
{
|
||||
CustomExt::loadCustomExt();
|
||||
$this->initSource(sources: ['php-src']);
|
||||
if ($this->getPHPVersionID() >= 80000) {
|
||||
$this->initSource(sources: ['micro']);
|
||||
}
|
||||
$this->initSource(exts: $extensions);
|
||||
foreach ($extensions as $extension) {
|
||||
$class = CustomExt::getExtClass($extension);
|
||||
$ext = new $class($extension, $this);
|
||||
@@ -226,6 +234,11 @@ abstract class BuilderBase
|
||||
return implode(', ', $ls);
|
||||
}
|
||||
|
||||
public function setStrip(bool $strip): void
|
||||
{
|
||||
$this->strip = $strip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否存在 lib 库对应的源码,如果不存在,则抛出异常
|
||||
*
|
||||
@@ -248,4 +261,52 @@ abstract class BuilderBase
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void
|
||||
{
|
||||
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
|
||||
throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?');
|
||||
}
|
||||
$lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true);
|
||||
|
||||
$sources_extracted = [];
|
||||
// source check exist
|
||||
if (is_array($sources)) {
|
||||
foreach ($sources as $source) {
|
||||
$sources_extracted[$source] = true;
|
||||
}
|
||||
}
|
||||
// lib check source exist
|
||||
if (is_array($libs)) {
|
||||
foreach ($libs as $lib) {
|
||||
// get source name for lib
|
||||
$source = Config::getLib($lib, 'source');
|
||||
$sources_extracted[$source] = true;
|
||||
}
|
||||
}
|
||||
// ext check source exist
|
||||
if (is_array($exts)) {
|
||||
foreach ($exts as $ext) {
|
||||
// get source name for ext
|
||||
if (Config::getExt($ext, 'type') !== 'external') {
|
||||
continue;
|
||||
}
|
||||
$source = Config::getExt($ext, 'source');
|
||||
$sources_extracted[$source] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// start check
|
||||
foreach ($sources_extracted as $source => $item) {
|
||||
if (!isset($lock[$source])) {
|
||||
throw new WrongUsageException('Source [' . $source . '] not downloaded, you should download it first !');
|
||||
}
|
||||
|
||||
// check source dir exist
|
||||
$check = $lock[$source]['move_path'] === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $lock[$source]['move_path'];
|
||||
if (!is_dir($check)) {
|
||||
FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ class BuilderProvider
|
||||
cc: $input->getOption('cc'),
|
||||
cxx: $input->getOption('cxx'),
|
||||
arch: $input->getOption('arch'),
|
||||
zts: $input->getOption('enable-zts'),
|
||||
),
|
||||
'Linux' => new LinuxBuilder(
|
||||
cc: $input->getOption('cc'),
|
||||
cxx: $input->getOption('cxx'),
|
||||
arch: $input->getOption('arch'),
|
||||
zts: $input->getOption('enable-zts'),
|
||||
),
|
||||
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder;
|
||||
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\Config;
|
||||
@@ -152,6 +153,11 @@ abstract class LibraryBase
|
||||
return BUILD_STATUS_OK;
|
||||
}
|
||||
}
|
||||
// pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制
|
||||
if ($this instanceof MacOSLibraryBase && static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
|
||||
$this->tryBuild(true);
|
||||
return BUILD_STATUS_OK;
|
||||
}
|
||||
// 到这里说明所有的文件都存在,就跳过编译
|
||||
return BUILD_STATUS_ALREADY;
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('curl')]
|
||||
class curl extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-curl CURL_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'CURL_LIBS="' . $this->getLibFilesString() . '"';
|
||||
}
|
||||
}
|
||||
26
src/SPC/builder/extension/event.php
Normal file
26
src/SPC/builder/extension/event.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('event')]
|
||||
class event extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
$arg = '--with-event-core --with-event-extra --with-event-libevent-dir=' . BUILD_ROOT_PATH;
|
||||
if ($this->builder->getLib('openssl')) {
|
||||
$arg .= ' --with-event-openssl=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
if ($this->builder->getExt('sockets')) {
|
||||
$arg .= ' --enable-event-sockets';
|
||||
} else {
|
||||
$arg .= ' --disable-event-sockets';
|
||||
}
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ class ffi extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-ffi FFI_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'FFI_LIBS="' . $this->getLibFilesString() . '"';
|
||||
return '--with-ffi --enable-zend-signals';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,10 @@ class gd extends Extension
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
$arg = '--enable-gd';
|
||||
if ($this->builder->getLib('freetype')) {
|
||||
$arg .= ' --with-freetype ' .
|
||||
'FREETYPE2_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '/freetype2" ' .
|
||||
'FREETYPE2_LIBS="' . $this->getLibFilesString() . '"';
|
||||
}
|
||||
$arg .= ' PNG_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'PNG_LIBS="' . $this->getLibFilesString() . '"';
|
||||
$arg .= $this->builder->getLib('freetype') ? ' --with-freetype' : '';
|
||||
$arg .= $this->builder->getLib('libjpeg') ? ' --with-jpeg' : '';
|
||||
$arg .= $this->builder->getLib('libwebp') ? ' --with-webp' : '';
|
||||
$arg .= $this->builder->getLib('libavif') ? ' --with-avif' : '';
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
17
src/SPC/builder/extension/imagick.php
Normal file
17
src/SPC/builder/extension/imagick.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
class imagick extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-imagick=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,6 @@ class mbstring extends Extension
|
||||
if ($this->builder->getExt('mbregex') === null) {
|
||||
$arg .= ' --disable-mbregex';
|
||||
}
|
||||
return $arg . ' ONIG_CFLAGS=-I"' . BUILD_ROOT_PATH . '" ONIG_LIBS="' . $this->getLibFilesString() . '"';
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
17
src/SPC/builder/extension/mongodb.php
Normal file
17
src/SPC/builder/extension/mongodb.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('mongodb')]
|
||||
class mongodb extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--enable-mongodb --without-mongodb-sasl';
|
||||
}
|
||||
}
|
||||
17
src/SPC/builder/extension/opcache.php
Normal file
17
src/SPC/builder/extension/opcache.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('opcache')]
|
||||
class opcache extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'Zend Opcache';
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('openssl')]
|
||||
class openssl extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-openssl OPENSSL_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'OPENSSL_LIBS="' . $this->getLibFilesString() . '" ';
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('sqlite3')]
|
||||
class sqlite3 extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-sqlite3="' . BUILD_ROOT_PATH . '" ' .
|
||||
'SQLITE_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'SQLITE_LIBS="' . $this->getLibFilesString() . '"';
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,8 @@ class swoole extends Extension
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
$arg = '--enable-swoole';
|
||||
if ($this->builder->getLib('openssl')) {
|
||||
$arg .= ' --enable-openssl';
|
||||
} else {
|
||||
$arg .= ' --disable-openssl --without-openssl';
|
||||
}
|
||||
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl';
|
||||
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
||||
// curl hook is buggy for static php
|
||||
$arg .= ' --disable-swoole-curl';
|
||||
return $arg;
|
||||
|
||||
@@ -30,9 +30,7 @@ class xml extends Extension
|
||||
'simplexml' => '--enable-simplexml',
|
||||
default => throw new RuntimeException('Not accept non-xml extension'),
|
||||
};
|
||||
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '" ' .
|
||||
'LIBXML_CFLAGS=-I"' . realpath('include/libxml2') . '" ' .
|
||||
'LIBXML_LIBS="' . $this->getLibFilesString() . '" ';
|
||||
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('zip')]
|
||||
class zip extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-zip LIBZIP_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'LIBZIP_LIBS="' . $this->getLibFilesString() . '"';
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('zlib')]
|
||||
class zlib extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-zlib ZLIB_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '" ' .
|
||||
'ZLIB_LIBS="' . $this->getLibFilesString() . '"';
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,6 @@ class zstd extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-libzstd';
|
||||
return '--enable-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use SPC\builder\traits\UnixBuilderTrait;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\Patcher;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
/**
|
||||
* Linux 系统环境下的构建器
|
||||
@@ -43,13 +43,17 @@ class LinuxBuilder extends BuilderBase
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null)
|
||||
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false)
|
||||
{
|
||||
// 初始化一些默认参数
|
||||
$this->cc = $cc ?? 'musl-gcc';
|
||||
$this->cc = $cc ?? match (SystemUtil::getOSRelease()['dist']) {
|
||||
'alpine' => 'gcc',
|
||||
default => 'musl-gcc'
|
||||
};
|
||||
$this->cxx = $cxx ?? 'g++';
|
||||
$this->arch = $arch ?? php_uname('m');
|
||||
$this->gnu_arch = arch2gnu($this->arch);
|
||||
$this->zts = $zts;
|
||||
$this->libc = 'musl'; // SystemUtil::selectLibc($this->cc);
|
||||
|
||||
// 根据 CPU 线程数设置编译进程数
|
||||
@@ -67,7 +71,7 @@ class LinuxBuilder extends BuilderBase
|
||||
cxx: $this->cxx
|
||||
);
|
||||
// 设置 pkgconfig
|
||||
$this->pkgconf_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig"';
|
||||
$this->pkgconf_env = 'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig"';
|
||||
// 设置 configure 依赖的环境变量
|
||||
$this->configure_env =
|
||||
$this->pkgconf_env . ' ' .
|
||||
@@ -135,6 +139,12 @@ class LinuxBuilder extends BuilderBase
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->getExt('swoole')) {
|
||||
$extra_libs .= ' -lstdc++';
|
||||
}
|
||||
if ($this->getExt('imagick')) {
|
||||
$extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a';
|
||||
}
|
||||
|
||||
$envs = $this->pkgconf_env . ' ' .
|
||||
"CC='{$this->cc}' " .
|
||||
@@ -158,11 +168,17 @@ class LinuxBuilder extends BuilderBase
|
||||
|
||||
$envs = "{$envs} CFLAGS='{$cflags}' LIBS='-ldl -lpthread'";
|
||||
|
||||
Patcher::patchPHPBeforeConfigure($this);
|
||||
SourcePatcher::patchPHPBuildconf($this);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||
|
||||
Patcher::patchPHPConfigure($this);
|
||||
SourcePatcher::patchPHPConfigure($this);
|
||||
|
||||
if ($this->getPHPVersionID() < 80000) {
|
||||
$json_74 = '--enable-json ';
|
||||
} else {
|
||||
$json_74 = '';
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec(
|
||||
@@ -171,19 +187,19 @@ class LinuxBuilder extends BuilderBase
|
||||
'--with-valgrind=no ' .
|
||||
'--enable-shared=no ' .
|
||||
'--enable-static=yes ' .
|
||||
"--host={$this->gnu_arch}-unknown-linux " .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--disable-phpdbg ' .
|
||||
'--enable-cli ' .
|
||||
'--enable-fpm ' .
|
||||
$json_74 .
|
||||
'--enable-micro=all-static ' .
|
||||
($this->zts ? '--enable-zts' : '') . ' ' .
|
||||
$this->makeExtensionArgs() . ' ' .
|
||||
$envs
|
||||
);
|
||||
|
||||
$extra_libs .= $this->generateExtraLibs();
|
||||
SourcePatcher::patchPHPAfterConfigure($this);
|
||||
|
||||
file_put_contents('/tmp/comment', $this->note_section);
|
||||
|
||||
@@ -213,7 +229,7 @@ class LinuxBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
if ($this->phar_patched) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 -R < sapi/micro/patches/phar.patch');
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,12 +266,7 @@ class LinuxBuilder extends BuilderBase
|
||||
}
|
||||
if ($this->getExt('phar')) {
|
||||
$this->phar_patched = true;
|
||||
try {
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 < sapi/micro/patches/phar.patch');
|
||||
} catch (RuntimeException $e) {
|
||||
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
||||
$this->phar_patched = false;
|
||||
}
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
@@ -274,7 +285,9 @@ class LinuxBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* 构建 fpm
|
||||
*
|
||||
* @throws FileSystemException|RuntimeException
|
||||
*/
|
||||
public function buildFpm(string $extra_libs, string $use_lld): void
|
||||
{
|
||||
@@ -295,40 +308,4 @@ class LinuxBuilder extends BuilderBase
|
||||
->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php-fpm.debug --remove-section=.note php-fpm");
|
||||
$this->deployBinary(BUILD_TARGET_FPM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function generateExtraLibs(): string
|
||||
{
|
||||
if ($this->libc === 'glibc') {
|
||||
$glibc_libs = [
|
||||
'rt',
|
||||
'm',
|
||||
'c',
|
||||
'pthread',
|
||||
'dl',
|
||||
'nsl',
|
||||
'anl',
|
||||
// 'crypt',
|
||||
'resolv',
|
||||
'util',
|
||||
];
|
||||
$makefile = file_get_contents(SOURCE_PATH . '/php-src/Makefile');
|
||||
preg_match('/^EXTRA_LIBS\s*=\s*(.*)$/m', $makefile, $matches);
|
||||
if (!$matches) {
|
||||
throw new RuntimeException('failed to find EXTRA_LIBS in Makefile');
|
||||
}
|
||||
$_extra_libs = [];
|
||||
foreach (array_filter(explode(' ', $matches[1])) as $used) {
|
||||
foreach ($glibc_libs as $libName) {
|
||||
if ("-l{$libName}" === $used && !in_array("-l{$libName}", $_extra_libs, true)) {
|
||||
array_unshift($_extra_libs, "-l{$libName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ' ' . implode(' ', $_extra_libs);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,44 +13,6 @@ class SystemUtil
|
||||
{
|
||||
use UnixSystemUtilTrait;
|
||||
|
||||
/**
|
||||
* 查找并选择编译器命令
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function selectCC(): string
|
||||
{
|
||||
logger()->debug('Choose cc');
|
||||
if (self::findCommand('clang')) {
|
||||
logger()->info('using clang');
|
||||
return 'clang';
|
||||
}
|
||||
if (self::findCommand('gcc')) {
|
||||
logger()->info('using gcc');
|
||||
return 'gcc';
|
||||
}
|
||||
throw new RuntimeException('no supported cc found');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找并选择编译器命令
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function selectCXX(): string
|
||||
{
|
||||
logger()->debug('Choose cxx');
|
||||
if (self::findCommand('clang++')) {
|
||||
logger()->info('using clang++');
|
||||
return 'clang++';
|
||||
}
|
||||
if (self::findCommand('g++')) {
|
||||
logger()->info('using g++');
|
||||
return 'g++';
|
||||
}
|
||||
return self::selectCC();
|
||||
}
|
||||
|
||||
#[ArrayShape(['dist' => 'mixed|string', 'ver' => 'mixed|string'])]
|
||||
public static function getOSRelease(): array
|
||||
{
|
||||
@@ -187,7 +149,7 @@ class SystemUtil
|
||||
{
|
||||
$paths = getenv('LIBPATH');
|
||||
if (!$paths) {
|
||||
$paths = '/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64';
|
||||
$paths = '/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:';
|
||||
}
|
||||
foreach (explode(':', $paths) as $path) {
|
||||
if (file_exists("{$path}/{$name}")) {
|
||||
|
||||
@@ -61,6 +61,11 @@ abstract class LinuxLibraryBase extends LibraryBase
|
||||
return BUILD_STATUS_OK;
|
||||
}
|
||||
}
|
||||
// pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制
|
||||
if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
|
||||
$this->tryBuild(true);
|
||||
return BUILD_STATUS_OK;
|
||||
}
|
||||
// 到这里说明所有的文件都存在,就跳过编译
|
||||
return BUILD_STATUS_ALREADY;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class brotli extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'brotli';
|
||||
use \SPC\builder\unix\library\brotli;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
// 清理旧的编译文件
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build');
|
||||
// 使用 cmake 编译
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
$this->builder->configure_env . ' cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlicommon-static")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlidec-static")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlienc-static")
|
||||
->exec('cp libbrotlidec-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libbrotlienc-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libbrotlicommon-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp -r ../c/include/brotli ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
public const NAME = 'brotli';
|
||||
}
|
||||
|
||||
@@ -1,43 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class bzip2 extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\bzip2;
|
||||
|
||||
public const NAME = 'bzip2';
|
||||
|
||||
protected array $dep_names = [];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class curl extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\curl;
|
||||
|
||||
public const NAME = 'curl';
|
||||
|
||||
protected array $static_libs = ['libcurl.a'];
|
||||
|
||||
protected array $headers = ['curl'];
|
||||
|
||||
protected array $pkgconfs = [
|
||||
'libcurl.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
supported_protocols="DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS MQTT POP3 POP3S RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP"
|
||||
supported_features="AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets alt-svc brotli libz zstd"
|
||||
|
||||
Name: libcurl
|
||||
URL: https://curl.se/
|
||||
Description: Library to transfer files with ftp, http, etc.
|
||||
Version: 7.83.0
|
||||
Libs: -L${libdir} -lcurl
|
||||
Libs.private: -lnghttp2 -lidn2 -lssh2 -lssh2 -lpsl -lssl -lcrypto -lssl -lcrypto -lgssapi_krb5 -lzstd -lbrotlidec -lz
|
||||
Cflags: -I${includedir}
|
||||
EOF
|
||||
];
|
||||
|
||||
protected array $dep_names = [
|
||||
'zlib' => false,
|
||||
'libssh2' => true,
|
||||
'brotli' => true,
|
||||
'nghttp2' => true,
|
||||
'zstd' => true,
|
||||
'openssl' => true,
|
||||
'idn2' => true,
|
||||
'psl' => true,
|
||||
];
|
||||
|
||||
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string
|
||||
{
|
||||
$libs = parent::getStaticLibFiles($style, $recursive);
|
||||
@@ -67,94 +18,4 @@ EOF
|
||||
}
|
||||
return $libs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:openssl
|
||||
$openssl = $this->builder->getLib('openssl');
|
||||
$use_openssl = $openssl instanceof LinuxLibraryBase ? 'ON' : 'OFF';
|
||||
$extra .= "-DCURL_USE_OPENSSL={$use_openssl} -DCURL_ENABLE_SSL={$use_openssl} ";
|
||||
// lib:zlib
|
||||
$zlib = $this->builder->getLib('zlib');
|
||||
if ($zlib instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZLIB_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
}
|
||||
// lib:libssh2
|
||||
$libssh2 = $this->builder->getLib('libssh2');
|
||||
if ($libssh2 instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DLIBSSH2_LIBRARY="' . $libssh2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBSSH2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_USE_LIBSSH2=OFF ';
|
||||
}
|
||||
// lib:brotli
|
||||
$brotli = $this->builder->getLib('brotli');
|
||||
if ($brotli) {
|
||||
$extra .= '-DCURL_BROTLI=ON ' .
|
||||
'-DBROTLIDEC_LIBRARY="' . realpath(BUILD_LIB_PATH . '/libbrotlidec-static.a') . ';' . realpath(BUILD_LIB_PATH . '/libbrotlicommon-static.a') . '" ' .
|
||||
'-DBROTLICOMMON_LIBRARY="' . realpath(BUILD_LIB_PATH . '/libbrotlicommon-static.a') . '" ' .
|
||||
'-DBROTLI_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_BROTLI=OFF ';
|
||||
}
|
||||
// lib:nghttp2
|
||||
$nghttp2 = $this->builder->getLib('nghttp2');
|
||||
if ($nghttp2 instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DUSE_NGHTTP2=ON ' .
|
||||
'-DNGHTTP2_LIBRARY="' . $nghttp2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DNGHTTP2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DUSE_NGHTTP2=OFF ';
|
||||
}
|
||||
// lib:ldap
|
||||
$ldap = $this->builder->getLib('ldap');
|
||||
if ($ldap instanceof LinuxLibraryBase) {
|
||||
// $extra .= '-DCURL_DISABLE_LDAP=OFF ';
|
||||
// TODO: LDAP support
|
||||
throw new RuntimeException('LDAP support is not implemented yet');
|
||||
}
|
||||
$extra .= '-DCURL_DISABLE_LDAP=ON ';
|
||||
// lib:zstd
|
||||
$zstd = $this->builder->getLib('zstd');
|
||||
if ($zstd instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DCURL_ZSTD=ON ' .
|
||||
'-DZstd_LIBRARY="' . $zstd->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZstd_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_ZSTD=OFF ';
|
||||
}
|
||||
// lib:idn2
|
||||
$idn2 = $this->builder->getLib('idn2');
|
||||
$extra .= $idn2 instanceof LinuxLibraryBase ? '-DUSE_LIBIDN2=ON ' : '-DUSE_LIBIDN2=OFF ';
|
||||
// lib:psl
|
||||
$libpsl = $this->builder->getLib('psl');
|
||||
$extra .= $libpsl instanceof LinuxLibraryBase ? '-DCURL_USE_LIBPSL=ON ' : '-DCURL_USE_LIBPSL=OFF ';
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
// compile!
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec("{$this->builder->configure_env} cmake " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_CURL_EXE=OFF ' .
|
||||
$extra .
|
||||
"-DCMAKE_INSTALL_PREFIX={$destdir} " .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR='{$destdir}'");
|
||||
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
|
||||
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake");
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/freetype.php
Normal file
12
src/SPC/builder/linux/library/freetype.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class freetype extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\freetype;
|
||||
|
||||
public const NAME = 'freetype';
|
||||
}
|
||||
@@ -9,20 +9,7 @@ namespace SPC\builder\linux\library;
|
||||
*/
|
||||
class gmp extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\gmp;
|
||||
|
||||
public const NAME = 'gmp';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/linux/library/imagemagick.php
Normal file
15
src/SPC/builder/linux/library/imagemagick.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* a template library class for unix
|
||||
*/
|
||||
class imagemagick extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\imagemagick;
|
||||
|
||||
public const NAME = 'imagemagick';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/libavif.php
Normal file
12
src/SPC/builder/linux/library/libavif.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libavif extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libavif;
|
||||
|
||||
public const NAME = 'libavif';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/libevent.php
Normal file
12
src/SPC/builder/linux/library/libevent.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libevent extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libevent;
|
||||
|
||||
public const NAME = 'libevent';
|
||||
}
|
||||
@@ -1,49 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libiconv extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libiconv;
|
||||
|
||||
public const NAME = 'libiconv';
|
||||
|
||||
protected array $dep_names = [];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/libjpeg.php
Normal file
12
src/SPC/builder/linux/library/libjpeg.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libjpeg extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libjpeg;
|
||||
|
||||
public const NAME = 'libjpeg';
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\Patcher;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
class libpng extends LinuxLibraryBase
|
||||
{
|
||||
@@ -34,7 +34,6 @@ class libpng extends LinuxLibraryBase
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// 不同架构的专属优化
|
||||
$optimizations = match ($this->builder->arch) {
|
||||
'x86_64' => '--enable-intel-sse ',
|
||||
'arm64' => '--enable-arm-neon ',
|
||||
@@ -42,7 +41,7 @@ class libpng extends LinuxLibraryBase
|
||||
};
|
||||
|
||||
// patch configure
|
||||
Patcher::patchUnixLibpng();
|
||||
SourcePatcher::patchUnixLibpng();
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('chmod +x ./configure')
|
||||
@@ -52,7 +51,7 @@ class libpng extends LinuxLibraryBase
|
||||
'--disable-shared ' .
|
||||
'--enable-static ' .
|
||||
'--enable-hardware-optimizations ' .
|
||||
'--with-zlib-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--with-zlib-prefix="' . BUILD_ROOT_PATH . '" ' .
|
||||
$optimizations .
|
||||
'--prefix='
|
||||
)
|
||||
@@ -61,5 +60,7 @@ class libpng extends LinuxLibraryBase
|
||||
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH)
|
||||
->cd(BUILD_LIB_PATH)
|
||||
->exec('ln -sf libpng16.a libpng.a');
|
||||
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
|
||||
$this->cleanLaFiles();
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/libsodium.php
Normal file
12
src/SPC/builder/linux/library/libsodium.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libsodium extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libsodium;
|
||||
|
||||
public const NAME = 'libsodium';
|
||||
}
|
||||
@@ -1,60 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libssh2 extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libssh2;
|
||||
|
||||
public const NAME = 'libssh2';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// lib:zlib
|
||||
$enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF';
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
"-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target libssh2")
|
||||
->exec('make install DESTDIR="' . $destdir . '"');
|
||||
}
|
||||
}
|
||||
|
||||
28
src/SPC/builder/linux/library/libwebp.php
Normal file
28
src/SPC/builder/linux/library/libwebp.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libwebp extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libwebp;
|
||||
|
||||
public const NAME = 'libwebp';
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -38,14 +22,11 @@ class libxml2 extends LinuxLibraryBase
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
@@ -55,14 +36,10 @@ class libxml2 extends LinuxLibraryBase
|
||||
'-DLIBXML2_WITH_PYTHON=OFF ' .
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
|
||||
'-DLIBXML2_WITH_TESTS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR="' . $destdir . '"');
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
|
||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) {
|
||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) {
|
||||
|
||||
@@ -1,93 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libyaml extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libyaml;
|
||||
|
||||
public const NAME = 'libyaml';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// prepare cmake/config.h.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/cmake/config.h.in')) {
|
||||
f_mkdir(SOURCE_PATH . '/libyaml/cmake');
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/cmake/config.h.in',
|
||||
<<<'EOF'
|
||||
#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@
|
||||
#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@
|
||||
#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@
|
||||
#define YAML_VERSION_STRING "@YAML_VERSION_STRING@"
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
// prepare yamlConfig.cmake.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/yamlConfig.cmake.in')) {
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/yamlConfig.cmake.in',
|
||||
<<<'EOF'
|
||||
# Config file for the yaml library.
|
||||
#
|
||||
# It defines the following variables:
|
||||
# yaml_LIBRARIES - libraries to link against
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake")
|
||||
|
||||
if(NOT yaml_TARGETS_IMPORTED)
|
||||
set(yaml_TARGETS_IMPORTED 1)
|
||||
include(${yaml_TARGETS})
|
||||
endif()
|
||||
|
||||
set(yaml_LIBRARIES yaml)
|
||||
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec("{$this->builder->configure_env} cmake " .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,106 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libzip extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libzip;
|
||||
|
||||
public const NAME = 'libzip';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException|RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:zlib
|
||||
$zlib = $this->builder->getLib('zlib');
|
||||
if ($zlib instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
}
|
||||
// lib:bzip2
|
||||
$libbzip2 = $this->builder->getLib('bzip2');
|
||||
if ($libbzip2 instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_BZIP2=ON ' .
|
||||
'-DBZIP2_LIBRARIES="' . $libbzip2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DBZIP2_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_BZIP2=OFF ';
|
||||
}
|
||||
// lib:xz
|
||||
$xz = $this->builder->getLib('xz');
|
||||
if ($xz instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_LZMA=ON ' .
|
||||
'-DLIBLZMA_LIBRARY="' . $xz->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBLZMA_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_LZMA=OFF ';
|
||||
}
|
||||
// lib:zstd
|
||||
$libzstd = $this->builder->getLib('zstd');
|
||||
if ($libzstd instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_ZSTD=ON ' .
|
||||
'-DZstd_LIBRARY="' . $libzstd->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZstd_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_ZSTD=OFF ';
|
||||
}
|
||||
// lib:openssl
|
||||
$libopenssl = $this->builder->getLib('openssl');
|
||||
if ($libopenssl instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_OPENSSL=ON ' .
|
||||
'-DOpenSSL_LIBRARY="' . $libopenssl->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DOpenSSL_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_OPENSSL=OFF ';
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
$this->builder->configure_env . ' cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DENABLE_GNUTLS=OFF ' .
|
||||
'-DENABLE_MBEDTLS=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_DOC=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_REGRESS=OFF ' .
|
||||
'-DBUILD_TOOLS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/linux/library/ncurses.php
Normal file
15
src/SPC/builder/linux/library/ncurses.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class ncurses extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\ncurses;
|
||||
|
||||
public const NAME = 'ncurses';
|
||||
}
|
||||
@@ -20,50 +20,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class nghttp2 extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'nghttp2';
|
||||
|
||||
protected array $static_libs = ['libnghttp2.a'];
|
||||
|
||||
protected array $headers = ['nghttp2'];
|
||||
|
||||
protected array $pkgconfs = [
|
||||
'libnghttp2.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libnghttp2
|
||||
Description: HTTP/2 C library
|
||||
URL: https://github.com/tatsuhiro-t/nghttp2
|
||||
Version: 1.47.0
|
||||
Libs: -L${libdir} -lnghttp2
|
||||
Cflags: -I${includedir}
|
||||
EOF
|
||||
];
|
||||
|
||||
protected array $dep_names = [
|
||||
'zlib' => false,
|
||||
'openssl' => false,
|
||||
'libxml2' => true,
|
||||
'libev' => true,
|
||||
'libcares' => true,
|
||||
'libngtcp2' => true,
|
||||
'libnghttp3' => true,
|
||||
'libbpf' => true,
|
||||
'libevent-openssl' => true,
|
||||
'jansson' => true,
|
||||
'jemalloc' => true,
|
||||
'systemd' => true,
|
||||
'cunit' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$args = $this->builder->makeAutoconfArgs(static::NAME, [
|
||||
@@ -98,5 +58,6 @@ EOF
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class onig extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\onig;
|
||||
|
||||
public const NAME = 'onig';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->arch}-unknown-linux " .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,5 +73,6 @@ class openssl extends LinuxLibraryBase
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->exec("make install_sw DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/linux/library/pkgconfig.php
Normal file
15
src/SPC/builder/linux/library/pkgconfig.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class pkgconfig extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\pkgconfig;
|
||||
|
||||
public const NAME = 'pkg-config';
|
||||
}
|
||||
15
src/SPC/builder/linux/library/readline.php
Normal file
15
src/SPC/builder/linux/library/readline.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class readline extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\readline;
|
||||
|
||||
public const NAME = 'readline';
|
||||
}
|
||||
@@ -1,47 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class sqlite extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\sqlite;
|
||||
|
||||
public const NAME = 'sqlite';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class xz extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\xz;
|
||||
|
||||
public const NAME = 'xz';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
// ->exec('autoreconf -i --force')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||
'--disable-xz ' .
|
||||
'--disable-xzdec ' .
|
||||
'--disable-lzmadec ' .
|
||||
'--disable-lzmainfo ' .
|
||||
'--disable-scripts ' .
|
||||
'--disable-doc ' .
|
||||
'--with-libiconv ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class zlib extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\zlib;
|
||||
|
||||
public const NAME = 'zlib';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--static ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class zstd extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'zstd';
|
||||
use \SPC\builder\unix\library\zstd;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec(
|
||||
"make -j{$this->builder->concurrency} " .
|
||||
"{$this->builder->configure_env} " .
|
||||
"PREFIX='" . BUILD_ROOT_PATH . "' " .
|
||||
'-C lib libzstd.a CPPFLAGS_STATLIB=-DZSTD_MULTITHREAD'
|
||||
)
|
||||
->exec('cp lib/libzstd.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp lib/zdict.h lib/zstd_errors.h lib/zstd.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
public const NAME = 'zstd';
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use SPC\builder\traits\UnixBuilderTrait;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\Patcher;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
/**
|
||||
* macOS 系统环境下的构建器
|
||||
@@ -31,7 +31,7 @@ class MacOSBuilder extends BuilderBase
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null)
|
||||
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false)
|
||||
{
|
||||
// 如果是 Debug 模式,才使用 set -x 显示每条执行的命令
|
||||
$this->set_x = defined('DEBUG_MODE') ? 'set -x' : 'true';
|
||||
@@ -40,6 +40,7 @@ class MacOSBuilder extends BuilderBase
|
||||
$this->cxx = $cxx ?? 'clang++';
|
||||
$this->arch = $arch ?? php_uname('m');
|
||||
$this->gnu_arch = arch2gnu($this->arch);
|
||||
$this->zts = $zts;
|
||||
// 根据 CPU 线程数设置编译进程数
|
||||
$this->concurrency = SystemUtil::getCpuCount();
|
||||
// 设置 cflags
|
||||
@@ -49,6 +50,7 @@ class MacOSBuilder extends BuilderBase
|
||||
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->arch, $this->arch_c_flags);
|
||||
// 设置 configure 依赖的环境变量
|
||||
$this->configure_env =
|
||||
'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" ' .
|
||||
'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' .
|
||||
"CC='{$this->cc}' " .
|
||||
"CXX='{$this->cxx}' " .
|
||||
@@ -77,7 +79,7 @@ class MacOSBuilder extends BuilderBase
|
||||
$prefix = $arr[1] ?? null;
|
||||
if ($lib instanceof MacOSLibraryBase) {
|
||||
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
|
||||
$ret .= $lib->makeAutoconfEnv($prefix) . ' ';
|
||||
$ret .= '--with-' . $libName . '=yes ';
|
||||
} else {
|
||||
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
|
||||
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
|
||||
@@ -136,16 +138,22 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
// patch before configure
|
||||
Patcher::patchPHPBeforeConfigure($this);
|
||||
SourcePatcher::patchPHPBuildconf($this);
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||
|
||||
Patcher::patchPHPConfigure($this);
|
||||
SourcePatcher::patchPHPConfigure($this);
|
||||
|
||||
if ($this->getLib('libxml2') || $this->getExt('iconv')) {
|
||||
$extra_libs .= ' -liconv';
|
||||
}
|
||||
|
||||
if ($this->getPHPVersionID() < 80000) {
|
||||
$json_74 = '--enable-json ';
|
||||
} else {
|
||||
$json_74 = '';
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec(
|
||||
'./configure ' .
|
||||
@@ -153,19 +161,21 @@ class MacOSBuilder extends BuilderBase
|
||||
'--with-valgrind=no ' . // 不检测内存泄漏
|
||||
'--enable-shared=no ' .
|
||||
'--enable-static=yes ' .
|
||||
"--host={$this->gnu_arch}-apple-darwin " .
|
||||
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
|
||||
'--disable-all ' .
|
||||
'--disable-cgi ' .
|
||||
'--disable-phpdbg ' .
|
||||
'--enable-cli ' .
|
||||
'--enable-fpm ' .
|
||||
$json_74 .
|
||||
'--enable-micro ' .
|
||||
($this->zts ? '--enable-zts' : '') . ' ' .
|
||||
$this->makeExtensionArgs() . ' ' .
|
||||
$this->configure_env
|
||||
);
|
||||
|
||||
SourcePatcher::patchPHPAfterConfigure($this);
|
||||
|
||||
$this->cleanMake();
|
||||
|
||||
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
||||
@@ -186,7 +196,7 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
if ($this->phar_patched) {
|
||||
f_passthru('cd ' . SOURCE_PATH . '/php-src && patch -p1 -R < sapi/micro/patches/phar.patch');
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +208,11 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildCli(string $extra_libs): void
|
||||
{
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli")
|
||||
->exec('dsymutil -f sapi/cli/php')
|
||||
->exec('strip sapi/cli/php');
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli");
|
||||
if ($this->strip) {
|
||||
$shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php');
|
||||
}
|
||||
$this->deployBinary(BUILD_TARGET_CLI);
|
||||
}
|
||||
|
||||
@@ -217,17 +228,11 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
if ($this->getExt('phar')) {
|
||||
$this->phar_patched = true;
|
||||
try {
|
||||
// TODO: 未来改进一下 patch,让除了这种 patch 类型的文件以外可以恢复原文件
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 < sapi/micro/patches/phar.patch');
|
||||
} catch (RuntimeException $e) {
|
||||
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
||||
$this->phar_patched = false;
|
||||
}
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" STRIP=\"dsymutil -f \" micro");
|
||||
->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" " . ($this->strip ? 'STRIP="dsymutil -f " ' : '') . 'micro');
|
||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||
}
|
||||
|
||||
@@ -239,10 +244,11 @@ class MacOSBuilder extends BuilderBase
|
||||
*/
|
||||
public function buildFpm(string $extra_libs): void
|
||||
{
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" fpm")
|
||||
->exec('dsymutil -f sapi/fpm/php-fpm')
|
||||
->exec('strip sapi/fpm/php-fpm');
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" fpm");
|
||||
if ($this->strip) {
|
||||
$shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip sapi/fpm/php-fpm');
|
||||
}
|
||||
$this->deployBinary(BUILD_TARGET_FPM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,26 +22,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class brotli extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'brotli';
|
||||
use \SPC\builder\unix\library\brotli;
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} cmake " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
public const NAME = 'brotli';
|
||||
}
|
||||
|
||||
@@ -22,14 +22,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class bzip2 extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'bzip2';
|
||||
use \SPC\builder\unix\library\bzip2;
|
||||
|
||||
protected function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
public const NAME = 'bzip2';
|
||||
}
|
||||
|
||||
@@ -20,97 +20,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
class curl extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\curl {
|
||||
build as unixBuild;
|
||||
}
|
||||
|
||||
public const NAME = 'curl';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:openssl
|
||||
$openssl = $this->getBuilder()->getLib('openssl');
|
||||
if ($openssl instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DCURL_USE_OPENSSL=ON ';
|
||||
} else {
|
||||
$extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
||||
}
|
||||
// lib:zlib
|
||||
$zlib = $this->getBuilder()->getLib('zlib');
|
||||
if ($zlib instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
}
|
||||
// lib:libssh2
|
||||
$libssh2 = $this->builder->getLib('libssh2');
|
||||
if ($libssh2 instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DLIBSSH2_LIBRARY="' . $libssh2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBSSH2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_USE_LIBSSH2=OFF ';
|
||||
}
|
||||
// lib:brotli
|
||||
$brotli = $this->builder->getLib('brotli');
|
||||
if ($brotli) {
|
||||
$extra .= '-DCURL_BROTLI=ON ' .
|
||||
'-DBROTLIDEC_LIBRARY="' . realpath(BUILD_LIB_PATH . '/libbrotlidec-static.a') . ';' . realpath(BUILD_LIB_PATH . '/libbrotlicommon-static.a') . '" ' .
|
||||
'-DBROTLICOMMON_LIBRARY="' . realpath(BUILD_LIB_PATH . '/libbrotlicommon-static.a') . '" ' .
|
||||
'-DBROTLI_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_BROTLI=OFF ';
|
||||
}
|
||||
// lib:nghttp2
|
||||
$nghttp2 = $this->builder->getLib('nghttp2');
|
||||
if ($nghttp2 instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DUSE_NGHTTP2=ON ' .
|
||||
'-DNGHTTP2_LIBRARY="' . $nghttp2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DNGHTTP2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DUSE_NGHTTP2=OFF ';
|
||||
}
|
||||
// lib:ldap
|
||||
$ldap = $this->builder->getLib('ldap');
|
||||
if ($ldap instanceof MacOSLibraryBase) {
|
||||
// $extra .= '-DCURL_DISABLE_LDAP=OFF ';
|
||||
// TODO: LDAP support
|
||||
throw new RuntimeException('LDAP support is not implemented yet');
|
||||
}
|
||||
$extra .= '-DCURL_DISABLE_LDAP=ON ';
|
||||
// lib:zstd
|
||||
$zstd = $this->builder->getLib('zstd');
|
||||
if ($zstd instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DCURL_ZSTD=ON ' .
|
||||
'-DZstd_LIBRARY="' . $zstd->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZstd_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_ZSTD=OFF ';
|
||||
}
|
||||
// lib:idn2
|
||||
$idn2 = $this->builder->getLib('idn2');
|
||||
$extra .= $idn2 instanceof MacOSLibraryBase ? '-DUSE_LIBIDN2=ON ' : '-DUSE_LIBIDN2=OFF ';
|
||||
// lib:psl
|
||||
$libpsl = $this->builder->getLib('psl');
|
||||
$extra .= $libpsl instanceof MacOSLibraryBase ? '-DCURL_USE_LIBPSL=ON ' : '-DCURL_USE_LIBPSL=OFF ';
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
// compile!
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} cmake " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX= ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
SourcePatcher::patchCurlMacOS();
|
||||
$this->unixBuild();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,28 +9,7 @@ namespace SPC\builder\macos\library;
|
||||
*/
|
||||
class freetype extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\freetype;
|
||||
|
||||
public const NAME = 'freetype';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
$suggested = '';
|
||||
$suggested .= ($this->builder->getLib('libpng') instanceof MacOSLibraryBase) ? ('--with-png=' . BUILD_ROOT_PATH) : '--without-png';
|
||||
$suggested .= ' ';
|
||||
$suggested .= ($this->builder->getLib('bzip2') instanceof MacOSLibraryBase) ? ('--with-bzip2=' . BUILD_ROOT_PATH) : '--without-bzip2';
|
||||
$suggested .= ' ';
|
||||
$suggested .= ($this->builder->getLib('brotli') instanceof MacOSLibraryBase) ? ('--with-brotli=' . BUILD_ROOT_PATH) : '--without-brotli';
|
||||
$suggested .= ' ';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
|
||||
$suggested
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,7 @@ namespace SPC\builder\macos\library;
|
||||
*/
|
||||
class gmp extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\gmp;
|
||||
|
||||
public const NAME = 'gmp';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/macos/library/imagemagick.php
Normal file
15
src/SPC/builder/macos/library/imagemagick.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class imagemagick extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\imagemagick;
|
||||
|
||||
public const NAME = 'imagemagick';
|
||||
}
|
||||
28
src/SPC/builder/macos/library/libavif.php
Normal file
28
src/SPC/builder/macos/library/libavif.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libavif extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libavif;
|
||||
|
||||
public const NAME = 'libavif';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/libevent.php
Normal file
12
src/SPC/builder/macos/library/libevent.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libevent extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libevent;
|
||||
|
||||
public const NAME = 'libevent';
|
||||
}
|
||||
@@ -34,11 +34,11 @@ class libffi extends MacOSLibraryBase
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->arch}-apple-darwin " .
|
||||
"--target={$this->builder->arch}-apple-darwin " .
|
||||
'--prefix= ' . // use prefix=/
|
||||
"--libdir={$lib}"
|
||||
'--prefix= ' // use prefix=/
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libffi.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,28 +20,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libiconv extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libiconv;
|
||||
|
||||
public const NAME = 'libiconv';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/macos/library/libjpeg.php
Normal file
12
src/SPC/builder/macos/library/libjpeg.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libjpeg extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libjpeg;
|
||||
|
||||
public const NAME = 'libjpeg';
|
||||
}
|
||||
@@ -22,7 +22,6 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\Patcher;
|
||||
|
||||
class libpng extends MacOSLibraryBase
|
||||
{
|
||||
@@ -34,15 +33,11 @@ class libpng extends MacOSLibraryBase
|
||||
*/
|
||||
protected function build()
|
||||
{
|
||||
// 不同架构的专属优化
|
||||
$optimizations = match ($this->builder->arch) {
|
||||
'x86_64' => '--enable-intel-sse ',
|
||||
'arm64' => '--enable-arm-neon ',
|
||||
default => '',
|
||||
};
|
||||
|
||||
// patch configure
|
||||
Patcher::patchUnixLibpng();
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('chmod +x ./configure')
|
||||
->exec(
|
||||
@@ -59,5 +54,7 @@ class libpng extends MacOSLibraryBase
|
||||
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH)
|
||||
->cd(BUILD_LIB_PATH)
|
||||
->exec('ln -sf libpng16.a libpng.a');
|
||||
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
|
||||
$this->cleanLaFiles();
|
||||
}
|
||||
}
|
||||
|
||||
12
src/SPC/builder/macos/library/libsodium.php
Normal file
12
src/SPC/builder/macos/library/libsodium.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libsodium extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libsodium;
|
||||
|
||||
public const NAME = 'libsodium';
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -22,33 +6,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class libssh2 extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libssh2;
|
||||
|
||||
public const NAME = 'libssh2';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
// lib:zlib
|
||||
$enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF';
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
"-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target libssh2")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
28
src/SPC/builder/macos/library/libwebp.php
Normal file
28
src/SPC/builder/macos/library/libwebp.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libwebp extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libwebp;
|
||||
|
||||
public const NAME = 'libwebp';
|
||||
}
|
||||
@@ -1,26 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libxml2 extends MacOSLibraryBase
|
||||
{
|
||||
@@ -37,10 +22,8 @@ class libxml2 extends MacOSLibraryBase
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
|
||||
@@ -1,94 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libyaml extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libyaml;
|
||||
|
||||
public const NAME = 'libyaml';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// prepare cmake/config.h.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/cmake/config.h.in')) {
|
||||
f_mkdir(SOURCE_PATH . '/libyaml/cmake');
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/cmake/config.h.in',
|
||||
<<<'EOF'
|
||||
#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@
|
||||
#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@
|
||||
#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@
|
||||
#define YAML_VERSION_STRING "@YAML_VERSION_STRING@"
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
// prepare yamlConfig.cmake.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/yamlConfig.cmake.in')) {
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/yamlConfig.cmake.in',
|
||||
<<<'EOF'
|
||||
# Config file for the yaml library.
|
||||
#
|
||||
# It defines the following variables:
|
||||
# yaml_LIBRARIES - libraries to link against
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake")
|
||||
|
||||
if(NOT yaml_TARGETS_IMPORTED)
|
||||
set(yaml_TARGETS_IMPORTED 1)
|
||||
include(${yaml_TARGETS})
|
||||
endif()
|
||||
|
||||
set(yaml_LIBRARIES yaml)
|
||||
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,79 +6,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class libzip extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libzip;
|
||||
|
||||
public const NAME = 'libzip';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:zlib
|
||||
$zlib = $this->builder->getLib('zlib');
|
||||
if ($zlib instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
}
|
||||
// lib:bzip2
|
||||
$libbzip2 = $this->builder->getLib('bzip2');
|
||||
if ($libbzip2 instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DENABLE_BZIP2=ON ' .
|
||||
'-DBZIP2_LIBRARIES="' . $libbzip2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DBZIP2_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_BZIP2=OFF ';
|
||||
}
|
||||
// lib:xz
|
||||
$xz = $this->builder->getLib('xz');
|
||||
if ($xz instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DENABLE_LZMA=ON ' .
|
||||
'-DLIBLZMA_LIBRARY="' . $xz->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBLZMA_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_LZMA=OFF ';
|
||||
}
|
||||
// lib:zstd
|
||||
$libzstd = $this->builder->getLib('zstd');
|
||||
if ($libzstd instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DENABLE_ZSTD=ON ' .
|
||||
'-DZstd_LIBRARY="' . $libzstd->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZstd_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_ZSTD=OFF ';
|
||||
}
|
||||
// lib:openssl
|
||||
$libopenssl = $this->builder->getLib('openssl');
|
||||
if ($libopenssl instanceof MacOSLibraryBase) {
|
||||
$extra .= '-DENABLE_OPENSSL=ON ' .
|
||||
'-DOpenSSL_LIBRARY="' . $libopenssl->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DOpenSSL_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_OPENSSL=OFF ';
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DENABLE_GNUTLS=OFF ' .
|
||||
'-DENABLE_MBEDTLS=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_DOC=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_REGRESS=OFF ' .
|
||||
'-DBUILD_TOOLS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/macos/library/ncurses.php
Normal file
15
src/SPC/builder/macos/library/ncurses.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class ncurses extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\ncurses;
|
||||
|
||||
public const NAME = 'ncurses';
|
||||
}
|
||||
@@ -58,5 +58,6 @@ class nghttp2 extends MacOSLibraryBase
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,22 +6,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class onig extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\onig;
|
||||
|
||||
public const NAME = 'onig';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' ./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->arch}-apple-darwin " .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +47,6 @@ class openssl extends MacOSLibraryBase
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->exec("make install_sw DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
15
src/SPC/builder/macos/library/pkgconfig.php
Normal file
15
src/SPC/builder/macos/library/pkgconfig.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class pkgconfig extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\pkgconfig;
|
||||
|
||||
public const NAME = 'pkg-config';
|
||||
}
|
||||
15
src/SPC/builder/macos/library/readline.php
Normal file
15
src/SPC/builder/macos/library/readline.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class readline extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\readline;
|
||||
|
||||
public const NAME = 'readline';
|
||||
}
|
||||
@@ -6,15 +6,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class sqlite extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'sqlite';
|
||||
use \SPC\builder\unix\library\sqlite;
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix=")
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
public const NAME = 'sqlite';
|
||||
}
|
||||
|
||||
@@ -22,30 +22,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class xz extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\xz;
|
||||
|
||||
public const NAME = 'xz';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('autoreconf -i --force')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->gnu_arch}-apple-darwin " .
|
||||
'--disable-xz ' .
|
||||
'--disable-xzdec ' .
|
||||
'--disable-lzmadec ' .
|
||||
'--disable-lzmainfo ' .
|
||||
'--disable-scripts ' .
|
||||
'--disable-doc ' .
|
||||
'--with-libiconv ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class zlib extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\zlib;
|
||||
|
||||
public const NAME = 'zlib';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("{$this->builder->configure_env} ./configure --static --prefix=")
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,19 +6,7 @@ namespace SPC\builder\macos\library;
|
||||
|
||||
class zstd extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'zstd';
|
||||
use \SPC\builder\unix\library\zstd;
|
||||
|
||||
protected function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec(
|
||||
"make -j{$this->builder->concurrency} " .
|
||||
"{$this->builder->configure_env} " .
|
||||
"PREFIX='" . BUILD_ROOT_PATH . "' " .
|
||||
'-C lib libzstd.a CPPFLAGS_STATLIB=-DZSTD_MULTITHREAD'
|
||||
)
|
||||
->exec('cp lib/libzstd.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp lib/zdict.h lib/zstd_errors.h lib/zstd.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
public const NAME = 'zstd';
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
@@ -71,7 +72,7 @@ trait UnixBuilderTrait
|
||||
}
|
||||
foreach ($this->exts as $ext) {
|
||||
logger()->debug('testing ext: ' . $ext->getName());
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri ' . $ext->getDistName(), false);
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $ext->getDistName() . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check');
|
||||
}
|
||||
@@ -133,4 +134,18 @@ trait UnixBuilderTrait
|
||||
logger()->info('cleaning up');
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return generic cmake options when configuring cmake projects
|
||||
*/
|
||||
public function makeCmakeArgs(): string
|
||||
{
|
||||
[$lib, $include] = SEPARATED_PATH;
|
||||
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->cc . ' ' : '';
|
||||
return $extra . '-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,46 @@ trait UnixLibraryTrait
|
||||
return $prefix . '_CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' .
|
||||
$prefix . '_LIBS="' . $this->getStaticLibFiles() . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch pkgconfig file prefix
|
||||
*
|
||||
* @param array $files file list
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function patchPkgconfPrefix(array $files, int $patch_option = PKGCONF_PATCH_ALL): void
|
||||
{
|
||||
logger()->info('Patching library [' . static::NAME . '] pkgconfig');
|
||||
foreach ($files as $name) {
|
||||
$realpath = realpath(BUILD_ROOT_PATH . '/lib/pkgconfig/' . $name);
|
||||
if ($realpath === false) {
|
||||
throw new RuntimeException('Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] !');
|
||||
}
|
||||
logger()->debug('Patching ' . $realpath);
|
||||
// replace prefix
|
||||
$file = FileSystem::readFile($realpath);
|
||||
$file = ($patch_option & PKGCONF_PATCH_PREFIX) === PKGCONF_PATCH_PREFIX ? preg_replace('/^prefix=.*$/m', 'prefix=' . BUILD_ROOT_PATH, $file) : $file;
|
||||
$file = ($patch_option & PKGCONF_PATCH_EXEC_PREFIX) === PKGCONF_PATCH_EXEC_PREFIX ? preg_replace('/^exec_prefix=.*$/m', 'exec_prefix=${prefix}', $file) : $file;
|
||||
$file = ($patch_option & PKGCONF_PATCH_LIBDIR) === PKGCONF_PATCH_LIBDIR ? preg_replace('/^libdir=.*$/m', 'libdir=${prefix}/lib', $file) : $file;
|
||||
$file = ($patch_option & PKGCONF_PATCH_INCLUDEDIR) === PKGCONF_PATCH_INCLUDEDIR ? preg_replace('/^includedir=.*$/m', 'includedir=${prefix}/include', $file) : $file;
|
||||
FileSystem::writeFile($realpath, $file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove libtool archive files
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function cleanLaFiles(): void
|
||||
{
|
||||
foreach ($this->getStaticLibs() as $lib) {
|
||||
$filename = pathinfo($lib, PATHINFO_FILENAME) . '.la';
|
||||
if (file_exists(BUILD_LIB_PATH . '/' . $filename)) {
|
||||
unlink(BUILD_LIB_PATH . '/' . $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +38,18 @@ trait UnixSystemUtilTrait
|
||||
$cxxLine = 'SET(CMAKE_CXX_COMPILER ' . self::findCommand($cxx) . ')';
|
||||
}
|
||||
$toolchain = <<<CMAKE
|
||||
SET(CMAKE_SYSTEM_NAME {$os})
|
||||
SET(CMAKE_SYSTEM_PROCESSOR {$target_arch})
|
||||
{$ccLine}
|
||||
{$cxxLine}
|
||||
SET(CMAKE_C_FLAGS "{$cflags}")
|
||||
SET(CMAKE_CXX_FLAGS "{$cflags}")
|
||||
SET(CMAKE_FIND_ROOT_PATH "{$root}")
|
||||
SET(CMAKE_PREFIX_PATH "{$root}")
|
||||
|
||||
set(PKG_CONFIG_EXECUTABLE "{$root}/bin/pkg-config")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
CMAKE;
|
||||
// 有时候系统的 cmake 找不到 ar 命令,真奇怪
|
||||
if (PHP_OS_FAMILY === 'Linux') {
|
||||
|
||||
34
src/SPC/builder/unix/library/brotli.php
Normal file
34
src/SPC/builder/unix/library/brotli.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait brotli
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
FileSystem::resetDir($this->source_dir . '/build-dir');
|
||||
shell()->cd($this->source_dir . '/build-dir')
|
||||
->exec(
|
||||
$this->builder->configure_env . ' cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
||||
shell()->cd(BUILD_ROOT_PATH . '/lib')
|
||||
->exec('ln -s libbrotlicommon-static.a libbrotlicommon.a')
|
||||
->exec('ln -s libbrotlidec-static.a libbrotlidec.a')
|
||||
->exec('ln -s libbrotlienc-static.a libbrotlienc.a');
|
||||
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||
if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/SPC/builder/unix/library/bzip2.php
Normal file
17
src/SPC/builder/unix/library/bzip2.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
trait bzip2
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
56
src/SPC/builder/unix/library/curl.php
Normal file
56
src/SPC/builder/unix/library/curl.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait curl
|
||||
{
|
||||
protected function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:openssl
|
||||
$extra .= $this->builder->getLib('openssl') ? '-DCURL_USE_OPENSSL=ON ' : '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
||||
// lib:brotli
|
||||
$extra .= $this->builder->getLib('brotli') ? '-DCURL_BROTLI=ON ' : '-DCURL_BROTLI=OFF ';
|
||||
// lib:libssh2
|
||||
$libssh2 = $this->builder->getLib('libssh2');
|
||||
if ($this->builder->getLib('libssh2')) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
$extra .= '-DLIBSSH2_LIBRARY="' . $libssh2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBSSH2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DCURL_USE_LIBSSH2=OFF ';
|
||||
}
|
||||
// lib:nghttp2
|
||||
if ($nghttp2 = $this->builder->getLib('nghttp2')) {
|
||||
$extra .= '-DUSE_NGHTTP2=ON ' .
|
||||
/* @phpstan-ignore-next-line */
|
||||
'-DNGHTTP2_LIBRARY="' . $nghttp2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DNGHTTP2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DUSE_NGHTTP2=OFF ';
|
||||
}
|
||||
// TODO: ldap is not supported yet
|
||||
$extra .= '-DCURL_DISABLE_LDAP=ON ';
|
||||
// lib:zstd
|
||||
$extra .= $this->builder->getLib('zstd') ? '-DCURL_ZSTD=ON ' : '-DCURL_ZSTD=OFF ';
|
||||
// lib:idn2
|
||||
$extra .= $this->builder->getLib('idn2') ? '-DUSE_LIBIDN2=ON ' : '-DUSE_LIBIDN2=OFF ';
|
||||
// lib:psl
|
||||
$extra .= $this->builder->getLib('psl') ? '-DCURL_USE_LIBPSL=ON ' : '-DCURL_USE_LIBPSL=OFF ';
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// compile!
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec("{$this->builder->configure_env} 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);
|
||||
// patch pkgconf
|
||||
$this->patchPkgconfPrefix(['libcurl.pc']);
|
||||
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
|
||||
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user