aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nimterop.nimble1
-rw-r--r--nimterop/cimport.nim6
-rw-r--r--nimterop/getters.nim2
-rw-r--r--nimterop/toast.nims (renamed from config.nims)7
-rw-r--r--tests/tsoloud.nims5
5 files changed, 16 insertions, 5 deletions
diff --git a/nimterop.nimble b/nimterop.nimble
index e520c71..caaaf90 100644
--- a/nimterop.nimble
+++ b/nimterop.nimble
@@ -7,7 +7,6 @@ license = "MIT"
bin = @["nimterop/toast"]
installDirs = @["nimterop"]
-installFiles = @["config.nims"]
# Dependencies
requires "nim >= 0.20.2", "regex >= 0.14.1", "cligen >= 0.9.45"
diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim
index 4afb27c..47dc0eb 100644
--- a/nimterop/cimport.nim
+++ b/nimterop/cimport.nim
@@ -100,6 +100,8 @@ proc getToastError(output: string): string =
# Filter out preprocessor errors
for line in output.splitLines():
if "fatal error:" in line.toLowerAscii:
+ if result.len == 0:
+ result = "\n\nFailed in preprocessing, check if `cIncludeDir()` is needed or compiler `mode` is correct (c/cpp)"
result &= "\n\nERROR:$1\n" % line.split("fatal error:")[1]
# Toast error
@@ -135,7 +137,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
let toastExe = toastExePath()
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.sanitizePath &
" make sure 'nimble build' or 'nimble install' built it"
- cmd &= &"{toastExe} --preprocess"
+ cmd &= &"{toastExe} --preprocess -m:{mode}"
if recurse:
cmd.add " --recurse"
@@ -679,7 +681,7 @@ macro c2nImport*(filename: static string, recurse: static bool = false, dynlib:
echo "# Importing " & fullpath & " with c2nim"
let
- output = getToast(@[fullpath], recurse, dynlib, noNimout = true)
+ output = getToast(@[fullpath], recurse, dynlib, mode, noNimout = true)
hash = output.hash().abs()
hpath = getProjectCacheDir("c2nimCache", forceClean = false) / "nimterop_" & $hash & ".h"
npath = hpath[0 .. hpath.rfind('.')] & "nim"
diff --git a/nimterop/getters.nim b/nimterop/getters.nim
index ebd3432..42a5a57 100644
--- a/nimterop/getters.nim
+++ b/nimterop/getters.nim
@@ -733,7 +733,7 @@ proc loadPlugin*(gState: State, sourcePath: string) =
else: getNimConfigFlags(getCurrentDir())
# Always set output to same directory as source, prevents override
- outflags = &"--out:\"{pdll.extractFilename()}\" --outdir:\"{pdll.parentDir()}\""
+ outflags = &"--out:\"{pdll}\""
# Compile plugin as library with `markAndSweep` GC
cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}"
diff --git a/config.nims b/nimterop/toast.nims
index f5f7d21..94c9f20 100644
--- a/config.nims
+++ b/nimterop/toast.nims
@@ -1,3 +1,5 @@
+import os
+
# Workaround for C++ scanner.cc causing link error with other C obj files
when defined(MacOSX):
switch("clang.linkerexe", "g++")
@@ -17,4 +19,7 @@ switch("path", "$nim")
# Case objects
when not defined(danger):
- switch("define", "nimOldCaseObjects") \ No newline at end of file
+ switch("define", "nimOldCaseObjects")
+
+# Prevent outdir override
+switch("out", currentSourcePath.parentDir() / "toast".addFileExt(ExeExt)) \ No newline at end of file
diff --git a/tests/tsoloud.nims b/tests/tsoloud.nims
new file mode 100644
index 0000000..3b6174b
--- /dev/null
+++ b/tests/tsoloud.nims
@@ -0,0 +1,5 @@
+# Workaround for C++ scanner.cc causing link error with other C obj files
+when defined(MacOSX):
+ switch("clang.linkerexe", "g++")
+else:
+ switch("gcc.linkerexe", "g++") \ No newline at end of file