From 0696acb9c55cc13789539510969096e424e4249f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 15:54:55 +0800 Subject: [PATCH] Add support for re2c in tool checklists and environment setup --- bin/spc-alpine-docker | 1 + src/SPC/doctor/item/LinuxToolCheckList.php | 6 +++--- src/SPC/doctor/item/MacOSToolCheckList.php | 1 + src/SPC/util/GlobalEnvManager.php | 10 ++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 18e981f8..204273e3 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -104,6 +104,7 @@ RUN apk update; \ m4 \ make \ pkgconfig \ + re2c \ wget \ xz \ gettext-dev \ diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 51e191bf..3d441bf3 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -16,7 +16,7 @@ class LinuxToolCheckList use UnixSystemUtilTrait; public const TOOLS_ALPINE = [ - 'make', 'bison', 'flex', + 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'gettext-dev', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', @@ -26,7 +26,7 @@ class LinuxToolCheckList ]; public const TOOLS_DEBIAN = [ - 'make', 'bison', 'flex', + 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'autopoint', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', @@ -35,7 +35,7 @@ class LinuxToolCheckList ]; public const TOOLS_RHEL = [ - 'perl', 'make', 'bison', 'flex', + 'perl', 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', 'which', diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index b4043a1d..b2dee2b5 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -19,6 +19,7 @@ class MacOSToolCheckList 'curl', 'make', 'bison', + 're2c', 'flex', 'pkg-config', 'git', diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 23ae242d..c499488c 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\util; +use SPC\builder\macos\SystemUtil; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\toolchain\ToolchainManager; @@ -111,6 +112,15 @@ class GlobalEnvManager if (!filter_var(getenv('SPC_SKIP_TOOLCHAIN_CHECK'), FILTER_VALIDATE_BOOL)) { ToolchainManager::afterInitToolchain(); } + // test bison + if (PHP_OS_FAMILY === 'Darwin') { + if ($bison = SystemUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + self::putenv("BISON={$bison}"); + } + if ($yacc = SystemUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + self::putenv("YACC={$yacc}"); + } + } } /**