mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
add extra runtime objects for shared libraries built directly by php make too
This commit is contained in:
parent
fff23649cf
commit
01887d652c
@ -495,6 +495,7 @@
|
|||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"arg-type-windows": "with",
|
"arg-type-windows": "with",
|
||||||
|
"build-with-php": true,
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"openssl",
|
"openssl",
|
||||||
"zlib"
|
"zlib"
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use SPC\store\FileSystem;
|
|||||||
use SPC\toolchain\ToolchainManager;
|
use SPC\toolchain\ToolchainManager;
|
||||||
use SPC\toolchain\ZigToolchain;
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
class Extension
|
class Extension
|
||||||
{
|
{
|
||||||
@ -187,6 +188,19 @@ class Extension
|
|||||||
*/
|
*/
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
if (
|
||||||
|
PHP_OS_FAMILY === 'Linux' &&
|
||||||
|
$this->isBuildShared() &&
|
||||||
|
ToolchainManager::getToolchainClass() === ZigToolchain::class &&
|
||||||
|
($extra = (new ZigToolchain())->getExtraRuntimeObjects())
|
||||||
|
) {
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
$this->source_dir . '/Makefile',
|
||||||
|
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
|
||||||
|
"$1 {$extra}",
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class amqp extends Extension
|
|||||||
{
|
{
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
if (PHP_OS_FAMILY === 'Windows') {
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
|
||||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
|
||||||
@ -20,7 +21,7 @@ class amqp extends Extension
|
|||||||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
|
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
|
|||||||
@ -60,13 +60,14 @@ class curl extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
$extra_libs = getenv('SPC_EXTRA_LIBS');
|
$extra_libs = getenv('SPC_EXTRA_LIBS');
|
||||||
if ($this->builder instanceof WindowsBuilder && !str_contains($extra_libs, 'secur32.lib')) {
|
if ($this->builder instanceof WindowsBuilder && !str_contains($extra_libs, 'secur32.lib')) {
|
||||||
$extra_libs .= ' secur32.lib';
|
$extra_libs .= ' secur32.lib';
|
||||||
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs));
|
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function patchBeforeSharedConfigure(): bool
|
public function patchBeforeSharedConfigure(): bool
|
||||||
|
|||||||
@ -41,10 +41,12 @@ class event extends Extension
|
|||||||
*/
|
*/
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
// Prevent event extension compile error on macOS
|
// Prevent event extension compile error on macOS
|
||||||
if ($this->builder instanceof MacOSBuilder) {
|
if ($this->builder instanceof MacOSBuilder) {
|
||||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return $patched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ class grpc extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
parent::patchBeforeMake();
|
||||||
// add -Wno-strict-prototypes
|
// add -Wno-strict-prototypes
|
||||||
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -45,8 +45,9 @@ class imap extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) {
|
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) {
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lcrypt');
|
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lcrypt');
|
||||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class openssl extends Extension
|
|||||||
{
|
{
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
// patch openssl3 with php8.0 bug
|
// patch openssl3 with php8.0 bug
|
||||||
if ($this->builder->getPHPVersionID() < 80100) {
|
if ($this->builder->getPHPVersionID() < 80100) {
|
||||||
$openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c');
|
$openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c');
|
||||||
@ -20,7 +21,7 @@ class openssl extends Extension
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
|
|||||||
@ -34,6 +34,7 @@ class opentelemetry extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
parent::patchBeforeMake();
|
||||||
// add -Wno-strict-prototypes
|
// add -Wno-strict-prototypes
|
||||||
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ class password_argon2 extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
if ($this->builder->getLib('libsodium') !== null) {
|
if ($this->builder->getLib('libsodium') !== null) {
|
||||||
$extraLibs = getenv('SPC_EXTRA_LIBS');
|
$extraLibs = getenv('SPC_EXTRA_LIBS');
|
||||||
if ($extraLibs !== false) {
|
if ($extraLibs !== false) {
|
||||||
@ -36,8 +37,9 @@ class password_argon2 extends Extension
|
|||||||
);
|
);
|
||||||
$extraLibs = trim(preg_replace('/\s+/', ' ', $extraLibs)); // normalize spacing
|
$extraLibs = trim(preg_replace('/\s+/', ' ', $extraLibs)); // normalize spacing
|
||||||
f_putenv('SPC_EXTRA_LIBS=' . $extraLibs);
|
f_putenv('SPC_EXTRA_LIBS=' . $extraLibs);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class rdkafka extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
parent::patchBeforeMake();
|
||||||
// when compiling rdkafka with inline builds, it shows some errors, I don't know why.
|
// when compiling rdkafka with inline builds, it shows some errors, I don't know why.
|
||||||
FileSystem::replaceFileStr(
|
FileSystem::replaceFileStr(
|
||||||
SOURCE_PATH . '/php-src/ext/rdkafka/rdkafka.c',
|
SOURCE_PATH . '/php-src/ext/rdkafka/rdkafka.c',
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class swoole extends Extension
|
|||||||
{
|
{
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
if ($this->builder instanceof MacOSBuilder) {
|
if ($this->builder instanceof MacOSBuilder) {
|
||||||
// Fix swoole with event extension <util.h> conflict bug
|
// Fix swoole with event extension <util.h> conflict bug
|
||||||
$util_path = shell()->execWithResult('xcrun --show-sdk-path', false)[1][0] . '/usr/include/util.h';
|
$util_path = shell()->execWithResult('xcrun --show-sdk-path', false)[1][0] . '/usr/include/util.h';
|
||||||
@ -24,7 +25,7 @@ class swoole extends Extension
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getExtVersion(): ?string
|
public function getExtVersion(): ?string
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class xlswriter extends Extension
|
|||||||
|
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
$patched = parent::patchBeforeMake();
|
||||||
if (PHP_OS_FAMILY === 'Windows') {
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
// fix windows build with openssl extension duplicate symbol bug
|
// fix windows build with openssl extension duplicate symbol bug
|
||||||
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
|
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
|
||||||
@ -37,6 +38,6 @@ class xlswriter extends Extension
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return $patched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user