[M6] populate Cargoxx.toml; add 'cargoxx linkdb add' CLI; codegen fixes for self-host

This commit is contained in:
2026-05-14 00:17:56 +00:00
parent a757149f99
commit 4f9b6f1827
8 changed files with 104 additions and 14 deletions

View File

@@ -58,6 +58,28 @@ auto run(int argc, char** argv) -> int {
std::string remove_name;
remove_cmd->add_option("name", remove_name, "Package name to remove")->required();
auto* linkdb_cmd =
app.add_subcommand("linkdb", "Manage the link database");
linkdb_cmd->require_subcommand(1);
auto* linkdb_add_cmd =
linkdb_cmd->add_subcommand("add", "Insert a manual recipe");
std::string ldb_package;
std::string ldb_version = "*";
std::string ldb_find_package;
std::string ldb_targets;
std::string ldb_nixpkgs_attr;
linkdb_add_cmd->add_option("package", ldb_package, "Package name")->required();
linkdb_add_cmd->add_option("--version", ldb_version, "Version range (default: *)");
linkdb_add_cmd->add_option("--find-package", ldb_find_package,
"Body of the find_package(...) call (e.g. \"fmt CONFIG REQUIRED\")")
->required();
linkdb_add_cmd->add_option("--targets", ldb_targets,
"Comma-separated CMake targets (e.g. fmt::fmt)")
->required();
linkdb_add_cmd->add_option("--nixpkgs-attr", ldb_nixpkgs_attr,
"nixpkgs attribute name (e.g. fmt_10)")
->required();
try {
app.parse(argc, argv);
} catch (const CLI::ParseError& e) {
@@ -175,6 +197,31 @@ auto run(int argc, char** argv) -> int {
return 0;
}
if (*linkdb_add_cmd) {
std::vector<std::string> targets;
std::size_t pos = 0;
while (pos <= ldb_targets.size()) {
auto comma = ldb_targets.find(',', pos);
auto piece = ldb_targets.substr(
pos, comma == std::string::npos ? ldb_targets.size() - pos : comma - pos);
if (!piece.empty()) {
targets.push_back(std::move(piece));
}
if (comma == std::string::npos) {
break;
}
pos = comma + 1;
}
auto r = cmd_linkdb_add(ldb_package, ldb_version, ldb_find_package,
std::move(targets), ldb_nixpkgs_attr);
if (!r) {
std::cerr << util::format(r.error());
return 1;
}
std::cout << std::format(" Added manual recipe for {}\n", ldb_package);
return 0;
}
return 0;
}