mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Add frankenphp sapi embed build at build command, not constant
This commit is contained in:
@@ -404,6 +404,9 @@ abstract class BuilderBase
|
|||||||
if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
||||||
$ls[] = 'embed';
|
$ls[] = 'embed';
|
||||||
}
|
}
|
||||||
|
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
|
||||||
|
$ls[] = 'frankenphp';
|
||||||
|
}
|
||||||
return implode(', ', $ls);
|
return implode(', ', $ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,6 +513,26 @@ abstract class BuilderBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkBeforeBuildPHP(int $rule): void
|
||||||
|
{
|
||||||
|
if (($rule & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
|
||||||
|
// frankenphp only support linux and macOS
|
||||||
|
if (!in_array(PHP_OS_FAMILY, ['Linux', 'Darwin'])) {
|
||||||
|
throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!');
|
||||||
|
}
|
||||||
|
// frankenphp needs package go-mod-frankenphp installed
|
||||||
|
$pkg_dir = PKG_ROOT_PATH . '/go-mod-frankenphp-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname();
|
||||||
|
if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) {
|
||||||
|
global $argv;
|
||||||
|
throw new WrongUsageException("FrankenPHP SAPI requires go-mod-frankenphp package, please install it first: {$argv[0]} install-pkg go-mod-frankenphp");
|
||||||
|
}
|
||||||
|
// frankenphp needs libxml2 libs
|
||||||
|
if (!$this->getLib('libxml2')) {
|
||||||
|
throw new WrongUsageException('FrankenPHP SAPI requires libxml2 library, please include `xml` extension in your build.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate micro extension test php code.
|
* Generate micro extension test php code.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -196,6 +196,9 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
// validate libs and extensions
|
// validate libs and extensions
|
||||||
$builder->validateLibsAndExts();
|
$builder->validateLibsAndExts();
|
||||||
|
|
||||||
|
// check some things before building all the things
|
||||||
|
$builder->checkBeforeBuildPHP($rule);
|
||||||
|
|
||||||
// clean builds and sources
|
// clean builds and sources
|
||||||
if ($this->input->getOption('with-clean')) {
|
if ($this->input->getOption('with-clean')) {
|
||||||
logger()->info('Cleaning source and previous build dir...');
|
logger()->info('Cleaning source and previous build dir...');
|
||||||
@@ -316,7 +319,7 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
$rule |= BUILD_TARGET_EMBED;
|
$rule |= BUILD_TARGET_EMBED;
|
||||||
f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared'));
|
f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared'));
|
||||||
}
|
}
|
||||||
$rule |= ($this->getOption('build-frankenphp') ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE);
|
$rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE);
|
||||||
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
||||||
return $rule;
|
return $rule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const BUILD_TARGET_CLI = 1; // build cli
|
|||||||
const BUILD_TARGET_MICRO = 2; // build micro
|
const BUILD_TARGET_MICRO = 2; // build micro
|
||||||
const BUILD_TARGET_FPM = 4; // build fpm
|
const BUILD_TARGET_FPM = 4; // build fpm
|
||||||
const BUILD_TARGET_EMBED = 8; // build embed
|
const BUILD_TARGET_EMBED = 8; // build embed
|
||||||
const BUILD_TARGET_FRANKENPHP = BUILD_TARGET_EMBED | 16; // build frankenphp
|
const BUILD_TARGET_FRANKENPHP = 16; // build frankenphp
|
||||||
const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all
|
const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all
|
||||||
|
|
||||||
// doctor error fix policy
|
// doctor error fix policy
|
||||||
|
|||||||
Reference in New Issue
Block a user