[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

@@ -78,6 +78,20 @@ All notable changes to cargoxx will be documented in this file.
and `[build]` honoring `warnings_as_errors` and `sanitizers`. Source
paths emitted relative to `build/` (i.e. prefixed with `../`).
Output is deterministic. `tests/codegen_cmake.cpp` covers 11 cases.
- `cargoxx.resolver::nix_cmake_scan(store_path, package_name)` — walks
`<store_path>/lib/cmake/**` for `*Config.cmake` / `*-config.cmake`
files, scans them and their sibling `.cmake` files (e.g. the
`<pkg>-targets.cmake` that real packages like fmt put their
`add_library(... IMPORTED)` calls in) for IMPORTED + ALIAS targets,
and returns the `NixCmakeCandidate` whose derived stem best matches
`package_name` (case-insensitive equality > prefix > first non-empty).
Pure helpers `scan_imported_targets(text)` and
`config_stem_to_package(filename)` are exported for unit testing.
`tests/nix_cmake_scan_parse.cpp` covers 11 cases including a fixture
that mirrors fmt's `<pkg>-config.cmake → <pkg>-targets.cmake`
layout. `tests/nix_cmake_scan_live.cpp` (gated by
`CARGOXX_NETWORK_TESTS=1`) realizes `nixpkgs#fmt.dev` via
`nix build` and verifies `fmt::fmt` is discovered end-to-end.
- `cargoxx.resolver::nixpkgs_probe(attr)` — runs
`nix eval nixpkgs#<attr> --json --apply 'p: { version, path }'` via
`exec::run` and returns a `NixpkgsInfo { attr, version, out_path }`.