mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
refactor and add more linux extensions and libraries
This commit is contained in:
parent
17e0265ed0
commit
84b1732683
@ -70,6 +70,9 @@
|
|||||||
"zlib",
|
"zlib",
|
||||||
"libpng"
|
"libpng"
|
||||||
],
|
],
|
||||||
|
"ext-depends": [
|
||||||
|
"zlib"
|
||||||
|
],
|
||||||
"lib-suggests": [
|
"lib-suggests": [
|
||||||
"gd",
|
"gd",
|
||||||
"libavif",
|
"libavif",
|
||||||
@ -148,6 +151,10 @@
|
|||||||
"onig"
|
"onig"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"mongodb": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "mongodb"
|
||||||
|
},
|
||||||
"mysqli": {
|
"mysqli": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "with",
|
"arg-type": "with",
|
||||||
@ -284,8 +291,7 @@
|
|||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "swoole",
|
"source": "swoole",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"openssl",
|
"openssl"
|
||||||
"curl"
|
|
||||||
],
|
],
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"openssl"
|
"openssl"
|
||||||
@ -357,6 +363,10 @@
|
|||||||
"libxslt"
|
"libxslt"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"protobuf": {
|
||||||
|
"type": "external",
|
||||||
|
"source": "protobuf"
|
||||||
|
},
|
||||||
"yaml": {
|
"yaml": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "yaml",
|
"source": "yaml",
|
||||||
|
|||||||
@ -349,6 +349,9 @@
|
|||||||
"headers-windows": [
|
"headers-windows": [
|
||||||
"lzma",
|
"lzma",
|
||||||
"lzma.h"
|
"lzma.h"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"libiconv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"zlib": {
|
"zlib": {
|
||||||
|
|||||||
@ -141,6 +141,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mongodb": {
|
||||||
|
"type": "ghrel",
|
||||||
|
"repo": "mongodb/mongo-php-driver",
|
||||||
|
"path": "php-src/ext/mongodb",
|
||||||
|
"match": "mongodb.+\\.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nghttp2": {
|
"nghttp2": {
|
||||||
"type": "ghrel",
|
"type": "ghrel",
|
||||||
"repo": "nghttp2/nghttp2",
|
"repo": "nghttp2/nghttp2",
|
||||||
@ -158,6 +168,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"protobuf": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "http://pecl.php.net/get/protobuf",
|
||||||
|
"path": "php-src/ext/protobuf",
|
||||||
|
"filename": "protobuf.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"onig": {
|
"onig": {
|
||||||
"type": "ghrel",
|
"type": "ghrel",
|
||||||
"repo": "kkos/oniguruma",
|
"repo": "kkos/oniguruma",
|
||||||
|
|||||||
@ -1,63 +1,61 @@
|
|||||||
# Extension List
|
# Extension List
|
||||||
|
|
||||||
> - yes: supported and tested
|
> - yes: supported and tested
|
||||||
> - untested: supported but not tested
|
> - untested: supported, but not tested
|
||||||
> - empty: not supported yet
|
> - empty: not supported yet
|
||||||
> - faulty with issue link: not supported yet due to issue
|
> - faulty with issue link: not supported yet due to issue
|
||||||
|
|
||||||
| | Linux | macOS | Windows |
|
| | Linux | macOS | Windows |
|
||||||
|------------|----------|--------------------------------------------------------------------|---------|
|
|------------|--------------------------------------------------------------------|--------------------------------------------------------------------|---------|
|
||||||
| bcmath | yes | yes | |
|
| bcmath | yes | yes | |
|
||||||
| bz2 | yes | untested | |
|
| bz2 | yes | untested | |
|
||||||
| calendar | yes | yes | |
|
| calendar | yes | yes | |
|
||||||
| ctype | yes | yes | |
|
| ctype | yes | yes | |
|
||||||
| curl | untested | yes | |
|
| curl | untested | yes | |
|
||||||
| date | | yes | |
|
| date | yes | yes | |
|
||||||
| dba | yes | yes | |
|
| dba | yes | yes | |
|
||||||
| dom | untested | untested | |
|
| dom | untested | untested | |
|
||||||
|
| enchant | | | |
|
||||||
| event | | | |
|
| event | | | |
|
||||||
| exif | | yes | |
|
| exif | yes | yes | |
|
||||||
| filter | | yes | |
|
| filter | yes | yes | |
|
||||||
| fileinfo | | | |
|
| fileinfo | yes | | |
|
||||||
| ftp | | yes | |
|
| ftp | yes | yes | |
|
||||||
| gd | | untested | |
|
| gd | untested | untested | |
|
||||||
| gmp | | untested | |
|
| gettext | | | |
|
||||||
|
| gmp | untested | untested | |
|
||||||
| hash | yes | yes | |
|
| hash | yes | yes | |
|
||||||
| iconv | untested | | |
|
| iconv | untested | | |
|
||||||
| inotify | | | |
|
| inotify | | | |
|
||||||
| json | yes | yes | |
|
| mbstring | yes | yes | |
|
||||||
| libxml | | yes | |
|
|
||||||
| mbstring | | yes | |
|
|
||||||
| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||||
| mongodb | | | |
|
| mongodb | untested | | |
|
||||||
| mysqli | | | |
|
| mysqli | | | |
|
||||||
| mysqlnd | | yes | |
|
| mysqlnd | yes | yes | |
|
||||||
| openssl | untested | yes | |
|
| openssl | untested | yes | |
|
||||||
| pcntl | untested | untested | |
|
| pcntl | untested | untested | |
|
||||||
| pcre | | yes | |
|
| pdo | yes | yes | |
|
||||||
| pdo | | yes | |
|
| pdo_mysql | yes | yes | |
|
||||||
| pdo_mysql | | yes | |
|
| pdo_sqlite | yes | yes | |
|
||||||
| pdo_sqlite | | yes | |
|
|
||||||
| pdo_pgsql | | | |
|
| pdo_pgsql | | | |
|
||||||
| phar | yes | yes | |
|
| phar | yes | yes | |
|
||||||
| posix | yes | yes | |
|
| posix | yes | yes | |
|
||||||
| protobuf | | | |
|
| protobuf | untested | | |
|
||||||
| readline | | | |
|
| readline | | | |
|
||||||
| redis | | yes | |
|
| redis | yes | yes | |
|
||||||
| Reflection | | yes | |
|
| session | yes | yes | |
|
||||||
| session | | yes | |
|
| shmop | untested | | |
|
||||||
| shmop | | | |
|
| simplexml | untested | untested | |
|
||||||
| simplexml | | untested | |
|
| soap | untested | | |
|
||||||
| soap | | | |
|
| sockets | untested | | |
|
||||||
| sockets | | | |
|
| sqlite3 | untested | untested | |
|
||||||
| sqlite3 | | untested | |
|
|
||||||
| swow | | | |
|
| swow | | | |
|
||||||
| swoole | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
| swoole | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||||
| tokenizer | | yes | |
|
| tokenizer | yes | yes | |
|
||||||
| xml | | yes | |
|
| xml | yes | yes | |
|
||||||
| xmlreader | | untested | |
|
| xmlreader | untested | untested | |
|
||||||
| xmlwriter | | untested | |
|
| xmlwriter | untested | untested | |
|
||||||
| zip | | yes | |
|
| zip | untested | yes | |
|
||||||
| zlib | yes | yes | |
|
| zlib | yes | yes | |
|
||||||
|
|
||||||
## Additional Requirements
|
## Additional Requirements
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
|||||||
*/
|
*/
|
||||||
class ConsoleApplication extends Application
|
class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION = '2.0-alpha1';
|
public const VERSION = '2.0-alpha2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
|
|||||||
@ -172,10 +172,9 @@ abstract class BuilderBase
|
|||||||
* - BUILD_MICRO_BOTH:同时编译 micro 和 cli
|
* - BUILD_MICRO_BOTH:同时编译 micro 和 cli
|
||||||
*
|
*
|
||||||
* @param int $build_micro_rule 规则
|
* @param int $build_micro_rule 规则
|
||||||
* @param bool $with_clean 是否为新构建?
|
|
||||||
* @param bool $bloat 保留
|
* @param bool $bloat 保留
|
||||||
*/
|
*/
|
||||||
abstract public function buildPHP(int $build_micro_rule = BUILD_MICRO_NONE, bool $with_clean = false, bool $bloat = false);
|
abstract public function buildPHP(int $build_micro_rule = BUILD_MICRO_NONE, bool $bloat = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成依赖的扩展编译启用参数
|
* 生成依赖的扩展编译启用参数
|
||||||
|
|||||||
@ -278,6 +278,8 @@ class Extension
|
|||||||
} else {
|
} else {
|
||||||
$arg .= ' --disable-openssl --without-openssl';
|
$arg .= ' --disable-openssl --without-openssl';
|
||||||
}
|
}
|
||||||
|
// curl hook is buggy for static php
|
||||||
|
$arg .= ' --disable-swoole-curl';
|
||||||
}
|
}
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,7 @@ abstract class LibraryBase
|
|||||||
{
|
{
|
||||||
// 传入 true,表明直接编译
|
// 传入 true,表明直接编译
|
||||||
if ($force_build) {
|
if ($force_build) {
|
||||||
|
logger()->info('Building required library ' . static::NAME);
|
||||||
$this->build();
|
$this->build();
|
||||||
return BUILD_STATUS_OK;
|
return BUILD_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,17 +158,12 @@ class LinuxBuilder extends BuilderBase
|
|||||||
|
|
||||||
Patcher::patchPHPBeforeConfigure($this);
|
Patcher::patchPHPBeforeConfigure($this);
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
|
||||||
$this->set_x . ' && ' .
|
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
|
||||||
'./buildconf --force'
|
|
||||||
);
|
|
||||||
|
|
||||||
Patcher::patchPHPConfigure($this);
|
Patcher::patchPHPConfigure($this);
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
$this->set_x . ' && ' .
|
->exec(
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
'--prefix= ' .
|
'--prefix= ' .
|
||||||
'--with-valgrind=no ' .
|
'--with-valgrind=no ' .
|
||||||
@ -189,14 +184,8 @@ class LinuxBuilder extends BuilderBase
|
|||||||
|
|
||||||
file_put_contents('/tmp/comment', $this->note_section);
|
file_put_contents('/tmp/comment', $this->note_section);
|
||||||
|
|
||||||
if ($with_clean) {
|
// 清理
|
||||||
logger()->info('cleaning up');
|
$this->cleanMake();
|
||||||
f_passthru(
|
|
||||||
$this->set_x . ' && ' .
|
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
|
||||||
'make clean'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bloat) {
|
if ($bloat) {
|
||||||
logger()->info('bloat linking');
|
logger()->info('bloat linking');
|
||||||
@ -224,7 +213,7 @@ class LinuxBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phar_patched) {
|
if ($this->phar_patched) {
|
||||||
f_passthru('cd ' . SOURCE_PATH . '/php-src && patch -p1 -R < sapi/micro/patches/phar.patch');
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 -R < sapi/micro/patches/phar.patch');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,23 +222,22 @@ class LinuxBuilder extends BuilderBase
|
|||||||
*/
|
*/
|
||||||
public function buildCli(string $extra_libs, string $use_lld): void
|
public function buildCli(string $extra_libs, string $use_lld): void
|
||||||
{
|
{
|
||||||
f_passthru(
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
$this->set_x . ' && ' .
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
->exec(
|
||||||
'sed -i "s|//lib|/lib|g" Makefile && ' .
|
'make -j' . $this->concurrency .
|
||||||
"make -j{$this->concurrency} " .
|
|
||||||
' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' .
|
' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' .
|
||||||
"EXTRA_LIBS=\"{$extra_libs}\" " .
|
"EXTRA_LIBS=\"{$extra_libs}\" " .
|
||||||
"EXTRA_LDFLAGS_PROGRAM='{$use_lld}" .
|
"EXTRA_LDFLAGS_PROGRAM='{$use_lld} -all-static' " .
|
||||||
' -all-static' .
|
'cli'
|
||||||
"' " .
|
|
||||||
'cli && ' .
|
|
||||||
'cd sapi/cli && ' .
|
|
||||||
"{$this->cross_compile_prefix}objcopy --only-keep-debug php php.debug && " .
|
|
||||||
'elfedit --output-osabi linux php && ' .
|
|
||||||
"{$this->cross_compile_prefix}strip --strip-all php && " .
|
|
||||||
"{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php.debug --remove-section=.note php"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
|
||||||
|
->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug php php.debug")
|
||||||
|
->exec('elfedit --output-osabi linux php')
|
||||||
|
->exec("{$this->cross_compile_prefix}strip --strip-all php")
|
||||||
|
->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php.debug --remove-section=.note php");
|
||||||
|
$this->deployBinary(BUILD_TYPE_CLI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,39 +248,30 @@ class LinuxBuilder extends BuilderBase
|
|||||||
if ($this->getExt('phar')) {
|
if ($this->getExt('phar')) {
|
||||||
$this->phar_patched = true;
|
$this->phar_patched = true;
|
||||||
try {
|
try {
|
||||||
f_passthru('cd ' . SOURCE_PATH . '/php-src && patch -p1 < sapi/micro/patches/phar.patch');
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 < sapi/micro/patches/phar.patch');
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
||||||
$this->phar_patched = false;
|
$this->phar_patched = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = [
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
'EXTRA_CFLAGS' => quote('-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags))),
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
'EXTRA_LIBS' => quote($extra_libs),
|
->exec(
|
||||||
'EXTRA_LDFLAGS_PROGRAM' => quote("{$cflags} {$use_lld}" . ' -all-static', "'"),
|
|
||||||
'POST_MICRO_BUILD_COMMANDS' => quote(
|
|
||||||
"sh -xc '" .
|
|
||||||
'cd sapi/micro && ' .
|
|
||||||
"{$this->cross_compile_prefix}objcopy --only-keep-debug micro.sfx micro.sfx.debug && " .
|
|
||||||
'elfedit --output-osabi linux micro.sfx && ' .
|
|
||||||
"{$this->cross_compile_prefix}strip --strip-all micro.sfx && " .
|
|
||||||
"{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=micro.sfx.debug --remove-section=.note micro.sfx'"
|
|
||||||
),
|
|
||||||
];
|
|
||||||
$var_cmdline = '';
|
|
||||||
foreach ($vars as $k => $v) {
|
|
||||||
$var_cmdline .= $k . '=' . $v . ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
f_passthru(
|
|
||||||
$this->set_x . ' && ' .
|
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
|
||||||
'sed -i "s|//lib|/lib|g" Makefile && ' .
|
|
||||||
"make -j{$this->concurrency} " .
|
"make -j{$this->concurrency} " .
|
||||||
$var_cmdline .
|
'EXTRA_CFLAGS=' . quote('-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags))) . ' ' .
|
||||||
|
'EXTRA_LIBS=' . quote($extra_libs) . ' ' .
|
||||||
|
'EXTRA_LDFLAGS_PROGRAM=' . quote("{$cflags} {$use_lld}" . ' -all-static', "'") . ' ' .
|
||||||
'micro'
|
'micro'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')
|
||||||
|
->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug micro.sfx micro.sfx.debug")
|
||||||
|
->exec('elfedit --output-osabi linux micro.sfx')
|
||||||
|
->exec("{$this->cross_compile_prefix}strip --strip-all micro.sfx")
|
||||||
|
->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=micro.sfx.debug --remove-section=.note micro.sfx'");
|
||||||
|
|
||||||
|
$this->deployBinary(BUILD_TYPE_MICRO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -157,8 +157,7 @@ class SystemUtil
|
|||||||
|
|
||||||
public static function checkCCFlag(string $flag, string $cc): string
|
public static function checkCCFlag(string $flag, string $cc): string
|
||||||
{
|
{
|
||||||
$ret = 0;
|
[$ret] = shell()->execWithResult("echo | {$cc} -E -x c - {$flag}");
|
||||||
f_exec("echo | {$cc} -E -x c - {$flag}", $dummy, $ret);
|
|
||||||
if ($ret != 0) {
|
if ($ret != 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ abstract class LinuxLibraryBase extends LibraryBase
|
|||||||
{
|
{
|
||||||
// 传入 true,表明直接编译
|
// 传入 true,表明直接编译
|
||||||
if ($force_build) {
|
if ($force_build) {
|
||||||
|
logger()->info('Building required library ' . static::NAME);
|
||||||
$this->build();
|
$this->build();
|
||||||
return BUILD_STATUS_OK;
|
return BUILD_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,28 +32,28 @@ class brotli extends LinuxLibraryBase
|
|||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||||
f_passthru(
|
// 清理旧的编译文件
|
||||||
"{$this->builder->set_x} && " .
|
shell()->cd($this->source_dir)
|
||||||
"cd {$this->source_dir} && " .
|
->exec('rm -rf build')
|
||||||
'rm -rf build && ' .
|
->exec('mkdir -p build');
|
||||||
'mkdir -p build && ' .
|
// 使用 cmake 编译
|
||||||
'cd build && ' .
|
shell()->cd($this->source_dir . '/build')
|
||||||
"{$this->builder->configure_env} " . ' cmake ' .
|
->exec(
|
||||||
// '--debug-find ' .
|
$this->builder->configure_env . ' cmake ' .
|
||||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
'.. && ' .
|
'..'
|
||||||
"cmake --build . -j {$this->builder->concurrency} --target brotlicommon-static && " .
|
)
|
||||||
"cmake --build . -j {$this->builder->concurrency} --target brotlidec-static && " .
|
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlicommon-static")
|
||||||
"cmake --build . -j {$this->builder->concurrency} --target brotlienc-static && " .
|
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlidec-static")
|
||||||
'cp libbrotlidec-static.a ' . BUILD_LIB_PATH . ' && ' .
|
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlienc-static")
|
||||||
'cp libbrotlienc-static.a ' . BUILD_LIB_PATH . ' && ' .
|
->exec('cp libbrotlidec-static.a ' . BUILD_LIB_PATH)
|
||||||
'cp libbrotlicommon-static.a ' . BUILD_LIB_PATH . ' && ' .
|
->exec('cp libbrotlienc-static.a ' . BUILD_LIB_PATH)
|
||||||
'cp -r ../c/include/brotli ' . BUILD_INCLUDE_PATH
|
->exec('cp libbrotlicommon-static.a ' . BUILD_LIB_PATH)
|
||||||
);
|
->exec('cp -r ../c/include/brotli ' . BUILD_INCLUDE_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,11 @@ class bzip2 extends LinuxLibraryBase
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
f_passthru(
|
shell()
|
||||||
$this->builder->set_x . ' && ' .
|
->cd($this->source_dir)
|
||||||
"cd {$this->source_dir} && " .
|
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||||
"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")
|
||||||
"make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a" . ' && ' .
|
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||||
// make install may fail when cross-compiling, so we copy files.
|
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||||
'cp libbz2.a ' . BUILD_LIB_PATH . ' && ' .
|
|
||||||
'cp bzlib.h ' . BUILD_INCLUDE_PATH
|
|
||||||
);
|
|
||||||
// $this->makeFakePkgconfs();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,11 +76,8 @@ EOF
|
|||||||
$extra = '';
|
$extra = '';
|
||||||
// lib:openssl
|
// lib:openssl
|
||||||
$openssl = $this->builder->getLib('openssl');
|
$openssl = $this->builder->getLib('openssl');
|
||||||
if ($openssl instanceof LinuxLibraryBase) {
|
$use_openssl = $openssl instanceof LinuxLibraryBase ? 'ON' : 'OFF';
|
||||||
$extra .= '-DCURL_USE_OPENSSL=ON -DCURL_ENABLE_SSL=ON ';
|
$extra .= "-DCURL_USE_OPENSSL={$use_openssl} -DCURL_ENABLE_SSL={$use_openssl} ";
|
||||||
} else {
|
|
||||||
$extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
|
||||||
}
|
|
||||||
// lib:zlib
|
// lib:zlib
|
||||||
$zlib = $this->builder->getLib('zlib');
|
$zlib = $this->builder->getLib('zlib');
|
||||||
if ($zlib instanceof LinuxLibraryBase) {
|
if ($zlib instanceof LinuxLibraryBase) {
|
||||||
@ -140,14 +137,12 @@ EOF
|
|||||||
|
|
||||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||||
// compile!
|
// compile!
|
||||||
f_passthru(
|
shell()
|
||||||
$this->builder->set_x . ' && ' .
|
->cd($this->source_dir)
|
||||||
"cd {$this->source_dir} && " .
|
->exec('rm -rf build')
|
||||||
'rm -rf build && ' .
|
->exec('mkdir -p build')
|
||||||
'mkdir -p build && ' .
|
->cd($this->source_dir . '/build')
|
||||||
'cd build && ' .
|
->exec("{$this->builder->configure_env} cmake " .
|
||||||
"{$this->builder->configure_env} " . ' cmake ' .
|
|
||||||
// '--debug-find ' .
|
|
||||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||||
$extra .
|
$extra .
|
||||||
@ -155,9 +150,8 @@ EOF
|
|||||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
'.. && ' .
|
'..')
|
||||||
"make -j{$this->builder->concurrency} && " .
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
'make install DESTDIR="' . $destdir . '"'
|
->exec("make install DESTDIR='{$destdir}'");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/SPC/builder/linux/library/gmp.php
Normal file
28
src/SPC/builder/linux/library/gmp.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gmp is a template library class for unix
|
||||||
|
*/
|
||||||
|
class gmp extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,16 +35,15 @@ class libiconv extends LinuxLibraryBase
|
|||||||
{
|
{
|
||||||
[,,$destdir] = SEPARATED_PATH;
|
[,,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd($this->source_dir)
|
||||||
$this->builder->set_x . ' && ' .
|
->exec(
|
||||||
"cd {$this->source_dir} && " .
|
|
||||||
"{$this->builder->configure_env} ./configure " .
|
"{$this->builder->configure_env} ./configure " .
|
||||||
'--enable-static ' .
|
'--enable-static ' .
|
||||||
'--disable-shared ' .
|
'--disable-shared ' .
|
||||||
'--prefix= && ' . // use prefix=/
|
'--prefix='
|
||||||
'make clean && ' .
|
)
|
||||||
"make -j{$this->builder->concurrency} && " .
|
->exec('make clean')
|
||||||
'make install DESTDIR=' . $destdir
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
);
|
->exec('make install DESTDIR=' . $destdir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
64
src/SPC/builder/linux/library/libpng.php
Normal file
64
src/SPC/builder/linux/library/libpng.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||||
|
*
|
||||||
|
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||||
|
* software according to the terms and conditions of the
|
||||||
|
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
*
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* See the Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\util\Patcher;
|
||||||
|
|
||||||
|
class libpng extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
public const NAME = 'libpng';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public 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(
|
||||||
|
"{$this->builder->configure_env} ./configure " .
|
||||||
|
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||||
|
'--disable-shared ' .
|
||||||
|
'--enable-static ' .
|
||||||
|
'--enable-hardware-optimizations ' .
|
||||||
|
'--with-zlib-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||||
|
$optimizations .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
|
||||||
|
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH)
|
||||||
|
->cd(BUILD_LIB_PATH)
|
||||||
|
->exec('ln -sf libpng16.a libpng.a');
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/SPC/builder/linux/library/libssh2.php
Normal file
60
src/SPC/builder/linux/library/libssh2.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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 . '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/SPC/builder/linux/library/libuv.php
Normal file
29
src/SPC/builder/linux/library/libuv.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is a template library class for unix
|
||||||
|
*/
|
||||||
|
class libuv extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
public const NAME = 'libuv';
|
||||||
|
|
||||||
|
protected function build()
|
||||||
|
{
|
||||||
|
[,,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec('./autogen.sh')
|
||||||
|
->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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,34 +27,6 @@ class libxml2 extends LinuxLibraryBase
|
|||||||
{
|
{
|
||||||
public const NAME = 'libxml2';
|
public const NAME = 'libxml2';
|
||||||
|
|
||||||
protected array $static_libs = ['libxml2.a'];
|
|
||||||
|
|
||||||
protected array $headers = [
|
|
||||||
'libxml2',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected array $pkgconfs = [
|
|
||||||
'libxml-2.0.pc' => <<<'EOF'
|
|
||||||
exec_prefix=${prefix}
|
|
||||||
libdir=${exec_prefix}/lib
|
|
||||||
includedir=${prefix}/include
|
|
||||||
modules=1
|
|
||||||
|
|
||||||
Name: libXML
|
|
||||||
Version: 2.9.14
|
|
||||||
Description: libXML library version2.
|
|
||||||
Requires:
|
|
||||||
Libs: -L${libdir} -lxml2
|
|
||||||
Cflags: -I${includedir}/libxml2
|
|
||||||
EOF
|
|
||||||
];
|
|
||||||
|
|
||||||
protected array $dep_names = [
|
|
||||||
'icu' => true,
|
|
||||||
'xz' => true,
|
|
||||||
'zlib' => true,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
@ -66,12 +38,11 @@ EOF
|
|||||||
|
|
||||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd($this->source_dir)
|
||||||
$this->builder->set_x . ' && ' .
|
->exec('rm -rf build')
|
||||||
"cd {$this->source_dir} && " .
|
->exec('mkdir -p build')
|
||||||
'rm -rf build && ' .
|
->cd($this->source_dir . '/build')
|
||||||
'mkdir -p build && ' .
|
->exec(
|
||||||
'cd build && ' .
|
|
||||||
"{$this->builder->configure_env} " . ' cmake ' .
|
"{$this->builder->configure_env} " . ' cmake ' .
|
||||||
// '--debug-find ' .
|
// '--debug-find ' .
|
||||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||||
@ -88,17 +59,18 @@ EOF
|
|||||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||||
'.. && ' .
|
'..'
|
||||||
"cmake --build . -j {$this->builder->concurrency} && " .
|
)
|
||||||
'make install DESTDIR="' . $destdir . '"'
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||||
);
|
->exec('make install DESTDIR="' . $destdir . '"');
|
||||||
|
|
||||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) {
|
if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) {
|
||||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) {
|
if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) {
|
||||||
f_passthru('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"');
|
shell()->exec('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"');
|
||||||
}
|
}
|
||||||
$path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/libxml2/libxml');
|
$path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/libxml2/libxml');
|
||||||
$dst_path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/');
|
$dst_path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/');
|
||||||
f_passthru('mv "' . $path . '" "' . $dst_path . '"');
|
shell()->exec('mv "' . $path . '" "' . $dst_path . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
93
src/SPC/builder/linux/library/libyaml.php
Normal file
93
src/SPC/builder/linux/library/libyaml.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/SPC/builder/linux/library/libzip.php
Normal file
106
src/SPC/builder/linux/library/libzip.php
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
102
src/SPC/builder/linux/library/nghttp2.php
Normal file
102
src/SPC/builder/linux/library/nghttp2.php
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<?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 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, [
|
||||||
|
'zlib' => null,
|
||||||
|
'openssl' => null,
|
||||||
|
'libxml2' => null,
|
||||||
|
'libev' => null,
|
||||||
|
'libcares' => null,
|
||||||
|
'libngtcp2' => null,
|
||||||
|
'libnghttp3' => null,
|
||||||
|
'libbpf' => null,
|
||||||
|
'libevent-openssl' => null,
|
||||||
|
'jansson' => null,
|
||||||
|
'jemalloc' => null,
|
||||||
|
'systemd' => null,
|
||||||
|
'cunit' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
[,,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec(
|
||||||
|
"{$this->builder->configure_env} ./configure " .
|
||||||
|
'--enable-static ' .
|
||||||
|
'--disable-shared ' .
|
||||||
|
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||||
|
'--enable-lib-only ' .
|
||||||
|
'--with-boost=no ' .
|
||||||
|
$args . ' ' .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec("make install DESTDIR={$destdir}");
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/SPC/builder/linux/library/onig.php
Normal file
48
src/SPC/builder/linux/library/onig.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -28,53 +28,6 @@ class openssl extends LinuxLibraryBase
|
|||||||
{
|
{
|
||||||
public const NAME = 'openssl';
|
public const NAME = 'openssl';
|
||||||
|
|
||||||
protected array $static_libs = [
|
|
||||||
'libssl.a',
|
|
||||||
'libcrypto.a',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected array $headers = ['openssl'];
|
|
||||||
|
|
||||||
protected array $pkgconfs = [
|
|
||||||
'openssl.pc' => <<<'EOF'
|
|
||||||
exec_prefix=${prefix}
|
|
||||||
libdir=${prefix}/lib
|
|
||||||
includedir=${prefix}/include
|
|
||||||
|
|
||||||
Name: OpenSSL
|
|
||||||
Description: Secure Sockets Layer and cryptography libraries and tools
|
|
||||||
Version: 3.0.3
|
|
||||||
Requires: libssl libcrypto
|
|
||||||
EOF,
|
|
||||||
'libssl.pc' => <<<'EOF'
|
|
||||||
exec_prefix=${prefix}
|
|
||||||
libdir=${prefix}/lib
|
|
||||||
includedir=${prefix}/include
|
|
||||||
|
|
||||||
Name: OpenSSL-libssl
|
|
||||||
Description: Secure Sockets Layer and cryptography libraries
|
|
||||||
Version: 3.0.3
|
|
||||||
Requires.private: libcrypto
|
|
||||||
Libs: -L${libdir} -lssl
|
|
||||||
Cflags: -I${includedir}
|
|
||||||
EOF,
|
|
||||||
'libcrypto.pc' => <<<'EOF'
|
|
||||||
exec_prefix=${prefix}
|
|
||||||
libdir=${prefix}/lib
|
|
||||||
includedir=${prefix}/include
|
|
||||||
enginesdir=${libdir}/engines-3
|
|
||||||
|
|
||||||
Name: OpenSSL-libcrypto
|
|
||||||
Description: OpenSSL cryptography library
|
|
||||||
Version: 3.0.3
|
|
||||||
Libs: -L${libdir} -lcrypto
|
|
||||||
Libs.private: -lz -ldl -pthread
|
|
||||||
Cflags: -I${includedir}
|
|
||||||
EOF,
|
|
||||||
];
|
|
||||||
|
|
||||||
protected array $dep_names = ['zlib' => true];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
@ -107,21 +60,18 @@ EOF,
|
|||||||
|
|
||||||
$clang_postfix = SystemUtil::getCCType($this->builder->cc) === 'clang' ? '-clang' : '';
|
$clang_postfix = SystemUtil::getCCType($this->builder->cc) === 'clang' ? '-clang' : '';
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd($this->source_dir)
|
||||||
$this->builder->set_x . ' && ' .
|
->exec(
|
||||||
"cd {$this->source_dir} && " .
|
|
||||||
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
|
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
|
||||||
'--prefix=/ ' . // use prefix=/
|
'--prefix=/ ' .
|
||||||
"--libdir={$lib} " .
|
"--libdir={$lib} " .
|
||||||
'--static -static ' .
|
'--static -static ' .
|
||||||
"{$zlib_extra}" .
|
"{$zlib_extra}" .
|
||||||
'no-legacy ' .
|
'no-legacy ' .
|
||||||
"linux-{$this->builder->arch}{$clang_postfix} && " .
|
"linux-{$this->builder->arch}{$clang_postfix}"
|
||||||
'make clean && ' .
|
)
|
||||||
"make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\" && " .
|
->exec('make clean')
|
||||||
'make install_sw DESTDIR=' . $destdir
|
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||||
// remove liblegacy
|
->exec("make install_sw DESTDIR={$destdir}");
|
||||||
// 'ar t lib/libcrypto.a | grep -e \'^liblegacy-\' | xargs ar d lib/libcrypto.a'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
src/SPC/builder/linux/library/sqlite.php
Normal file
47
src/SPC/builder/linux/library/sqlite.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
56
src/SPC/builder/linux/library/xz.php
Normal file
56
src/SPC/builder/linux/library/xz.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,15 +33,14 @@ class zlib extends LinuxLibraryBase
|
|||||||
{
|
{
|
||||||
[,,$destdir] = SEPARATED_PATH;
|
[,,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
f_passthru(
|
shell()->cd($this->source_dir)
|
||||||
$this->builder->set_x . ' && ' .
|
->exec(
|
||||||
"cd {$this->source_dir} && " .
|
|
||||||
"{$this->builder->configure_env} ./configure " .
|
"{$this->builder->configure_env} ./configure " .
|
||||||
'--static ' .
|
'--static ' .
|
||||||
'--prefix= && ' . // use prefix=/
|
'--prefix='
|
||||||
'make clean && ' .
|
)
|
||||||
"make -j{$this->builder->concurrency} && " .
|
->exec('make clean')
|
||||||
'make install DESTDIR=' . $destdir
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
);
|
->exec("make install DESTDIR={$destdir}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/SPC/builder/linux/library/zstd.php
Normal file
45
src/SPC/builder/linux/library/zstd.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -127,7 +127,7 @@ class MacOSBuilder extends BuilderBase
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function buildPHP(int $build_micro_rule = BUILD_MICRO_NONE, bool $with_clean = false, bool $bloat = false): void
|
public function buildPHP(int $build_micro_rule = BUILD_MICRO_NONE, bool $bloat = false): void
|
||||||
{
|
{
|
||||||
$extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') ? '-lc++ ' : '');
|
$extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') ? '-lc++ ' : '');
|
||||||
if (!$bloat) {
|
if (!$bloat) {
|
||||||
@ -178,14 +178,7 @@ class MacOSBuilder extends BuilderBase
|
|||||||
$this->configure_env
|
$this->configure_env
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($with_clean) {
|
$this->cleanMake();
|
||||||
logger()->info('cleaning up');
|
|
||||||
f_passthru(
|
|
||||||
$this->set_x . ' && ' .
|
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
|
||||||
'make clean'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($build_micro_rule) {
|
switch ($build_micro_rule) {
|
||||||
case BUILD_MICRO_NONE:
|
case BUILD_MICRO_NONE:
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class SystemUtil
|
|||||||
*/
|
*/
|
||||||
public static function getCpuCount(): int
|
public static function getCpuCount(): int
|
||||||
{
|
{
|
||||||
f_exec('sysctl -n hw.ncpu', $output, $ret);
|
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu');
|
||||||
if ($ret !== 0) {
|
if ($ret !== 0) {
|
||||||
throw new RuntimeException('Failed to get cpu count');
|
throw new RuntimeException('Failed to get cpu count');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\traits;
|
namespace SPC\builder\traits;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
trait UnixBuilderTrait
|
trait UnixBuilderTrait
|
||||||
{
|
{
|
||||||
@ -60,23 +62,18 @@ trait UnixBuilderTrait
|
|||||||
{
|
{
|
||||||
logger()->info('running sanity check');
|
logger()->info('running sanity check');
|
||||||
if ($build_micro_rule !== BUILD_MICRO_ONLY) {
|
if ($build_micro_rule !== BUILD_MICRO_ONLY) {
|
||||||
f_exec(
|
[$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "echo \"hello\";"');
|
||||||
$this->set_x . ' && ' .
|
|
||||||
SOURCE_PATH . '/php-src/sapi/cli/php -r "echo \"hello\";"',
|
|
||||||
$output,
|
|
||||||
$ret
|
|
||||||
);
|
|
||||||
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
||||||
throw new RuntimeException('cli failed sanity check');
|
throw new RuntimeException('cli failed sanity check');
|
||||||
}
|
}
|
||||||
foreach ($this->exts as $ext) {
|
foreach ($this->exts as $ext) {
|
||||||
logger()->debug('checking ext: ' . $ext->getName());
|
logger()->debug('testing ext: ' . $ext->getName());
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri ' . $ext->getName(), false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check');
|
||||||
|
}
|
||||||
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) {
|
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) {
|
||||||
f_exec(
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php ' . ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php');
|
||||||
$this->set_x . ' && ' . SOURCE_PATH . '/php-src/sapi/cli/php ' . ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php',
|
|
||||||
$output,
|
|
||||||
$ret
|
|
||||||
);
|
|
||||||
if ($ret !== 0) {
|
if ($ret !== 0) {
|
||||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check');
|
throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check');
|
||||||
}
|
}
|
||||||
@ -93,10 +90,41 @@ trait UnixBuilderTrait
|
|||||||
'<?php echo "hello";'
|
'<?php echo "hello";'
|
||||||
);
|
);
|
||||||
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
||||||
f_exec(SOURCE_PATH . '/hello.exe', $output2, $ret);
|
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
||||||
if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') {
|
if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') {
|
||||||
throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']');
|
throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将编译好的二进制文件发布到 buildroot
|
||||||
|
*
|
||||||
|
* @param int $type 发布类型
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function deployBinary(int $type): bool
|
||||||
|
{
|
||||||
|
$src = match ($type) {
|
||||||
|
BUILD_TYPE_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
||||||
|
BUILD_TYPE_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
||||||
|
default => throw new RuntimeException('Deployment does not accept type ' . $type),
|
||||||
|
};
|
||||||
|
logger()->info('Deploying ' . ($type === BUILD_TYPE_CLI ? 'cli' : 'micro') . ' file');
|
||||||
|
FileSystem::createDir(BUILD_ROOT_PATH . '/bin');
|
||||||
|
shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '/bin/'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理编译好的文件
|
||||||
|
*
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function cleanMake(): void
|
||||||
|
{
|
||||||
|
logger()->info('cleaning up');
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,15 +62,15 @@ class BuildCliCommand extends BuildCommand
|
|||||||
// 执行扩展检测
|
// 执行扩展检测
|
||||||
$builder->proveExts($extensions);
|
$builder->proveExts($extensions);
|
||||||
// 构建
|
// 构建
|
||||||
$builder->buildPHP($rule, $input->getOption('with-clean'), $input->getOption('bloat'));
|
$builder->buildPHP($rule, $input->getOption('bloat'));
|
||||||
// 统计时间
|
// 统计时间
|
||||||
$time = round(microtime(true) - START_TIME, 3);
|
$time = round(microtime(true) - START_TIME, 3);
|
||||||
logger()->info('Build complete, used ' . $time . ' s !');
|
logger()->info('Build complete, used ' . $time . ' s !');
|
||||||
if ($rule !== BUILD_MICRO_ONLY) {
|
if ($rule !== BUILD_MICRO_ONLY) {
|
||||||
logger()->info('Static php binary path: ' . SOURCE_PATH . '/php-src/sapi/cli/php');
|
logger()->info('Static php binary path: ' . BUILD_ROOT_PATH . '/bin/php');
|
||||||
}
|
}
|
||||||
if ($rule !== BUILD_MICRO_NONE) {
|
if ($rule !== BUILD_MICRO_NONE) {
|
||||||
logger()->info('phpmicro binary path: ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx');
|
logger()->info('phpmicro binary path: ' . BUILD_ROOT_PATH . '/bin/micro.sfx');
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@ -228,6 +228,10 @@ class Downloader
|
|||||||
*/
|
*/
|
||||||
public static function fetchSource(string $name, array $source): void
|
public static function fetchSource(string $name, array $source): void
|
||||||
{
|
{
|
||||||
|
// 如果是 git 类型,且没有设置 path,那我就需要指定一下 path
|
||||||
|
if ($source['type'] === 'git' && !isset($source['path'])) {
|
||||||
|
$source['path'] = $name;
|
||||||
|
}
|
||||||
// 避免重复 fetch
|
// 避免重复 fetch
|
||||||
if (!isset($source['path']) && is_dir(FileSystem::convertPath(DOWNLOAD_PATH . "/{$name}")) || isset($source['path']) && is_dir(FileSystem::convertPath(SOURCE_PATH . "/{$source['path']}"))) {
|
if (!isset($source['path']) && is_dir(FileSystem::convertPath(DOWNLOAD_PATH . "/{$name}")) || isset($source['path']) && is_dir(FileSystem::convertPath(SOURCE_PATH . "/{$source['path']}"))) {
|
||||||
logger()->notice("{$name} source already extracted");
|
logger()->notice("{$name} source already extracted");
|
||||||
|
|||||||
@ -378,4 +378,11 @@ class FileSystem
|
|||||||
}
|
}
|
||||||
return $ret === 0;
|
return $ret === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createDir(string $path): void
|
||||||
|
{
|
||||||
|
if (!is_dir($path) && !mkdir($path, 0755, true) && !is_dir($path)) {
|
||||||
|
throw new FileSystemException(sprintf('无法建立目录:%s', $path));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
57
src/SPC/util/UnixShell.php
Normal file
57
src/SPC/util/UnixShell.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\util;
|
||||||
|
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use ZM\Logger\ConsoleColor;
|
||||||
|
|
||||||
|
class UnixShell
|
||||||
|
{
|
||||||
|
private ?string $cd = null;
|
||||||
|
|
||||||
|
private bool $debug;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->debug = defined('DEBUG_MODE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cd(string $dir): UnixShell
|
||||||
|
{
|
||||||
|
logger()->info('Entering dir: ' . $dir);
|
||||||
|
$c = clone $this;
|
||||||
|
$c->cd = $dir;
|
||||||
|
return $c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function exec(string $cmd): UnixShell
|
||||||
|
{
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd));
|
||||||
|
if ($this->cd !== null) {
|
||||||
|
$cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd;
|
||||||
|
}
|
||||||
|
if (!$this->debug) {
|
||||||
|
$cmd .= ' 1>/dev/null 2>&1';
|
||||||
|
}
|
||||||
|
f_passthru($cmd);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execWithResult(string $cmd, bool $with_log = true): array
|
||||||
|
{
|
||||||
|
if ($with_log) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd));
|
||||||
|
} else {
|
||||||
|
logger()->debug('Running command with result: ' . $cmd);
|
||||||
|
}
|
||||||
|
exec($cmd, $out, $code);
|
||||||
|
return [$code, $out];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -45,4 +45,8 @@ const BUILD_STATUS_OK = 0;
|
|||||||
const BUILD_STATUS_ALREADY = 1;
|
const BUILD_STATUS_ALREADY = 1;
|
||||||
const BUILD_STATUS_FAILED = 2;
|
const BUILD_STATUS_FAILED = 2;
|
||||||
|
|
||||||
|
// 编译类型
|
||||||
|
const BUILD_TYPE_CLI = 1;
|
||||||
|
const BUILD_TYPE_MICRO = 2;
|
||||||
|
|
||||||
ConsoleLogger::$date_format = 'H:i:s';
|
ConsoleLogger::$date_format = 'H:i:s';
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use SPC\util\UnixShell;
|
||||||
use ZM\Logger\ConsoleLogger;
|
use ZM\Logger\ConsoleLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,3 +96,8 @@ function f_mkdir(string $directory, int $permissions = 0777, bool $recursive = f
|
|||||||
logger()->debug('Making new directory ' . ($recursive ? 'recursive' : '') . ': ' . $directory);
|
logger()->debug('Making new directory ' . ($recursive ? 'recursive' : '') . ': ' . $directory);
|
||||||
return mkdir($directory, $permissions, $recursive);
|
return mkdir($directory, $permissions, $recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shell(): UnixShell
|
||||||
|
{
|
||||||
|
return new UnixShell();
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user