Enable conf detection in toast standalone
This commit is contained in:
parent
33d77f82e8
commit
c57666d5db
2 changed files with 31 additions and 13 deletions
|
|
@ -726,7 +726,13 @@ proc loadPlugin*(gState: State, sourcePath: string) =
|
||||||
pdll = sourcePath.dll
|
pdll = sourcePath.dll
|
||||||
if not fileExists(pdll) or
|
if not fileExists(pdll) or
|
||||||
sourcePath.getLastModificationTime() > pdll.getLastModificationTime():
|
sourcePath.getLastModificationTime() > pdll.getLastModificationTime():
|
||||||
discard execAction(&"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {sourcePath.sanitizePath}")
|
let
|
||||||
|
# Get Nim configuration flags if not already specified in a .cfg file
|
||||||
|
flags =
|
||||||
|
if fileExists(sourcePath & ".cfg"): ""
|
||||||
|
else: getNimConfigFlags(getCurrentDir())
|
||||||
|
cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {sourcePath.sanitizePath}"
|
||||||
|
discard execAction(cmd)
|
||||||
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
||||||
|
|
||||||
let lib = loadLib(pdll)
|
let lib = loadLib(pdll)
|
||||||
|
|
|
||||||
|
|
@ -171,29 +171,41 @@ proc getNimConfig*(projectDir = ""): Config =
|
||||||
|
|
||||||
result.nimcacheDir = getNimcacheDir(projectDir)
|
result.nimcacheDir = getNimcacheDir(projectDir)
|
||||||
|
|
||||||
proc writeNimConfig*(cfg: Config, cfgFile: string) =
|
proc getNimConfigFlags(cfg: Config): string =
|
||||||
# Write Nim configuration to file
|
# Convert configuration into Nim flags for cfg file or command line
|
||||||
var
|
result = &"--nimcache:\"{cfg.nimcacheDir}\"\n"
|
||||||
cfgOut = &"--nimcache:\"{cfg.nimcacheDir}\"\n"
|
|
||||||
|
|
||||||
if (cfg.NimMajor, cfg.NimMinor, cfg.NimPatch) >= (1, 2, 0):
|
if (cfg.NimMajor, cfg.NimMinor, cfg.NimPatch) >= (1, 2, 0):
|
||||||
# --clearNimbleCache if Nim v1.2.0+
|
# --clearNimbleCache if Nim v1.2.0+
|
||||||
cfgOut &= "--clearNimblePath\n"
|
result &= "--clearNimblePath\n"
|
||||||
|
|
||||||
# Add `nimblePaths` if detected - v1.2.0+
|
# Add `nimblePaths` if detected - v1.2.0+
|
||||||
for path in cfg.nimblePaths:
|
for path in cfg.nimblePaths:
|
||||||
cfgOut &= &"--nimblePath:\"{path}\"\n"
|
result &= &"--nimblePath:\"{path}\"\n"
|
||||||
|
|
||||||
# Add `paths` in all cases if any detected
|
# Add `paths` in all cases if any detected
|
||||||
for path in cfg.paths:
|
for path in cfg.paths:
|
||||||
cfgOut &= &"--path:\"{path}\"\n"
|
result &= &"--path:\"{path}\"\n"
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
cfgOut = cfgOut.replace("\\", "/")
|
result = result.replace("\\", "/")
|
||||||
|
|
||||||
writeFile(cfgFile, cfgOut)
|
proc getNimConfigFlags*(projectDir = ""): string =
|
||||||
|
## Get Nim command line configuration flags for `projectDir`
|
||||||
proc writeNimConfig*(cfgFile: string, projectDir = "") =
|
##
|
||||||
|
## If `projectDir` is not specified, it is detected if compile time or
|
||||||
|
## current directory is used.
|
||||||
let
|
let
|
||||||
cfg = getNimConfig(projectDir)
|
cfg = getNimConfig(projectDir)
|
||||||
writeNimConfig(cfg, cfgFile)
|
cfgOut = getNimConfigFlags(cfg)
|
||||||
|
return cfgOut.replace("\n", " ")
|
||||||
|
|
||||||
|
proc writeNimConfig*(cfgFile: string, projectDir = "") =
|
||||||
|
## Write Nim configuration for `projectDir` to specified `cfgFile`
|
||||||
|
##
|
||||||
|
## If `projectDir` is not specified, it is detected if compile time or
|
||||||
|
## current directory is used.
|
||||||
|
let
|
||||||
|
cfg = getNimConfig(projectDir)
|
||||||
|
cfgOut = getNimConfigFlags(cfg)
|
||||||
|
writeFile(cfgFile, cfgOut)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue