Skip to content

Commit

Permalink
~/.config/nim/config.nims can now be used
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Aug 18, 2018
1 parent 11818ef commit e1da01a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions compiler/nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
else:
conf.projectPath = canonicalizePath(conf, getCurrentDir())
loadConfigs(DefaultConfig, cache, conf) # load all config files
let scriptFile = conf.projectFull.changeFileExt("nims")
if fileExists(conf.projectPath / "config.nims"):
# directory wide NimScript file
runNimScript(cache, conf.projectPath / "config.nims", freshDefines=false, conf)
if fileExists(scriptFile):
runNimScript(cache, scriptFile, freshDefines=false, conf)

proc runNimScriptIfExists(scriptFile:string)=
if fileExists(scriptFile):
runNimScript(cache, scriptFile, freshDefines=false, conf)

runNimScriptIfExists(getConfigDir() / "nim" / "config.nims")
runNimScriptIfExists(conf.projectPath / "config.nims")
block:
let scriptFile = conf.projectFull.changeFileExt("nims")
runNimScriptIfExists(scriptFile)
# 'nim foo.nims' means to just run the NimScript file and do nothing more:
if scriptFile == conf.projectFull: return
if fileExists(scriptFile) and scriptFile == conf.projectFull: return

# now process command line arguments again, because some options in the
# command line can overwite the config file's settings
extccomp.initVars(conf)
Expand Down

0 comments on commit e1da01a

Please sign in to comment.