45 lines
1.7 KiB
C++
45 lines
1.7 KiB
C++
#include <Void/Build.hpp>
|
|
#include <Void/Build/BootstrapConfig.hpp>
|
|
#include <Void/Configuration/Argparse.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
int main(int argc, char **argv) {
|
|
std::string profile;
|
|
std::string compiler;
|
|
Void::Argparse::Parser parser{
|
|
"vbs_describe",
|
|
"Evaluate the compiled example description; no target compiler is invoked."};
|
|
parser.option_default("--profile", "", "profile: debug or release", profile, "debug")
|
|
.option_default("--compiler", "", "target compiler context: gcc or clang", compiler, "gcc");
|
|
if (argc == 2 && (std::string_view{argv[1]} == "--help" || std::string_view{argv[1]} == "-h")) {
|
|
std::cout << parser.help();
|
|
return 0;
|
|
}
|
|
// Help is deliberately successful only as a standalone request.
|
|
for (int i = 1; i < argc; ++i) {
|
|
if (std::string_view{argv[i]} == "--help" || std::string_view{argv[i]} == "-h") {
|
|
std::cerr << "vbs_describe: --help must be used alone\n";
|
|
return 2;
|
|
}
|
|
}
|
|
const auto parsed = parser.parse(argc, argv);
|
|
if (!parsed) {
|
|
std::cerr << "vbs_describe: " << parsed.error() << '\n';
|
|
return 2;
|
|
}
|
|
try {
|
|
Void::Build::Profiles descriptions;
|
|
profiles(descriptions);
|
|
Void::Build::Project project{descriptions.resolve(
|
|
profile, Void::Build::parse_compiler(compiler), std::string{Void::Build::Bootstrap::os},
|
|
std::string{Void::Build::Bootstrap::architecture})};
|
|
build(project);
|
|
std::cout << project.to_json() << '\n';
|
|
return 0;
|
|
} catch (const std::exception &error) {
|
|
std::cerr << "vbs_describe: " << error.what() << '\n';
|
|
return 2;
|
|
}
|
|
}
|