mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
fix openssl build with corrupted pkg-config file (#406)
* fix openssl build with corrupted pkg-config file * add test * fix linux openssl * add exec exit error counter for postgresql
This commit is contained in:
parent
c77dc1af6c
commit
99aadd3e73
@ -24,6 +24,7 @@ use SPC\builder\linux\SystemUtil;
|
|||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
class openssl extends LinuxLibraryBase
|
class openssl extends LinuxLibraryBase
|
||||||
{
|
{
|
||||||
@ -76,5 +77,15 @@ class openssl extends LinuxLibraryBase
|
|||||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||||
->exec("make install_sw DESTDIR={$destdir}");
|
->exec("make install_sw DESTDIR={$destdir}");
|
||||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||||
|
// patch for openssl 3.3.0+
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace SPC\builder\macos\library;
|
|||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
class openssl extends MacOSLibraryBase
|
class openssl extends MacOSLibraryBase
|
||||||
{
|
{
|
||||||
@ -58,5 +59,15 @@ class openssl extends MacOSLibraryBase
|
|||||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||||
->exec("make install_sw DESTDIR={$destdir}");
|
->exec("make install_sw DESTDIR={$destdir}");
|
||||||
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
||||||
|
// patch for openssl 3.3.0+
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||||
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,26 +27,31 @@ trait postgresql
|
|||||||
'libxslt' => 'libxslt',
|
'libxslt' => 'libxslt',
|
||||||
'icu' => 'icu-i18n',
|
'icu' => 'icu-i18n',
|
||||||
];
|
];
|
||||||
|
$error_exec_cnt = 0;
|
||||||
|
|
||||||
foreach ($optional_packages as $lib => $pkg) {
|
foreach ($optional_packages as $lib => $pkg) {
|
||||||
if ($this->getBuilder()->getLib($lib)) {
|
if ($this->getBuilder()->getLib($lib)) {
|
||||||
$packages .= ' ' . $pkg;
|
$packages .= ' ' . $pkg;
|
||||||
$output = shell()->execWithResult("pkg-config --static {$pkg}");
|
$output = shell()->execWithResult("pkg-config --static {$pkg}");
|
||||||
|
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||||
logger()->info(var_export($output[1], true));
|
logger()->info(var_export($output[1], true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}");
|
$output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}");
|
||||||
|
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||||
if (!empty($output[1][0])) {
|
if (!empty($output[1][0])) {
|
||||||
$cppflags = $output[1][0];
|
$cppflags = $output[1][0];
|
||||||
$envs .= " CPPFLAGS=\"{$cppflags}\"";
|
$envs .= " CPPFLAGS=\"{$cppflags}\"";
|
||||||
}
|
}
|
||||||
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
|
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
|
||||||
|
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||||
if (!empty($output[1][0])) {
|
if (!empty($output[1][0])) {
|
||||||
$ldflags = $output[1][0];
|
$ldflags = $output[1][0];
|
||||||
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
||||||
}
|
}
|
||||||
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
|
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
|
||||||
|
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||||
if (!empty($output[1][0])) {
|
if (!empty($output[1][0])) {
|
||||||
$libs = $output[1][0];
|
$libs = $output[1][0];
|
||||||
$libcpp = '';
|
$libcpp = '';
|
||||||
@ -55,6 +60,9 @@ trait postgresql
|
|||||||
}
|
}
|
||||||
$envs .= " LIBS=\"{$libs}{$libcpp}\" ";
|
$envs .= " LIBS=\"{$libs}{$libcpp}\" ";
|
||||||
}
|
}
|
||||||
|
if ($error_exec_cnt > 0) {
|
||||||
|
throw new RuntimeException('Failed to get pkg-config information!');
|
||||||
|
}
|
||||||
|
|
||||||
FileSystem::resetDir($this->source_dir . '/build');
|
FileSystem::resetDir($this->source_dir . '/build');
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'ds,simdjson',
|
'Linux', 'Darwin' => 'pgsql,intl,xml,openssl',
|
||||||
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson',
|
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) {
|
|||||||
// You can use `common`, `bulk`, `minimal` or `none`.
|
// You can use `common`, `bulk`, `minimal` or `none`.
|
||||||
// note: combination is only available for *nix platform. Windows must use `none` combination
|
// note: combination is only available for *nix platform. Windows must use `none` combination
|
||||||
$base_combination = match (PHP_OS_FAMILY) {
|
$base_combination = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'common',
|
'Linux', 'Darwin' => 'minimal',
|
||||||
'Windows' => 'none',
|
'Windows' => 'none',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user