From 2060c8964d6960808b86f767ea3949da9b3341e6 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Tue, 28 Apr 2020 11:54:00 -0500 Subject: Prevent plugin outdir override by configuration --- nimterop.nimble | 2 +- nimterop/getters.nim | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nimterop.nimble b/nimterop.nimble index a6fba1e..e520c71 100644 --- a/nimterop.nimble +++ b/nimterop.nimble @@ -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 diff --git a/nimterop/getters.nim b/nimterop/getters.nim index d829cf0..ebd3432 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -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 -- cgit v1.2.3