compiler: minor refactoring (#16633)

This commit is contained in:
Andreas Rumpf 2021-01-08 13:36:03 +01:00 • committed by GitHub
commit add1ccb6cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -211,18 +211,17 @@ proc mainCommand*(graph: ModuleGraph) =
defineSymbol(conf.symbols, "nimdoc") defineSymbol(conf.symbols, "nimdoc")
body body
block: ## command prepass ## command prepass
if conf.cmd == cmdCrun: conf.globalOptions.incl {optRun, optUseNimcache} if conf.cmd == cmdCrun: conf.globalOptions.incl {optRun, optUseNimcache}
if conf.cmd notin cmdBackends + {cmdTcc}: customizeForBackend(backendC) if conf.cmd notin cmdBackends + {cmdTcc}: customizeForBackend(backendC)
if conf.outDir.isEmpty: if conf.outDir.isEmpty:
# doc like commands can generate a lot of files (especially with --project) # doc like commands can generate a lot of files (especially with --project)
# so by default should not end up in $PWD nor in $projectPath. # so by default should not end up in $PWD nor in $projectPath.
conf.outDir = block: var ret = if optUseNimcache in conf.globalOptions: getNimcacheDir(conf)
var ret = if optUseNimcache in conf.globalOptions: getNimcacheDir(conf) else: conf.projectPath
else: conf.projectPath doAssert ret.string.isAbsolute # `AbsoluteDir` is not a real guarantee
doAssert ret.string.isAbsolute # `AbsoluteDir` is not a real guarantee if conf.cmd in cmdDocLike + {cmdRst2html, cmdRst2tex}: ret = ret / htmldocsDir
if conf.cmd in cmdDocLike + {cmdRst2html, cmdRst2tex}: ret = ret / htmldocsDir conf.outDir = ret
ret
## process all commands ## process all commands
case conf.cmd case conf.cmd