feat: adopt VoidLibrary VL-001..VL-013, self-building build.cpp, live logs, and generated CLI help
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 10s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 10s
This commit is contained in:
1 parent
ab64147f9d
commit
363fb8200e
33 files changed
+1754
-3155
No files matched your search
@@ -11,48 +11,49 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using namespace Void::Build;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::string files_opt;
|
||||
std::string jobs_opt;
|
||||
std::vector<std::string> positional_files;
|
||||
Void::Argparse::Parser parser{
|
||||
"vbs_benchmarks",
|
||||
"Run reproducible snapshot, cold build, and warm no-op timings for VoidBuildSystem."};
|
||||
parser.option_default("--files", "-n", "number of generated source units", files_opt, "20")
|
||||
.option_default("--jobs", "-j", "parallel worker count", jobs_opt, "4");
|
||||
.option_default("--jobs", "-j", "parallel worker count", jobs_opt, "4")
|
||||
.positional_many("count", "optional positional file count override", positional_files,
|
||||
false);
|
||||
|
||||
// Preserve positional shorthand `vbs_benchmarks 15` alongside `--files 15`.
|
||||
if (argc == 2 && (std::string_view{argv[1]} == "--help" || std::string_view{argv[1]} == "-h")) {
|
||||
std::cout << parser.help();
|
||||
const auto parsed = parser.parse_detailed(argc, argv);
|
||||
if (parsed.is_help()) {
|
||||
std::cout << parsed.message;
|
||||
return 0;
|
||||
}
|
||||
if (parsed.is_error()) {
|
||||
std::cerr << "vbs_benchmarks: " << parsed.message << '\n';
|
||||
return 2;
|
||||
}
|
||||
if (positional_files.size() > 1) {
|
||||
std::cerr << "vbs_benchmarks: expected at most one positional count argument\n";
|
||||
return 2;
|
||||
}
|
||||
if (!positional_files.empty()) {
|
||||
files_opt = positional_files.front();
|
||||
}
|
||||
|
||||
int parsed_files = 20;
|
||||
int parsed_jobs = 4;
|
||||
if (argc == 2 && Void::Str::to_int(argv[1], parsed_files)) {
|
||||
if (parsed_files <= 0) {
|
||||
std::cerr << "vbs_benchmarks: file count must be positive\n";
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
auto parsed = parser.parse(argc, argv);
|
||||
if (!parsed) {
|
||||
std::cerr << "vbs_benchmarks: " << parsed.error() << '\n';
|
||||
return 2;
|
||||
}
|
||||
if (!Void::Str::to_int(files_opt, parsed_files) || parsed_files <= 0) {
|
||||
std::cerr << "vbs_benchmarks: invalid --files value '" << files_opt << "'\n";
|
||||
return 2;
|
||||
}
|
||||
if (!Void::Str::to_int(jobs_opt, parsed_jobs) || parsed_jobs <= 0) {
|
||||
std::cerr << "vbs_benchmarks: invalid --jobs value '" << jobs_opt << "'\n";
|
||||
return 2;
|
||||
}
|
||||
if (!Void::Str::to_int(files_opt, parsed_files) || parsed_files <= 0) {
|
||||
std::cerr << "vbs_benchmarks: invalid --files value '" << files_opt << "'\n";
|
||||
return 2;
|
||||
}
|
||||
if (!Void::Str::to_int(jobs_opt, parsed_jobs) || parsed_jobs <= 0) {
|
||||
std::cerr << "vbs_benchmarks: invalid --jobs value '" << jobs_opt << "'\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto file_count = static_cast<std::size_t>(parsed_files);
|
||||
|
||||
Reference in new issue
Block a user