mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
update building of frankenphp
This commit is contained in:
parent
09073c5517
commit
e2b80e7f03
@ -105,9 +105,16 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
if (PHP_OS_FAMILY === 'Darwin') {
|
if (PHP_OS_FAMILY === 'Darwin') {
|
||||||
shell()->exec("dsymutil -f {$binary_path} -o {$debug_file}");
|
shell()->exec("dsymutil -f {$binary_path} -o {$debug_file}");
|
||||||
} elseif (PHP_OS_FAMILY === 'Linux') {
|
} elseif (PHP_OS_FAMILY === 'Linux') {
|
||||||
shell()
|
$has_eu_strip = shell()->execWithResult('which eu-strip')[0] === 0;
|
||||||
->exec("objcopy --only-keep-debug {$binary_path} {$debug_file}")
|
if ($has_eu_strip) {
|
||||||
->exec("objcopy --add-gnu-debuglink={$debug_file} {$binary_path}");
|
shell()
|
||||||
|
->exec("eu-strip -f {$debug_file} {$binary_path}")
|
||||||
|
->exec("objcopy --add-gnu-debuglink={$debug_file} {$binary_path}");
|
||||||
|
} else {
|
||||||
|
shell()
|
||||||
|
->exec("objcopy --only-keep-debug {$binary_path} {$debug_file}")
|
||||||
|
->exec("objcopy --add-gnu-debuglink={$debug_file} {$binary_path}");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new SPCInternalException('extractDebugInfo is only supported on Linux and macOS');
|
throw new SPCInternalException('extractDebugInfo is only supported on Linux and macOS');
|
||||||
}
|
}
|
||||||
@ -351,8 +358,10 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
*/
|
*/
|
||||||
protected function processFrankenphpApp(): void
|
protected function processFrankenphpApp(): void
|
||||||
{
|
{
|
||||||
$frankenphpSourceDir = SOURCE_PATH . '/frankenphp';
|
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
|
||||||
SourceManager::initSource(['frankenphp'], ['frankenphp']);
|
if (!is_dir($frankenphpSourceDir)) {
|
||||||
|
SourceManager::initSource(['frankenphp'], ['frankenphp']);
|
||||||
|
}
|
||||||
$frankenphpAppPath = $this->getOption('with-frankenphp-app');
|
$frankenphpAppPath = $this->getOption('with-frankenphp-app');
|
||||||
|
|
||||||
if ($frankenphpAppPath) {
|
if ($frankenphpAppPath) {
|
||||||
@ -376,7 +385,11 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
|
|
||||||
protected function getFrankenPHPVersion(): string
|
protected function getFrankenPHPVersion(): string
|
||||||
{
|
{
|
||||||
$goModPath = SOURCE_PATH . '/frankenphp/caddy/go.mod';
|
if ($version = getenv('FRANKENPHP_VERSION')) {
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
|
||||||
|
$goModPath = $frankenphpSourceDir . '/caddy/go.mod';
|
||||||
|
|
||||||
if (!file_exists($goModPath)) {
|
if (!file_exists($goModPath)) {
|
||||||
throw new SPCInternalException("FrankenPHP caddy/go.mod file not found at {$goModPath}, why did we not download FrankenPHP?");
|
throw new SPCInternalException("FrankenPHP caddy/go.mod file not found at {$goModPath}, why did we not download FrankenPHP?");
|
||||||
@ -397,7 +410,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';
|
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';
|
||||||
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
||||||
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
||||||
$frankenphpSourceDir = SOURCE_PATH . '/frankenphp';
|
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
|
||||||
|
|
||||||
$xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules);
|
$xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules);
|
||||||
$xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " .
|
$xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " .
|
||||||
@ -417,7 +430,6 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$dynamic_exports = ' ' . $dynamicSymbolsArgument;
|
$dynamic_exports = ' ' . $dynamicSymbolsArgument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$debugFlags = $this->getOption('no-strip') ? '' : '-w -s ';
|
|
||||||
$extLdFlags = "-extldflags '-pie{$dynamic_exports} {$this->arch_ld_flags}'";
|
$extLdFlags = "-extldflags '-pie{$dynamic_exports} {$this->arch_ld_flags}'";
|
||||||
$muslTags = '';
|
$muslTags = '';
|
||||||
$staticFlags = '';
|
$staticFlags = '';
|
||||||
@ -442,7 +454,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
'CGO_CFLAGS' => clean_spaces($cflags),
|
'CGO_CFLAGS' => clean_spaces($cflags),
|
||||||
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
||||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
|
||||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||||
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
||||||
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user