refactor download

This commit is contained in:
crazywhalecc
2023-04-30 12:42:19 +08:00
parent 117cd93e8f
commit 0bed76da11
30 changed files with 901 additions and 673 deletions

View File

@@ -10,7 +10,7 @@ use SPC\builder\traits\UnixBuilderTrait;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\Patcher;
use SPC\store\SourcePatcher;
/**
* Linux 系统环境下的构建器
@@ -46,7 +46,10 @@ class LinuxBuilder extends BuilderBase
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null)
{
// 初始化一些默认参数
$this->cc = $cc ?? 'musl-gcc';
$this->cc = $cc ?? match (SystemUtil::getOSRelease()['dist']) {
'alpine' => 'gcc',
default => 'musl-gcc'
};
$this->cxx = $cxx ?? 'g++';
$this->arch = $arch ?? php_uname('m');
$this->gnu_arch = arch2gnu($this->arch);
@@ -135,6 +138,9 @@ class LinuxBuilder extends BuilderBase
)
);
}
if ($this->getExt('swoole')) {
$extra_libs .= ' -lstdc++';
}
$envs = $this->pkgconf_env . ' ' .
"CC='{$this->cc}' " .
@@ -158,11 +164,11 @@ class LinuxBuilder extends BuilderBase
$envs = "{$envs} CFLAGS='{$cflags}' LIBS='-ldl -lpthread'";
Patcher::patchPHPBeforeConfigure($this);
SourcePatcher::patchPHPBuildconf($this);
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
Patcher::patchPHPConfigure($this);
SourcePatcher::patchPHPConfigure($this);
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
@@ -183,6 +189,8 @@ class LinuxBuilder extends BuilderBase
$envs
);
SourcePatcher::patchPHPAfterConfigure($this);
file_put_contents('/tmp/comment', $this->note_section);
// 清理

View File

@@ -13,44 +13,6 @@ class SystemUtil
{
use UnixSystemUtilTrait;
/**
* 查找并选择编译器命令
*
* @throws RuntimeException
*/
public static function selectCC(): string
{
logger()->debug('Choose cc');
if (self::findCommand('clang')) {
logger()->info('using clang');
return 'clang';
}
if (self::findCommand('gcc')) {
logger()->info('using gcc');
return 'gcc';
}
throw new RuntimeException('no supported cc found');
}
/**
* 查找并选择编译器命令
*
* @throws RuntimeException
*/
public static function selectCXX(): string
{
logger()->debug('Choose cxx');
if (self::findCommand('clang++')) {
logger()->info('using clang++');
return 'clang++';
}
if (self::findCommand('g++')) {
logger()->info('using g++');
return 'g++';
}
return self::selectCC();
}
#[ArrayShape(['dist' => 'mixed|string', 'ver' => 'mixed|string'])]
public static function getOSRelease(): array
{

View File

@@ -22,7 +22,7 @@ namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\Patcher;
use SPC\store\SourcePatcher;
class libpng extends LinuxLibraryBase
{
@@ -41,7 +41,7 @@ class libpng extends LinuxLibraryBase
};
// patch configure
Patcher::patchUnixLibpng();
SourcePatcher::patchUnixLibpng();
shell()->cd($this->source_dir)
->exec('chmod +x ./configure')