Compare commits

...

12 Commits

Author SHA1 Message Date
crazywhalecc
f1eacac4fd
change extension count 2023-07-22 17:34:33 +08:00
crazywhalecc
4abe0064e6
add dev commands 2023-07-22 17:33:38 +08:00
crazywhalecc
cbc3adbec0
fix pgsql env problem 2023-07-22 16:29:46 +08:00
Jerry Ma
0902f80b46
Merge pull request #84 from jingjingxyk/pgsql
添加pgsql 库
2023-07-22 16:19:43 +08:00
crazywhalecc
47101d058b
reformat code 2023-07-22 16:12:12 +08:00
crazywhalecc
bc978ecbde
add macOS support for pgsql 2023-07-22 15:07:53 +08:00
jingjingxyk
085437e925 pgsql 禁用 依赖libzstd icu库 2023-07-01 18:04:42 +08:00
jingjingxyk
fa17a48483 pgsql 禁用 依赖libzstd icu库 2023-07-01 17:31:46 +08:00
jingjingxyk
78c1484570 解决debian 环境下 pgsql 构建共享库报错 2023-07-01 13:01:53 +08:00
jingjingxyk
9c2ea79bec update pgsql config 2023-06-30 21:00:49 +08:00
jingjingxyk
b7ffe3fd1f 添加pgsql 配置 2023-06-30 20:53:18 +08:00
jingjingxyk
dac14ae16e 添加pgsql 库 2023-06-30 20:36:51 +08:00
11 changed files with 206 additions and 6 deletions

View File

@ -16,7 +16,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
> 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.

View File

@ -16,7 +16,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions.
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]()
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
> 在项目发布最后一个 RC 版本后(可能不超过 5 个候选版),项目将会重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。

View File

@ -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": {

View File

@ -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": {

View File

@ -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"

View 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';
}

View 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';
}

View 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");
}
}

View 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;
}
}

View 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;
}
}

View File

@ -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]);