mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
apply suggestions
This commit is contained in:
parent
b6a1182876
commit
a68212672b
@ -235,7 +235,7 @@ class Extension
|
||||
$ret = '';
|
||||
foreach ($order as $ext) {
|
||||
if ($ext instanceof Extension && $ext->isBuildShared()) {
|
||||
if (Config::getExt($ext->getName(), 'zend_extension', false) === true) {
|
||||
if (Config::getExt($ext->getName(), 'zend-extension', false) === true) {
|
||||
$ret .= " -d \"zend_extension={$ext->getName()}\"";
|
||||
} else {
|
||||
$ret .= " -d \"extension={$ext->getName()}\"";
|
||||
@ -371,6 +371,7 @@ class Extension
|
||||
}
|
||||
$env = [
|
||||
'CFLAGS' => $config['cflags'],
|
||||
'CXXFLAGS' => $config['cflags'],
|
||||
'LDFLAGS' => $config['ldflags'],
|
||||
'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs,
|
||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||
@ -485,6 +486,11 @@ class Extension
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists(0, $deps)) {
|
||||
$zero = [0 => $deps[0]];
|
||||
unset($deps[0]);
|
||||
return $zero + $deps;
|
||||
}
|
||||
return $deps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class curl extends Extension
|
||||
{
|
||||
logger()->info('patching before-configure for curl checks');
|
||||
$file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])";
|
||||
$files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4');
|
||||
$files = FileSystem::readFile($this->source_dir . '/config.m4');
|
||||
$file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [
|
||||
save_old_LDFLAGS=$LDFLAGS
|
||||
ac_stuff="$5"
|
||||
@ -41,7 +41,7 @@ class curl extends Extension
|
||||
$4
|
||||
])dnl
|
||||
])';
|
||||
file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2);
|
||||
file_put_contents($this->source_dir . '/config.m4', $file1 . "\n" . $files . "\n" . $file2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class curl extends Extension
|
||||
|
||||
public function patchBeforeSharedConfigure(): bool
|
||||
{
|
||||
$file = SOURCE_PATH . '/php-src/ext/curl/config.m4';
|
||||
$file = $this->source_dir . '/config.m4';
|
||||
$content = FileSystem::readFile($file);
|
||||
|
||||
// Inject patch before it
|
||||
|
||||
@ -30,6 +30,6 @@ class dom extends Extension
|
||||
|
||||
public function getWindowsConfigureArg($shared = false): string
|
||||
{
|
||||
return '--with-dom --with-libxml';
|
||||
return '--with-dom';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
|
||||
#[CustomExt('pdo_sqlsrv')]
|
||||
class pdo_sqlsrv extends Extension
|
||||
{
|
||||
public function buildUnixShared(): void
|
||||
{
|
||||
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()]);
|
||||
$env = [
|
||||
'CFLAGS' => $config['cflags'],
|
||||
'CXXFLAGS' => $config['cflags'],
|
||||
'LDFLAGS' => $config['ldflags'],
|
||||
'LIBS' => $config['libs'],
|
||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||
];
|
||||
// prepare configure args
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv($env)
|
||||
->execWithEnv(BUILD_BIN_PATH . '/phpize')
|
||||
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static --with-pic')
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv('make -j' . $this->builder->concurrency)
|
||||
->execWithEnv('make install');
|
||||
}
|
||||
}
|
||||
@ -39,12 +39,9 @@ class pgsql extends Extension
|
||||
$libfiles = $this->getLibFilesString();
|
||||
$libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles);
|
||||
$libfiles = str_replace('.a', '', $libfiles);
|
||||
$libfiles = str_replace(' -lpq', '', $libfiles);
|
||||
$libfiles = str_replace(' -lpgport', '', $libfiles);
|
||||
$libfiles = str_replace(' -lpgcommon', '', $libfiles);
|
||||
return '--with-pgsql' . ($shared ? '=shared' : '') .
|
||||
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH .
|
||||
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon ' . $libfiles . '"';
|
||||
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"';
|
||||
}
|
||||
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
|
||||
}
|
||||
|
||||
@ -109,18 +109,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
if ($build_target === BUILD_TARGET_EMBED &&
|
||||
file_exists(BUILD_BIN_PATH . '/php-config') &&
|
||||
file_exists(BUILD_BIN_PATH . '/phpize')
|
||||
) {
|
||||
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
|
||||
if ($embed_type === 'shared' && file_exists(BUILD_LIB_PATH . '/libphp.so')) {
|
||||
return;
|
||||
}
|
||||
if (file_exists(BUILD_LIB_PATH . '/libphp.a')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ---------- Update extra-libs ----------
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
// bloat means force-load all static libraries, even if they are not used
|
||||
|
||||
@ -208,7 +208,7 @@ class BuildPHPCommand extends BuildCommand
|
||||
SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion());
|
||||
|
||||
// start to build
|
||||
$builder->buildPHP($rule);
|
||||
// $builder->buildPHP($rule);
|
||||
|
||||
SourcePatcher::patchBeforeSharedBuild($builder);
|
||||
|
||||
|
||||
@ -457,16 +457,11 @@ class SourcePatcher
|
||||
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') {
|
||||
return false;
|
||||
}
|
||||
$version = null;
|
||||
if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
|
||||
$file = SOURCE_PATH . '/php-src/main/php_version.h';
|
||||
$cnt = preg_match('/PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match);
|
||||
if (!$cnt) {
|
||||
return false;
|
||||
}
|
||||
$version = $match[1];
|
||||
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
|
||||
return false;
|
||||
}
|
||||
if (version_compare($version, '8.3.16', '<')) {
|
||||
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
|
||||
if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0 && intval($match[1]) < 80316) {
|
||||
return false;
|
||||
}
|
||||
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user