mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Merge branch 'v3' into v3c/library-fixes
This commit is contained in:
20
config/pkg/ext/ext-fastchart.yml
Normal file
20
config/pkg/ext/ext-fastchart.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
ext-fastchart:
|
||||||
|
type: php-extension
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghtar
|
||||||
|
repo: iliaal/fastchart
|
||||||
|
extract: php-src/ext/fastchart
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE]
|
||||||
|
depends:
|
||||||
|
- freetype
|
||||||
|
suggests:
|
||||||
|
- libpng
|
||||||
|
- libjpeg
|
||||||
|
- libwebp
|
||||||
|
php-extension:
|
||||||
|
os:
|
||||||
|
- Linux
|
||||||
|
- Darwin
|
||||||
14
config/pkg/ext/ext-fastjson.yml
Normal file
14
config/pkg/ext/ext-fastjson.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
ext-fastjson:
|
||||||
|
type: php-extension
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghtar
|
||||||
|
repo: iliaal/fastjson
|
||||||
|
extract: php-src/ext/fastjson
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE]
|
||||||
|
php-extension:
|
||||||
|
os:
|
||||||
|
- Linux
|
||||||
|
- Darwin
|
||||||
@@ -20,8 +20,8 @@ class unixodbc extends LibraryPackage
|
|||||||
{
|
{
|
||||||
$sysconf_selector = match ($os = SystemTarget::getTargetOS()) {
|
$sysconf_selector = match ($os = SystemTarget::getTargetOS()) {
|
||||||
'Darwin' => match (SystemTarget::getTargetArch()) {
|
'Darwin' => match (SystemTarget::getTargetArch()) {
|
||||||
'x86_64' => '/usr/local/etc',
|
'x86_64' => is_dir('/usr/local/etc') ? '/usr/local/etc' : '/opt/local/etc',
|
||||||
'aarch64' => '/opt/homebrew/etc',
|
'aarch64' => is_dir('/opt/homebrew/etc') ? '/opt/homebrew/etc' : '/opt/local/etc',
|
||||||
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
||||||
},
|
},
|
||||||
'Linux' => '/etc',
|
'Linux' => '/etc',
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class GenExtTestMatrixCommand extends BaseCommand
|
|||||||
'glfw',
|
'glfw',
|
||||||
'imagick',
|
'imagick',
|
||||||
'intl',
|
'intl',
|
||||||
|
'mongodb',
|
||||||
|
'gmssl',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,15 +33,20 @@ class MacOSToolCheck
|
|||||||
'glibtoolize',
|
'glibtoolize',
|
||||||
];
|
];
|
||||||
|
|
||||||
#[CheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)]
|
#[CheckItem('if homebrew or macports has installed', limit_os: 'Darwin', level: 998)]
|
||||||
public function checkBrew(): ?CheckResult
|
public function checkBrewOrPorts(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (($path = MacOSUtil::findCommand('brew')) === null) {
|
$brewPath = MacOSUtil::findCommand('brew');
|
||||||
return CheckResult::fail('Homebrew is not installed', 'brew');
|
$portPath = MacOSUtil::findCommand('port');
|
||||||
}
|
|
||||||
if ($path !== '/opt/homebrew/bin/brew' && getenv('GNU_ARCH') === 'aarch64') {
|
if ($brewPath && $brewPath !== '/opt/homebrew/bin/brew' && getenv('GNU_ARCH') === 'aarch64') {
|
||||||
return CheckResult::fail('Current homebrew (/usr/local/bin/homebrew) is not installed for M1 Mac, please re-install homebrew in /opt/homebrew/ !');
|
return CheckResult::fail('Current homebrew (/usr/local/bin/homebrew) is not installed for M1 Mac, please re-install homebrew in /opt/homebrew/ !');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($brewPath === null && $portPath === null) {
|
||||||
|
return CheckResult::fail('Homebrew is not installed', 'brew');
|
||||||
|
}
|
||||||
|
|
||||||
return CheckResult::ok();
|
return CheckResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +65,8 @@ class MacOSToolCheck
|
|||||||
return CheckResult::ok();
|
return CheckResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[CheckItem('if homebrew llvm are installed', limit_os: 'Darwin')]
|
#[CheckItem('if homebrew or macports llvm are installed', limit_os: 'Darwin')]
|
||||||
public function checkBrewLLVM(): ?CheckResult
|
public function checkBrewOrPortsLLVM(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (getenv('SPC_USE_LLVM') === 'brew') {
|
if (getenv('SPC_USE_LLVM') === 'brew') {
|
||||||
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
|
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
|
||||||
@@ -71,6 +76,16 @@ class MacOSToolCheck
|
|||||||
}
|
}
|
||||||
return CheckResult::ok($path);
|
return CheckResult::ok($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getenv('SPC_USE_LLVM') === 'port') {
|
||||||
|
$macportsPrefix = '/opt/local';
|
||||||
|
|
||||||
|
if (($path = MacOSUtil::findCommand('clang', ["{$macportsPrefix}/bin"])) === null) {
|
||||||
|
return CheckResult::fail('MacPorts llvm is not installed', 'build-tools', ['missing' => ['llvm']]);
|
||||||
|
}
|
||||||
|
return CheckResult::ok($path);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +106,7 @@ class MacOSToolCheck
|
|||||||
if ($command_path !== []) {
|
if ($command_path !== []) {
|
||||||
return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]);
|
return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]);
|
||||||
}
|
}
|
||||||
return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin']);
|
return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin', '/opt/local/bin']);
|
||||||
}
|
}
|
||||||
return CheckResult::ok($matches[0]);
|
return CheckResult::ok($matches[0]);
|
||||||
}
|
}
|
||||||
@@ -108,6 +123,9 @@ class MacOSToolCheck
|
|||||||
#[FixItem('build-tools')]
|
#[FixItem('build-tools')]
|
||||||
public function fixBuildTools(array $missing): bool
|
public function fixBuildTools(array $missing): bool
|
||||||
{
|
{
|
||||||
|
$brewPath = MacOSUtil::findCommand('brew');
|
||||||
|
$portPath = MacOSUtil::findCommand('port');
|
||||||
|
|
||||||
$replacement = [
|
$replacement = [
|
||||||
'glibtoolize' => 'libtool',
|
'glibtoolize' => 'libtool',
|
||||||
];
|
];
|
||||||
@@ -115,7 +133,18 @@ class MacOSToolCheck
|
|||||||
if (isset($replacement[$cmd])) {
|
if (isset($replacement[$cmd])) {
|
||||||
$cmd = $replacement[$cmd];
|
$cmd = $replacement[$cmd];
|
||||||
}
|
}
|
||||||
shell()->exec('brew install --formula ' . escapeshellarg($cmd));
|
|
||||||
|
if ($brewPath !== null) {
|
||||||
|
shell()->exec('brew install --formula ' . escapeshellarg($cmd));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($portPath !== null) {
|
||||||
|
shell()->exec('port install ' . escapeshellarg($cmd));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/StaticPHP/Toolchain/ClangPortsToolchain.php
Normal file
20
src/StaticPHP/Toolchain/ClangPortsToolchain.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace StaticPHP\Toolchain;
|
||||||
|
|
||||||
|
use StaticPHP\Util\GlobalEnvManager;
|
||||||
|
|
||||||
|
class ClangPortsToolchain extends ClangNativeToolchain
|
||||||
|
{
|
||||||
|
public function initEnv(): void
|
||||||
|
{
|
||||||
|
$macports_prefix = getenv('MACPORTS_PREFIX') ?: '/opt/local';
|
||||||
|
GlobalEnvManager::putenv("SPC_DEFAULT_CC={$macports_prefix}/bin/clang");
|
||||||
|
GlobalEnvManager::putenv("SPC_DEFAULT_CXX={$macports_prefix}/bin/clang++");
|
||||||
|
GlobalEnvManager::putenv("SPC_DEFAULT_AR={$macports_prefix}/bin/llvm-ar");
|
||||||
|
GlobalEnvManager::putenv('SPC_DEFAULT_LD=ld');
|
||||||
|
GlobalEnvManager::addPathIfNotExists("{$macports_prefix}/bin");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,7 @@ class ToolchainManager
|
|||||||
'Windows' => MSVCToolchain::class,
|
'Windows' => MSVCToolchain::class,
|
||||||
'Darwin' => match (getenv('SPC_USE_LLVM') ?: 'system') {
|
'Darwin' => match (getenv('SPC_USE_LLVM') ?: 'system') {
|
||||||
'brew' => ClangBrewToolchain::class,
|
'brew' => ClangBrewToolchain::class,
|
||||||
|
'port' => ClangPortsToolchain::class,
|
||||||
default => ClangNativeToolchain::class,
|
default => ClangNativeToolchain::class,
|
||||||
},
|
},
|
||||||
default => throw new WrongUsageException('Unsupported OS family: ' . PHP_OS_FAMILY),
|
default => throw new WrongUsageException('Unsupported OS family: ' . PHP_OS_FAMILY),
|
||||||
|
|||||||
@@ -134,10 +134,10 @@ class GlobalEnvManager
|
|||||||
}
|
}
|
||||||
// test bison
|
// test bison
|
||||||
if (PHP_OS_FAMILY === 'Darwin') {
|
if (PHP_OS_FAMILY === 'Darwin') {
|
||||||
if ($bison = MacOSUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin'])) {
|
if ($bison = MacOSUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin', '/opt/local/bin/bison'])) {
|
||||||
self::putenv("BISON={$bison}");
|
self::putenv("BISON={$bison}");
|
||||||
}
|
}
|
||||||
if ($yacc = MacOSUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin'])) {
|
if ($yacc = MacOSUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin', '/opt/local/bin/yacc'])) {
|
||||||
self::putenv("YACC={$yacc}");
|
self::putenv("YACC={$yacc}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user