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
|
||||
if not fileExists(pdll) or
|
||||
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
|
||||
|
||||
let lib = loadLib(pdll)
|
||||
|
|
|
|||
|
|
@ -171,29 +171,41 @@ proc getNimConfig*(projectDir = ""): Config =
|
|||
|
||||
result.nimcacheDir = getNimcacheDir(projectDir)
|
||||
|
||||
proc writeNimConfig*(cfg: Config, cfgFile: string) =
|
||||
# Write Nim configuration to file
|
||||
var
|
||||
cfgOut = &"--nimcache:\"{cfg.nimcacheDir}\"\n"
|
||||
proc getNimConfigFlags(cfg: Config): string =
|
||||
# Convert configuration into Nim flags for cfg file or command line
|
||||
result = &"--nimcache:\"{cfg.nimcacheDir}\"\n"
|
||||
|
||||
if (cfg.NimMajor, cfg.NimMinor, cfg.NimPatch) >= (1, 2, 0):
|
||||
# --clearNimbleCache if Nim v1.2.0+
|
||||
cfgOut &= "--clearNimblePath\n"
|
||||
result &= "--clearNimblePath\n"
|
||||
|
||||
# Add `nimblePaths` if detected - v1.2.0+
|
||||
for path in cfg.nimblePaths:
|
||||
cfgOut &= &"--nimblePath:\"{path}\"\n"
|
||||
result &= &"--nimblePath:\"{path}\"\n"
|
||||
|
||||
# Add `paths` in all cases if any detected
|
||||
for path in cfg.paths:
|
||||
cfgOut &= &"--path:\"{path}\"\n"
|
||||
result &= &"--path:\"{path}\"\n"
|
||||
|
||||
when defined(windows):
|
||||
cfgOut = cfgOut.replace("\\", "/")
|
||||
result = result.replace("\\", "/")
|
||||
|
||||
writeFile(cfgFile, cfgOut)
|
||||
|
||||
proc writeNimConfig*(cfgFile: string, projectDir = "") =
|
||||
proc getNimConfigFlags*(projectDir = ""): string =
|
||||
## Get Nim command line configuration flags for `projectDir`
|
||||
##
|
||||
## If `projectDir` is not specified, it is detected if compile time or
|
||||
## current directory is used.
|
||||
let
|
||||
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