Fix path resolution of submodules in the std namespace (#8453)
This commit is contained in:
parent
57c3b807d0
commit
97ea18746b
2 changed files with 20 additions and 17 deletions
|
|
@ -556,13 +556,28 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): string {.pro
|
|||
result = rawFindFile2(conf, f.toLowerAscii)
|
||||
patchModule(conf)
|
||||
|
||||
const stdlibDirs = [
|
||||
"pure", "core", "arch",
|
||||
"pure/collections",
|
||||
"pure/concurrency", "impure",
|
||||
"wrappers", "wrappers/linenoise",
|
||||
"windows", "posix", "js"]
|
||||
|
||||
proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
||||
# returns path to module
|
||||
const pkgPrefix = "pkg/"
|
||||
let m = addFileExt(modulename, NimExt)
|
||||
const stdPrefix = "std/"
|
||||
var m = addFileExt(modulename, NimExt)
|
||||
if m.startsWith(pkgPrefix):
|
||||
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)
|
||||
else:
|
||||
if m.startsWith(stdPrefix):
|
||||
let stripped = m.substr(stdPrefix.len)
|
||||
for candidate in stdlibDirs:
|
||||
let path = (conf.libpath / candidate / stripped)
|
||||
if fileExists(path):
|
||||
m = path
|
||||
break
|
||||
let currentPath = currentModule.splitFile.dir
|
||||
result = currentPath / m
|
||||
if not existsFile(result):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue