mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Compare commits
8 Commits
2.8.1
...
feat/xcadd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
587aec3065 | ||
|
|
823b26fbb9 | ||
|
|
df0807f07c | ||
|
|
f680731f9d | ||
|
|
0fe1442f7e | ||
|
|
1e4780397b | ||
|
|
6b67cb90fc | ||
|
|
b89ff3c083 |
@@ -43,6 +43,14 @@
|
||||
"calendar": {
|
||||
"type": "builtin"
|
||||
},
|
||||
"com_dotnet": {
|
||||
"support": {
|
||||
"BSD": "no",
|
||||
"Linux": "no",
|
||||
"Darwin": "no"
|
||||
},
|
||||
"type": "builtin"
|
||||
},
|
||||
"ctype": {
|
||||
"type": "builtin"
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const string VERSION = '2.8.0';
|
||||
public const string VERSION = '2.8.2';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
17
src/SPC/builder/extension/com_dotnet.php
Normal file
17
src/SPC/builder/extension/com_dotnet.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('com_dotnet')]
|
||||
class com_dotnet extends Extension
|
||||
{
|
||||
public function getWindowsConfigureArg(bool $shared = false): string
|
||||
{
|
||||
return '--enable-com-dotnet=yes';
|
||||
}
|
||||
}
|
||||
@@ -411,10 +411,17 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
||||
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
||||
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
|
||||
FileSystem::replaceFileStr(
|
||||
$frankenphpSourceDir . '/caddy/php-server.go',
|
||||
'config, _, err := caddycmd.LoadConfig',
|
||||
'config, _, _, err := caddycmd.LoadConfig'
|
||||
);
|
||||
|
||||
$xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules);
|
||||
$xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " .
|
||||
"--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy {$xcaddyModules}";
|
||||
"--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy " .
|
||||
"--with github.com/caddyserver/caddy/v2=github.com/henderkes/caddy/v2@master " .
|
||||
"{$xcaddyModules}";
|
||||
if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) {
|
||||
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
|
||||
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
|
||||
@@ -453,7 +460,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
'CGO_ENABLED' => '1',
|
||||
'CGO_CFLAGS' => clean_spaces($cflags),
|
||||
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie -trimpath ' .
|
||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
|
||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
||||
|
||||
@@ -4,29 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\PkgConfigUtil;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait postgresql
|
||||
{
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
|
||||
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
|
||||
try {
|
||||
FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
|
||||
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
|
||||
'#if defined(__linux__) && !defined(HWCAP_CRC32)'
|
||||
);
|
||||
} catch (FileSystemException) {
|
||||
// allow file not-existence to make it compatible with old and new version
|
||||
}
|
||||
}
|
||||
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
|
||||
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
|
||||
// disable shared libs build
|
||||
|
||||
@@ -20,9 +20,9 @@ class SwitchPhpVersionCommand extends BaseCommand
|
||||
$this->addArgument(
|
||||
'php-major-version',
|
||||
InputArgument::REQUIRED,
|
||||
'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4)',
|
||||
'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5)',
|
||||
null,
|
||||
fn () => ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
|
||||
fn () => ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
|
||||
);
|
||||
$this->no_motd = true;
|
||||
|
||||
@@ -32,7 +32,7 @@ class SwitchPhpVersionCommand extends BaseCommand
|
||||
public function handle(): int
|
||||
{
|
||||
$php_ver = $this->input->getArgument('php-major-version');
|
||||
if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'])) {
|
||||
if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'])) {
|
||||
// match x.y.z
|
||||
preg_match('/^\d+\.\d+\.\d+$/', $php_ver, $matches);
|
||||
if (!$matches) {
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\store\pkg;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\store\Downloader;
|
||||
use SPC\store\FileSystem;
|
||||
@@ -30,10 +31,10 @@ class GoXcaddy extends CustomPackage
|
||||
public function fetch(string $name, bool $force = false, ?array $config = null): void
|
||||
{
|
||||
$pkgroot = PKG_ROOT_PATH;
|
||||
$go_exec = "{$pkgroot}/{$name}/bin/go";
|
||||
$xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy";
|
||||
$go_exec = "{$pkgroot}/go-xcaddy/bin/go";
|
||||
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy";
|
||||
if ($force) {
|
||||
FileSystem::removeDir("{$pkgroot}/{$name}");
|
||||
FileSystem::removeDir("{$pkgroot}/go-xcaddy");
|
||||
}
|
||||
if (file_exists($go_exec) && file_exists($xcaddy_exec)) {
|
||||
return;
|
||||
@@ -41,12 +42,12 @@ class GoXcaddy extends CustomPackage
|
||||
$arch = match (explode('-', $name)[2]) {
|
||||
'x86_64' => 'amd64',
|
||||
'aarch64' => 'arm64',
|
||||
default => throw new \InvalidArgumentException('Unsupported architecture: ' . $name),
|
||||
default => throw new InvalidArgumentException('Unsupported architecture: ' . $name),
|
||||
};
|
||||
$os = match (explode('-', $name)[3]) {
|
||||
'linux' => 'linux',
|
||||
'macos' => 'darwin',
|
||||
default => throw new \InvalidArgumentException('Unsupported OS: ' . $name),
|
||||
default => throw new InvalidArgumentException('Unsupported OS: ' . $name),
|
||||
};
|
||||
[$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text'));
|
||||
$config = [
|
||||
@@ -78,6 +79,18 @@ class GoXcaddy extends CustomPackage
|
||||
}
|
||||
|
||||
// install xcaddy without using musl tools, xcaddy build requires dynamic linking
|
||||
// Clone the fork and install from local clone to avoid module path conflicts
|
||||
$xcaddyClonePath = "{$pkgroot}/go/src/github.com/henderkes/xcaddy";
|
||||
if (!is_dir($xcaddyClonePath)) {
|
||||
shell()
|
||||
->appendEnv([
|
||||
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
|
||||
])
|
||||
->exec("git clone https://github.com/henderkes/xcaddy {$xcaddyClonePath}");
|
||||
} else {
|
||||
shell()->cd($xcaddyClonePath)->exec('git fetch && git pull');
|
||||
}
|
||||
|
||||
shell()
|
||||
->appendEnv([
|
||||
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
|
||||
@@ -85,7 +98,8 @@ class GoXcaddy extends CustomPackage
|
||||
'GOBIN' => "{$pkgroot}/go-xcaddy/bin",
|
||||
'GOPATH' => "{$pkgroot}/go",
|
||||
])
|
||||
->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest');
|
||||
->cd($xcaddyClonePath)
|
||||
->exec('CC=cc go install ./cmd/xcaddy');
|
||||
}
|
||||
|
||||
public static function getEnvironment(): array
|
||||
|
||||
@@ -14,22 +14,22 @@ declare(strict_types=1);
|
||||
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
||||
$test_php_version = [
|
||||
// '8.1',
|
||||
'8.2',
|
||||
'8.3',
|
||||
'8.4',
|
||||
// '8.2',
|
||||
// '8.3',
|
||||
// '8.4',
|
||||
'8.5',
|
||||
// 'git',
|
||||
];
|
||||
|
||||
// test os (macos-15-intel, macos-15, ubuntu-latest, windows-latest are available)
|
||||
$test_os = [
|
||||
'macos-15-intel', // bin/spc for x86_64
|
||||
'macos-15', // bin/spc for arm64
|
||||
'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
||||
// 'macos-15-intel', // bin/spc for x86_64
|
||||
// 'macos-15', // bin/spc for arm64
|
||||
// 'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
||||
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
||||
'ubuntu-24.04', // bin/spc for x86_64
|
||||
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||
// 'ubuntu-24.04-arm', // bin/spc for arm64
|
||||
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||
'ubuntu-24.04-arm', // bin/spc for arm64
|
||||
// 'windows-2022', // .\bin\spc.ps1
|
||||
// 'windows-2025',
|
||||
];
|
||||
@@ -50,13 +50,13 @@ $prefer_pre_built = false;
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'mysqli,gmp',
|
||||
'Windows' => 'bcmath',
|
||||
'Linux', 'Darwin' => 'pgsql',
|
||||
'Windows' => 'com_dotnet',
|
||||
};
|
||||
|
||||
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
||||
$shared_extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux' => 'grpc,mysqlnd_parsec,mysqlnd_ed25519',
|
||||
'Linux' => '',
|
||||
'Darwin' => '',
|
||||
'Windows' => '',
|
||||
};
|
||||
@@ -66,7 +66,7 @@ $with_suggested_libs = false;
|
||||
|
||||
// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true.
|
||||
$with_libs = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'libwebp',
|
||||
'Linux', 'Darwin' => '',
|
||||
'Windows' => '',
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user