prepare Nimble for NimCompilerApiVersion 3

This commit is contained in:
Andreas Rumpf 2018-09-07 01:40:01 +02:00
commit e6c41248e6

View file

@ -45,6 +45,9 @@ when declared(NimCompilerApiVersion):
else: else:
const finalApi = false const finalApi = false
when NimCompilerApiVersion >= 3:
import compiler / pathutils
proc getGlobal(g: ModuleGraph; ident: PSym): string = proc getGlobal(g: ModuleGraph; ident: PSym): string =
when finalApi: when finalApi:
let n = vm.getGlobalValue(PCtx g.vm, ident) let n = vm.getGlobalValue(PCtx g.vm, ident)
@ -201,6 +204,13 @@ proc setupVM(graph: ModuleGraph; module: PSym; scriptName: string, flags: Flags)
let arg = a.getString 1 let arg = a.getString 1
if arg.len > 0: if arg.len > 0:
conf.projectName = arg conf.projectName = arg
when NimCompilerApiVersion >= 3:
try:
conf.projectFull = canonicalizePath(conf,
conf.projectPath / RelativeFile(conf.projectName))
except OSError:
conf.projectFull = AbsoluteFile conf.projectName
else:
try: try:
conf.projectFull = canonicalizePath(conf, conf.projectPath / conf.projectName) conf.projectFull = canonicalizePath(conf, conf.projectPath / conf.projectName)
except OSError: except OSError:
@ -311,6 +321,14 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
# Ensure the compiler can find its standard library #220. # Ensure the compiler can find its standard library #220.
when declared(NimCompilerApiVersion): when declared(NimCompilerApiVersion):
when NimCompilerApiVersion >= 3:
conf.prefixDir = AbsoluteDir getNimPrefixDir(options)
display("Setting", "Nim stdlib prefix to " & conf.prefixDir.string,
priority=LowPriority)
template myLibPath(): untyped = conf.libpath.string
else:
conf.prefixDir = getNimPrefixDir(options) conf.prefixDir = getNimPrefixDir(options)
display("Setting", "Nim stdlib prefix to " & conf.prefixDir, display("Setting", "Nim stdlib prefix to " & conf.prefixDir,
priority=LowPriority) priority=LowPriority)
@ -367,6 +385,9 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
createDir(tmpNimscriptApiPath.splitFile.dir) createDir(tmpNimscriptApiPath.splitFile.dir)
writeFile(tmpNimscriptApiPath, nimscriptApi) writeFile(tmpNimscriptApiPath, nimscriptApi)
when declared(NimCompilerApiVersion): when declared(NimCompilerApiVersion):
when NimCompilerApiVersion >= 3:
conf.searchPaths.add(AbsoluteDir t)
else:
conf.searchPaths.add(t) conf.searchPaths.add(t)
else: else:
searchPaths.add(t) searchPaths.add(t)
@ -434,6 +455,9 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
when finalApi: when finalApi:
graph.compileSystemModule() graph.compileSystemModule()
when NimCompilerApiVersion >= 3:
graph.processModule(result, llStreamOpen(AbsoluteFile scriptName, fmRead))
else:
graph.processModule(result, llStreamOpen(scriptName, fmRead)) graph.processModule(result, llStreamOpen(scriptName, fmRead))
elif declared(newIdentCache): elif declared(newIdentCache):
graph.compileSystemModule(identCache) graph.compileSystemModule(identCache)