mirror of
https://github.com/nim-lang/Nim.git
synced 2026-09-17 18:44:53 +00:00
changed the compiler's path handling; fixes #546
This commit is contained in:
@@ -262,15 +262,7 @@ proc processPath(path: string, info: TLineInfo,
|
||||
else:
|
||||
options.gProjectPath / path
|
||||
try:
|
||||
result = unixToNativePath(p % ["nimrod", getPrefixDir(),
|
||||
"nim", getPrefixDir(),
|
||||
"lib", libpath,
|
||||
"home", removeTrailingDirSep(os.getHomeDir()),
|
||||
"config", info.toFullPath().splitFile().dir,
|
||||
"projectname", options.gProjectName,
|
||||
"projectpath", options.gProjectPath])
|
||||
if '~' in result:
|
||||
result = result.replace("~", os.getHomeDir())
|
||||
result = pathSubs(p, info.toFullPath().splitFile().dir)
|
||||
except ValueError:
|
||||
localError(info, "invalid path: " & p)
|
||||
result = p
|
||||
|
||||
@@ -22,7 +22,11 @@ proc getModuleName*(n: PNode): string =
|
||||
# The proc won't perform any checks that the path is actually valid
|
||||
case n.kind
|
||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||
result = unixToNativePath(n.strVal)
|
||||
try:
|
||||
result = pathSubs(n.strVal, n.info.toFullPath().splitFile().dir)
|
||||
except ValueError:
|
||||
localError(n.info, "invalid path: " & n.strVal)
|
||||
result = n.strVal
|
||||
of nkIdent:
|
||||
result = n.ident.s
|
||||
of nkSym:
|
||||
|
||||
@@ -242,7 +242,7 @@ proc mainCommand* =
|
||||
clearPasses()
|
||||
gLastCmdTime = epochTime()
|
||||
appendStr(searchPaths, options.libpath)
|
||||
if gProjectFull.len != 0:
|
||||
when false: # gProjectFull.len != 0:
|
||||
# current path is always looked first for modules
|
||||
prependStr(searchPaths, gProjectPath)
|
||||
setId(100)
|
||||
|
||||
@@ -7,7 +7,7 @@ path:"$projectPath/.."
|
||||
path:"$lib/packages/docutils"
|
||||
|
||||
define:booting
|
||||
import:testability
|
||||
#import:"$projectpath/testability"
|
||||
|
||||
@if windows:
|
||||
cincludes: "$lib/wrappers/libffi/common"
|
||||
|
||||
@@ -242,6 +242,21 @@ proc getNimcacheDir*: string =
|
||||
result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir /
|
||||
genSubDir
|
||||
|
||||
|
||||
proc pathSubs*(p, config: string): string =
|
||||
let home = removeTrailingDirSep(os.getHomeDir())
|
||||
result = unixToNativePath(p % [
|
||||
"nim", getPrefixDir(),
|
||||
"lib", libpath,
|
||||
"home", home,
|
||||
"config", config,
|
||||
"projectname", options.gProjectName,
|
||||
"projectpath", options.gProjectPath,
|
||||
"projectdir", options.gProjectPath,
|
||||
"nimcache", getNimcacheDir()])
|
||||
if '~' in result:
|
||||
result = result.replace("~", home)
|
||||
|
||||
template newPackageCache(): expr =
|
||||
newStringTable(when FileSystemCaseSensitive:
|
||||
modeCaseInsensitive
|
||||
|
||||
Reference in New Issue
Block a user