mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 21:34:53 +08:00
Use zig toolchain by default, lint files
This commit is contained in:
parent
6fdbf629dc
commit
38f742156d
@ -83,7 +83,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
|
||||
; - gnu-native: used for general linux distros, can build gnu target for the installed glibc version only.
|
||||
|
||||
; option to specify the target, superceded by SPC_TARGET if set
|
||||
SPC_LIBC=musl
|
||||
; SPC_LIBC=musl
|
||||
; uncomment to link libc dynamically on musl
|
||||
; SPC_MUSL_DYNAMIC=true
|
||||
|
||||
@ -94,13 +94,13 @@ SPC_LIBC=musl
|
||||
; `native-native` - links against system libc dynamically
|
||||
; `native-native-musl` - links against musl libc statically
|
||||
; `native-native-musl -dynamic` - links against musl libc dynamically
|
||||
; SPC_TARGET=
|
||||
SPC_TARGET=native-native-musl
|
||||
|
||||
; compiler environments
|
||||
CC=${SPC_LINUX_DEFAULT_CC}
|
||||
CXX=${SPC_LINUX_DEFAULT_CXX}
|
||||
AR=${SPC_LINUX_DEFAULT_AR}
|
||||
LD=${SPC_LINUX_DEFAULT_LD}
|
||||
; compiler environments (default value is defined by selected toolchain)
|
||||
CC=${SPC_DEFAULT_CC}
|
||||
CXX=${SPC_DEFAULT_CXX}
|
||||
AR=${SPC_DEFAULT_AR}
|
||||
LD=${SPC_DEFAULT_LD}
|
||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||
SPC_DEFAULT_C_FLAGS="-fPIC -Os"
|
||||
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
|
||||
@ -132,11 +132,11 @@ OPENSSLDIR=""
|
||||
; build target: macho or macho (possibly we could support macho-universal in the future)
|
||||
; Currently we do not support universal and cross-compilation for macOS.
|
||||
SPC_TARGET=native-macos
|
||||
; compiler environments
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
AR=ar
|
||||
LD=ld
|
||||
; compiler environments (default value is defined by selected toolchain)
|
||||
CC=${SPC_DEFAULT_CC}
|
||||
CXX=${SPC_DEFAULT_CXX}
|
||||
AR=${SPC_DEFAULT_AR}
|
||||
LD=${SPC_DEFAULT_LD}
|
||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
|
||||
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
{
|
||||
"frankenphp": {
|
||||
"type": "virtual-target",
|
||||
"artifact": "frankenphp",
|
||||
"depends": [
|
||||
"php-embed",
|
||||
@ -9,90 +10,78 @@
|
||||
"php-embed",
|
||||
"go-xcaddy",
|
||||
"libxml2"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"go-xcaddy": {
|
||||
"type": "target",
|
||||
"artifact": "go-xcaddy",
|
||||
"static-bins": [
|
||||
"xcaddy"
|
||||
],
|
||||
"type": "target"
|
||||
]
|
||||
},
|
||||
"musl-toolchain": {
|
||||
"artifact": "musl-toolchain",
|
||||
"type": "target"
|
||||
"type": "target",
|
||||
"artifact": "musl-toolchain"
|
||||
},
|
||||
"nasm": {
|
||||
"artifact": "nasm",
|
||||
"type": "target"
|
||||
"type": "target",
|
||||
"artifact": "nasm"
|
||||
},
|
||||
"php": {
|
||||
"type": "target",
|
||||
"artifact": "php-src",
|
||||
"depends@macos": [
|
||||
"libxml2"
|
||||
],
|
||||
"type": "target"
|
||||
]
|
||||
},
|
||||
"php-cgi": {
|
||||
"type": "virtual-target",
|
||||
"depends": [
|
||||
"php"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"php-cli": {
|
||||
"type": "virtual-target",
|
||||
"depends": [
|
||||
"php"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"php-embed": {
|
||||
"type": "virtual-target",
|
||||
"depends": [
|
||||
"php"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"php-fpm": {
|
||||
"type": "virtual-target",
|
||||
"depends": [
|
||||
"php"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"php-micro": {
|
||||
"type": "virtual-target",
|
||||
"artifact": "micro",
|
||||
"depends": [
|
||||
"php"
|
||||
],
|
||||
"type": "virtual-target"
|
||||
]
|
||||
},
|
||||
"php-sdk-binary-tools": {
|
||||
"artifact": "php-sdk-binary-tools",
|
||||
"type": "target"
|
||||
},
|
||||
"pkg-config": {
|
||||
"artifact": "pkg-config",
|
||||
"static-bins": [
|
||||
"pkg-config"
|
||||
],
|
||||
"type": "target"
|
||||
"type": "target",
|
||||
"artifact": "php-sdk-binary-tools"
|
||||
},
|
||||
"strawberry-perl": {
|
||||
"artifact": "strawberry-perl",
|
||||
"type": "target"
|
||||
"type": "target",
|
||||
"artifact": "strawberry-perl"
|
||||
},
|
||||
"upx": {
|
||||
"artifact": "upx",
|
||||
"type": "target"
|
||||
"type": "target",
|
||||
"artifact": "upx"
|
||||
},
|
||||
"vswhere": {
|
||||
"type": "target",
|
||||
"artifact": "vswhere",
|
||||
"static-bins@windows": [
|
||||
"vswhere.exe"
|
||||
],
|
||||
"type": "target"
|
||||
},
|
||||
"zig": {
|
||||
"artifact": "zig",
|
||||
"type": "target"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,15 +4,11 @@ curl:
|
||||
source:
|
||||
type: ghrel
|
||||
repo: curl/curl
|
||||
match: 'curl.+\.tar\.xz'
|
||||
match: curl.+\.tar\.xz
|
||||
prefer-stable: true
|
||||
metadata:
|
||||
license-files: [COPYING]
|
||||
license: curl
|
||||
static-libs@unix:
|
||||
- libcurl.a
|
||||
headers:
|
||||
- curl
|
||||
depends@unix:
|
||||
- openssl
|
||||
- zlib
|
||||
@ -31,3 +27,7 @@ curl:
|
||||
- CoreFoundation
|
||||
- CoreServices
|
||||
- SystemConfiguration
|
||||
headers:
|
||||
- curl
|
||||
static-libs@unix:
|
||||
- libcurl.a
|
||||
|
||||
@ -10,10 +10,10 @@ gettext:
|
||||
license: LGPL-2.1-or-later
|
||||
depends:
|
||||
- libiconv
|
||||
suggests:
|
||||
- ncurses
|
||||
- libxml2
|
||||
frameworks:
|
||||
- CoreFoundation
|
||||
static-libs@unix:
|
||||
- libintl.a
|
||||
suggests:
|
||||
- ncurses
|
||||
- libxml2
|
||||
|
||||
@ -11,11 +11,11 @@ idn2:
|
||||
depends@macos:
|
||||
- libiconv
|
||||
- gettext
|
||||
headers:
|
||||
- idn2.h
|
||||
pkg-configs:
|
||||
- libidn2
|
||||
suggests@unix:
|
||||
- libiconv
|
||||
- gettext
|
||||
- libunistring
|
||||
headers:
|
||||
- idn2.h
|
||||
pkg-configs:
|
||||
- libidn2
|
||||
|
||||
@ -11,6 +11,9 @@ krb5:
|
||||
source-root: src
|
||||
depends:
|
||||
- openssl
|
||||
suggests:
|
||||
- ldap
|
||||
- libedit
|
||||
frameworks:
|
||||
- Kerberos
|
||||
headers:
|
||||
@ -18,6 +21,3 @@ krb5:
|
||||
- gssapi/gssapi.h
|
||||
pkg-configs:
|
||||
- krb5-gssapi
|
||||
suggests:
|
||||
- ldap
|
||||
- libedit
|
||||
|
||||
@ -10,10 +10,10 @@ libxml2:
|
||||
license: MIT
|
||||
depends@unix:
|
||||
- libiconv
|
||||
suggests@unix:
|
||||
- xz
|
||||
- zlib
|
||||
headers:
|
||||
- libxml2
|
||||
pkg-configs:
|
||||
- libxml-2.0
|
||||
suggests@unix:
|
||||
- xz
|
||||
- zlib
|
||||
|
||||
@ -11,14 +11,14 @@ nghttp2:
|
||||
depends:
|
||||
- zlib
|
||||
- openssl
|
||||
suggests:
|
||||
- libxml2
|
||||
- nghttp3
|
||||
- ngtcp2
|
||||
- brotli
|
||||
headers:
|
||||
- nghttp2
|
||||
pkg-configs:
|
||||
- libnghttp2
|
||||
static-libs@unix:
|
||||
- libnghttp2.a
|
||||
suggests:
|
||||
- libxml2
|
||||
- nghttp3
|
||||
- ngtcp2
|
||||
- brotli
|
||||
|
||||
@ -11,6 +11,9 @@ ngtcp2:
|
||||
license: MIT
|
||||
depends:
|
||||
- openssl
|
||||
suggests:
|
||||
- nghttp3
|
||||
- brotli
|
||||
headers:
|
||||
- ngtcp2
|
||||
pkg-configs:
|
||||
@ -19,6 +22,3 @@ ngtcp2:
|
||||
static-libs@unix:
|
||||
- libngtcp2.a
|
||||
- libngtcp2_crypto_ossl.a
|
||||
suggests:
|
||||
- nghttp3
|
||||
- brotli
|
||||
|
||||
9
config/pkg/target/pkg-config.yml
Normal file
9
config/pkg/target/pkg-config.yml
Normal file
@ -0,0 +1,9 @@
|
||||
pkg-config:
|
||||
type: target
|
||||
artifact:
|
||||
source: 'https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz'
|
||||
binary:
|
||||
linux-x86_64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-x86_64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||
linux-aarch64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-aarch64-linux-musl-1.2.5.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||
macos-x86_64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-x86_64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||
macos-aarch64: { type: ghrel, repo: static-php/static-php-cli-hosted, match: pkg-config-aarch64-darwin.txz, extract: { bin/pkg-config: '{pkg_root_path}/bin/pkg-config' } }
|
||||
4
config/pkg/target/zig.yml
Normal file
4
config/pkg/target/zig.yml
Normal file
@ -0,0 +1,4 @@
|
||||
zig:
|
||||
type: target
|
||||
artifact:
|
||||
binary: custom
|
||||
@ -13,6 +13,7 @@
|
||||
"config": [
|
||||
"config/pkg.ext.json",
|
||||
"config/pkg/lib",
|
||||
"config/pkg/target",
|
||||
"config/pkg.target.json"
|
||||
]
|
||||
},
|
||||
|
||||
@ -56,7 +56,7 @@ class LintConfigCommand extends BaseCommand
|
||||
public function packageSortKey(string $a, string $b): int
|
||||
{
|
||||
// sort by predefined order, other not matching keys go to the end alphabetically
|
||||
$order = ['type', 'artifact'];
|
||||
$order = ['type', 'artifact', 'depends', 'suggests', 'frameworks'];
|
||||
|
||||
// Handle suffix patterns (e.g., 'depends@unix', 'static-libs@windows')
|
||||
$base_a = preg_replace('/@(unix|windows|macos|linux|freebsd|bsd)$/', '', $a);
|
||||
|
||||
@ -27,25 +27,25 @@ class LinuxMuslCheck
|
||||
public static function optionalCheck(): bool
|
||||
{
|
||||
$toolchain = ApplicationContext::get(ToolchainInterface::class);
|
||||
return $toolchain instanceof MuslToolchain || $toolchain instanceof ZigToolchain && !LinuxUtil::isMuslDist();
|
||||
return $toolchain instanceof MuslToolchain || $toolchain instanceof ZigToolchain && !LinuxUtil::isMuslDist() && !str_contains(getenv('SPC_TARGET') ?: '', 'gnu');
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
#[CheckItem('if musl-wrapper is installed', limit_os: 'Linux', level: 800)]
|
||||
public function checkMusl(): CheckResult
|
||||
public function checkMusl(): ?CheckResult
|
||||
{
|
||||
$musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m'));
|
||||
if (file_exists($musl_wrapper_lib) && (file_exists('/usr/local/musl/lib/libc.a') || getenv('SPC_TOOLCHAIN') === ZigToolchain::class)) {
|
||||
return CheckResult::ok();
|
||||
return null;
|
||||
}
|
||||
return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper');
|
||||
}
|
||||
|
||||
#[CheckItem('if musl-cross-make is installed', limit_os: 'Linux', level: 799)]
|
||||
public function checkMuslCrossMake(): CheckResult
|
||||
public function checkMuslCrossMake(): ?CheckResult
|
||||
{
|
||||
if (getenv('SPC_TOOLCHAIN') === ZigToolchain::class && !LinuxUtil::isMuslDist()) {
|
||||
return CheckResult::ok();
|
||||
return null;
|
||||
}
|
||||
$arch = arch2gnu(php_uname('m'));
|
||||
$cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a";
|
||||
|
||||
@ -259,7 +259,7 @@ class PackageInstaller
|
||||
if ($this->isBuildPackage($package)) {
|
||||
return $package->isInstalled();
|
||||
}
|
||||
if ($package instanceof LibraryPackage && $package->getArtifact()->shouldUseBinary()) {
|
||||
if ($package->getArtifact() !== null && $package->getArtifact()->shouldUseBinary()) {
|
||||
$artifact = $package->getArtifact();
|
||||
return $artifact->isBinaryExtracted();
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@ class ClangNativeToolchain implements UnixToolchainInterface
|
||||
{
|
||||
public function initEnv(): void
|
||||
{
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=clang');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=clang++');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_CC=clang');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_CXX=clang++');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_AR=ar');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_LD=ld');
|
||||
}
|
||||
|
||||
public function afterInit(): void
|
||||
|
||||
@ -15,10 +15,10 @@ class GccNativeToolchain implements UnixToolchainInterface
|
||||
{
|
||||
public function initEnv(): void
|
||||
{
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=gcc');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=g++');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_CC=gcc');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_CXX=g++');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_AR=ar');
|
||||
GlobalEnvManager::putenv('SPC_DEFAULT_LD=ld');
|
||||
}
|
||||
|
||||
public function afterInit(): void
|
||||
|
||||
@ -14,10 +14,10 @@ class MuslToolchain implements UnixToolchainInterface
|
||||
{
|
||||
$arch = getenv('GNU_ARCH');
|
||||
// Set environment variables for musl toolchain
|
||||
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_CC={$arch}-linux-musl-gcc");
|
||||
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
|
||||
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar");
|
||||
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_LD={$arch}-linux-musl-ld");
|
||||
GlobalEnvManager::putenv("SPC_DEFAULT_CC={$arch}-linux-musl-gcc");
|
||||
GlobalEnvManager::putenv("SPC_DEFAULT_CXX={$arch}-linux-musl-g++");
|
||||
GlobalEnvManager::putenv("SPC_DEFAULT_AR={$arch}-linux-musl-ar");
|
||||
GlobalEnvManager::putenv("SPC_DEFAULT_LD={$arch}-linux-musl-ld");
|
||||
GlobalEnvManager::addPathIfNotExists('/usr/local/musl/bin');
|
||||
GlobalEnvManager::addPathIfNotExists("/usr/local/musl/{$arch}-linux-musl/bin");
|
||||
|
||||
@ -40,7 +40,7 @@ class MuslToolchain implements UnixToolchainInterface
|
||||
|
||||
public function getCompilerInfo(): ?string
|
||||
{
|
||||
$compiler = getenv('CC') ?: getenv('SPC_LINUX_DEFAULT_CC');
|
||||
$compiler = getenv('CC') ?: getenv('SPC_DEFAULT_CC');
|
||||
$version = shell(false)->execWithResult("{$compiler} --version", false);
|
||||
$head = pathinfo($compiler, PATHINFO_BASENAME);
|
||||
if ($version[0] === 0 && preg_match('/linux-musl-cc.*(\d+.\d+.\d+)/', $version[1][0], $match)) {
|
||||
|
||||
@ -28,7 +28,12 @@ class PkgConfigUtil
|
||||
];
|
||||
$found = null;
|
||||
foreach ($find_list as $file) {
|
||||
if (file_exists($file) && is_executable($file)) {
|
||||
$exists = file_exists($file);
|
||||
$executable = is_executable($file);
|
||||
if (!$exists) {
|
||||
continue;
|
||||
}
|
||||
if (!$executable && chmod($file, 0755) || $executable) {
|
||||
$found = $file;
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user