nim-ffi/examples/nim_timer/nim_timer.nimble
Ivan FB 1eb8f2bdf8
fix Hardcoded Nim build flags in generated build files. build.rs and CMakeLists.txt both bake in --mm:orc and -d:chronicles_log_level=WARN (rust.nim:121–122, cpp.nim:463–464).
The whole point of a generic generator is decoupling — this couples every consumer of nim-ffi to one specific project's Nim build conventions. Plumb these through
  genBindings() parameters or a config block.
2026-05-11 22:11:25 +02:00

34 lines
1.4 KiB
Nim

version = "0.1.0"
packageName = "nimtimer"
author = "Institute of Free Technology"
description = "Example Nim timer library using nim-ffi"
license = "MIT or Apache License 2.0"
requires "nim >= 2.2.4"
requires "chronos"
requires "chronicles"
requires "taskpools"
requires "https://github.com/logos-messaging/nim-ffi >= 0.1.3"
const nimFlags = "--mm:orc -d:chronicles_log_level=WARN"
# Flags baked into the generated build.rs / CMakeLists.txt -- see ffi.nimble.
const genBakedFlags = "--mm:orc -d:chronicles_log_level=WARN"
task build, "Compile the nimtimer library":
exec "nim c " & nimFlags &
" --app:lib --noMain --nimMainPrefix:libnimtimer nim_timer.nim"
task genbindings_rust, "Generate Rust bindings for the nimtimer example":
exec "nim c " & nimFlags & " --app:lib --noMain --nimMainPrefix:libnimtimer" &
" -d:ffiGenBindings -d:targetLang=rust" & " -d:ffiOutputDir=rust_bindings" &
" -d:ffiNimSrcRelPath=nim_timer.nim" &
" -d:ffiNimBuildFlags=\"" & genBakedFlags & "\"" &
" -o:/dev/null nim_timer.nim"
task genbindings_cpp, "Generate C++ bindings for the nimtimer example":
exec "nim c " & nimFlags & " --app:lib --noMain --nimMainPrefix:libnimtimer" &
" -d:ffiGenBindings -d:targetLang=cpp" & " -d:ffiOutputDir=cpp_bindings" &
" -d:ffiNimSrcRelPath=nim_timer.nim" &
" -d:ffiNimBuildFlags=\"" & genBakedFlags & "\"" &
" -o:/dev/null nim_timer.nim"