apply suggestions

This commit is contained in:
DubbleClick
2025-06-06 23:49:58 +07:00
parent b6a1182876
commit a68212672b
8 changed files with 17 additions and 64 deletions

View File

@@ -235,7 +235,7 @@ class Extension
$ret = ''; $ret = '';
foreach ($order as $ext) { foreach ($order as $ext) {
if ($ext instanceof Extension && $ext->isBuildShared()) { 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()}\""; $ret .= " -d \"zend_extension={$ext->getName()}\"";
} else { } else {
$ret .= " -d \"extension={$ext->getName()}\""; $ret .= " -d \"extension={$ext->getName()}\"";
@@ -371,6 +371,7 @@ class Extension
} }
$env = [ $env = [
'CFLAGS' => $config['cflags'], 'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'], 'LDFLAGS' => $config['ldflags'],
'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs,
'LD_LIBRARY_PATH' => BUILD_LIB_PATH, '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; return $deps;
} }
} }

View File

@@ -22,7 +22,7 @@ class curl extends Extension
{ {
logger()->info('patching before-configure for curl checks'); logger()->info('patching before-configure for curl checks');
$file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])"; $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], [ $file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5" ac_stuff="$5"
@@ -41,7 +41,7 @@ class curl extends Extension
$4 $4
])dnl ])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; return true;
} }
@@ -59,7 +59,7 @@ class curl extends Extension
public function patchBeforeSharedConfigure(): bool public function patchBeforeSharedConfigure(): bool
{ {
$file = SOURCE_PATH . '/php-src/ext/curl/config.m4'; $file = $this->source_dir . '/config.m4';
$content = FileSystem::readFile($file); $content = FileSystem::readFile($file);
// Inject patch before it // Inject patch before it

View File

@@ -30,6 +30,6 @@ class dom extends Extension
public function getWindowsConfigureArg($shared = false): string public function getWindowsConfigureArg($shared = false): string
{ {
return '--with-dom --with-libxml'; return '--with-dom';
} }
} }

View File

@@ -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');
}
}

View File

@@ -39,12 +39,9 @@ class pgsql extends Extension
$libfiles = $this->getLibFilesString(); $libfiles = $this->getLibFilesString();
$libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles); $libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles);
$libfiles = str_replace('.a', '', $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' : '') . return '--with-pgsql' . ($shared ? '=shared' : '') .
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' 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; return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
} }

View File

@@ -109,18 +109,6 @@ class LinuxBuilder extends UnixBuilderBase
*/ */
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void 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 ---------- // ---------- Update extra-libs ----------
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; $extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
// bloat means force-load all static libraries, even if they are not used // bloat means force-load all static libraries, even if they are not used

View File

@@ -208,7 +208,7 @@ class BuildPHPCommand extends BuildCommand
SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion());
// start to build // start to build
$builder->buildPHP($rule); // $builder->buildPHP($rule);
SourcePatcher::patchBeforeSharedBuild($builder); SourcePatcher::patchBeforeSharedBuild($builder);

View File

@@ -457,16 +457,11 @@ class SourcePatcher
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') { if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') {
return false; return false;
} }
$version = null; if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { return false;
$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 (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; return false;
} }
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');