mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Merge
This commit is contained in:
parent
a5d26d6517
commit
dd72b32559
@ -332,6 +332,15 @@ abstract class LibraryBase
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch php-config after embed was built
|
||||||
|
* Example: imap requires -lcrypt
|
||||||
|
*/
|
||||||
|
public function patchPhpConfig(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build this library.
|
* Build this library.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,6 +5,7 @@ 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\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
@ -41,4 +42,14 @@ class imap extends Extension
|
|||||||
}
|
}
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lcrypt');
|
||||||
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ namespace SPC\builder\linux\library;
|
|||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
class imap extends LinuxLibraryBase
|
class imap extends LinuxLibraryBase
|
||||||
{
|
{
|
||||||
@ -34,6 +35,15 @@ class imap extends LinuxLibraryBase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchPhpConfig(): bool
|
||||||
|
{
|
||||||
|
if (SPCTarget::getLibc() === 'glibc') {
|
||||||
|
FileSystem::replaceFileRegex(BUILD_BIN_PATH . '/php-config', '/^libs="(.*)"$/m', 'libs="$1 -lcrypt"');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
@ -44,6 +54,8 @@ class imap extends LinuxLibraryBase
|
|||||||
} else {
|
} else {
|
||||||
$ssl_options = 'SSLTYPE=none';
|
$ssl_options = 'SSLTYPE=none';
|
||||||
}
|
}
|
||||||
|
$libcVer = SPCTarget::getLibcVersion();
|
||||||
|
$extraLibs = $libcVer && version_compare($libcVer, '2.17', '<=') ? 'EXTRALDFLAGS="-ldl -lrt -lpthread"' : '';
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->exec('make clean')
|
->exec('make clean')
|
||||||
->exec('touch ip6')
|
->exec('touch ip6')
|
||||||
@ -51,9 +63,7 @@ class imap extends LinuxLibraryBase
|
|||||||
->exec('chmod +x tools/ua')
|
->exec('chmod +x tools/ua')
|
||||||
->exec('chmod +x src/osdep/unix/drivers')
|
->exec('chmod +x src/osdep/unix/drivers')
|
||||||
->exec('chmod +x src/osdep/unix/mkauths')
|
->exec('chmod +x src/osdep/unix/mkauths')
|
||||||
->exec(
|
->exec("yes | make slx {$ssl_options} EXTRACFLAGS='-fPIC -fpermissive' {$extraLibs}");
|
||||||
"yes | make slx {$ssl_options} EXTRACFLAGS='-fPIC -fpermissive'"
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
shell()
|
shell()
|
||||||
->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a')
|
->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a')
|
||||||
|
|||||||
@ -294,6 +294,11 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$php_config_str = preg_replace('/(libs=")(.*?)\s*(-lstdc\+\+)\s*(.*?)"/', '$1$2 $4 $3"', $php_config_str);
|
$php_config_str = preg_replace('/(libs=")(.*?)\s*(-lstdc\+\+)\s*(.*?)"/', '$1$2 $4 $3"', $php_config_str);
|
||||||
FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str);
|
FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str);
|
||||||
}
|
}
|
||||||
|
foreach ($this->getLibs() as $lib) {
|
||||||
|
if ($lib->patchPhpConfig()) {
|
||||||
|
logger()->debug("Library {$lib->getName()} patched php-config");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -66,7 +66,7 @@ class SourceManager
|
|||||||
$check = LockFile::getExtractPath($lock_name, SOURCE_PATH . '/' . $source);
|
$check = LockFile::getExtractPath($lock_name, SOURCE_PATH . '/' . $source);
|
||||||
// $check = $lock[$lock_name]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$lock_name]['move_path']);
|
// $check = $lock[$lock_name]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$lock_name]['move_path']);
|
||||||
if (!is_dir($check)) {
|
if (!is_dir($check)) {
|
||||||
logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...');
|
logger()->debug("Extracting source [{$source}] to {$check} ...");
|
||||||
$filename = LockFile::getLockFullPath($lock_content);
|
$filename = LockFile::getLockFullPath($lock_content);
|
||||||
FileSystem::extractSource($source, $lock_content['source_type'], $filename, $check);
|
FileSystem::extractSource($source, $lock_content['source_type'], $filename, $check);
|
||||||
LockFile::putLockSourceHash($lock_content, $check);
|
LockFile::putLockSourceHash($lock_content, $check);
|
||||||
@ -81,7 +81,14 @@ class SourceManager
|
|||||||
|
|
||||||
// when source already extracted, detect if the extracted source hash is the same as the lock file one
|
// when source already extracted, detect if the extracted source hash is the same as the lock file one
|
||||||
if (file_exists("{$check}/.spc-hash") && FileSystem::readFile("{$check}/.spc-hash") === $hash) {
|
if (file_exists("{$check}/.spc-hash") && FileSystem::readFile("{$check}/.spc-hash") === $hash) {
|
||||||
logger()->debug('Source [' . $source . '] already extracted in ' . $check . ', skip !');
|
logger()->debug("Source [{$source}] already extracted in {$check}, skip !");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ext imap was included in php < 8.4 which we should not extract,
|
||||||
|
// but since it's not simple to compare php version, for now we just skip it
|
||||||
|
if ($source === 'ext-imap') {
|
||||||
|
logger()->debug("Source [ext-imap] already extracted in {$check}, skip !");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -145,6 +145,9 @@ class SPCConfigUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (in_array('imap', $libraries) && SPCTarget::getLibc() === 'glibc') {
|
||||||
|
$short_name[] = '-lcrypt';
|
||||||
|
}
|
||||||
return implode(' ', $short_name);
|
return implode(' ', $short_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user