[M3] add cargoxx build --no-build

This commit is contained in:
2026-05-08 12:56:17 +00:00
parent 4380c5181c
commit 219254a1dd
7 changed files with 363 additions and 7 deletions

View File

@@ -19,20 +19,29 @@ auto run(int argc, char** argv) -> int {
new_cmd->add_option("name", new_name, "Project name")->required();
new_cmd->add_flag("--lib", new_lib, "Create a library project");
auto* build_cmd = app.add_subcommand(
"build", "Generate flake.nix and build/CMakeLists.txt; build with nix+cmake");
bool build_no_build = false;
bool build_release = false;
build_cmd->add_flag("--no-build", build_no_build,
"Generate files only; do not invoke nix/cmake");
build_cmd->add_flag("--release", build_release, "Build the release profile");
try {
app.parse(argc, argv);
} catch (const CLI::ParseError& e) {
return app.exit(e);
}
std::error_code ec;
auto cwd = std::filesystem::current_path(ec);
if (ec) {
std::cerr << std::format("error: cannot determine current working directory: {}\n",
ec.message());
return 1;
}
if (*new_cmd) {
std::error_code ec;
auto cwd = std::filesystem::current_path(ec);
if (ec) {
std::cerr << std::format("error: cannot determine current working directory: {}\n",
ec.message());
return 1;
}
auto r = cmd_new(new_name, new_lib, cwd);
if (!r) {
std::cerr << util::format(r.error());
@@ -42,6 +51,16 @@ auto run(int argc, char** argv) -> int {
return 0;
}
if (*build_cmd) {
auto r = cmd_build(cwd, build_no_build, build_release);
if (!r) {
std::cerr << util::format(r.error());
return 1;
}
std::cout << " Generated flake.nix, build/CMakeLists.txt, Cargoxx.lock\n";
return 0;
}
return 0;
}