logos-chat/nim_chat_poc.nimble
Jazz Turner-Baggs 702d25a0d8 Libchat library Integration (#55)
* chore: add smoke test and redesign CI workflow (#62)

Add a smoke test that validates the binary links all dependencies
at runtime by instantiating a client without networking. Redesign
CI into separate build and test jobs, with test gated on build.

* Add libchat module

* Add Context

* Add libchat

* Update to latest libchat

* Remove stale files

* Bump to latest Libchat

* Update imports

* Update client

* Update library to work with Libchat

* Fix examples

* Remove Tui Examples - Replace with logos-core

* Add Indentity Todo

* fix: add `build-libchat` as dependency for examples, tests, and library (#59)

The Rust liblogos_chat.so was not being built automatically, causing
runtime failures when loading the shared library.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add Todo for Sender data

* Updated error log

---------

Co-authored-by: osmaczko <33099791+osmaczko@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-16 10:29:40 -08:00

84 lines
2.6 KiB
Nim

# Package
version = "0.1.0"
author = "jazzz"
description = "An example of the chat sdk in Nim"
license = "MIT"
srcDir = "src"
bin = @["nim_chat_poc"]
# Dependencies
requires "nim >= 2.2.4",
"protobuf_serialization",
"secp256k1",
"blake2",
"chronicles",
"libp2p",
"nimchacha20poly1305", # TODO: remove
"confutils",
"eth",
"regex",
"web3",
"https://github.com/jazzz/nim-sds#exports",
"libchat",
"waku",
"ffi"
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
if not dirExists "build":
mkDir "build"
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
for i in 2 ..< paramCount():
extra_params &= " " & paramStr(i)
exec "nim " & lang & " --out:build/" & name & " --mm:refc " & extra_params & " " &
srcDir & name & ".nim"
proc buildLibrary(name: string, srcDir = "library/", params = "", lang = "c") =
## Build a shared library (.so on Linux, .dylib on macOS, .dll on Windows)
if not dirExists "build":
mkDir "build"
# Determine library extension based on OS
let libExt = when defined(macosx): "dylib"
elif defined(windows): "dll"
else: "so"
var extra_params = params
for i in 2 ..< paramCount():
extra_params &= " " & paramStr(i)
exec "nim " & lang & " --app:lib --out:build/lib" & name & "." & libExt &
" --mm:refc --nimMainPrefix:lib" & name & " " & extra_params & " " &
srcDir & "lib" & name & ".nim"
proc test(name: string, params = "-d:chronicles_log_level=DEBUG", lang = "c") =
buildBinary name, "tests/", params
exec "build/" & name
task tests, "Build & run tests":
test "all_tests", "-d:chronicles_log_level=ERROR -d:chronosStrictException"
test "smoke_test", "-d:chronicles_log_level=ERROR"
task waku_example, "Build Waku based simple example":
let name = "waku_example"
buildBinary name, "examples/", " -d:chronicles_log_level='TRACE' "
task tui, "Build Waku based simple example":
let name = "tui"
buildBinary name, "examples/", " -d:chronicles_enabled=on -d:chronicles_log_level='INFO' -d:chronicles_sinks=textlines[file]"
task bot_echo, "Build the EchoBot example":
let name = "bot_echo"
buildBinary name, "examples/", "-d:chronicles_log_level='INFO' -d:chronicles_disabled_topics='waku node' "
task pingpong, "Build the Pingpong example":
let name = "pingpong"
buildBinary name, "examples/", "-d:chronicles_log_level='INFO' -d:chronicles_disabled_topics='waku node' "
task liblogoschat, "Build the Chat SDK shared library (C bindings)":
buildLibrary "logoschat", "library/",
"-d:chronicles_log_level='INFO' -d:chronicles_enabled=on --path:src --path:vendor/nim-ffi"