From f37110605eec4972ed661ac9202b4aaaff4c5a41 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 25 Mar 2025 16:13:41 +0800 Subject: [PATCH] Remove dev build target --- src/SPC/builder/BuilderBase.php | 2 +- src/SPC/builder/linux/LinuxBuilder.php | 14 ----------- src/SPC/builder/macos/MacOSBuilder.php | 14 ----------- src/SPC/command/BuildPHPCommand.php | 34 ++++++++++++-------------- src/globals/defines.php | 3 +-- 5 files changed, 18 insertions(+), 49 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 0e864460..665ce7fa 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -227,7 +227,7 @@ abstract class BuilderBase */ abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE); - public function buildDynamicExts(): void + public function buildSharedExts(): void { foreach ($this->getExts() as $ext) { if (!$ext->isBuildShared()) { diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 3b0527f1..e38714f1 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -149,7 +149,6 @@ class LinuxBuilder extends UnixBuilderBase $enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; - $emable_dev = ($build_target & BUILD_TARGET_DEV) === BUILD_TARGET_DEV; $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs @@ -204,11 +203,6 @@ class LinuxBuilder extends UnixBuilderBase logger()->info('building micro'); $this->buildMicro(); } - if ($emable_dev && !$enable_embed) { - // install dynamic php extension building - logger()->info('building dynamic php extension dev dependencies'); - $this->buildPhpDev(); - } if ($enable_embed) { logger()->info('building embed'); if ($enable_micro) { @@ -320,14 +314,6 @@ class LinuxBuilder extends UnixBuilderBase $this->patchPhpScripts(); } - protected function buildPhpDev(): void - { - $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); - shell()->cd(SOURCE_PATH . '/php-src') - ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install-build install-programs install-headers"); - $this->patchPhpScripts(); - } - private function getMakeExtraVars(): array { return [ diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 4da9e455..9f9ad684 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -146,7 +146,6 @@ class MacOSBuilder extends UnixBuilderBase $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; - $enableDev = ($build_target & BUILD_TARGET_DEV) === BUILD_TARGET_DEV; // prepare build php envs $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; @@ -198,11 +197,6 @@ class MacOSBuilder extends UnixBuilderBase logger()->info('building micro'); $this->buildMicro(); } - if ($enableDev && !$enableEmbed) { - // install dynamic php extension building - logger()->info('building dynamic php extension dev dependencies'); - $this->buildPhpDev(); - } if ($enableEmbed) { logger()->info('building embed'); if ($enableMicro) { @@ -309,14 +303,6 @@ class MacOSBuilder extends UnixBuilderBase $this->patchPhpScripts(); } - protected function buildPhpDev(): void - { - $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); - shell()->cd(SOURCE_PATH . '/php-src') - ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install-build install-programs install-headers"); - $this->patchPhpScripts(); - } - private function getMakeExtraVars(): array { return [ diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index ea0b9f95..f55bebbf 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -27,12 +27,11 @@ class BuildPHPCommand extends BuildCommand $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); - $this->addOption('with-dynamic', 'D', InputOption::VALUE_REQUIRED, 'Dynamic extensions to build, comma separated', ''); + $this->addOption('with-shared', 'D', InputOption::VALUE_REQUIRED, 'Shared extensions to build, comma separated', ''); $this->addOption('build-micro', null, null, 'Build micro SAPI'); $this->addOption('build-cli', null, null, 'Build cli SAPI'); $this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)'); $this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)'); - $this->addOption('build-dev', null, null, 'Build dev things for building dynamic extensions (not available on Windows)'); $this->addOption('build-all', null, null, 'Build all SAPI'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); @@ -54,26 +53,26 @@ class BuildPHPCommand extends BuildCommand // transform string to array $libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs')))); // transform string to array - $dynamic_extensions = array_map('trim', array_filter(explode(',', $this->getOption('with-dynamic')))); + $shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('with-shared')))); // transform string to array $static_extensions = $this->parseExtensionList($this->getArgument('extensions')); // parse rule with options - $rule = $this->parseRules($dynamic_extensions); + $rule = $this->parseRules($shared_extensions); // check dynamic extension build env // macOS must use --no-strip option - if (!empty($dynamic_extensions) && PHP_OS_FAMILY === 'Darwin' && !$this->getOption('no-strip')) { + if (!empty($shared_extensions) && PHP_OS_FAMILY === 'Darwin' && !$this->getOption('no-strip')) { $this->output->writeln('MacOS does not support dynamic extension loading with stripped binary, please use --no-strip option!'); return static::FAILURE; } // linux must build with glibc - if (!empty($dynamic_extensions) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') !== 'glibc') { + if (!empty($shared_extensions) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') !== 'glibc') { $this->output->writeln('Linux does not support dynamic extension loading with musl-libc full-static build, please build with glibc!'); return static::FAILURE; } - if ($rule === BUILD_TARGET_NONE || $rule === BUILD_TARGET_DEV) { + if ($rule === BUILD_TARGET_NONE) { $this->output->writeln('Please add at least one build SAPI!'); $this->output->writeln("\t--build-cli\tBuild php-cli SAPI"); $this->output->writeln("\t--build-micro\tBuild phpmicro SAPI"); @@ -123,9 +122,9 @@ class BuildPHPCommand extends BuildCommand $builder = BuilderProvider::makeBuilderByInput($this->input); $include_suggest_ext = $this->getOption('with-suggested-exts'); $include_suggest_lib = $this->getOption('with-suggested-libs'); - [$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs(array_merge($static_extensions, $dynamic_extensions), $libraries, $include_suggest_ext, $include_suggest_lib); + [$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs(array_merge($static_extensions, $shared_extensions), $libraries, $include_suggest_ext, $include_suggest_lib); $display_libs = array_filter($libraries, fn ($lib) => in_array(Config::getLib($lib, 'type', 'lib'), ['lib', 'package'])); - $display_extensions = array_map(fn ($ext) => in_array($ext, $dynamic_extensions) ? "*{$ext}" : $ext, $extensions); + $display_extensions = array_map(fn ($ext) => in_array($ext, $shared_extensions) ? "*{$ext}" : $ext, $extensions); // print info $indent_texts = [ @@ -136,7 +135,7 @@ class BuildPHPCommand extends BuildCommand 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', ]; - if (!empty($dynamic_extensions) || ($rule & BUILD_TARGET_EMBED) || ($rule & BUILD_TARGET_DEV)) { + if (!empty($shared_extensions) || ($rule & BUILD_TARGET_EMBED)) { $indent_texts['Build Dev'] = 'yes'; } if (!empty($this->input->getOption('with-config-file-path'))) { @@ -172,7 +171,7 @@ class BuildPHPCommand extends BuildCommand // compile libraries $builder->proveLibs($libraries); // check extensions - $builder->proveExts($extensions, shared_build_extensions: $dynamic_extensions); + $builder->proveExts($extensions, shared_build_extensions: $shared_extensions); // validate libs and extensions $builder->validateLibsAndExts(); @@ -204,9 +203,9 @@ class BuildPHPCommand extends BuildCommand $builder->buildPHP($rule); // build dynamic extensions if needed - if (!empty($dynamic_extensions)) { - logger()->info('Building dynamic extensions ...'); - $builder->buildDynamicExts(); + if (!empty($shared_extensions)) { + logger()->info('Building shared extensions ...'); + $builder->buildSharedExts(); } // compile stopwatch :P @@ -237,8 +236,8 @@ class BuildPHPCommand extends BuildCommand $path = FileSystem::convertPath("{$build_root_path}/bin/php-fpm"); logger()->info("Static php-fpm binary path{$fixed}: {$path}"); } - if (!empty($dynamic_extensions)) { - foreach ($dynamic_extensions as $ext) { + if (!empty($shared_extensions)) { + foreach ($shared_extensions as $ext) { $path = FileSystem::convertPath("{$build_root_path}/ext/{$ext}.so"); logger()->info("Dynamic extension path{$fixed}: {$path}"); } @@ -277,8 +276,7 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); - $rule |= ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); - $rule |= ($this->getOption('build-dev') || !empty($dynamic_exts) ? BUILD_TARGET_DEV : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-embed') || !empty($dynamic_exts) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; } diff --git a/src/globals/defines.php b/src/globals/defines.php index a7059775..46c98915 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -61,8 +61,7 @@ const BUILD_TARGET_CLI = 1; // build cli const BUILD_TARGET_MICRO = 2; // build micro const BUILD_TARGET_FPM = 4; // build fpm const BUILD_TARGET_EMBED = 8; // build embed -const BUILD_TARGET_DEV = 16; // build dev -const BUILD_TARGET_ALL = 31; // build all +const BUILD_TARGET_ALL = 15; // build all // doctor error fix policy const FIX_POLICY_DIE = 1; // die directly