implements pkg/ prefix to enforce searching for the module ignore the stdlib paths; refs #7250
This commit is contained in:
parent
894f21eb73
commit
1578d222e2
1 changed files with 14 additions and 18 deletions
|
|
@ -516,8 +516,10 @@ proc completeGeneratedFilePath*(conf: ConfigRef; f: string, createSubDir: bool =
|
||||||
result = joinPath(subdir, tail)
|
result = joinPath(subdir, tail)
|
||||||
#echo "completeGeneratedFilePath(", f, ") = ", result
|
#echo "completeGeneratedFilePath(", f, ") = ", result
|
||||||
|
|
||||||
proc rawFindFile(conf: ConfigRef; f: string): string =
|
proc rawFindFile(conf: ConfigRef; f: string; suppressStdlib: bool): string =
|
||||||
for it in conf.searchPaths:
|
for it in conf.searchPaths:
|
||||||
|
if suppressStdlib and it.startsWith(conf.libpath):
|
||||||
|
continue
|
||||||
result = joinPath(it, f)
|
result = joinPath(it, f)
|
||||||
if existsFile(result):
|
if existsFile(result):
|
||||||
return canonicalizePath(conf, result)
|
return canonicalizePath(conf, result)
|
||||||
|
|
@ -541,13 +543,13 @@ template patchModule(conf: ConfigRef) {.dirty.} =
|
||||||
let ov = conf.moduleOverrides[key]
|
let ov = conf.moduleOverrides[key]
|
||||||
if ov.len > 0: result = ov
|
if ov.len > 0: result = ov
|
||||||
|
|
||||||
proc findFile*(conf: ConfigRef; f: string): string {.procvar.} =
|
proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): string {.procvar.} =
|
||||||
if f.isAbsolute:
|
if f.isAbsolute:
|
||||||
result = if f.existsFile: f else: ""
|
result = if f.existsFile: f else: ""
|
||||||
else:
|
else:
|
||||||
result = rawFindFile(conf, f)
|
result = rawFindFile(conf, f, suppressStdlib)
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
result = rawFindFile(conf, f.toLowerAscii)
|
result = rawFindFile(conf, f.toLowerAscii, suppressStdlib)
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
result = rawFindFile2(conf, f)
|
result = rawFindFile2(conf, f)
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
|
|
@ -556,21 +558,15 @@ proc findFile*(conf: ConfigRef; f: string): string {.procvar.} =
|
||||||
|
|
||||||
proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
||||||
# returns path to module
|
# returns path to module
|
||||||
when defined(nimfix):
|
const pkgPrefix = "pkg/"
|
||||||
# '.nimfix' modules are preferred over '.nim' modules so that specialized
|
|
||||||
# versions can be kept for 'nimfix'.
|
|
||||||
block:
|
|
||||||
let m = addFileExt(modulename, "nimfix")
|
|
||||||
let currentPath = currentModule.splitFile.dir
|
|
||||||
result = currentPath / m
|
|
||||||
if not existsFile(result):
|
|
||||||
result = findFile(conf, m)
|
|
||||||
if existsFile(result): return result
|
|
||||||
let m = addFileExt(modulename, NimExt)
|
let m = addFileExt(modulename, NimExt)
|
||||||
let currentPath = currentModule.splitFile.dir
|
if m.startsWith(pkgPrefix):
|
||||||
result = currentPath / m
|
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)
|
||||||
if not existsFile(result):
|
else:
|
||||||
result = findFile(conf, m)
|
let currentPath = currentModule.splitFile.dir
|
||||||
|
result = currentPath / m
|
||||||
|
if not existsFile(result):
|
||||||
|
result = findFile(conf, m)
|
||||||
patchModule(conf)
|
patchModule(conf)
|
||||||
|
|
||||||
proc findProjectNimFile*(conf: ConfigRef; pkg: string): string =
|
proc findProjectNimFile*(conf: ConfigRef; pkg: string): string =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue