mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
A runnable main.go that constructs the timer with a TimerConfig, then calls
Echo (struct param), Complex (slice-of-structs + slice + two optionals) and
Schedule (three struct params) with idiomatic Go values — the methods the Go
generator used to skip. The Makefile builds the dylib next to the package
(cgo's ${SRCDIR} rpath finds it at runtime); README documents the Nim->Go type
mapping. Verified end-to-end with `go run`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
893 B
Makefile
35 lines
893 B
Makefile
# Build the Nim dylib next to the generated Go package and run the example.
|
|
#
|
|
# make run # build libmy_timer + run the example
|
|
# make clean
|
|
#
|
|
# The generated package's cgo directives use ${SRCDIR}, so the library only has
|
|
# to sit in this directory (-L/-rpath point here). It is compiled from the repo
|
|
# root so the 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
|
|
else
|
|
LIBNAME := libmy_timer.so
|
|
endif
|
|
|
|
NIMFLAGS := --mm:orc -d:chronicles_log_level=WARN --app:lib --noMain \
|
|
--nimMainPrefix:libmy_timer
|
|
|
|
.PHONY: all run clean
|
|
|
|
all: $(LIBNAME)
|
|
|
|
$(LIBNAME):
|
|
cd $(REPO_ROOT) && nim c $(NIMFLAGS) -o:$(CURDIR)/$(LIBNAME) $(NIM_SRC)
|
|
|
|
run: $(LIBNAME)
|
|
cd example && go run .
|
|
|
|
clean:
|
|
rm -f $(LIBNAME) example/example
|