From f158fba48df405bf407d75f451e3daa135cc7247 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 01:48:48 +0800 Subject: [PATCH] Remove unused cmake things --- .../builder/traits/UnixSystemUtilTrait.php | 55 ------------------- .../unix/executor/UnixCMakeExecutor.php | 18 +++++- tests/SPC/builder/unix/UnixSystemUtilTest.php | 10 ---- 3 files changed, 16 insertions(+), 67 deletions(-) diff --git a/src/SPC/builder/traits/UnixSystemUtilTrait.php b/src/SPC/builder/traits/UnixSystemUtilTrait.php index 8b8cb743..3407a00b 100644 --- a/src/SPC/builder/traits/UnixSystemUtilTrait.php +++ b/src/SPC/builder/traits/UnixSystemUtilTrait.php @@ -4,66 +4,11 @@ declare(strict_types=1); namespace SPC\builder\traits; -use SPC\exception\FileSystemException; -use SPC\store\FileSystem; - /** * Unix 系统的工具函数 Trait,适用于 Linux、macOS */ trait UnixSystemUtilTrait { - /** - * 生成 toolchain.cmake,用于 cmake 构建 - * - * @param string $os 操作系统代号 - * @param string $target_arch 目标架构 - * @param string $cflags CFLAGS 参数 - * @param null|string $cc CC 参数(默认空) - * @param null|string $cxx CXX 参数(默认空) - * @throws FileSystemException - */ - public static function makeCmakeToolchainFile( - string $os, - string $target_arch, - string $cflags, - ?string $cc = null, - ?string $cxx = null - ): string { - logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'"); - $root = BUILD_ROOT_PATH; - $ccLine = ''; - if ($cc) { - $ccLine = 'SET(CMAKE_C_COMPILER ' . $cc . ')'; - } - $cxxLine = ''; - if ($cxx) { - $cxxLine = 'SET(CMAKE_CXX_COMPILER ' . $cxx . ')'; - } - $toolchain = <<steps = $step; @@ -106,6 +114,10 @@ class UnixCMakeExecutor extends Executor return $this; } + /** + * Set the reset status. + * If we set it to false, it will not clean and create the specified cmake working directory. + */ public function setReset(bool $reset): static { $this->reset = $reset; @@ -152,6 +164,8 @@ class UnixCMakeExecutor extends Executor } /** + * Generate cmake toolchain file for current spc instance, and return the file path. + * * @return string CMake toolchain file path * @throws FileSystemException * @throws WrongUsageException diff --git a/tests/SPC/builder/unix/UnixSystemUtilTest.php b/tests/SPC/builder/unix/UnixSystemUtilTest.php index 8da6c278..e17574af 100644 --- a/tests/SPC/builder/unix/UnixSystemUtilTest.php +++ b/tests/SPC/builder/unix/UnixSystemUtilTest.php @@ -8,7 +8,6 @@ use PHPUnit\Framework\TestCase; use SPC\builder\freebsd\SystemUtil as FreebsdSystemUtil; use SPC\builder\linux\SystemUtil as LinuxSystemUtil; use SPC\builder\macos\SystemUtil as MacosSystemUtil; -use SPC\exception\FileSystemException; /** * @internal @@ -31,15 +30,6 @@ class UnixSystemUtilTest extends TestCase $this->util = new $util_class(); } - /** - * @throws FileSystemException - */ - public function testMakeCmakeToolchainFile() - { - $str = $this->util->makeCmakeToolchainFile(PHP_OS_FAMILY, 'x86_64', ''); - $this->assertIsString($str); - } - public function testFindCommand() { $this->assertIsString($this->util->findCommand('bash'));