mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
incremental compilation: simple recompilation works
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -22,6 +22,8 @@ when not nimIncremental:
|
||||
|
||||
template storeRemaining*(g: ModuleGraph; module: PSym) = discard
|
||||
|
||||
template registerModule*(g: ModuleGraph; module: PSym) = discard
|
||||
|
||||
else:
|
||||
include rodimpl
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user