Skip to content

conanfile: per-component build selection (c-api, node-exe, both) #293

@fpelliccioni

Description

@fpelliccioni

Problem

Today a `conan create` on the kth recipe builds the full tree (domain + blockchain + consensus + database + network + node + node-exe + c-api + console tools). Downstream consumers have different needs:

  • A Python / C# / WASM binding only needs `c-api` (the shared library + headers).
  • A node operator only needs `node-exe` + its runtime deps, not the C-API layer.
  • A library consumer that links against `kth_node` wants neither the exe nor the C-API, just the C++ libs.

Currently every downstream pays the full build cost (and gets the full install tree) even when they use a small slice.

Proposal

Add a Conan option (or a pair) to select which deliverables the build produces:

  • `components=[c-api, node-exe, both]` (default `both` for backwards compatibility), OR
  • two boolean options: `with_c_api` (default true) + `with_node_exe` (default true).

`conanfile.py::generate` / `build` / `package` forwards the selected components to CMake via `-DWITH_C_API=ON/OFF` + `-DWITH_NODE_EXE=ON/OFF` (or a single `-DKTH_COMPONENTS=...` string). The root `CMakeLists.txt` already has `WITH_CONSOLE` / `WITH_CONSOLE_CAPI` — extend the same pattern.

The default stays `both` so nothing existing breaks; consumers that want a faster / smaller build flip the options.

Why it matters

  • py-native cold-builds today include the full node + consensus + network tree for a library that only links the c-api. Cuts significant CI minutes.
  • Downstream CI matrices (cs-api, wasm, future bindings) all pay the same cost.
  • Separates the "run a node" from "embed kth as a library" use cases more cleanly at the package-manager layer.

Notes

  • Needs a pass through each `src//CMakeLists.txt` to guard `add_subdirectory` calls on the new toggles.
  • The `c-api` sub-project already has `GLOBAL_BUILD` and `ENABLE_SHARED_CAPI` — those are orthogonal and stay as-is.
  • Test plan: `conan create . --version=0.81.2 -o kth/:with_c_api=False` should produce a package with no `libkth-c-api.so` / c-api headers; same with `-o kth/:with_node_exe=False`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions