mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Compare commits
8 Commits
v3c/llvm-t
...
v3c/artifa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a1fd1f388 | ||
|
|
48d6e9ebc2 | ||
|
|
6cab47db67 | ||
|
|
ec3fd0f4b0 | ||
|
|
e72f9aa623 | ||
|
|
91cf4f83b5 | ||
|
|
c666cd6cd0 | ||
|
|
b8dd508148 |
@@ -15,6 +15,23 @@ use StaticPHP\Util\GlobalEnvManager;
|
||||
|
||||
class go_win
|
||||
{
|
||||
/** GOROOT for the Windows Go toolchain. */
|
||||
public static function path(): string
|
||||
{
|
||||
return PKG_ROOT_PATH . '/go-win';
|
||||
}
|
||||
|
||||
/** Path to a binary inside go-win's bin/ (go.exe, gofmt.exe, …). */
|
||||
public static function binary(string $name = 'go.exe'): string
|
||||
{
|
||||
return self::path() . '/bin/' . $name;
|
||||
}
|
||||
|
||||
public static function isInstalled(): bool
|
||||
{
|
||||
return is_file(self::binary());
|
||||
}
|
||||
|
||||
#[CustomBinary('go-win', [
|
||||
'windows-x86_64',
|
||||
])]
|
||||
|
||||
@@ -17,6 +17,23 @@ use StaticPHP\Util\System\LinuxUtil;
|
||||
|
||||
class go_xcaddy
|
||||
{
|
||||
/** GOROOT for the bundled Go toolchain used to build xcaddy. */
|
||||
public static function path(): string
|
||||
{
|
||||
return PKG_ROOT_PATH . '/go-xcaddy';
|
||||
}
|
||||
|
||||
/** Path to a binary inside go-xcaddy's bin/ (xcaddy, go, …). */
|
||||
public static function binary(string $name = 'xcaddy'): string
|
||||
{
|
||||
return self::path() . '/bin/' . $name;
|
||||
}
|
||||
|
||||
public static function isInstalled(): bool
|
||||
{
|
||||
return is_file(self::binary());
|
||||
}
|
||||
|
||||
#[CustomBinary('go-xcaddy', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
|
||||
@@ -16,6 +16,23 @@ use StaticPHP\Util\System\LinuxUtil;
|
||||
|
||||
class rust
|
||||
{
|
||||
/** Install prefix the rust tarball's install.sh writes into. */
|
||||
public static function path(): string
|
||||
{
|
||||
return PKG_ROOT_PATH . '/rust';
|
||||
}
|
||||
|
||||
/** Path to a binary inside the rust install dir (cargo, rustc, rustup, …). */
|
||||
public static function binary(string $name = 'cargo'): string
|
||||
{
|
||||
return self::path() . '/bin/' . $name;
|
||||
}
|
||||
|
||||
public static function isInstalled(): bool
|
||||
{
|
||||
return is_file(self::binary());
|
||||
}
|
||||
|
||||
#[CustomBinary('rust', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
|
||||
@@ -15,6 +15,23 @@ use StaticPHP\Runtime\SystemTarget;
|
||||
|
||||
class zig
|
||||
{
|
||||
/** Directory zig extracts into. */
|
||||
public static function path(): string
|
||||
{
|
||||
return PKG_ROOT_PATH . '/zig';
|
||||
}
|
||||
|
||||
/** Path to a binary inside the zig install dir (zig, zig-cc, zig-c++, zig-ar, …). */
|
||||
public static function binary(string $name = 'zig'): string
|
||||
{
|
||||
return self::path() . '/' . $name;
|
||||
}
|
||||
|
||||
public static function isInstalled(): bool
|
||||
{
|
||||
return is_file(self::binary());
|
||||
}
|
||||
|
||||
#[CustomBinary('zig', [
|
||||
'linux-x86_64',
|
||||
'linux-aarch64',
|
||||
|
||||
@@ -73,13 +73,20 @@ class LinuxMuslCheck
|
||||
$prefix = 'sudo ';
|
||||
logger()->warning('Current user is not root, using sudo for running command');
|
||||
}
|
||||
$sysEnv = ['CC' => 'gcc', 'CXX' => 'g++', 'AR' => 'ar', 'LD' => 'ld', 'RANLIB' => 'ranlib'];
|
||||
$envFlags = '';
|
||||
foreach ($sysEnv as $k => $v) {
|
||||
$envFlags .= "{$k}={$v} ";
|
||||
}
|
||||
$envFlags = rtrim($envFlags);
|
||||
$shell = shell()->cd(SOURCE_PATH . '/musl-wrapper')
|
||||
->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper')
|
||||
->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j');
|
||||
->setEnv($sysEnv)
|
||||
->exec('./configure --disable-gcc-wrapper')
|
||||
->exec('make -j');
|
||||
if ($prefix !== '') {
|
||||
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && {$envFlags} {$prefix}make install");
|
||||
} else {
|
||||
$shell->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||
$shell->exec("{$prefix}make install");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -256,10 +256,30 @@ function clean_spaces(string $string): string
|
||||
*/
|
||||
function deduplicate_flags(string $flags): string
|
||||
{
|
||||
$tokens = preg_split('/\s+/', trim($flags));
|
||||
// Flags that take their value as a separate token.
|
||||
static $paired = [
|
||||
'-Xclang', '-Xpreprocessor', '-Xlinker', '-Xassembler',
|
||||
'-framework', '-arch', '-target',
|
||||
'-include', '-imacros', '-isystem', '-isysroot', '-iquote', '-idirafter',
|
||||
'-MT', '-MF', '-MQ',
|
||||
];
|
||||
|
||||
$tokens = preg_split('/\s+/', trim($flags)) ?: [];
|
||||
|
||||
// Group paired flag+value into a single atom before dedup.
|
||||
$atoms = [];
|
||||
$n = count($tokens);
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
if (in_array($tokens[$i], $paired, true) && $i + 1 < $n) {
|
||||
$atoms[] = $tokens[$i] . ' ' . $tokens[$i + 1];
|
||||
++$i;
|
||||
} else {
|
||||
$atoms[] = $tokens[$i];
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse, unique, reverse back - keeps last occurrence of duplicates
|
||||
$deduplicated = array_reverse(array_unique(array_reverse($tokens)));
|
||||
$deduplicated = array_reverse(array_unique(array_reverse($atoms)));
|
||||
|
||||
return implode(' ', $deduplicated);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user