From bd98fe42f9f311c6a56beaa4413c16862bc481c0 Mon Sep 17 00:00:00 2001 From: sami Date: Thu, 10 Sep 2026 00:31:02 +0400 Subject: [PATCH] core: add the libveloxproto target (ADR 0009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit core/ now produces two libraries as ADR 0009 specifies: - veloxcore — the engine; still links only Threads + CURL, no JSON. - veloxproto — generated/velox_proto.cpp, generated/ as a PUBLIC include dir, nlohmann_json linked PUBLIC. velox::proto alias. Consumed by veloxd / CLI / GUI / the conformance runner; veloxcore must never link it. nlohmann_json is found here too (the root only finds it when daemon/ has landed) so core builds standalone. Generated code is built -Wall -Wextra -Wno-error — it is committed and never hand-edited, so a codegen quirk must not break the build. A configure-time FATAL_ERROR trips if veloxcore ever links veloxproto. Verified: libveloxproto.a builds clean; veloxcore's link deps contain no proto/nlohmann; full suite green. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HPPSGhiArbvQgwC2DNiURS --- core/CMakeLists.txt | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f5cbdb1..16dd02c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,8 +1,8 @@ -# libveloxcore — the download engine. Lane CORE. -# -# No JSON, no SQL, no Qt, no RPC in this tree (CLAUDE.md §3, AGENT-CORE brief). -# This file is self-contained; it is wired into the build by PKG uncommenting -# `add_subdirectory(core)` in the root CMakeLists.txt (see core/docs/pkg-requests-m1.md). +# core/ produces TWO targets (ADR 0009): +# veloxcore — the download engine. No JSON, no SQL, no Qt, no RPC. Ever (CLAUDE.md §3). +# veloxproto — the generated wire types, which ARE JSON. NOT linked by veloxcore. +# The `no JSON in core/` rule constrains core/src/ and core/include/; core/generated/ is +# the sanctioned exception. Wired in by PKG via add_subdirectory(core) in the root file. find_package(Threads REQUIRED) find_package(CURL 8.0 REQUIRED) @@ -37,6 +37,32 @@ target_link_libraries(veloxcore PUBLIC Threads::Threads CURL::libcurl) # Later stages add: find_package(OpenSSL) for meta/ (streaming SHA-256 + resume CRC). +# --- libveloxproto — generated wire code (ADR 0009) -------------------------------------- +# Its own target so libveloxcore stays JSON-free. Consumed by veloxd, the CLI, the GUI and +# the conformance runner. The root CMakeLists only find_package(nlohmann_json)'s when +# daemon/ has landed, so find it here too — this must build even if core is the only lane. +if(NOT TARGET nlohmann_json::nlohmann_json) + find_package(nlohmann_json 3.11 REQUIRED) +endif() + +add_library(veloxproto STATIC generated/velox_proto.cpp) +add_library(velox::proto ALIAS veloxproto) + +target_include_directories(veloxproto PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/generated) +target_compile_features(veloxproto PUBLIC cxx_std_23) +target_link_libraries(veloxproto PUBLIC nlohmann_json::nlohmann_json) + +# Generated code is committed and never hand-edited (CLAUDE.md §2); do not fail the build +# on a codegen quirk that trips -Werror. Warnings stay on for visibility. +target_compile_options(veloxproto PRIVATE -Wall -Wextra -Wno-error) + +# A build-time tripwire for the split ADR 0009 exists to protect: veloxcore must never end +# up linking veloxproto. +get_target_property(_core_links veloxcore LINK_LIBRARIES) +if(_core_links AND "veloxproto" IN_LIST _core_links) + message(FATAL_ERROR "veloxcore links veloxproto — ADR 0009 violation (engine sees JSON).") +endif() + if(VELOX_BUILD_TESTS) add_subdirectory(tests) endif()