incremental compilation: simple recompilation works

This commit is contained in:
Araq
2018-11-19 17:16:42 +01:00
parent 1e08fff2d5
commit 6acffcd28f
4 changed files with 11 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ proc compileModule*(graph: ModuleGraph; fileIdx: FileIndex; flags: TSymFlags): P
graph.config.mainPackageId = result.owner.id
result.id = getModuleId(graph, fileIdx, AbsoluteFile toFullPath(graph.config, fileIdx))
registerModule(graph, result)
discard processModule(graph, result,
if sfMainModule in flags and graph.config.projectIsStdin: stdin.llStreamOpen else: nil)
elif graph.isDirty(result):
@@ -128,6 +129,7 @@ proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) =
proc makeModule*(graph: ModuleGraph; filename: AbsoluteFile): PSym =
result = graph.newModule(fileInfoIdx(graph.config, filename))
result.id = getID()
registerModule(graph, result)
proc makeModule*(graph: ModuleGraph; filename: string): PSym =
result = makeModule(graph, AbsoluteFile filename)

View File

@@ -22,6 +22,8 @@ when not nimIncremental:
template storeRemaining*(g: ModuleGraph; module: PSym) = discard
template registerModule*(g: ModuleGraph; module: PSym) = discard
else:
include rodimpl

View File

@@ -752,6 +752,9 @@ proc loadSym(g; id: int; info: TLineInfo): PSym =
result = loadSymFromBlob(g, b, info)
doAssert id == result.id, "symbol ID is not consistent!"
proc registerModule*(g; module: PSym) =
g.incr.r.syms.add(abs module.id, module)
proc loadModuleSymTab(g; module: PSym) =
## goal: fill module.tab
g.incr.r.syms.add(module.id, module)
@@ -868,6 +871,7 @@ proc setupModuleCache*(g: ModuleGraph) =
let dbfile = getNimcacheDir(g.config) / RelativeFile"rodfiles.db"
if g.config.symbolFiles == writeOnlySf:
removeFile(dbfile)
createDir getNimcacheDir(g.config)
if not fileExists(dbfile):
db = open(connection=string dbfile, user="nim", password="",
database="nim")

View File

@@ -159,6 +159,8 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
freshDefines=true; conf: ConfigRef) =
rawMessage(conf, hintConf, scriptName.string)
let oldSymbolFiles = conf.symbolFiles
conf.symbolFiles = disabledSf
let graph = newModuleGraph(cache, conf)
connectCallbacks(graph)
@@ -184,3 +186,4 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
#initDefines()
undefSymbol(conf.symbols, "nimscript")
undefSymbol(conf.symbols, "nimconfig")
conf.symbolFiles = oldSymbolFiles