make nimfix compile again (#7708)

This commit is contained in:
alaviss 2018-04-28 01:58:39 +07:00 • committed by Andreas Rumpf
commit c8a412998a

View file

@ -47,7 +47,7 @@ proc mainCommand =
compileProject(newModuleGraph(), newIdentCache()) compileProject(newModuleGraph(), newIdentCache())
pretty.overwriteFiles() pretty.overwriteFiles()
proc processCmdLine*(pass: TCmdLinePass, cmd: string) = proc processCmdLine*(pass: TCmdLinePass, cmd: string, config: ConfigRef) =
var p = parseopt.initOptParser(cmd) var p = parseopt.initOptParser(cmd)
var argsCount = 0 var argsCount = 0
gOnlyMainfile = true gOnlyMainfile = true
@ -76,16 +76,16 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
of "wholeproject": gOnlyMainfile = false of "wholeproject": gOnlyMainfile = false
of "besteffort": msgs.gErrorMax = high(int) # don't stop after first error of "besteffort": msgs.gErrorMax = high(int) # don't stop after first error
else: else:
processSwitch(pass, p) processSwitch(pass, p, config)
of cmdArgument: of cmdArgument:
options.gProjectName = unixToNativePath(p.key) options.gProjectName = unixToNativePath(p.key)
# if processArgument(pass, p, argsCount): break # if processArgument(pass, p, argsCount): break
proc handleCmdLine() = proc handleCmdLine(config: ConfigRef) =
if paramCount() == 0: if paramCount() == 0:
stdout.writeLine(Usage) stdout.writeLine(Usage)
else: else:
processCmdLine(passCmd1, "") processCmdLine(passCmd1, "", config)
if gProjectName != "": if gProjectName != "":
try: try:
gProjectFull = canonicalizePath(gProjectName) gProjectFull = canonicalizePath(gProjectName)
@ -96,11 +96,11 @@ proc handleCmdLine() =
gProjectName = p.name gProjectName = p.name
else: else:
gProjectPath = getCurrentDir() gProjectPath = getCurrentDir()
loadConfigs(DefaultConfig) # load all config files loadConfigs(DefaultConfig, config) # load all config files
# now process command line arguments again, because some options in the # now process command line arguments again, because some options in the
# command line can overwite the config file's settings # command line can overwite the config file's settings
extccomp.initVars() extccomp.initVars()
processCmdLine(passCmd2, "") processCmdLine(passCmd2, "", config)
mainCommand() mainCommand()
when compileOption("gc", "v2") or compileOption("gc", "refc"): when compileOption("gc", "v2") or compileOption("gc", "refc"):
@ -108,4 +108,4 @@ when compileOption("gc", "v2") or compileOption("gc", "refc"):
condsyms.initDefines() condsyms.initDefines()
defineSymbol "nimfix" defineSymbol "nimfix"
handleCmdline() handleCmdline newConfigRef()