Use cmake executor instead of raw command

This commit is contained in:
crazywhalecc
2025-06-09 01:07:30 +08:00
parent 7d26aa533a
commit 1718806042
23 changed files with 151 additions and 394 deletions

View File

@@ -18,7 +18,9 @@ class UnixCMakeExecutor extends Executor
protected ?array $custom_default_args = null;
public function build(): void
protected int $steps = 3;
public function build(string $build_pos = '..'): void
{
// set cmake dir
$this->initCMakeBuildDir();
@@ -35,13 +37,13 @@ class UnixCMakeExecutor extends Executor
$shell = shell()->cd($this->cmake_build_dir)->setEnv($env);
// config
$shell->execWithEnv("cmake {$this->getConfigureArgs()} {$this->getDefaultCMakeArgs()}");
$this->steps >= 1 && $shell->execWithEnv("cmake {$this->getConfigureArgs()} {$this->getDefaultCMakeArgs()} {$build_pos}");
// make
$shell->execWithEnv("cmake --build . -j {$this->library->getBuilder()->concurrency}");
$this->steps >= 2 && $shell->execWithEnv("cmake --build . -j {$this->library->getBuilder()->concurrency}");
// install
$shell->execWithEnv('make install');
$this->steps >= 3 && $shell->execWithEnv('make install');
}
/**
@@ -73,6 +75,11 @@ class UnixCMakeExecutor extends Executor
return $this;
}
public function toStep(int $step): static
{
$this->steps = $step;
}
/**
* Set custom CMake build directory.
*
@@ -113,6 +120,7 @@ class UnixCMakeExecutor extends Executor
'-DCMAKE_INSTALL_BINDIR=bin',
'-DCMAKE_INSTALL_LIBDIR=lib',
'-DCMAKE_INSTALL_INCLUDE_DIR=include',
'-DBUILD_SHARED_LIBS=OFF',
"-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}",
'..',
]);