Prevent plugin outdir override by configuration

This commit is contained in:
Ganesh Viswanathan 2020-04-28 11:54:00 -05:00
commit 2060c8964d
2 changed files with 8 additions and 2 deletions

View file

@ -10,7 +10,7 @@ installDirs = @["nimterop"]
installFiles = @["config.nims"]
# Dependencies
requires "nim >= 0.20.2", "regex#v0.13.1", "cligen >= 0.9.43"
requires "nim >= 0.20.2", "regex >= 0.14.1", "cligen >= 0.9.45"
import nimterop/docs

View file

@ -731,7 +731,13 @@ proc loadPlugin*(gState: State, sourcePath: string) =
flags =
if fileExists(sourcePath & ".cfg"): ""
else: getNimConfigFlags(getCurrentDir())
cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {sourcePath.sanitizePath}"
# Always set output to same directory as source, prevents override
outflags = &"--out:\"{pdll.extractFilename()}\" --outdir:\"{pdll.parentDir()}\""
# Compile plugin as library with `markAndSweep` GC
cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}"
discard execAction(cmd)
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath