Ivan FB a3e68333ab
refactor(codegen): reconcile C++ header names with the native/cbor convention
Aligns the C++ generators with the C generator and the symbol naming: the
native (zero-serialization, same-process) wrapper is the bare `<lib>.hpp` and
the CBOR (inter-process) wrapper carries the `_cbor` suffix — mirroring the C
headers (`<lib>.h` / `<lib>_cbor.h`) and the `<name>` / `<name>_cbor` exports.

Previously native was `<lib>_native.hpp` and CBOR was the bare `<lib>.hpp`,
which is backwards from the symbol convention and would collide on the native
`<lib>.h` when both ABIs emit into one dir (ffiMode=both). With the flip, a
single `genbindings_cpp` run now drops `<lib>.hpp` + `<lib>_cbor.hpp` side by
side, exactly like c_bindings holds both `.h` headers.

Consumers updated to match: the CBOR cpp_bindings driver and the C++ e2e suite
include `*_cbor.hpp`; the native example includes the bare `<lib>.hpp`.

Validated: native example runs on `my_timer.hpp`; C++ e2e suite 19/19 on the
`_cbor.hpp` headers; check_bindings_cpp regen is deterministic.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 19:31:39 +02:00

42 lines
1.0 KiB
Makefile

# Build + run the GENERATED native C++ example.
#
# make run # build the Nim dylib + the C++ driver against the generated hpp
# make clean
#
# Regenerate the bindings with `nimble genbindings_cpp_native` (from the repo
# root). The Nim library is compiled from the repo root so its vendored Nimble
# dependencies resolve.
REPO_ROOT := $(abspath ../../..)
NIM_SRC := $(REPO_ROOT)/examples/timer/timer.nim
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LIBNAME := libmy_timer.dylib
RPATH := -Wl,-rpath,.
else
LIBNAME := libmy_timer.so
RPATH := -Wl,-rpath,'$$ORIGIN'
endif
CXX ?= c++
CXXFLAGS ?= -std=c++17 -Wall -Wextra -O2 -I.
NIMFLAGS := --mm:orc -d:chronicles_log_level=WARN --app:lib --noMain \
--nimMainPrefix:libmy_timer
.PHONY: all run clean
all: example
$(LIBNAME):
cd $(REPO_ROOT) && nim c $(NIMFLAGS) -o:$(CURDIR)/$(LIBNAME) $(NIM_SRC)
example: main.cpp my_timer.hpp my_timer.h $(LIBNAME)
$(CXX) $(CXXFLAGS) main.cpp -L. -lmy_timer $(RPATH) -o example
run: example
./example
clean:
rm -f example $(LIBNAME)