Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
082617f
完善 gd 扩展依赖库
jingjingxyk Apr 22, 2023
3741977
完善libgif libpng libwebp freetype brotli
jingjingxyk Apr 22, 2023
299f56a
test
jingjingxyk Apr 22, 2023
66e3385
Merge branch 'refactor' into feature_gd
jingjingxyk Apr 22, 2023
8e4c782
去除无效的配置libpng 配置
jingjingxyk Apr 22, 2023
c2ce203
验证编译
jingjingxyk Apr 22, 2023
a70b4b3
使用 china mirror
jingjingxyk Apr 23, 2023
31bad1b
验证gdz
jingjingxyk Apr 23, 2023
b03a0a5
编译添加 pkg-config 管理依赖
jingjingxyk Apr 23, 2023
6b24724
移除实验配置
jingjingxyk Apr 23, 2023
9fb0c81
gd for php ok
jingjingxyk Apr 24, 2023
3eed907
save changed
jingjingxyk Apr 24, 2023
befe857
merge code
jingjingxyk Apr 24, 2023
ea5bdac
验证不同编译器
jingjingxyk Apr 25, 2023
61d9283
验证musl-gcc
jingjingxyk Apr 25, 2023
32bb691
save changed
jingjingxyk Apr 25, 2023
ebb2f6a
save changed
jingjingxyk Apr 25, 2023
9663a88
save changed
jingjingxyk Apr 25, 2023
71ed3a3
fix copy shell script error
jingjingxyk Apr 25, 2023
fd8aaf0
保存结果
jingjingxyk Apr 25, 2023
c886c89
验证 alpine 环境下 gcc 和 clang 编译区别
jingjingxyk Apr 26, 2023
78e9ff3
验证macos 启用gd
jingjingxyk Apr 26, 2023
71ec35b
fix
jingjingxyk Apr 26, 2023
d0491e5
save changed
jingjingxyk Apr 27, 2023
ea5a889
fix bug
jingjingxyk Apr 27, 2023
554b835
Merge branch 'refactor' into feature_gd
jingjingxyk Apr 27, 2023
db53638
merge code
jingjingxyk May 1, 2023
ca346ac
merge code
jingjingxyk May 1, 2023
7141405
merge code
jingjingxyk May 1, 2023
b1e623d
merge code
jingjingxyk May 24, 2023
7acbd41
merge code
jingjingxyk May 24, 2023
f29ab9f
merge code
jingjingxyk May 27, 2023
2d777cb
stop docker timeout
jingjingxyk May 27, 2023
c05f27b
quickstart delete macos script
jingjingxyk May 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/setup-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ __PROJECT__=$(cd ${__DIR__}/../ && pwd)
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"


# use china mirror
# bash bin/setup-runtime --mirror china

mirror=''
while [ $# -gt 0 ]; do
case "$1" in
Expand Down
6 changes: 5 additions & 1 deletion config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
"arg-type-windows": "with",
"lib-depends": [
"zlib",
"libpng"
"libpng",
"libjpeg",
"freetype",
"libgif",
"libwebp"
],
"ext-depends": [
"zlib"
Expand Down
30 changes: 28 additions & 2 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,34 @@
"url": "https://git.code.sf.net/p/libpng/code",
"rev": "libpng16",
"license": {
"type": "text",
"text": "COPYRIGHT NOTICE, DISCLAIMER, and LICENSE\n=========================================\n\nPNG Reference Library License version 2\n---------------------------------------\n\n * Copyright (c) 1995-2019 The PNG Reference Library Authors.\n * Copyright (c) 2018-2019 Cosmin Truta.\n * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.\n * Copyright (c) 1996-1997 Andreas Dilger.\n * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nThe software is supplied \"as is\", without warranty of any kind,\nexpress or implied, including, without limitation, the warranties\nof merchantability, fitness for a particular purpose, title, and\nnon-infringement. In no event shall the Copyright owners, or\nanyone distributing the software, be liable for any damages or\nother liability, whether in contract, tort or otherwise, arising\nfrom, out of, or in connection with the software, or the use or\nother dealings in the software, even if advised of the possibility\nof such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute\nthis software, or portions hereof, for any purpose, without fee,\nsubject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you\n must not claim that you wrote the original software. If you\n use this software in a product, an acknowledgment in the product\n documentation would be appreciated, but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must\n not be misrepresented as being the original software.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\n\nPNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)\n-----------------------------------------------------------------------\n\nlibpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are\nCopyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are\nderived from libpng-1.0.6, and are distributed according to the same\ndisclaimer and license as libpng-1.0.6 with the following individuals\nadded to the list of Contributing Authors:\n\n Simon-Pierre Cadieux\n Eric S. Raymond\n Mans Rullgard\n Cosmin Truta\n Gilles Vollant\n James Yu\n Mandar Sahastrabuddhe\n Google Inc.\n Vadim Barkov\n\nand with the following additions to the disclaimer:\n\n There is no warranty against interference with your enjoyment of\n the library or against infringement. There is no warranty that our\n efforts or the library will fulfill any of your particular purposes\n or needs. This library is provided with all faults, and the entire\n risk of satisfactory quality, performance, accuracy, and effort is\n with the user.\n\nSome files in the \"contrib\" directory and some configure-generated\nfiles that are distributed with libpng have other copyright owners, and\nare released under other open source licenses.\n\nlibpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\nCopyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from\nlibpng-0.96, and are distributed according to the same disclaimer and\nlicense as libpng-0.96, with the following individuals added to the\nlist of Contributing Authors:\n\n Tom Lane\n Glenn Randers-Pehrson\n Willem van Schaik\n\nlibpng versions 0.89, June 1996, through 0.96, May 1997, are\nCopyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,\nand are distributed according to the same disclaimer and license as\nlibpng-0.88, with the following individuals added to the list of\nContributing Authors:\n\n John Bowler\n Kevin Bracey\n Sam Bushell\n Magnus Holmgren\n Greg Roelofs\n Tom Tanner\n\nSome files in the \"scripts\" directory have other copyright owners,\nbut are released under this license.\n\nlibpng versions 0.5, May 1995, through 0.88, January 1996, are\nCopyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nFor the purposes of this copyright and license, \"Contributing Authors\"\nis defined as the following set of individuals:\n\n Andreas Dilger\n Dave Martindale\n Guy Eric Schalnat\n Paul Schmidt\n Tim Wegner\n\nThe PNG Reference Library is supplied \"AS IS\". The Contributing\nAuthors and Group 42, Inc. disclaim all warranties, expressed or\nimplied, including, without limitation, the warranties of\nmerchantability and of fitness for any purpose. The Contributing\nAuthors and Group 42, Inc. assume no liability for direct, indirect,\nincidental, special, exemplary, or consequential damages, which may\nresult from the use of the PNG Reference Library, even if advised of\nthe possibility of such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsource code, or portions hereof, for any purpose, without fee, subject\nto the following restrictions:\n\n 1. The origin of this source code must not be misrepresented.\n\n 2. Altered versions must be plainly marked as such and must not\n be misrepresented as being the original source.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\nThe Contributing Authors and Group 42, Inc. specifically permit,\nwithout fee, and encourage the use of this source code as a component\nto supporting the PNG file format in commercial products. If you use\nthis source code in a product, acknowledgment is not required but would\nbe appreciated.\n"
"type": "file",
"path": "LICENSE"
}
},
"libjpeg": {
"type": "git",
"url": "https://github.com/libjpeg-turbo/libjpeg-turbo.git",
"rev": "2.1.91",
"license": {
"type": "file",
"path": "LICENSE.md"
}
},
"libgif": {
"type": "url",
"url": "https://nchc.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libwebp": {
"type": "git",
"url": "https://chromium.googlesource.com/webm/libwebp",
"rev": "v1.3.0",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libressl": {
Expand Down
21 changes: 19 additions & 2 deletions quickstart/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ sh quickstart/linux/run-debian-11-container.sh
sh quickstart/linux/connection-static-php-cli.sh

# 准备构建基础软件
sh quickstart/linux/debian-11-init.sh
sh quickstart/linux/x86_64/debian-11-init.sh

# 准备构建基础软件 使用镜像
sh quickstart/linux/x86_64/debian-11-init.sh --mirror china


```

Expand All @@ -29,6 +33,19 @@ sh quickstart/linux/run-alpine-3.16-container.sh
sh sh quickstart/linux/connection-static-php-cli.sh

# 准备构建基础软件
sh quickstart/linux/alpine-3.16-init.sh
sh quickstart/linux/x86_64/alpine-3.16-init.sh

# 准备构建基础软件 使用镜像
sh quickstart/linux/x86_64/alpine-3.16-init.sh --mirror china
```


## 准备PHP 运行时镜像
```bash
sh bin/setup-runtime

# 使用镜像
sh bin/setup-runtime --mirror china


```
3 changes: 1 addition & 2 deletions quickstart/linux/alpine-3.16-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ esac


apk update

apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils
apk add bash p7zip zip unzip flex pkgconf ca-certificates
apk add wget git curl
apk add wget git curl
3 changes: 3 additions & 0 deletions quickstart/linux/debian-11-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext c
apt install -y pkg-config bzip2 flex p7zip
apt install -y musl-tools g++
apt install -y clang

# apt install build-essential linux-headers-$(uname -r)

1 change: 1 addition & 0 deletions quickstart/linux/run-alpine-3.16-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cd ${__DIR__}

{
docker stop static-php-cli-dev-1
sleep 5
} || {
echo $?
}
Expand Down
1 change: 1 addition & 0 deletions quickstart/linux/run-debian-11-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cd ${__DIR__}

{
docker stop static-php-cli-dev-1
sleep 5
} || {
echo $?
}
Expand Down
3 changes: 3 additions & 0 deletions quickstart/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ EXTENSIONS="${EXTENSIONS},mongodb"
# EXTENSIONS="${EXTENSIONS},swoole"
EXTENSIONS="${EXTENSIONS},swow"


# # musl-gcc/musl-clang(或 gcc-musl/gcc-clang

./bin/spc build "${EXTENSIONS}" --build-cli --cc=clang --cxx=clang++ --debug
# ./bin/spc build "${EXTENSIONS}" --build-cli --cc=gcc --cxx=g++ --debug
23 changes: 18 additions & 5 deletions src/SPC/builder/BuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public function buildLibs(array $libraries): void
// 过滤不支持的库后添加
foreach ($libraries as $library) {
if (!isset($support_lib_list[$library])) {
throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
throw new RuntimeException(
'library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'
);
}
$lib = new ($support_lib_list[$library])($this);
$this->addLib($lib);
Expand All @@ -91,6 +93,7 @@ public function buildLibs(array $libraries): void

// 构建库
foreach ($this->libs as $lib) {
// $lib->build(true);
match ($lib->tryBuild()) {
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
Expand Down Expand Up @@ -257,15 +260,19 @@ protected function checkLibsSource(): void
'"' . implode(', ', $not_downloaded) .
'" totally ' . count($not_downloaded) .
' source' . (count($not_downloaded) === 1 ? '' : 's') .
' not downloaded, maybe you need to "fetch" ' . (count($not_downloaded) === 1 ? 'it' : 'them') . ' first?'
' not downloaded, maybe you need to "fetch" ' . (count(
$not_downloaded
) === 1 ? 'it' : 'them') . ' first?'
);
}
}

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 ?');
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);

Expand Down Expand Up @@ -299,13 +306,19 @@ protected function initSource(?array $sources = null, ?array $libs = null, ?arra
// start check
foreach ($sources_extracted as $source => $item) {
if (!isset($lock[$source])) {
throw new WrongUsageException('Source [' . $source . '] not downloaded, you should download it first !');
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']);
FileSystem::extractSource(
$source,
DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']),
$lock[$source]['move_path']
);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/SPC/builder/extension/zip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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';
}
}
17 changes: 17 additions & 0 deletions src/SPC/builder/extension/zlib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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';
}
}
Loading