mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
1 Commits
shared
...
fix/postgr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e00814bfe |
19
.github/workflows/build-unix.yml
vendored
19
.github/workflows/build-unix.yml
vendored
@@ -46,10 +46,6 @@ on:
|
|||||||
description: Prefer pre-built binaries (reduce build time)
|
description: Prefer pre-built binaries (reduce build time)
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
with-suggested-libs:
|
|
||||||
description: Build with suggested libs
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
debug:
|
debug:
|
||||||
description: Show full build logs
|
description: Show full build logs
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -90,10 +86,6 @@ on:
|
|||||||
description: Prefer pre-built binaries (reduce build time)
|
description: Prefer pre-built binaries (reduce build time)
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
with-suggested-libs:
|
|
||||||
description: Include suggested libs
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
debug:
|
debug:
|
||||||
description: Show full build logs
|
description: Show full build logs
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -165,9 +157,6 @@ jobs:
|
|||||||
if [ ${{ inputs.prefer-pre-built }} == true ]; then
|
if [ ${{ inputs.prefer-pre-built }} == true ]; then
|
||||||
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
|
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
|
||||||
fi
|
fi
|
||||||
if [ ${{ inputs.with-suggested-libs }} == true ]; then
|
|
||||||
BUILD_CMD="$BUILD_CMD --with-suggested-libs"
|
|
||||||
fi
|
|
||||||
if [ ${{ inputs.build-cli }} == true ]; then
|
if [ ${{ inputs.build-cli }} == true ]; then
|
||||||
BUILD_CMD="$BUILD_CMD --build-cli"
|
BUILD_CMD="$BUILD_CMD --build-cli"
|
||||||
fi
|
fi
|
||||||
@@ -213,14 +202,6 @@ jobs:
|
|||||||
# if: ${{ failure() }}
|
# if: ${{ failure() }}
|
||||||
# uses: mxschmitt/action-tmate@v3
|
# uses: mxschmitt/action-tmate@v3
|
||||||
|
|
||||||
# Upload debug logs
|
|
||||||
- if: ${{ inputs.debug && failure() }}
|
|
||||||
name: "Upload build logs on failure"
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: spc-logs-${{ inputs.php-version }}-${{ inputs.os }}
|
|
||||||
path: log/*.log
|
|
||||||
|
|
||||||
# Upload cli executable
|
# Upload cli executable
|
||||||
- if: ${{ inputs.build-cli == true }}
|
- if: ${{ inputs.build-cli == true }}
|
||||||
name: "Upload PHP cli SAPI"
|
name: "Upload PHP cli SAPI"
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
|
|||||||
SPC_LIBC=musl
|
SPC_LIBC=musl
|
||||||
; uncomment to link libc dynamically on musl
|
; uncomment to link libc dynamically on musl
|
||||||
; SPC_MUSL_DYNAMIC=true
|
; SPC_MUSL_DYNAMIC=true
|
||||||
SPC_LINK_STATIC=true
|
|
||||||
|
|
||||||
; Recommended: specify your target here. Zig toolchain will be used.
|
; Recommended: specify your target here. Zig toolchain will be used.
|
||||||
; examples:
|
; examples:
|
||||||
@@ -98,7 +97,7 @@ LD=${SPC_LINUX_DEFAULT_LD}
|
|||||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||||
SPC_DEFAULT_C_FLAGS="-fPIC -Os"
|
SPC_DEFAULT_C_FLAGS="-fPIC -Os"
|
||||||
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
|
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
|
||||||
SPC_DEFAULT_LD_FLAGS="-Wl,--as-needed"
|
SPC_DEFAULT_LD_FLAGS=""
|
||||||
; upx executable path
|
; upx executable path
|
||||||
UPX_EXEC=${PKG_ROOT_PATH}/bin/upx
|
UPX_EXEC=${PKG_ROOT_PATH}/bin/upx
|
||||||
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
|
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
|
||||||
@@ -116,7 +115,7 @@ SPC_CMD_VAR_PHP_EMBED_TYPE="static"
|
|||||||
; EXTRA_CFLAGS for `configure` and `make` php
|
; EXTRA_CFLAGS for `configure` and `make` php
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
|
||||||
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
|
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS="-Wl,--as-needed"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
|
||||||
|
|
||||||
; optional, path to openssl conf. This affects where openssl will look for the default CA.
|
; optional, path to openssl conf. This affects where openssl will look for the default CA.
|
||||||
; default on Debian/Alpine: /etc/ssl, default on RHEL: /etc/pki/tls
|
; default on Debian/Alpine: /etc/ssl, default on RHEL: /etc/pki/tls
|
||||||
|
|||||||
@@ -303,9 +303,6 @@
|
|||||||
},
|
},
|
||||||
"krb5": {
|
"krb5": {
|
||||||
"source": "krb5",
|
"source": "krb5",
|
||||||
"target": [
|
|
||||||
"static"
|
|
||||||
],
|
|
||||||
"pkg-configs": [
|
"pkg-configs": [
|
||||||
"krb5-gssapi"
|
"krb5-gssapi"
|
||||||
],
|
],
|
||||||
@@ -376,15 +373,6 @@
|
|||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
"avif.lib"
|
"avif.lib"
|
||||||
],
|
|
||||||
"lib-depends": [
|
|
||||||
"libaom"
|
|
||||||
],
|
|
||||||
"lib-suggests": [
|
|
||||||
"libwebp",
|
|
||||||
"libjpeg",
|
|
||||||
"libxml2",
|
|
||||||
"libpng"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"libcares": {
|
"libcares": {
|
||||||
@@ -865,9 +853,6 @@
|
|||||||
},
|
},
|
||||||
"openssl": {
|
"openssl": {
|
||||||
"source": "openssl",
|
"source": "openssl",
|
||||||
"pkg-configs": [
|
|
||||||
"openssl"
|
|
||||||
],
|
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libssl.a",
|
"libssl.a",
|
||||||
"libcrypto.a"
|
"libcrypto.a"
|
||||||
@@ -980,11 +965,6 @@
|
|||||||
},
|
},
|
||||||
"unixodbc": {
|
"unixodbc": {
|
||||||
"source": "unixodbc",
|
"source": "unixodbc",
|
||||||
"pkg-configs": [
|
|
||||||
"odbc",
|
|
||||||
"odbccr",
|
|
||||||
"odbcinst"
|
|
||||||
],
|
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libodbc.a",
|
"libodbc.a",
|
||||||
"libodbccr.a",
|
"libodbccr.a",
|
||||||
@@ -1026,10 +1006,7 @@
|
|||||||
},
|
},
|
||||||
"zlib": {
|
"zlib": {
|
||||||
"source": "zlib",
|
"source": "zlib",
|
||||||
"pkg-configs": [
|
"static-libs-unix": [
|
||||||
"zlib"
|
|
||||||
],
|
|
||||||
"static-libs": [
|
|
||||||
"libz.a"
|
"libz.a"
|
||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
@@ -1042,15 +1019,14 @@
|
|||||||
},
|
},
|
||||||
"zstd": {
|
"zstd": {
|
||||||
"source": "zstd",
|
"source": "zstd",
|
||||||
"pkg-configs": [
|
|
||||||
"libzstd"
|
|
||||||
],
|
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libzstd.a"
|
"libzstd.a"
|
||||||
],
|
],
|
||||||
"static-libs-windows": [
|
"static-libs-windows": [
|
||||||
"zstd.lib",
|
[
|
||||||
"zstd_static.lib"
|
"zstd.lib",
|
||||||
|
"zstd_static.lib"
|
||||||
|
]
|
||||||
],
|
],
|
||||||
"headers-unix": [
|
"headers-unix": [
|
||||||
"zdict.h",
|
"zdict.h",
|
||||||
|
|||||||
@@ -361,7 +361,7 @@
|
|||||||
},
|
},
|
||||||
"gmp": {
|
"gmp": {
|
||||||
"type": "filelist",
|
"type": "filelist",
|
||||||
"url": "https://ftp.gnu.org/gnu/gmp/",
|
"url": "https://gmplib.org/download/gmp/",
|
||||||
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||||
"provide-pre-built": true,
|
"provide-pre-built": true,
|
||||||
"alt": {
|
"alt": {
|
||||||
@@ -526,7 +526,7 @@
|
|||||||
"libavif": {
|
"libavif": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "AOMediaCodec/libavif",
|
"repo": "AOMediaCodec/libavif",
|
||||||
"provide-pre-built": false,
|
"provide-pre-built": true,
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const string VERSION = '2.8.3';
|
public const string VERSION = '2.8.0';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ class Extension
|
|||||||
fn ($x) => $x->getStaticLibFiles(),
|
fn ($x) => $x->getStaticLibFiles(),
|
||||||
$this->getLibraryDependencies(recursive: true)
|
$this->getLibraryDependencies(recursive: true)
|
||||||
);
|
);
|
||||||
$libs = implode(' ', $ret);
|
return implode(' ', $ret);
|
||||||
return deduplicate_flags($libs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -365,31 +365,8 @@ abstract class LibraryBase
|
|||||||
|
|
||||||
protected function isLibraryInstalled(): bool
|
protected function isLibraryInstalled(): bool
|
||||||
{
|
{
|
||||||
$pkg_configs = Config::getLib(static::NAME, 'pkg-configs', []);
|
|
||||||
if (count($pkg_configs) !== 0) {
|
|
||||||
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
|
|
||||||
$search_paths = array_unique(array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path)));
|
|
||||||
|
|
||||||
foreach ($pkg_configs as $name) {
|
|
||||||
$found = false;
|
|
||||||
foreach ($search_paths as $path) {
|
|
||||||
if (file_exists($path . "/{$name}.pc")) {
|
|
||||||
$found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$found) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true; // allow using system dependencies if pkg_config_path is explicitly defined
|
|
||||||
}
|
|
||||||
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
|
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
|
||||||
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
|
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
|
||||||
$sharedLib = str_replace('.a', '.so', $name);
|
|
||||||
if (!getenv('SPC_LINK_STATIC') && file_exists(BUILD_LIB_PATH . "/{$sharedLib}")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -398,6 +375,20 @@ abstract class LibraryBase
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
|
||||||
|
$search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
|
||||||
|
foreach (Config::getLib(static::NAME, 'pkg-configs', []) as $name) {
|
||||||
|
$found = false;
|
||||||
|
foreach ($search_paths as $path) {
|
||||||
|
if (file_exists($path . "/{$name}.pc")) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (Config::getLib(static::NAME, 'bin', []) as $name) {
|
foreach (Config::getLib(static::NAME, 'bin', []) as $name) {
|
||||||
if (!file_exists(BUILD_BIN_PATH . "/{$name}")) {
|
if (!file_exists(BUILD_BIN_PATH . "/{$name}")) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -5,21 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
use SPC\builder\linux\SystemUtil;
|
|
||||||
use SPC\store\SourcePatcher;
|
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('ffi')]
|
#[CustomExt('ffi')]
|
||||||
class ffi extends Extension
|
class ffi extends Extension
|
||||||
{
|
{
|
||||||
public function patchBeforeBuildconf(): bool
|
|
||||||
{
|
|
||||||
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getOSRelease()['dist'] === 'centos') {
|
|
||||||
return SourcePatcher::patchFfiCentos7FixO3strncmp();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
{
|
{
|
||||||
return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals';
|
return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals';
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class pgsql extends Extension
|
|||||||
{
|
{
|
||||||
if ($this->builder->getPHPVersionID() >= 80400) {
|
if ($this->builder->getPHPVersionID() >= 80400) {
|
||||||
$libfiles = $this->getLibFilesString();
|
$libfiles = $this->getLibFilesString();
|
||||||
$libfiles = deduplicate_flags($libfiles);
|
$libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles);
|
||||||
$libfiles = clean_spaces($libfiles);
|
$libfiles = str_replace('.a', '', $libfiles);
|
||||||
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
||||||
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH .
|
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH .
|
||||||
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"';
|
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"';
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class openssl extends BSDLibraryBase
|
|||||||
|
|
||||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||||
->exec(
|
->exec(
|
||||||
"./Configure {$extra} " .
|
"./Configure no-shared {$extra} " .
|
||||||
'--prefix=/ ' . // use prefix=/
|
'--prefix=/ ' . // use prefix=/
|
||||||
"--libdir={$lib} " .
|
"--libdir={$lib} " .
|
||||||
'--openssldir=/etc/ssl ' .
|
'--openssldir=/etc/ssl ' .
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
||||||
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
|
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
|
||||||
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
|
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
|
||||||
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
|
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -317,7 +316,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
*/
|
*/
|
||||||
private function getMakeExtraVars(): array
|
private function getMakeExtraVars(): array
|
||||||
{
|
{
|
||||||
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
|
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
|
||||||
$static = SPCTarget::isStatic() ? '-all-static' : '';
|
$static = SPCTarget::isStatic() ? '-all-static' : '';
|
||||||
$lib = BUILD_LIB_PATH;
|
$lib = BUILD_LIB_PATH;
|
||||||
return array_filter([
|
return array_filter([
|
||||||
|
|||||||
@@ -35,13 +35,10 @@ class liburing extends LinuxLibraryBase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$shared = getenv('SPC_LINK_STATIC') ? 'ENABLE_SHARED=0' : 'ENABLE_SHARED=1';
|
|
||||||
$make
|
$make
|
||||||
->removeConfigureArgs(
|
->removeConfigureArgs(
|
||||||
'--enable-static',
|
|
||||||
'--disable-static',
|
|
||||||
'--enable-shared',
|
|
||||||
'--disable-shared',
|
'--disable-shared',
|
||||||
|
'--enable-static',
|
||||||
'--with-pic',
|
'--with-pic',
|
||||||
'--enable-pic',
|
'--enable-pic',
|
||||||
)
|
)
|
||||||
@@ -49,7 +46,7 @@ class liburing extends LinuxLibraryBase
|
|||||||
$use_libc ? '--use-libc' : '',
|
$use_libc ? '--use-libc' : '',
|
||||||
)
|
)
|
||||||
->configure()
|
->configure()
|
||||||
->make("library {$shared}", "install {$shared}", with_clean: false);
|
->make('library ENABLE_SHARED=0', 'install ENABLE_SHARED=0', with_clean: false);
|
||||||
|
|
||||||
$this->patchPkgconfPrefix();
|
$this->patchPkgconfPrefix();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,10 @@ class openssl extends LinuxLibraryBase
|
|||||||
// TODO: in v3 use the following: $openssl_dir ??= SystemUtil::getOSRelease()['dist'] === 'redhat' ? '/etc/pki/tls' : '/etc/ssl';
|
// TODO: in v3 use the following: $openssl_dir ??= SystemUtil::getOSRelease()['dist'] === 'redhat' ? '/etc/pki/tls' : '/etc/ssl';
|
||||||
$openssl_dir ??= '/etc/ssl';
|
$openssl_dir ??= '/etc/ssl';
|
||||||
$ex_lib = trim($ex_lib);
|
$ex_lib = trim($ex_lib);
|
||||||
$noShared = getenv('SPC_LINK_STATIC') ? 'no-shared' : '';
|
|
||||||
|
|
||||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||||
->exec(
|
->exec(
|
||||||
"./Configure {$noShared} {$extra} " .
|
"{$env} ./Configure no-shared {$extra} " .
|
||||||
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||||
'--libdir=' . BUILD_LIB_PATH . ' ' .
|
'--libdir=' . BUILD_LIB_PATH . ' ' .
|
||||||
"--openssldir={$openssl_dir} " .
|
"--openssldir={$openssl_dir} " .
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class openssl extends MacOSLibraryBase
|
|||||||
|
|
||||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||||
->exec(
|
->exec(
|
||||||
"./Configure {$extra} " .
|
"./Configure no-shared {$extra} " .
|
||||||
'--prefix=' . BUILD_ROOT_PATH . ' ' . // use prefix=/
|
'--prefix=' . BUILD_ROOT_PATH . ' ' . // use prefix=/
|
||||||
'--libdir=lib ' .
|
'--libdir=lib ' .
|
||||||
'--openssldir=/etc/ssl ' .
|
'--openssldir=/etc/ssl ' .
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ trait UnixLibraryTrait
|
|||||||
{
|
{
|
||||||
$libs = $include_self ? [$this] : [];
|
$libs = $include_self ? [$this] : [];
|
||||||
array_unshift($libs, ...array_values($this->getDependencies(recursive: true)));
|
array_unshift($libs, ...array_values($this->getDependencies(recursive: true)));
|
||||||
$config = new SPCConfigUtil($this->builder, options: ['libs_only_deps' => true]);
|
$config = new SPCConfigUtil($this->builder, options: ['libs_only_deps' => true, 'absolute_libs' => true]);
|
||||||
$res = $config->config(libraries: array_map(fn ($x) => $x->getName(), $libs));
|
$res = $config->config(libraries: array_map(fn ($x) => $x->getName(), $libs));
|
||||||
return $res['libs'];
|
return $res['libs'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace SPC\builder\traits;
|
|||||||
use SPC\exception\ExecutionException;
|
use SPC\exception\ExecutionException;
|
||||||
use SPC\exception\SPCInternalException;
|
use SPC\exception\SPCInternalException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\pkg\Zig;
|
|
||||||
use SPC\toolchain\ToolchainManager;
|
use SPC\toolchain\ToolchainManager;
|
||||||
use SPC\toolchain\ZigToolchain;
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\SPCTarget;
|
use SPC\util\SPCTarget;
|
||||||
@@ -74,10 +73,6 @@ trait UnixSystemUtilTrait
|
|||||||
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
|
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
|
||||||
}
|
}
|
||||||
// macOS/zig
|
// macOS/zig
|
||||||
// https://github.com/ziglang/zig/issues/24662
|
|
||||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
|
||||||
return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then
|
|
||||||
}
|
|
||||||
if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
return "-Wl,-exported_symbols_list,{$symbol_file}";
|
return "-Wl,-exported_symbols_list,{$symbol_file}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,7 +365,6 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$frankenphpAppPath = $this->getOption('with-frankenphp-app');
|
$frankenphpAppPath = $this->getOption('with-frankenphp-app');
|
||||||
|
|
||||||
if ($frankenphpAppPath) {
|
if ($frankenphpAppPath) {
|
||||||
$frankenphpAppPath = trim($frankenphpAppPath, "\"'");
|
|
||||||
if (!is_dir($frankenphpAppPath)) {
|
if (!is_dir($frankenphpAppPath)) {
|
||||||
throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}");
|
throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}");
|
||||||
}
|
}
|
||||||
@@ -456,7 +455,6 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
||||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
|
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
|
||||||
'-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' .
|
|
||||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||||
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
||||||
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ trait brotli
|
|||||||
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlidec.pc', 'Libs: -L${libdir} -lbrotlidec', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon');
|
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlidec.pc', 'Libs: -L${libdir} -lbrotlidec', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon');
|
||||||
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlienc.pc', 'Libs: -L${libdir} -lbrotlienc', 'Libs: -L${libdir} -lbrotlienc -lbrotlicommon');
|
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlienc.pc', 'Libs: -L${libdir} -lbrotlienc', 'Libs: -L${libdir} -lbrotlienc -lbrotlicommon');
|
||||||
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists(BUILD_BIN_PATH . '/brotli')) {
|
if (file_exists(BUILD_BIN_PATH . '/brotli')) {
|
||||||
unlink(BUILD_BIN_PATH . '/brotli');
|
unlink(BUILD_BIN_PATH . '/brotli');
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
use SPC\util\executor\UnixCMakeExecutor;
|
use SPC\util\executor\UnixCMakeExecutor;
|
||||||
use SPC\util\SPCConfigUtil;
|
|
||||||
|
|
||||||
trait curl
|
trait curl
|
||||||
{
|
{
|
||||||
@@ -13,13 +12,6 @@ trait curl
|
|||||||
{
|
{
|
||||||
shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
||||||
|
|
||||||
$linkerFlags = null;
|
|
||||||
if ($this->builder->getLib('krb5') && !getenv('SPC_LINK_STATIC')) {
|
|
||||||
$util = new SPCConfigUtil($this->builder, ['libs_only_deps' => true]);
|
|
||||||
$config = $util->config(libraries: ['krb5']);
|
|
||||||
$linkerFlags = $config['ldflags'] . ' -Wl,--whole-archive -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lkrb5support -Wl,--no-whole-archive -Wl,--no-undefined';
|
|
||||||
}
|
|
||||||
|
|
||||||
UnixCMakeExecutor::create($this)
|
UnixCMakeExecutor::create($this)
|
||||||
->optionalLib('openssl', '-DCURL_USE_OPENSSL=ON -DCURL_CA_BUNDLE=OFF -DCURL_CA_PATH=OFF -DCURL_CA_FALLBACK=ON', '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF')
|
->optionalLib('openssl', '-DCURL_USE_OPENSSL=ON -DCURL_CA_BUNDLE=OFF -DCURL_CA_PATH=OFF -DCURL_CA_FALLBACK=ON', '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF')
|
||||||
->optionalLib('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
->optionalLib('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
||||||
@@ -37,7 +29,6 @@ trait curl
|
|||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DBUILD_CURL_EXE=OFF',
|
'-DBUILD_CURL_EXE=OFF',
|
||||||
'-DBUILD_LIBCURL_DOCS=OFF',
|
'-DBUILD_LIBCURL_DOCS=OFF',
|
||||||
$linkerFlags ? "-DCMAKE_SHARED_LINKER_FLAGS='{$linkerFlags}'" : null
|
|
||||||
)
|
)
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
|
|||||||
@@ -40,16 +40,6 @@ trait krb5
|
|||||||
->appendEnv($extraEnv)
|
->appendEnv($extraEnv)
|
||||||
->optionalLib('ldap', '--with-ldap', '--without-ldap')
|
->optionalLib('ldap', '--with-ldap', '--without-ldap')
|
||||||
->optionalLib('libedit', '--with-libedit', '--without-libedit')
|
->optionalLib('libedit', '--with-libedit', '--without-libedit')
|
||||||
->removeConfigureArgs(
|
|
||||||
'--enable-static',
|
|
||||||
'--disable-static',
|
|
||||||
'--enable-shared',
|
|
||||||
'--disable-shared'
|
|
||||||
)
|
|
||||||
->addConfigureArgs(
|
|
||||||
'--enable-static',
|
|
||||||
'--disable-shared'
|
|
||||||
)
|
|
||||||
->configure(...$args)
|
->configure(...$args)
|
||||||
->make();
|
->make();
|
||||||
$this->patchPkgconfPrefix([
|
$this->patchPkgconfPrefix([
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
trait libargon2
|
trait libargon2
|
||||||
{
|
{
|
||||||
protected function build()
|
protected function build()
|
||||||
@@ -15,6 +17,12 @@ trait libargon2
|
|||||||
|
|
||||||
$this->patchPkgconfPrefix(['libargon2.pc']);
|
$this->patchPkgconfPrefix(['libargon2.pc']);
|
||||||
|
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists(BUILD_BIN_PATH . '/argon2')) {
|
if (file_exists(BUILD_BIN_PATH . '/argon2')) {
|
||||||
unlink(BUILD_BIN_PATH . '/argon2');
|
unlink(BUILD_BIN_PATH . '/argon2');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ trait libavif
|
|||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
UnixCMakeExecutor::create($this)
|
UnixCMakeExecutor::create($this)
|
||||||
->optionalLib('libaom', '-DAVIF_CODEC_AOM=SYSTEM', '-DAVIF_CODEC_AOM=OFF')
|
|
||||||
->optionalLib('libsharpyuv', '-DAVIF_LIBSHARPYUV=SYSTEM', '-DAVIF_LIBSHARPYUV=OFF')
|
|
||||||
->optionalLib('libjpeg', '-DAVIF_JPEG=SYSTEM', '-DAVIF_JPEG=OFF')
|
|
||||||
->optionalLib('libxml2', '-DAVIF_LIBXML2=SYSTEM', '-DAVIF_LIBXML2=OFF')
|
|
||||||
->optionalLib('libpng', '-DAVIF_LIBPNG=SYSTEM', '-DAVIF_LIBPNG=OFF')
|
|
||||||
->addConfigureArgs('-DAVIF_LIBYUV=OFF')
|
->addConfigureArgs('-DAVIF_LIBYUV=OFF')
|
||||||
->build();
|
->build();
|
||||||
// patch pkgconfig
|
// patch pkgconfig
|
||||||
|
|||||||
@@ -27,5 +27,11 @@ trait liblz4
|
|||||||
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
$this->patchPkgconfPrefix(['liblz4.pc']);
|
$this->patchPkgconfPrefix(['liblz4.pc']);
|
||||||
|
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ trait libuuid
|
|||||||
{
|
{
|
||||||
UnixCMakeExecutor::create($this)->toStep(2)->build();
|
UnixCMakeExecutor::create($this)->toStep(2)->build();
|
||||||
copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a');
|
copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a');
|
||||||
copy($this->source_dir . '/build/libuuid.so', BUILD_LIB_PATH . '/libuuid.so');
|
|
||||||
FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid');
|
FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid');
|
||||||
copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h');
|
copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h');
|
||||||
$pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in');
|
$pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in');
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ trait libuv
|
|||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
UnixCMakeExecutor::create($this)
|
UnixCMakeExecutor::create($this)
|
||||||
->addConfigureArgs('-DLIBUV_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'))
|
->addConfigureArgs('-DLIBUV_BUILD_SHARED=OFF')
|
||||||
->build();
|
->build();
|
||||||
// patch pkgconfig
|
// patch pkgconfig
|
||||||
$this->patchPkgconfPrefix(['libuv-static.pc']);
|
$this->patchPkgconfPrefix(['libuv-static.pc']);
|
||||||
|
|||||||
@@ -6,29 +6,10 @@ namespace SPC\builder\unix\library;
|
|||||||
|
|
||||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\toolchain\ToolchainManager;
|
|
||||||
use SPC\toolchain\ZigToolchain;
|
|
||||||
use SPC\util\executor\UnixCMakeExecutor;
|
use SPC\util\executor\UnixCMakeExecutor;
|
||||||
|
|
||||||
trait libxml2
|
trait libxml2
|
||||||
{
|
{
|
||||||
public function patchBeforeBuild(): bool
|
|
||||||
{
|
|
||||||
if (ToolchainManager::getToolchainClass() !== ZigToolchain::class) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$patched = (bool) FileSystem::replaceFileStr(
|
|
||||||
$this->source_dir . '/configure.ac',
|
|
||||||
'AX_APPEND_FLAG([-Wl,--version-script=], [VERSION_SCRIPT_FLAGS])',
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
return $patched || FileSystem::replaceFileStr(
|
|
||||||
$this->source_dir . '/CMakeLists.txt',
|
|
||||||
'target_link_options(LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")',
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function build(): void
|
public function build(): void
|
||||||
{
|
{
|
||||||
$cmake = UnixCMakeExecutor::create($this)
|
$cmake = UnixCMakeExecutor::create($this)
|
||||||
@@ -39,6 +20,7 @@ trait libxml2
|
|||||||
"-DZLIB_INCLUDE_DIR={$this->getIncludeDir()}",
|
"-DZLIB_INCLUDE_DIR={$this->getIncludeDir()}",
|
||||||
'-DLIBXML2_WITH_ZLIB=OFF',
|
'-DLIBXML2_WITH_ZLIB=OFF',
|
||||||
)
|
)
|
||||||
|
->optionalLib('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA'))
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DLIBXML2_WITH_ICONV=ON',
|
'-DLIBXML2_WITH_ICONV=ON',
|
||||||
'-DLIBXML2_WITH_ICU=OFF', // optional, but discouraged: https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/README.md
|
'-DLIBXML2_WITH_ICU=OFF', // optional, but discouraged: https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/README.md
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ trait mimalloc
|
|||||||
{
|
{
|
||||||
$cmake = UnixCMakeExecutor::create($this)
|
$cmake = UnixCMakeExecutor::create($this)
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DMI_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'),
|
'-DMI_BUILD_SHARED=OFF',
|
||||||
'-DMI_BUILD_OBJECT=OFF',
|
'-DMI_BUILD_OBJECT=OFF',
|
||||||
'-DMI_INSTALL_TOPLEVEL=ON',
|
'-DMI_INSTALL_TOPLEVEL=ON',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,16 +4,28 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\PkgConfigUtil;
|
use SPC\util\PkgConfigUtil;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
trait postgresql
|
trait postgresql
|
||||||
{
|
{
|
||||||
public function patchBeforeBuild(): bool
|
public function patchBeforeBuild(): bool
|
||||||
{
|
{
|
||||||
if (!getenv('SPC_LINK_STATIC')) {
|
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
|
||||||
return false;
|
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
|
||||||
|
try {
|
||||||
|
// FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
"{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
|
||||||
|
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
|
||||||
|
'#if defined(__linux__) && !defined(HWCAP_CRC32)'
|
||||||
|
);
|
||||||
|
} catch (FileSystemException) {
|
||||||
|
// allow file not-existence to make it compatible with old and new version
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
|
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
|
||||||
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
|
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
|
||||||
@@ -95,11 +107,11 @@ trait postgresql
|
|||||||
->exec('make -C src/interfaces/libpq install');
|
->exec('make -C src/interfaces/libpq install');
|
||||||
|
|
||||||
// remove dynamic libs
|
// remove dynamic libs
|
||||||
if (getenv('SPC_LINK_STATIC')) {
|
shell()->cd($this->source_dir . '/build')
|
||||||
shell()->cd($this->source_dir . '/build')
|
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*")
|
||||||
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*")
|
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so")
|
||||||
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
|
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
|
||||||
}
|
|
||||||
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');
|
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ trait tidy
|
|||||||
->setBuildDir("{$this->source_dir}/build-dir")
|
->setBuildDir("{$this->source_dir}/build-dir")
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DSUPPORT_CONSOLE_APP=OFF',
|
'-DSUPPORT_CONSOLE_APP=OFF',
|
||||||
'-DBUILD_SHARED_LIB=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON')
|
'-DBUILD_SHARED_LIB=OFF'
|
||||||
);
|
);
|
||||||
if (version_compare(get_cmake_version(), '4.0.0', '>=')) {
|
if (version_compare(get_cmake_version(), '4.0.0', '>=')) {
|
||||||
$cmake->addConfigureArgs('-DCMAKE_POLICY_VERSION_MINIMUM=3.5');
|
$cmake->addConfigureArgs('-DCMAKE_POLICY_VERSION_MINIMUM=3.5');
|
||||||
|
|||||||
@@ -10,14 +10,7 @@ trait xz
|
|||||||
{
|
{
|
||||||
public function build(): void
|
public function build(): void
|
||||||
{
|
{
|
||||||
$make = UnixAutoconfExecutor::create($this);
|
UnixAutoconfExecutor::create($this)
|
||||||
if (!getenv('SPC_LINK_STATIC')) {
|
|
||||||
// liblzma can only build one of static or shared at a time
|
|
||||||
$make
|
|
||||||
->removeConfigureArgs('--enable-static')
|
|
||||||
->addConfigureArgs('--disable-static');
|
|
||||||
}
|
|
||||||
$make
|
|
||||||
->configure(
|
->configure(
|
||||||
'--disable-scripts',
|
'--disable-scripts',
|
||||||
'--disable-doc',
|
'--disable-doc',
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ trait zlib
|
|||||||
{
|
{
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : '';
|
UnixAutoconfExecutor::create($this)->exec("./configure --static --prefix={$this->getBuildRootPath()}")->make();
|
||||||
UnixAutoconfExecutor::create($this)->exec("./configure {$static} --prefix={$this->getBuildRootPath()}")->make();
|
|
||||||
$this->patchPkgconfPrefix(['zlib.pc']);
|
$this->patchPkgconfPrefix(['zlib.pc']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ trait zstd
|
|||||||
->setBuildDir("{$this->source_dir}/build/cmake/build")
|
->setBuildDir("{$this->source_dir}/build/cmake/build")
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DZSTD_BUILD_STATIC=ON',
|
'-DZSTD_BUILD_STATIC=ON',
|
||||||
'-DZSTD_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'),
|
'-DZSTD_BUILD_SHARED=OFF',
|
||||||
)
|
)
|
||||||
->build();
|
->build();
|
||||||
$this->patchPkgconfPrefix();
|
$this->patchPkgconfPrefix(['libzstd.pc']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class openssl extends WindowsLibraryBase
|
|||||||
->execWithWrapper(
|
->execWithWrapper(
|
||||||
$this->builder->makeSimpleWrapper($this->perl),
|
$this->builder->makeSimpleWrapper($this->perl),
|
||||||
'Configure zlib VC-WIN64A ' .
|
'Configure zlib VC-WIN64A ' .
|
||||||
|
'no-shared ' .
|
||||||
'--prefix=' . quote(BUILD_ROOT_PATH) . ' ' .
|
'--prefix=' . quote(BUILD_ROOT_PATH) . ' ' .
|
||||||
'--with-zlib-lib=' . quote(BUILD_LIB_PATH) . ' ' .
|
'--with-zlib-lib=' . quote(BUILD_LIB_PATH) . ' ' .
|
||||||
'--with-zlib-include=' . quote(BUILD_INCLUDE_PATH) . ' ' .
|
'--with-zlib-include=' . quote(BUILD_INCLUDE_PATH) . ' ' .
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class SPCConfigCommand extends BaseCommand
|
|||||||
$util = new SPCConfigUtil(options: [
|
$util = new SPCConfigUtil(options: [
|
||||||
'no_php' => $this->getOption('no-php'),
|
'no_php' => $this->getOption('no-php'),
|
||||||
'libs_only_deps' => $this->getOption('libs-only-deps'),
|
'libs_only_deps' => $this->getOption('libs-only-deps'),
|
||||||
|
'absolute_libs' => $this->getOption('absolute-libs'),
|
||||||
]);
|
]);
|
||||||
$config = $util->config($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
$config = $util->config($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class SourcePatcher
|
|||||||
FileSystem::addSourceExtractHook('swoole', [__CLASS__, 'patchSwoole']);
|
FileSystem::addSourceExtractHook('swoole', [__CLASS__, 'patchSwoole']);
|
||||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']);
|
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']);
|
||||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']);
|
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']);
|
||||||
// FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']);
|
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']);
|
||||||
FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']);
|
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class GoXcaddy extends CustomPackage
|
|||||||
public function fetch(string $name, bool $force = false, ?array $config = null): void
|
public function fetch(string $name, bool $force = false, ?array $config = null): void
|
||||||
{
|
{
|
||||||
$pkgroot = PKG_ROOT_PATH;
|
$pkgroot = PKG_ROOT_PATH;
|
||||||
$go_exec = "{$pkgroot}/go-xcaddy/bin/go";
|
$go_exec = "{$pkgroot}/{$name}/bin/go";
|
||||||
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy";
|
$xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy";
|
||||||
if ($force) {
|
if ($force) {
|
||||||
FileSystem::removeDir("{$pkgroot}/{$name}");
|
FileSystem::removeDir("{$pkgroot}/{$name}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,11 @@ namespace SPC\store\source;
|
|||||||
|
|
||||||
use JetBrains\PhpStorm\ArrayShape;
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
use SPC\exception\DownloaderException;
|
use SPC\exception\DownloaderException;
|
||||||
use SPC\exception\SPCException;
|
|
||||||
use SPC\store\Downloader;
|
use SPC\store\Downloader;
|
||||||
|
|
||||||
class PhpSource extends CustomSourceBase
|
class PhpSource extends CustomSourceBase
|
||||||
{
|
{
|
||||||
public const string NAME = 'php-src';
|
public const NAME = 'php-src';
|
||||||
|
|
||||||
public const array WEB_PHP_DOMAINS = [
|
|
||||||
'https://www.php.net',
|
|
||||||
'https://phpmirror.static-php.dev',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
|
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
|
||||||
{
|
{
|
||||||
@@ -34,26 +28,21 @@ class PhpSource extends CustomSourceBase
|
|||||||
#[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])]
|
#[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])]
|
||||||
public function getLatestPHPInfo(string $major_version): array
|
public function getLatestPHPInfo(string $major_version): array
|
||||||
{
|
{
|
||||||
foreach (self::WEB_PHP_DOMAINS as $domain) {
|
// 查找最新的小版本号
|
||||||
try {
|
$info = json_decode(Downloader::curlExec(
|
||||||
$info = json_decode(Downloader::curlExec(
|
url: "https://www.php.net/releases/index.php?json&version={$major_version}",
|
||||||
url: "{$domain}/releases/index.php?json&version={$major_version}",
|
retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0
|
||||||
retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0
|
), true);
|
||||||
), true);
|
if (!isset($info['version'])) {
|
||||||
if (!isset($info['version'])) {
|
throw new DownloaderException("Version {$major_version} not found.");
|
||||||
throw new DownloaderException("Version {$major_version} not found.");
|
|
||||||
}
|
|
||||||
$version = $info['version'];
|
|
||||||
return [
|
|
||||||
'type' => 'url',
|
|
||||||
'url' => "{$domain}/distributions/php-{$version}.tar.xz",
|
|
||||||
];
|
|
||||||
} catch (SPCException) {
|
|
||||||
logger()->warning('Failed to fetch latest PHP version for major version {$major_version} from {$domain}, trying next mirror if available.');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// exception if all mirrors failed
|
|
||||||
throw new DownloaderException("Failed to fetch latest PHP version for major version {$major_version} from all tried mirrors.");
|
$version = $info['version'];
|
||||||
|
|
||||||
|
// 从官网直接下载
|
||||||
|
return [
|
||||||
|
'type' => 'url',
|
||||||
|
'url' => "https://www.php.net/distributions/php-{$version}.tar.xz",
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,10 +58,6 @@ class ZigToolchain implements ToolchainInterface
|
|||||||
GlobalEnvManager::putenv("SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS={$extraCflags}");
|
GlobalEnvManager::putenv("SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS={$extraCflags}");
|
||||||
GlobalEnvManager::putenv('RANLIB=zig-ranlib');
|
GlobalEnvManager::putenv('RANLIB=zig-ranlib');
|
||||||
GlobalEnvManager::putenv('OBJCOPY=zig-objcopy');
|
GlobalEnvManager::putenv('OBJCOPY=zig-objcopy');
|
||||||
$defaultLdFlags = getenv('SPC_DEFAULT_LD_FLAGS') ?: '';
|
|
||||||
if (!str_contains($defaultLdFlags, '-Wl,--undefined-version') && !getenv('SPC_LINK_STATIC')) {
|
|
||||||
GlobalEnvManager::putenv("SPC_DEFAULT_LD_FLAGS={$defaultLdFlags} -Wl,--undefined-version");
|
|
||||||
}
|
|
||||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||||
if (!str_contains($extra_libs, '-lunwind')) {
|
if (!str_contains($extra_libs, '-lunwind')) {
|
||||||
// Add unwind library if not already present
|
// Add unwind library if not already present
|
||||||
|
|||||||
@@ -38,13 +38,6 @@ class GlobalEnvManager
|
|||||||
|
|
||||||
// Define env vars for unix
|
// Define env vars for unix
|
||||||
if (is_unix()) {
|
if (is_unix()) {
|
||||||
if (!getenv('SPC_LINK_STATIC')) {
|
|
||||||
$ldLibPath = getenv('LD_LIBRARY_PATH=' . BUILD_LIB_PATH);
|
|
||||||
if ($ldLibPath) {
|
|
||||||
$ldLibPath = ":{$ldLibPath}";
|
|
||||||
}
|
|
||||||
self::putenv('LD_LIBRARY_PATH=' . BUILD_LIB_PATH . $ldLibPath);
|
|
||||||
}
|
|
||||||
self::addPathIfNotExists(BUILD_BIN_PATH);
|
self::addPathIfNotExists(BUILD_BIN_PATH);
|
||||||
self::addPathIfNotExists(PKG_ROOT_PATH . '/bin');
|
self::addPathIfNotExists(PKG_ROOT_PATH . '/bin');
|
||||||
$pkgConfigPath = getenv('PKG_CONFIG_PATH');
|
$pkgConfigPath = getenv('PKG_CONFIG_PATH');
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ class PkgConfigUtil
|
|||||||
* @param string $pkg_config_str .pc file string, accepts multiple files
|
* @param string $pkg_config_str .pc file string, accepts multiple files
|
||||||
* @return string CFLAGS string, e.g. "-Wno-implicit-int-float-conversion ..."
|
* @return string CFLAGS string, e.g. "-Wno-implicit-int-float-conversion ..."
|
||||||
*/
|
*/
|
||||||
public static function getCflags(string $pkg_config_str, string $extra = '--static'): string
|
public static function getCflags(string $pkg_config_str): string
|
||||||
{
|
{
|
||||||
// get other things
|
// get other things
|
||||||
$result = self::execWithResult("pkg-config {$extra} --cflags-only-other {$pkg_config_str}");
|
$result = self::execWithResult("pkg-config --static --cflags-only-other {$pkg_config_str}");
|
||||||
return trim($result);
|
return trim($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,14 +75,14 @@ class PkgConfigUtil
|
|||||||
* @param string $pkg_config_str .pc file string, accepts multiple files
|
* @param string $pkg_config_str .pc file string, accepts multiple files
|
||||||
* @return array Unique libs array, e.g. [-lz, -lxml, ...]
|
* @return array Unique libs array, e.g. [-lz, -lxml, ...]
|
||||||
*/
|
*/
|
||||||
public static function getLibsArray(string $pkg_config_str, string $extra = '--static'): array
|
public static function getLibsArray(string $pkg_config_str): array
|
||||||
{
|
{
|
||||||
// Use this instead of shell() to avoid unnecessary outputs
|
// Use this instead of shell() to avoid unnecessary outputs
|
||||||
$result = self::execWithResult("pkg-config {$extra} --libs-only-l {$pkg_config_str}");
|
$result = self::execWithResult("pkg-config --static --libs-only-l {$pkg_config_str}");
|
||||||
$libs = explode(' ', trim($result));
|
$libs = explode(' ', trim($result));
|
||||||
|
|
||||||
// get other things
|
// get other things
|
||||||
$result = self::execWithResult("pkg-config {$extra} --libs-only-other {$pkg_config_str}");
|
$result = self::execWithResult("pkg-config --static --libs-only-other {$pkg_config_str}");
|
||||||
// convert libxxx.a to -L{path} -lxxx
|
// convert libxxx.a to -L{path} -lxxx
|
||||||
$exp = explode(' ', trim($result));
|
$exp = explode(' ', trim($result));
|
||||||
foreach ($exp as $item) {
|
foreach ($exp as $item) {
|
||||||
|
|||||||
@@ -20,10 +20,13 @@ class SPCConfigUtil
|
|||||||
|
|
||||||
private bool $libs_only_deps;
|
private bool $libs_only_deps;
|
||||||
|
|
||||||
|
private bool $absolute_libs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{
|
* @param array{
|
||||||
* no_php?: bool,
|
* no_php?: bool,
|
||||||
* libs_only_deps?: bool
|
* libs_only_deps?: bool,
|
||||||
|
* absolute_libs?: bool
|
||||||
* } $options Options pass to spc-config
|
* } $options Options pass to spc-config
|
||||||
*/
|
*/
|
||||||
public function __construct(?BuilderBase $builder = null, array $options = [])
|
public function __construct(?BuilderBase $builder = null, array $options = [])
|
||||||
@@ -33,6 +36,7 @@ class SPCConfigUtil
|
|||||||
}
|
}
|
||||||
$this->no_php = $options['no_php'] ?? false;
|
$this->no_php = $options['no_php'] ?? false;
|
||||||
$this->libs_only_deps = $options['libs_only_deps'] ?? false;
|
$this->libs_only_deps = $options['libs_only_deps'] ?? false;
|
||||||
|
$this->absolute_libs = $options['absolute_libs'] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +77,7 @@ class SPCConfigUtil
|
|||||||
ob_get_clean();
|
ob_get_clean();
|
||||||
$ldflags = $this->getLdflagsString();
|
$ldflags = $this->getLdflagsString();
|
||||||
$cflags = $this->getIncludesString($libraries);
|
$cflags = $this->getIncludesString($libraries);
|
||||||
$libs = $this->getLibsString($libraries);
|
$libs = $this->getLibsString($libraries, !$this->absolute_libs);
|
||||||
|
|
||||||
// additional OS-specific libraries (e.g. macOS -lresolv)
|
// additional OS-specific libraries (e.g. macOS -lresolv)
|
||||||
if ($extra_libs = SPCTarget::getRuntimeLibs()) {
|
if ($extra_libs = SPCTarget::getRuntimeLibs()) {
|
||||||
@@ -235,8 +239,7 @@ class SPCConfigUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pc_cflags = implode(' ', $pc);
|
$pc_cflags = implode(' ', $pc);
|
||||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : '';
|
if ($pc_cflags !== '' && ($pc_cflags = PkgConfigUtil::getCflags($pc_cflags)) !== '') {
|
||||||
if ($pc_cflags !== '' && ($pc_cflags = PkgConfigUtil::getCflags($pc_cflags, $static)) !== '') {
|
|
||||||
$arr = explode(' ', $pc_cflags);
|
$arr = explode(' ', $pc_cflags);
|
||||||
$arr = array_unique($arr);
|
$arr = array_unique($arr);
|
||||||
$arr = array_filter($arr, fn ($x) => !str_starts_with($x, 'SHELL:-Xarch_'));
|
$arr = array_filter($arr, fn ($x) => !str_starts_with($x, 'SHELL:-Xarch_'));
|
||||||
@@ -253,7 +256,7 @@ class SPCConfigUtil
|
|||||||
return '-L' . BUILD_LIB_PATH;
|
return '-L' . BUILD_LIB_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLibsString(array $libraries): string
|
private function getLibsString(array $libraries, bool $use_short_libs = true): string
|
||||||
{
|
{
|
||||||
$lib_names = [];
|
$lib_names = [];
|
||||||
$frameworks = [];
|
$frameworks = [];
|
||||||
@@ -261,11 +264,6 @@ class SPCConfigUtil
|
|||||||
foreach ($libraries as $library) {
|
foreach ($libraries as $library) {
|
||||||
// add pkg-configs libs
|
// add pkg-configs libs
|
||||||
$pkg_configs = Config::getLib($library, 'pkg-configs', []);
|
$pkg_configs = Config::getLib($library, 'pkg-configs', []);
|
||||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : null;
|
|
||||||
if (!$static) {
|
|
||||||
$target = Config::getLib($library, 'target');
|
|
||||||
$static = $target && !in_array('shared', $target) ? '--static' : '';
|
|
||||||
}
|
|
||||||
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
|
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
|
||||||
$search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
|
$search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
|
||||||
foreach ($pkg_configs as $file) {
|
foreach ($pkg_configs as $file) {
|
||||||
@@ -282,14 +280,14 @@ class SPCConfigUtil
|
|||||||
$pkg_configs = implode(' ', $pkg_configs);
|
$pkg_configs = implode(' ', $pkg_configs);
|
||||||
if ($pkg_configs !== '') {
|
if ($pkg_configs !== '') {
|
||||||
// static libs with dependencies come in reverse order, so reverse this too
|
// static libs with dependencies come in reverse order, so reverse this too
|
||||||
$pc_libs = array_reverse(PkgConfigUtil::getLibsArray($static, $pkg_configs));
|
$pc_libs = array_reverse(PkgConfigUtil::getLibsArray($pkg_configs));
|
||||||
$lib_names = [...$lib_names, ...$pc_libs];
|
$lib_names = [...$lib_names, ...$pc_libs];
|
||||||
}
|
}
|
||||||
// convert all static-libs to short names
|
// convert all static-libs to short names
|
||||||
$libs = array_reverse(Config::getLib($library, 'static-libs', []));
|
$libs = array_reverse(Config::getLib($library, 'static-libs', []));
|
||||||
foreach ($libs as $lib) {
|
foreach ($libs as $lib) {
|
||||||
// check file existence
|
// check file existence
|
||||||
if (!file_exists(BUILD_LIB_PATH . "/{$lib}") && getenv('SPC_LINK_STATIC')) {
|
if (!file_exists(BUILD_LIB_PATH . "/{$lib}")) {
|
||||||
throw new WrongUsageException("Library file '{$lib}' for lib [{$library}] does not exist in '" . BUILD_LIB_PATH . "'. Please build it first.");
|
throw new WrongUsageException("Library file '{$lib}' for lib [{$library}] does not exist in '" . BUILD_LIB_PATH . "'. Please build it first.");
|
||||||
}
|
}
|
||||||
$lib_names[] = $this->getShortLibName($lib);
|
$lib_names[] = $this->getShortLibName($lib);
|
||||||
@@ -318,8 +316,8 @@ class SPCConfigUtil
|
|||||||
if (in_array('imap', $libraries) && SPCTarget::getLibc() === 'glibc') {
|
if (in_array('imap', $libraries) && SPCTarget::getLibc() === 'glibc') {
|
||||||
$lib_names[] = '-lcrypt';
|
$lib_names[] = '-lcrypt';
|
||||||
}
|
}
|
||||||
if (getenv('SPC_LINK_STATIC')) {
|
if (!$use_short_libs) {
|
||||||
$lib_names = array_map(fn ($l) => $this->getStaticLibname($l), $lib_names);
|
$lib_names = array_map(fn ($l) => $this->getFullLibName($l), $lib_names);
|
||||||
}
|
}
|
||||||
return implode(' ', $lib_names);
|
return implode(' ', $lib_names);
|
||||||
}
|
}
|
||||||
@@ -333,7 +331,7 @@ class SPCConfigUtil
|
|||||||
return '-l' . substr($lib, 3, -2);
|
return '-l' . substr($lib, 3, -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStaticLibname(string $lib)
|
private function getFullLibName(string $lib)
|
||||||
{
|
{
|
||||||
if (!str_starts_with($lib, '-l')) {
|
if (!str_starts_with($lib, '-l')) {
|
||||||
return $lib;
|
return $lib;
|
||||||
@@ -341,7 +339,7 @@ class SPCConfigUtil
|
|||||||
$libname = substr($lib, 2);
|
$libname = substr($lib, 2);
|
||||||
$staticLib = BUILD_LIB_PATH . '/' . "lib{$libname}.a";
|
$staticLib = BUILD_LIB_PATH . '/' . "lib{$libname}.a";
|
||||||
if (file_exists($staticLib)) {
|
if (file_exists($staticLib)) {
|
||||||
return "-l:lib{$libname}.a";
|
return $staticLib;
|
||||||
}
|
}
|
||||||
return $lib;
|
return $lib;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
|
|
||||||
protected array $configure_args = [];
|
protected array $configure_args = [];
|
||||||
|
|
||||||
|
protected array $ignore_args = [];
|
||||||
|
|
||||||
public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library)
|
public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library)
|
||||||
{
|
{
|
||||||
parent::__construct($library);
|
parent::__construct($library);
|
||||||
$this->initShell();
|
$this->initShell();
|
||||||
$this->configure_args = $this->getDefaultConfigureArgs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,12 +29,19 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
*/
|
*/
|
||||||
public function configure(...$args): static
|
public function configure(...$args): static
|
||||||
{
|
{
|
||||||
$args = array_merge($args, $this->configure_args);
|
// remove all the ignored args
|
||||||
|
$args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args);
|
||||||
|
$args = array_diff($args, $this->ignore_args);
|
||||||
$configure_args = implode(' ', $args);
|
$configure_args = implode(' ', $args);
|
||||||
|
|
||||||
return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}"));
|
return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigureArgsString(): string
|
||||||
|
{
|
||||||
|
return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run make
|
* Run make
|
||||||
*
|
*
|
||||||
@@ -103,7 +111,7 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
*/
|
*/
|
||||||
public function removeConfigureArgs(...$args): static
|
public function removeConfigureArgs(...$args): static
|
||||||
{
|
{
|
||||||
$this->configure_args = array_diff($this->configure_args, $args);
|
$this->ignore_args = [...$this->ignore_args, ...$args];
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +133,8 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
private function getDefaultConfigureArgs(): array
|
private function getDefaultConfigureArgs(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'--disable-shared',
|
||||||
'--enable-static',
|
'--enable-static',
|
||||||
getenv('SPC_LINK_STATIC') ? '--disable-shared' : '--enable-shared',
|
|
||||||
"--prefix={$this->library->getBuildRootPath()}",
|
"--prefix={$this->library->getBuildRootPath()}",
|
||||||
'--with-pic',
|
'--with-pic',
|
||||||
'--enable-pic',
|
'--enable-pic',
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class UnixCMakeExecutor extends Executor
|
|||||||
'-DCMAKE_INSTALL_LIBDIR=lib',
|
'-DCMAKE_INSTALL_LIBDIR=lib',
|
||||||
'-DCMAKE_INSTALL_INCLUDEDIR=include',
|
'-DCMAKE_INSTALL_INCLUDEDIR=include',
|
||||||
'-DPOSITION_INDEPENDENT_CODE=ON',
|
'-DPOSITION_INDEPENDENT_CODE=ON',
|
||||||
'-DBUILD_SHARED_LIBS=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'),
|
'-DBUILD_SHARED_LIBS=OFF',
|
||||||
"-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}",
|
"-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ $test_os = [
|
|||||||
// 'macos-15', // bin/spc for arm64
|
// 'macos-15', // bin/spc for arm64
|
||||||
// 'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
// 'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
||||||
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
||||||
'ubuntu-24.04', // bin/spc for x86_64
|
// 'ubuntu-24.04', // bin/spc for x86_64
|
||||||
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||||
'ubuntu-24.04-arm', // bin/spc for arm64
|
'ubuntu-24.04-arm', // bin/spc for arm64
|
||||||
// 'windows-2022', // .\bin\spc.ps1
|
// 'windows-2022', // .\bin\spc.ps1
|
||||||
|
|||||||
Reference in New Issue
Block a user