diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/nimconf.nim | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim index 6cb5bab0f..a455b4a44 100644 --- a/compiler/nimconf.nim +++ b/compiler/nimconf.nim @@ -201,7 +201,8 @@ proc parseAssignment(L: var TLexer, tok: var TToken; else: processSwitch(s, val, passPP, info, config) -proc readConfigFile(filename: string; cache: IdentCache; config: ConfigRef) = +proc readConfigFile( + filename: string; cache: IdentCache; config: ConfigRef): bool = var L: TLexer tok: TToken @@ -216,7 +217,7 @@ proc readConfigFile(filename: string; cache: IdentCache; config: ConfigRef) = while tok.tokType != tkEof: parseAssignment(L, tok, config, condStack) if len(condStack) > 0: lexMessage(L, errGenerated, "expected @end") closeLexer(L) - rawMessage(config, hintConf, filename) + return true proc getUserConfigPath(filename: string): string = result = joinPath(getConfigDir(), filename) @@ -232,27 +233,37 @@ proc getSystemConfigPath(conf: ConfigRef; filename: string): string = proc loadConfigs*(cfg: string; cache: IdentCache; conf: ConfigRef) = setDefaultLibpath(conf) + + var configFiles = newSeq[string]() + + template readConfigFile(path: string) = + let configPath = path + if readConfigFile(configPath, cache, conf): + add(configFiles, configPath) if optSkipConfigFile notin conf.globalOptions: - readConfigFile(getSystemConfigPath(conf, cfg), cache, conf) + readConfigFile(getSystemConfigPath(conf, cfg)) if optSkipUserConfigFile notin conf.globalOptions: - readConfigFile(getUserConfigPath(cfg), cache, conf) + readConfigFile(getUserConfigPath(cfg)) let pd = if conf.projectPath.len > 0: conf.projectPath else: getCurrentDir() if optSkipParentConfigFiles notin conf.globalOptions: for dir in parentDirs(pd, fromRoot=true, inclusive=false): - readConfigFile(dir / cfg, cache, conf) + readConfigFile(dir / cfg) if optSkipProjConfigFile notin conf.globalOptions: - readConfigFile(pd / cfg, cache, conf) + readConfigFile(pd / cfg) if conf.projectName.len != 0: # new project wide config file: var projectConfig = changeFileExt(conf.projectFull, "nimcfg") if not fileExists(projectConfig): projectConfig = changeFileExt(conf.projectFull, "nim.cfg") - readConfigFile(projectConfig, cache, conf) + readConfigFile(projectConfig) + + for filename in configFiles: + rawMessage(conf, hintConf, filename) proc loadConfigs*(cfg: string; conf: ConfigRef) = # for backwards compatibility only. |