mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 11:54:11 +00:00
fixed a regression: compiling projects not residing in the current directory
This commit is contained in:
@@ -175,9 +175,6 @@ proc compileModule(fileIdx: int32, flags: TSymFlags): PSym =
|
||||
else:
|
||||
result = gCompiledModules[fileIdx]
|
||||
|
||||
proc compileModule(filename: string, flags: TSymFlags): PSym =
|
||||
result = compileModule(filename.fileInfoIdx, flags)
|
||||
|
||||
proc importModule(s: PSym, fileIdx: int32): PSym =
|
||||
# this is called by the semantic checking phase
|
||||
result = compileModule(fileIdx, {})
|
||||
@@ -203,9 +200,9 @@ proc compileSystemModule =
|
||||
SystemFileIdx = fileInfoIdx(options.libpath/"system.nim")
|
||||
discard CompileModule(SystemFileIdx, {sfSystemModule})
|
||||
|
||||
proc CompileProject(projectFile = gProjectFull) =
|
||||
let systemFile = options.libpath / "system"
|
||||
if projectFile.addFileExt(nimExt) ==^ systemFile.addFileExt(nimExt):
|
||||
proc CompileProject(projectFile = gProjectMainIdx) =
|
||||
let systemFileIdx = fileInfoIdx(options.libpath / "system.nim")
|
||||
if projectFile == SystemFileIdx:
|
||||
discard CompileModule(projectFile, {sfMainModule, sfSystemModule})
|
||||
else:
|
||||
compileSystemModule()
|
||||
@@ -232,15 +229,15 @@ proc CommandCheck =
|
||||
msgs.gErrorMax = high(int) # do not stop after first error
|
||||
semanticPasses() # use an empty backend for semantic checking only
|
||||
rodPass()
|
||||
compileProject(mainCommandArg())
|
||||
compileProject()
|
||||
|
||||
proc CommandDoc2 =
|
||||
msgs.gErrorMax = high(int) # do not stop after first error
|
||||
semanticPasses()
|
||||
registerPass(docgen2Pass)
|
||||
#registerPass(cleanupPass())
|
||||
compileProject(mainCommandArg())
|
||||
finishDoc2Pass(gProjectFull)
|
||||
compileProject()
|
||||
finishDoc2Pass(gProjectName)
|
||||
|
||||
proc CommandCompileToC =
|
||||
semanticPasses()
|
||||
@@ -336,7 +333,7 @@ proc CommandInteractive =
|
||||
InteractivePasses()
|
||||
compileSystemModule()
|
||||
if commandArgs.len > 0:
|
||||
discard CompileModule(mainCommandArg(), {})
|
||||
discard CompileModule(gProjectMainIdx, {})
|
||||
else:
|
||||
var m = makeStdinModule()
|
||||
incl(m.flags, sfMainModule)
|
||||
|
||||
@@ -561,17 +561,19 @@ proc getInfoContext*(index: int): TLineInfo =
|
||||
if i >=% L: result = UnknownLineInfo()
|
||||
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 =
|
||||
if fileIdx < 0: result = "???"
|
||||
else: result = fileInfos[fileIdx].projPath
|
||||
|
||||
proc toFullPath*(info: TLineInfo): string =
|
||||
if info.fileIndex < 0: result = "???"
|
||||
else: result = fileInfos[info.fileIndex].fullPath
|
||||
proc toFullPath*(fileIdx: int32): string =
|
||||
if fileIdx < 0: result = "???"
|
||||
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.} =
|
||||
result = info.line
|
||||
|
||||
@@ -168,7 +168,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||
if rd == nil:
|
||||
openPasses(a, module)
|
||||
if stream == nil:
|
||||
let filename = fileIdx.toFilename
|
||||
let filename = fileIdx.toFullPath
|
||||
s = LLStreamOpen(filename, fmRead)
|
||||
if s == nil:
|
||||
rawMessage(errCannotOpenFile, filename)
|
||||
|
||||
@@ -44,7 +44,7 @@ proc ParseFile(fileIdx: int32): PNode =
|
||||
var
|
||||
p: TParsers
|
||||
f: tfile
|
||||
let filename = fileIdx.toFilename
|
||||
let filename = fileIdx.toFullPath
|
||||
if not open(f, filename):
|
||||
rawMessage(errCannotOpenFile, filename)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user