mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Compare commits
12 Commits
a2cb5165d3
...
f1eacac4fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1eacac4fd | ||
|
|
4abe0064e6 | ||
|
|
cbc3adbec0 | ||
|
|
0902f80b46 | ||
|
|
47101d058b | ||
|
|
bc978ecbde | ||
|
|
085437e925 | ||
|
|
fa17a48483 | ||
|
|
78c1484570 | ||
|
|
9c2ea79bec | ||
|
|
b7ffe3fd1f | ||
|
|
dac14ae16e |
@ -16,7 +16,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
|
||||
> After the project releases the last RC version (maybe no more than 5 candidate releases), the project will rename the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects.
|
||||
|
||||
@ -16,7 +16,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
|
||||
> 在项目发布最后一个 RC 版本后(可能不超过 5 个候选版),项目将会重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。
|
||||
|
||||
@ -211,12 +211,19 @@
|
||||
},
|
||||
"pdo_pgsql": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
"arg-type": "with-prefix",
|
||||
"ext-depends": [
|
||||
"pdo"
|
||||
],
|
||||
"lib-depends": [
|
||||
"pq"
|
||||
"postgresql"
|
||||
]
|
||||
},
|
||||
"pgsql": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"postgresql"
|
||||
]
|
||||
},
|
||||
"pdo_sqlite": {
|
||||
|
||||
@ -381,7 +381,16 @@
|
||||
"postgresql": {
|
||||
"source": "postgresql",
|
||||
"static-libs-unix": [
|
||||
"libpg.a"
|
||||
"libpq.a",
|
||||
"libpgport.a",
|
||||
"libpgcommon.a"
|
||||
],
|
||||
"lib-depends": [
|
||||
"libiconv",
|
||||
"libxml2",
|
||||
"openssl",
|
||||
"zlib",
|
||||
"readline"
|
||||
]
|
||||
},
|
||||
"pthreads4w": {
|
||||
|
||||
@ -318,7 +318,8 @@
|
||||
}
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "custom",
|
||||
"type": "url",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYRIGHT"
|
||||
|
||||
12
src/SPC/builder/linux/library/postgresql.php
Normal file
12
src/SPC/builder/linux/library/postgresql.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class postgresql extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\postgresql;
|
||||
|
||||
public const NAME = 'postgresql';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/postgresql.php
Normal file
12
src/SPC/builder/macos/library/postgresql.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class postgresql extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\postgresql;
|
||||
|
||||
public const NAME = 'postgresql';
|
||||
}
|
||||
89
src/SPC/builder/unix/library/postgresql.php
Normal file
89
src/SPC/builder/unix/library/postgresql.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait postgresql
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build()
|
||||
{
|
||||
$builddir = BUILD_ROOT_PATH;
|
||||
$env = $this->builder->configure_env;
|
||||
$envs = $env;
|
||||
$packages = 'openssl zlib readline libxml-2.0'; // icu-uc icu-io icu-i18n libzstd
|
||||
|
||||
$pkgconfig_executable = $builddir . '/bin/pkg-config';
|
||||
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages);
|
||||
if (!empty($output[1][0])) {
|
||||
$cppflags = $output[1][0];
|
||||
$envs .= " CPPFLAGS=\"{$cppflags}\"";
|
||||
}
|
||||
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages);
|
||||
if (!empty($output[1][0])) {
|
||||
$ldflags = $output[1][0];
|
||||
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
||||
}
|
||||
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages);
|
||||
if (!empty($output[1][0])) {
|
||||
$libs = $output[1][0];
|
||||
$envs .= " LIBS=\"{$libs}\" ";
|
||||
}
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
|
||||
# 有静态链接配置 参考文件: src/interfaces/libpq/Makefile
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile')
|
||||
->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib')
|
||||
->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib');
|
||||
|
||||
// configure
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$envs} ../configure " .
|
||||
"--prefix={$builddir} " .
|
||||
'--disable-thread-safety ' .
|
||||
'--enable-coverage=no ' .
|
||||
'--with-ssl=openssl ' .
|
||||
'--with-readline ' .
|
||||
'--with-libxml ' .
|
||||
'--without-icu ' .
|
||||
'--without-ldap ' .
|
||||
'--without-libxslt ' .
|
||||
'--without-lz4 ' .
|
||||
'--without-zstd ' .
|
||||
'--without-perl ' .
|
||||
'--without-python ' .
|
||||
'--without-pam ' .
|
||||
'--without-ldap ' .
|
||||
'--without-bonjour ' .
|
||||
'--without-tcl '
|
||||
);
|
||||
|
||||
// build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec($envs . ' make -C src/bin/pg_config install')
|
||||
->exec($envs . ' make -C src/include install')
|
||||
->exec($envs . ' make -C src/common install')
|
||||
->exec($envs . ' make -C src/backend/port install')
|
||||
->exec($envs . ' make -C src/port install')
|
||||
->exec($envs . ' make -C src/backend/libpq install')
|
||||
->exec($envs . ' make -C src/interfaces/libpq install');
|
||||
|
||||
// remove dynamic libs
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec("rm -rf {$builddir}/lib/*.so.*")
|
||||
->exec("rm -rf {$builddir}/lib/*.so")
|
||||
->exec("rm -rf {$builddir}/lib/*.dylib");
|
||||
}
|
||||
}
|
||||
24
src/SPC/command/dev/AllExtCommand.php
Normal file
24
src/SPC/command/dev/AllExtCommand.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\command\dev;
|
||||
|
||||
use SPC\command\BaseCommand;
|
||||
use SPC\store\Config;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand('dev:ext-all', 'Dev command')]
|
||||
class AllExtCommand extends BaseCommand
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->output->writeln(implode(',', array_keys(Config::getExts())));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
43
src/SPC/command/dev/ExtInfoCommand.php
Normal file
43
src/SPC/command/dev/ExtInfoCommand.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\command\dev;
|
||||
|
||||
use SPC\command\BaseCommand;
|
||||
use SPC\store\Config;
|
||||
use SPC\util\DependencyUtil;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
#[AsCommand('dev:ext-info', 'Dev command')]
|
||||
class ExtInfoCommand extends BaseCommand
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->addArgument('extensions', InputArgument::REQUIRED, 'The extension name you need to get info');
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions'))));
|
||||
|
||||
// 根据提供的扩展列表获取依赖库列表并编译
|
||||
foreach ($extensions as $extension) {
|
||||
$this->output->writeln('<comment>[ ' . $extension . ' ]</comment>');
|
||||
[, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]);
|
||||
$lib_suggests = Config::getExt($extension, 'lib-suggests', []);
|
||||
$ext_suggests = Config::getExt($extension, 'ext-suggests', []);
|
||||
$this->output->writeln("<info>lib-depends:\t" . implode(', ', $libraries) . '</info>');
|
||||
$this->output->writeln("<info>lib-suggests:\t" . implode(', ', $lib_suggests) . '</info>');
|
||||
$this->output->writeln("<info>ext-depends:\t" . implode(',', $not_included) . '</info>');
|
||||
$this->output->writeln("<info>ext-suggests:\t" . implode(', ', $ext_suggests) . '</info>');
|
||||
if (Config::getExt($extension, 'unix-only', false)) {
|
||||
$this->output->writeln("<info>Unix only:\ttrue</info>");
|
||||
}
|
||||
$this->output->writeln('');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -88,6 +88,9 @@ class SourcePatcher
|
||||
if ($ssh2 = $builder->getExt('ssh2')) {
|
||||
$patch[] = ['ssh2 patch', '/-lssh2/', $ssh2->getLibFilesString()];
|
||||
}
|
||||
if ($pgsql = $builder->getExt('pgsql')) {
|
||||
$patch[] = ['pgsql patch', '/-lpq/', $pgsql->getLibFilesString()];
|
||||
}
|
||||
$patch[] = ['disable capstone', '/have_capstone="yes"/', 'have_capstone="no"'];
|
||||
foreach ($patch as $item) {
|
||||
logger()->info('Patching configure: ' . $item[0]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user