From 5763c25043cc2ee31449ffe8717c4dad81512776 Mon Sep 17 00:00:00 2001 From: Alex Jbanca Date: Fri, 30 Jan 2026 15:02:42 +0200 Subject: [PATCH] fix: Enable lib as nim module --- library/libsds.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/libsds.nim b/library/libsds.nim index ec0527f..dba0527 100644 --- a/library/libsds.nim +++ b/library/libsds.nim @@ -141,7 +141,8 @@ proc onRetrievalHint(ctx: ptr SdsContext): RetrievalHintProvider = # Every Nim library must have this function called - the name is derived from # the `--nimMainPrefix` command line option -proc libsdsNimMain() {.importc.} +when isMainModule: + proc libsdsNimMain() {.importc.} # To control when the library has been initialized var initialized: Atomic[bool] @@ -158,7 +159,8 @@ proc initializeLibrary() {.exported.} = if not initialized.exchange(true): ## Every Nim library needs to call `NimMain` once exactly, to initialize the Nim runtime. ## Being `` the value given in the optional compilation flag --nimMainPrefix:yourprefix - libsdsNimMain() + when isMainModule: + libsdsNimMain() ctxPoolLock.initLock() # ensure the lock is initialized once (fix Windows crash) when declared(setupForeignThreadGc): setupForeignThreadGc()