Add build jobs arg
All checks were successful
Build / Build (linux) (push) Successful in 31s
Build / Build (windows) (push) Successful in 34s

This commit is contained in:
2026-06-29 10:38:10 -04:00
parent e6dff25b62
commit 00b4a22c9e
6 changed files with 17 additions and 8 deletions

2
.vscode/tasks.json vendored
View File

@@ -10,7 +10,7 @@
"args": [
"-NoProfile",
"-Command",
"& './scripts/build_script.exe' configure -b debug -v"
"& './scripts/build_script.exe' configure -b debug"
],
"options": {
"cwd": "${workspaceFolder}"

View File

@@ -34,7 +34,14 @@ void Application::buildDir(const std::filesystem::path& path) {
}
spdlog::get("build")->info("Building '{}'", path.string());
if (int exitCode = runCmd(std::format("cd {} && ninja", path.string()));
std::string jobsStr = "";
if (m_BuildJobs != 0) {
jobsStr = std::format("-j {}", m_BuildJobs);
}
if (int exitCode =
runCmd(std::format("cd {} && ninja {}", path.string(), jobsStr));
exitCode != 0) {
spdlog::get("build")->critical("Command exited with exit code: {}",
exitCode);

View File

@@ -11,7 +11,8 @@ Application::Application(Options options)
m_Verbose(options.verbose.value()),
m_BuildType(options.buildType.value()),
m_Command(options.command),
m_Multithreaded(options.multithreaded.value()) {
m_Multithreaded(options.multithreaded.value()),
m_BuildJobs(options.jobs.value()) {
createAllLoggers();
}

View File

@@ -21,6 +21,7 @@ class Application {
bool m_DryRun;
bool m_Verbose;
bool m_Multithreaded;
int m_BuildJobs;
BuildType m_BuildType;
Command m_Command;

View File

@@ -13,9 +13,10 @@ struct Options {
std::optional<bool> verbose = false;
std::optional<bool> dryrun = false;
std::optional<bool> multithreaded = false;
std::optional<int> jobs = 0;
std::optional<std::string> graphFilename;
};
STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded,
STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded, jobs,
graphFilename);
Options parse(int argc, char** argv);

View File

@@ -46,14 +46,13 @@ void Application::checkDir(std::string path) {
if (!std::filesystem::is_directory(path)) {
if (!std::filesystem::exists(path)) {
spdlog::get("filesystem")
->info("Creating 'build/debug' directory.");
spdlog::get("filesystem")->info("Creating '{}' directory.", path);
createDir(path);
return;
}
spdlog::get("filesystem")
->warn("'build/debug' is not a directory. Deleting.");
deleteDir("build/debug");
->warn("'{}' is not a directory. Deleting.", path);
deleteDir(path);
}
}