@@ -761,8 +761,24 @@ when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):
761761 let ret = relativePath (path, base)
762762 result = path.len > 0 and not ret.startsWith " .."
763763
764+ const stdlibDirs = [
765+ " pure" , " core" , " arch" ,
766+ " pure/collections" ,
767+ " pure/concurrency" ,
768+ " pure/unidecode" , " impure" ,
769+ " wrappers" , " wrappers/linenoise" ,
770+ " windows" , " posix" , " js" ]
771+
772+ const
773+ pkgPrefix = " pkg/"
774+ stdPrefix = " std/"
775+
764776proc getRelativePathFromConfigPath * (conf: ConfigRef ; f: AbsoluteFile ): RelativeFile =
765777 let f = $ f
778+ for dir in stdlibDirs:
779+ let path = conf.libpath.string / dir / f.lastPathPart
780+ if path.cmpPaths (f.string ) == 0 :
781+ return RelativeFile (stdPrefix & f.splitFile.name)
766782 template search (paths) =
767783 for it in paths:
768784 let it = $ it
@@ -784,18 +800,8 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): AbsoluteFile
784800 result = rawFindFile2 (conf, RelativeFile f.toLowerAscii)
785801 patchModule (conf)
786802
787- const stdlibDirs = [
788- " pure" , " core" , " arch" ,
789- " pure/collections" ,
790- " pure/concurrency" ,
791- " pure/unidecode" , " impure" ,
792- " wrappers" , " wrappers/linenoise" ,
793- " windows" , " posix" , " js" ]
794-
795803proc findModule * (conf: ConfigRef ; modulename, currentModule: string ): AbsoluteFile =
796804 # returns path to module
797- const pkgPrefix = " pkg/"
798- const stdPrefix = " std/"
799805 var m = addFileExt (modulename, NimExt )
800806 if m.startsWith (pkgPrefix):
801807 result = findFile (conf, m.substr (pkgPrefix.len), suppressStdlib = true )
0 commit comments