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"]
|
bin = @["nimterop/toast"]
|
||||||
installDirs = @["nimterop"]
|
installDirs = @["nimterop"]
|
||||||
installFiles = @["config.nims"]
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
requires "nim >= 0.20.2", "regex >= 0.14.1", "cligen >= 0.9.45"
|
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
|
# Filter out preprocessor errors
|
||||||
for line in output.splitLines():
|
for line in output.splitLines():
|
||||||
if "fatal error:" in line.toLowerAscii:
|
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]
|
result &= "\n\nERROR:$1\n" % line.split("fatal error:")[1]
|
||||||
|
|
||||||
# Toast error
|
# Toast error
|
||||||
|
|
@ -135,7 +137,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
let toastExe = toastExePath()
|
let toastExe = toastExePath()
|
||||||
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.sanitizePath &
|
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.sanitizePath &
|
||||||
" make sure 'nimble build' or 'nimble install' built it"
|
" make sure 'nimble build' or 'nimble install' built it"
|
||||||
cmd &= &"{toastExe} --preprocess"
|
cmd &= &"{toastExe} --preprocess -m:{mode}"
|
||||||
|
|
||||||
if recurse:
|
if recurse:
|
||||||
cmd.add " --recurse"
|
cmd.add " --recurse"
|
||||||
|
|
@ -679,7 +681,7 @@ macro c2nImport*(filename: static string, recurse: static bool = false, dynlib:
|
||||||
echo "# Importing " & fullpath & " with c2nim"
|
echo "# Importing " & fullpath & " with c2nim"
|
||||||
|
|
||||||
let
|
let
|
||||||
output = getToast(@[fullpath], recurse, dynlib, noNimout = true)
|
output = getToast(@[fullpath], recurse, dynlib, mode, noNimout = true)
|
||||||
hash = output.hash().abs()
|
hash = output.hash().abs()
|
||||||
hpath = getProjectCacheDir("c2nimCache", forceClean = false) / "nimterop_" & $hash & ".h"
|
hpath = getProjectCacheDir("c2nimCache", forceClean = false) / "nimterop_" & $hash & ".h"
|
||||||
npath = hpath[0 .. hpath.rfind('.')] & "nim"
|
npath = hpath[0 .. hpath.rfind('.')] & "nim"
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,7 @@ proc loadPlugin*(gState: State, sourcePath: string) =
|
||||||
else: getNimConfigFlags(getCurrentDir())
|
else: getNimConfigFlags(getCurrentDir())
|
||||||
|
|
||||||
# Always set output to same directory as source, prevents override
|
# 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
|
# Compile plugin as library with `markAndSweep` GC
|
||||||
cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}"
|
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
|
# Workaround for C++ scanner.cc causing link error with other C obj files
|
||||||
when defined(MacOSX):
|
when defined(MacOSX):
|
||||||
switch("clang.linkerexe", "g++")
|
switch("clang.linkerexe", "g++")
|
||||||
|
|
@ -18,3 +20,6 @@ switch("path", "$nim")
|
||||||
# Case objects
|
# Case objects
|
||||||
when not defined(danger):
|
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