diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 609bf73..9d7fac9 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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}" diff --git a/src/actions.cpp b/src/actions.cpp index 71d3a50..83be043 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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); diff --git a/src/app.cpp b/src/app.cpp index 22533b5..4f63a7f 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -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(); } diff --git a/src/app.h b/src/app.h index 7285648..db41ee2 100644 --- a/src/app.h +++ b/src/app.h @@ -21,6 +21,7 @@ class Application { bool m_DryRun; bool m_Verbose; bool m_Multithreaded; + int m_BuildJobs; BuildType m_BuildType; Command m_Command; diff --git a/src/args.h b/src/args.h index 78d590b..961c971 100644 --- a/src/args.h +++ b/src/args.h @@ -13,9 +13,10 @@ struct Options { std::optional verbose = false; std::optional dryrun = false; std::optional multithreaded = false; + std::optional jobs = 0; std::optional graphFilename; }; -STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded, +STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded, jobs, graphFilename); Options parse(int argc, char** argv); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index ff5e6bd..64fa714 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -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); } }