22 if (index_path ==
"-v" || index_path ==
"--version") {
25 }
else if (index_path ==
"--dry-run" || index_path ==
"-n") {
28 }
else if (index_path ==
"-h" || index_path ==
"--help") {
31 }
else if (index_path ==
"/h" || index_path ==
"/help") {
34 }
else if (index_path ==
"/v" || index_path ==
"/version") {
37 }
else if (index_path ==
"/dry-run" || index_path ==
"/n") {
46int main(
int argc,
char** argv) {
53 std::vector<std::thread> jobs;
56 std::string index_path = argv[
index];
59 if (cmdline(index_path, config) ==
EXIT_SUCCESS)
continue;
73 size_t index_cpy{
index};
76 jobs.push_back(std::thread{
77 [&mutex, &
index, &index_cpy, &argc, &argv, &config](std::string index_path) ->
void {
78 std::unique_lock<
decltype(mutex)> lk{mutex};
79 std::unique_ptr<BldKit::IManifestBuilder> builder;
81 constexpr auto kJsonExtension =
".json";
83 if (index_path.ends_with(kJsonExtension)) {
84 builder = std::make_unique<BldKit::JSONManifestBuilder>();
86#ifndef NEBUILD_WINDOWS
87 constexpr auto kTomlExtension =
".toml";
89 builder = std::make_unique<BldKit::TOMLManifestBuilder>();
91 if (!index_path.ends_with(kTomlExtension)) {
93 <<
"error: file '" << index_path <<
"' is not a manifest file!" << std::endl;
99 <<
"' is not a manifest file! (TOML support is not "
100 "available on Windows)"
109 if ((index_cpy + 1) < argc && argv[index_cpy + 1])
path = argv[index_cpy + 1];
111 if (
path ==
"--build-system" ||
path ==
"-B") {
118 config.
path(index_path);
120 if (builder && !builder->BuildTarget(config)) {
127 for (
auto& job : jobs) job.join();
131 }
catch (
const std::runtime_error& err) {
JSON manifest builder header file.
TOML manifest builder header file.
std::ostream & info() noexcept
replacement for std::cout for NeBuild logging.
const std::string & path()
std::size_t manifest_count
int operator()(const std::string &index_path, BldKit::BuildConfig &config)
std::vector< std::string > manifest_paths