[M8] reusable libraries: install layout + cargoxx-path deps
This commit is contained in:
63
CHANGELOG.md
63
CHANGELOG.md
@@ -435,3 +435,66 @@ All notable changes to cargoxx will be documented in this file.
|
||||
Added `inputs.bundlers.url = "github:NixOS/bundlers"` (with
|
||||
`inputs.nixpkgs.follows = "nixpkgs"`) to keep the closure aligned
|
||||
with the project's pinned nixpkgs.
|
||||
- M8 multiple binary build artifacts (Cargo `src/bin/` parity).
|
||||
Codegen now routes every executable (`add_executable`) to
|
||||
`${CMAKE_BINARY_DIR}/bin` via `set_target_properties(... RUNTIME_OUTPUT_DIRECTORY ...)`.
|
||||
`buildCppPackage` and `cargoxx run --bin <name>` follow suit, and
|
||||
layout discovery picks up Cargo's `src/bin/<sub>/main.cpp` form
|
||||
(subdir name becomes the binary name). End-to-end fixture
|
||||
`tests/e2e/buildCppPackage/src/bin/extra.cpp` proves a second
|
||||
binary lands in `$out/bin/` alongside the primary.
|
||||
- M8 reusable library install layout. `cargoxx`-built libraries now
|
||||
ship a CMake-idiomatic `$out` tree: `lib/lib<name>.a`,
|
||||
`lib/cmake/<name>/{<name>Config.cmake,<name>ConfigVersion.cmake,
|
||||
<name>Targets.cmake}`, `lib/pkgconfig/<name>.pc`, and modules
|
||||
under `include/<name>/` (via `install(TARGETS ... FILE_SET CXX_MODULES ...)`).
|
||||
Codegen emits the install rules + a `Config.cmake.in` template
|
||||
(inline `file(WRITE …)`) consumed by
|
||||
`configure_package_config_file` and `write_basic_package_version_file`,
|
||||
plus a basic `.pc.in` template. The exported library target
|
||||
carries `target_compile_features(... PUBLIC cxx_std_<NN>)` so
|
||||
consumers `find_package`-ing it get the right standard for
|
||||
module BMI regeneration.
|
||||
`buildCppPackage.installPhase` switched from `cp -a build/release/bin/.`
|
||||
to `cmake --install build/release --prefix $out` — bins, libs,
|
||||
headers, config, and pc files all land via one invocation.
|
||||
`project(... VERSION <pkg.version> ...)` is now part of the
|
||||
generated header so `<name>ConfigVersion.cmake` reflects the
|
||||
manifest's version.
|
||||
- M8 cargoxx-path dependencies (Cargo's `{ path = "..." }`). The
|
||||
manifest gains a discriminated dep table form:
|
||||
```toml
|
||||
[dependencies]
|
||||
greeter = { path = "./greeter" }
|
||||
```
|
||||
`manifest::Dependency` carries `DepSource source` +
|
||||
`optional<string> path`. The parser branches on `path`; unknown
|
||||
dep-table keys still rejected for tables that have neither
|
||||
`version` nor `path`. Round-tripped by the writer.
|
||||
Lockfile schema adds per-package `source_kind` + `source_path`
|
||||
so the consumer's `Cargoxx.lock` records "this dep is built from
|
||||
a cargoxx source tree at `./greeter`" (not nixpkgs).
|
||||
`cmd_build::resolve_path_dep` reads `<path>/Cargoxx.toml` to
|
||||
verify the dep's name matches, then synthesizes a Recipe
|
||||
(`find_package = "<name> CONFIG REQUIRED"`,
|
||||
`targets = ["<name>::<name>"]`, `source = "cargoxx-path"`).
|
||||
Codegen needs no special case — the synthesized recipe flows
|
||||
through the existing `find_package` emission path.
|
||||
`buildCppPackage`'s recursion: `evalDep` branches on
|
||||
`source_kind == "cargoxx-path"` and recurses with
|
||||
`src = src + "/" + source_path`. The resulting derivation joins
|
||||
`buildInputs`; CMake's `CMAKE_PREFIX_PATH` picks it up so the
|
||||
consumer's `find_package(<dep> CONFIG REQUIRED)` resolves
|
||||
against the producer's installed Config.cmake. Path deps must be
|
||||
subdirectories of the consumer's source tree (no sibling form in
|
||||
v1 — sibling deps will land with git/registry sources in 1c/1d).
|
||||
New e2e fixture `tests/e2e/pathDep/`: a `consumer` project with
|
||||
`[dependencies] greeter = { path = "./greeter" }`. `run.sh`
|
||||
generates locks in both, then `nix build .#default` produces a
|
||||
binary that prints "Hello from greeter, world!".
|
||||
- M8 design doc at `docs/library-reuse-and-publish.md` covers the
|
||||
full two-part roadmap: library reuse (path → git → registry deps)
|
||||
and Gitea-hosted public registry with `cargoxx publish` + bot
|
||||
validation + binary-cache substitution. Phase 1a (install rules)
|
||||
and Phase 1b (path deps) shipped in this commit; phases 1c, 1d,
|
||||
and 2 remain to be built.
|
||||
|
||||
Reference in New Issue
Block a user