Make the library more friendly to JavaScript and NimScript

This commit is contained in:
Zahary Karadjov 2020-06-16 22:09:07 +03:00
parent 2ddb255b14
commit 35eeb035b2
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 25 additions and 25 deletions

View File

@ -10,34 +10,34 @@
# and users need to import it, even if they don't call getBacktrace() manually).
{.used.}
import libbacktrace_wrapper, os, system/ansi_c
const installPath = currentSourcePath.parentDir() / "install" / "usr"
{.passc: "-I" & currentSourcePath.parentDir().}
when defined(cpp):
{.passl: installPath / "lib" / "libbacktracenimcpp.a".}
else:
{.passl: installPath / "lib" / "libbacktracenim.a".}
when defined(libbacktraceUseSystemLibs):
{.passl: "-lbacktrace".}
when defined(macosx) or defined(windows):
{.passl: "-lunwind".}
else:
{.passc: "-I" & installPath / "include".}
{.passl: installPath / "lib" / "libbacktrace.a".}
when defined(macosx) or defined(windows):
{.passl: installPath / "lib" / "libunwind.a".}
when defined(windows):
{.passl: "-lpsapi".}
# There is no "copyMem()" in Nimscript, so "getBacktrace()" will not work in
# there, but we might still want to import this module with a global
# "--import:libbacktrace" Nim compiler flag.
when not defined(nimscript):
when not (defined(nimscript) or defined(js)):
import libbacktrace_wrapper, os, system/ansi_c
const installPath = currentSourcePath.parentDir() / "install" / "usr"
{.passc: "-I" & currentSourcePath.parentDir().}
when defined(cpp):
{.passl: installPath / "lib" / "libbacktracenimcpp.a".}
else:
{.passl: installPath / "lib" / "libbacktracenim.a".}
when defined(libbacktraceUseSystemLibs):
{.passl: "-lbacktrace".}
when defined(macosx) or defined(windows):
{.passl: "-lunwind".}
else:
{.passc: "-I" & installPath / "include".}
{.passl: installPath / "lib" / "libbacktrace.a".}
when defined(macosx) or defined(windows):
{.passl: installPath / "lib" / "libunwind.a".}
when defined(windows):
{.passl: "-lpsapi".}
proc getBacktrace*(): string {.noinline.} =
var
bt: cstring = get_backtrace_c()