[M5+] add resolver::nix_cmake_scan

This commit is contained in:
2026-05-10 10:08:55 +00:00
parent 1c7ff39f64
commit e63ac69239
8 changed files with 783 additions and 0 deletions

View File

@@ -26,4 +26,29 @@ auto parse_nix_eval_json(std::string_view attr, std::string_view json)
// `ResolutionNetworkError` on timeout or evaluator errors.
auto nixpkgs_probe(const std::string& attr) -> util::Result<NixpkgsInfo>;
// One CMake config-file's IMPORTED targets together with the find_package
// expression derived from its filename stem.
struct NixCmakeCandidate {
std::string find_package; // e.g. "fmt CONFIG REQUIRED"
std::vector<std::string> targets; // e.g. ["fmt::fmt"]
std::filesystem::path config_file; // the *Config.cmake we scraped
};
// Pure: scan a single CMake config text for `add_library(... IMPORTED)`
// target names. ALIAS targets are also collected so canonical
// `<alias>::<member>` forms get picked up.
auto scan_imported_targets(std::string_view config_text) -> std::vector<std::string>;
// Pure: turn a CMake config filename into the find_package name.
// `fmtConfig.cmake` / `fmt-config.cmake` -> `fmt`.
auto config_stem_to_package(std::string_view filename) -> std::string;
// Walks <store_path>/lib/cmake/** for *Config.cmake / *-config.cmake files.
// Picks the candidate whose derived package name best matches `package_name`
// (exact case-insensitive equality > prefix > first non-empty target list).
// Returns ResolutionUnknownPackage when nothing usable is found.
auto nix_cmake_scan(const std::filesystem::path& store_path,
const std::string& package_name)
-> util::Result<NixCmakeCandidate>;
} // namespace cargoxx::resolver