Add build jobs arg
This commit is contained in:
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -10,7 +10,7 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-Command",
|
"-Command",
|
||||||
"& './scripts/build_script.exe' configure -b debug -v"
|
"& './scripts/build_script.exe' configure -b debug"
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
|
|||||||
@@ -34,7 +34,14 @@ void Application::buildDir(const std::filesystem::path& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spdlog::get("build")->info("Building '{}'", path.string());
|
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) {
|
exitCode != 0) {
|
||||||
spdlog::get("build")->critical("Command exited with exit code: {}",
|
spdlog::get("build")->critical("Command exited with exit code: {}",
|
||||||
exitCode);
|
exitCode);
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ Application::Application(Options options)
|
|||||||
m_Verbose(options.verbose.value()),
|
m_Verbose(options.verbose.value()),
|
||||||
m_BuildType(options.buildType.value()),
|
m_BuildType(options.buildType.value()),
|
||||||
m_Command(options.command),
|
m_Command(options.command),
|
||||||
m_Multithreaded(options.multithreaded.value()) {
|
m_Multithreaded(options.multithreaded.value()),
|
||||||
|
m_BuildJobs(options.jobs.value()) {
|
||||||
createAllLoggers();
|
createAllLoggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class Application {
|
|||||||
bool m_DryRun;
|
bool m_DryRun;
|
||||||
bool m_Verbose;
|
bool m_Verbose;
|
||||||
bool m_Multithreaded;
|
bool m_Multithreaded;
|
||||||
|
int m_BuildJobs;
|
||||||
BuildType m_BuildType;
|
BuildType m_BuildType;
|
||||||
Command m_Command;
|
Command m_Command;
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ struct Options {
|
|||||||
std::optional<bool> verbose = false;
|
std::optional<bool> verbose = false;
|
||||||
std::optional<bool> dryrun = false;
|
std::optional<bool> dryrun = false;
|
||||||
std::optional<bool> multithreaded = false;
|
std::optional<bool> multithreaded = false;
|
||||||
|
std::optional<int> jobs = 0;
|
||||||
std::optional<std::string> graphFilename;
|
std::optional<std::string> graphFilename;
|
||||||
};
|
};
|
||||||
STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded,
|
STRUCTOPT(Options, command, buildType, verbose, dryrun, multithreaded, jobs,
|
||||||
graphFilename);
|
graphFilename);
|
||||||
|
|
||||||
Options parse(int argc, char** argv);
|
Options parse(int argc, char** argv);
|
||||||
|
|||||||
@@ -46,14 +46,13 @@ void Application::checkDir(std::string path) {
|
|||||||
|
|
||||||
if (!std::filesystem::is_directory(path)) {
|
if (!std::filesystem::is_directory(path)) {
|
||||||
if (!std::filesystem::exists(path)) {
|
if (!std::filesystem::exists(path)) {
|
||||||
spdlog::get("filesystem")
|
spdlog::get("filesystem")->info("Creating '{}' directory.", path);
|
||||||
->info("Creating 'build/debug' directory.");
|
|
||||||
createDir(path);
|
createDir(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spdlog::get("filesystem")
|
spdlog::get("filesystem")
|
||||||
->warn("'build/debug' is not a directory. Deleting.");
|
->warn("'{}' is not a directory. Deleting.", path);
|
||||||
deleteDir("build/debug");
|
deleteDir(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user