Fix mode, toast output dir
This commit is contained in:
parent
2060c8964d
commit
76d9be756a
5 changed files with 16 additions and 5 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
switch("define", "nimOldCaseObjects")
|
||||
|
||||
# Prevent outdir override
|
||||
switch("out", currentSourcePath.parentDir() / "toast".addFileExt(ExeExt))
|
||||
5
tests/tsoloud.nims
Normal file
5
tests/tsoloud.nims
Normal file
|
|
@ -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++")
|
||||
Loading…
Add table
Add a link
Reference in a new issue