Extract default build env to unix shell

This commit is contained in:
crazywhalecc
2025-06-09 10:24:06 +08:00
parent 9babe7f1d2
commit 123cc92756
29 changed files with 166 additions and 196 deletions

View File

@@ -33,24 +33,17 @@ class UnixCMakeExecutor extends Executor
FileSystem::resetDir($this->build_dir);
}
// prepare environment variables
$env = [
'CFLAGS' => $this->library->getLibExtraCFlags(),
'LDFLAGS' => $this->library->getLibExtraLdFlags(),
'LIBS' => $this->library->getLibExtraLibs(),
];
// prepare shell
$shell = shell()->cd($this->build_dir)->setEnv($env);
$shell = shell()->cd($this->build_dir)->initLibBuildEnv($this->library);
// config
$this->steps >= 1 && $shell->execWithEnv("cmake {$this->getConfigureArgs()} {$this->getDefaultCMakeArgs()} {$build_pos}");
$this->steps >= 1 && $shell->exec("cmake {$this->getConfigureArgs()} {$this->getDefaultCMakeArgs()} {$build_pos}");
// make
$this->steps >= 2 && $shell->execWithEnv("cmake --build . -j {$this->library->getBuilder()->concurrency}");
$this->steps >= 2 && $shell->exec("cmake --build . -j {$this->library->getBuilder()->concurrency}");
// install
$this->steps >= 3 && $shell->execWithEnv('make install');
$this->steps >= 3 && $shell->exec('make install');
}
/**