Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
let build tool to resolve -j option by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dimas1185 committed Apr 28, 2023
1 parent 2a2cc64 commit abf390d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <iostream>
#include <string>
#include <sys/sysinfo.h>

#include "CLI11.hpp"

Expand All @@ -19,7 +18,7 @@ namespace antler {
subcommand->footer(std::string(R"(Examples:)")
+ "\n\t" + app.get_name() +R"( build -j3)");
subcommand->add_option("-p, path", path, "This is the path to the root of the project.");
subcommand->add_option("-j, --jobs", jobs, "The number of jobs to use with cmake. If 0 is specified (default value) antler will use number of available processors.")->default_val(0);
subcommand->add_option("-j, --jobs", jobs, "The number of jobs to use with cmake build tool. Default is number of CPUs.");
subcommand->add_flag("-c, --clean", clean, "This will force a clean build.")->default_val(false);
}

Expand All @@ -40,7 +39,11 @@ namespace antler {
system::fs::create_directory(bin_dir);
system::info_log("Building project...");

return system::execute("cmake", {"--build", bin_dir.string(), "-j", std::to_string(jobs)});
CLI::results_t args = {"--build", bin_dir.string(), "-j"};
if (jobs)
args.push_back(std::to_string(jobs));

return system::execute("cmake", std::move(args));
}

void move_artifacts(const project::project& proj) noexcept {
Expand All @@ -67,8 +70,6 @@ namespace antler {
}

int32_t exec() {
if (!jobs)
jobs = get_nprocs();

auto proj = load_project(path);

Expand Down

0 comments on commit abf390d

Please sign in to comment.