fixed a regression: compiling projects not residing in the current directory
This commit is contained in:
parent
86bf97a730
commit
8be307713e
4 changed files with 18 additions and 19 deletions
|
|
@ -175,9 +175,6 @@ proc compileModule(fileIdx: int32, flags: TSymFlags): PSym =
|
||||||
else:
|
else:
|
||||||
result = gCompiledModules[fileIdx]
|
result = gCompiledModules[fileIdx]
|
||||||
|
|
||||||
proc compileModule(filename: string, flags: TSymFlags): PSym =
|
|
||||||
result = compileModule(filename.fileInfoIdx, flags)
|
|
||||||
|
|
||||||
proc importModule(s: PSym, fileIdx: int32): PSym =
|
proc importModule(s: PSym, fileIdx: int32): PSym =
|
||||||
# this is called by the semantic checking phase
|
# this is called by the semantic checking phase
|
||||||
result = compileModule(fileIdx, {})
|
result = compileModule(fileIdx, {})
|
||||||
|
|
@ -203,9 +200,9 @@ proc compileSystemModule =
|
||||||
SystemFileIdx = fileInfoIdx(options.libpath/"system.nim")
|
SystemFileIdx = fileInfoIdx(options.libpath/"system.nim")
|
||||||
discard CompileModule(SystemFileIdx, {sfSystemModule})
|
discard CompileModule(SystemFileIdx, {sfSystemModule})
|
||||||
|
|
||||||
proc CompileProject(projectFile = gProjectFull) =
|
proc CompileProject(projectFile = gProjectMainIdx) =
|
||||||
let systemFile = options.libpath / "system"
|
let systemFileIdx = fileInfoIdx(options.libpath / "system.nim")
|
||||||
if projectFile.addFileExt(nimExt) ==^ systemFile.addFileExt(nimExt):
|
if projectFile == SystemFileIdx:
|
||||||
discard CompileModule(projectFile, {sfMainModule, sfSystemModule})
|
discard CompileModule(projectFile, {sfMainModule, sfSystemModule})
|
||||||
else:
|
else:
|
||||||
compileSystemModule()
|
compileSystemModule()
|
||||||
|
|
@ -232,15 +229,15 @@ proc CommandCheck =
|
||||||
msgs.gErrorMax = high(int) # do not stop after first error
|
msgs.gErrorMax = high(int) # do not stop after first error
|
||||||
semanticPasses() # use an empty backend for semantic checking only
|
semanticPasses() # use an empty backend for semantic checking only
|
||||||
rodPass()
|
rodPass()
|
||||||
compileProject(mainCommandArg())
|
compileProject()
|
||||||
|
|
||||||
proc CommandDoc2 =
|
proc CommandDoc2 =
|
||||||
msgs.gErrorMax = high(int) # do not stop after first error
|
msgs.gErrorMax = high(int) # do not stop after first error
|
||||||
semanticPasses()
|
semanticPasses()
|
||||||
registerPass(docgen2Pass)
|
registerPass(docgen2Pass)
|
||||||
#registerPass(cleanupPass())
|
#registerPass(cleanupPass())
|
||||||
compileProject(mainCommandArg())
|
compileProject()
|
||||||
finishDoc2Pass(gProjectFull)
|
finishDoc2Pass(gProjectName)
|
||||||
|
|
||||||
proc CommandCompileToC =
|
proc CommandCompileToC =
|
||||||
semanticPasses()
|
semanticPasses()
|
||||||
|
|
@ -336,7 +333,7 @@ proc CommandInteractive =
|
||||||
InteractivePasses()
|
InteractivePasses()
|
||||||
compileSystemModule()
|
compileSystemModule()
|
||||||
if commandArgs.len > 0:
|
if commandArgs.len > 0:
|
||||||
discard CompileModule(mainCommandArg(), {})
|
discard CompileModule(gProjectMainIdx, {})
|
||||||
else:
|
else:
|
||||||
var m = makeStdinModule()
|
var m = makeStdinModule()
|
||||||
incl(m.flags, sfMainModule)
|
incl(m.flags, sfMainModule)
|
||||||
|
|
|
||||||
|
|
@ -561,17 +561,19 @@ proc getInfoContext*(index: int): TLineInfo =
|
||||||
if i >=% L: result = UnknownLineInfo()
|
if i >=% L: result = UnknownLineInfo()
|
||||||
else: result = msgContext[i]
|
else: result = msgContext[i]
|
||||||
|
|
||||||
proc toFilename*(info: TLineInfo): string =
|
|
||||||
if info.fileIndex < 0: result = "???"
|
|
||||||
else: result = fileInfos[info.fileIndex].projPath
|
|
||||||
|
|
||||||
proc toFilename*(fileIdx: int32): string =
|
proc toFilename*(fileIdx: int32): string =
|
||||||
if fileIdx < 0: result = "???"
|
if fileIdx < 0: result = "???"
|
||||||
else: result = fileInfos[fileIdx].projPath
|
else: result = fileInfos[fileIdx].projPath
|
||||||
|
|
||||||
proc toFullPath*(info: TLineInfo): string =
|
proc toFullPath*(fileIdx: int32): string =
|
||||||
if info.fileIndex < 0: result = "???"
|
if fileIdx < 0: result = "???"
|
||||||
else: result = fileInfos[info.fileIndex].fullPath
|
else: result = fileInfos[fileIdx].fullPath
|
||||||
|
|
||||||
|
template toFilename*(info: TLineInfo): string =
|
||||||
|
info.fileIndex.toFilename
|
||||||
|
|
||||||
|
template toFullPath*(info: TLineInfo): string =
|
||||||
|
info.fileIndex.toFullPath
|
||||||
|
|
||||||
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
||||||
result = info.line
|
result = info.line
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||||
if rd == nil:
|
if rd == nil:
|
||||||
openPasses(a, module)
|
openPasses(a, module)
|
||||||
if stream == nil:
|
if stream == nil:
|
||||||
let filename = fileIdx.toFilename
|
let filename = fileIdx.toFullPath
|
||||||
s = LLStreamOpen(filename, fmRead)
|
s = LLStreamOpen(filename, fmRead)
|
||||||
if s == nil:
|
if s == nil:
|
||||||
rawMessage(errCannotOpenFile, filename)
|
rawMessage(errCannotOpenFile, filename)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ proc ParseFile(fileIdx: int32): PNode =
|
||||||
var
|
var
|
||||||
p: TParsers
|
p: TParsers
|
||||||
f: tfile
|
f: tfile
|
||||||
let filename = fileIdx.toFilename
|
let filename = fileIdx.toFullPath
|
||||||
if not open(f, filename):
|
if not open(f, filename):
|
||||||
rawMessage(errCannotOpenFile, filename)
|
rawMessage(errCannotOpenFile, filename)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue