mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 03:15:35 +08:00
fix frankenphp build
This commit is contained in:
@@ -16,7 +16,9 @@ use SPC\store\CurlHook;
|
|||||||
use SPC\store\Downloader;
|
use SPC\store\Downloader;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\pkg\GoXcaddy;
|
use SPC\store\pkg\GoXcaddy;
|
||||||
|
use SPC\store\pkg\Zig;
|
||||||
use SPC\util\DependencyUtil;
|
use SPC\util\DependencyUtil;
|
||||||
|
use SPC\util\GlobalEnvManager;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
|
|
||||||
abstract class UnixBuilderBase extends BuilderBase
|
abstract class UnixBuilderBase extends BuilderBase
|
||||||
@@ -52,7 +54,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
array_unshift($libFiles, ...$lib->getStaticLibs());
|
array_unshift($libFiles, ...$lib->getStaticLibs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array_map(fn ($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles);
|
return array_map(fn($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +100,8 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
if ($lib instanceof LinuxLibraryBase || $lib instanceof MacOSLibraryBase || $lib instanceof BSDLibraryBase) {
|
if ($lib instanceof LinuxLibraryBase || $lib instanceof MacOSLibraryBase || $lib instanceof BSDLibraryBase) {
|
||||||
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
|
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
|
||||||
$ret .= "--with-{$libName}=yes " . $lib->makeAutoconfEnv($prefix) . ' ';
|
$ret .= "--with-{$libName}=yes " . $lib->makeAutoconfEnv($prefix) . ' ';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
|
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
|
||||||
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
|
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
|
||||||
}
|
}
|
||||||
@@ -212,7 +215,8 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
||||||
$ext_path = 'LD_LIBRARY_PATH=' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ';
|
$ext_path = 'LD_LIBRARY_PATH=' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ';
|
||||||
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.a');
|
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.a');
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$ext_path = '';
|
$ext_path = '';
|
||||||
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.so');
|
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.so');
|
||||||
}
|
}
|
||||||
@@ -241,7 +245,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
/**
|
/**
|
||||||
* 将编译好的二进制文件发布到 buildroot
|
* 将编译好的二进制文件发布到 buildroot
|
||||||
*
|
*
|
||||||
* @param int $type 发布类型
|
* @param int $type 发布类型
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
@@ -333,7 +337,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
|
|
||||||
$config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true);
|
$config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true);
|
||||||
|
|
||||||
$env = [...GoXcaddy::getEnvironment(), ...[
|
$env = [
|
||||||
'CGO_ENABLED' => '1',
|
'CGO_ENABLED' => '1',
|
||||||
'CGO_CFLAGS' => $config['cflags'],
|
'CGO_CFLAGS' => $config['cflags'],
|
||||||
'CGO_LDFLAGS' => "{$config['ldflags']} {$config['libs']} {$lrt}",
|
'CGO_LDFLAGS' => "{$config['ldflags']} {$config['libs']} {$lrt}",
|
||||||
@@ -343,7 +347,14 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
"{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
"{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
||||||
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
]];
|
];
|
||||||
|
foreach (GoXcaddy::getEnvironment() as $key => $value) {
|
||||||
|
if ($key === 'PATH') {
|
||||||
|
GlobalEnvManager::addPathIfNotExists($value);
|
||||||
|
} else {
|
||||||
|
$env[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
shell()->cd(BUILD_BIN_PATH)
|
shell()->cd(BUILD_BIN_PATH)
|
||||||
->setEnv($env)
|
->setEnv($env)
|
||||||
->exec("xcaddy build --output frankenphp {$xcaddyModules}");
|
->exec("xcaddy build --output frankenphp {$xcaddyModules}");
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class GlobalEnvManager
|
|||||||
self::$env_cache[] = $val;
|
self::$env_cache[] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function addPathIfNotExists(string $path): void
|
public static function addPathIfNotExists(string $path): void
|
||||||
{
|
{
|
||||||
if (is_unix() && !str_contains(getenv('PATH'), $path)) {
|
if (is_unix() && !str_contains(getenv('PATH'), $path)) {
|
||||||
self::putenv("PATH={$path}:" . getenv('PATH'));
|
self::putenv("PATH={$path}:" . getenv('PATH'));
|
||||||
|
|||||||
Reference in New Issue
Block a user