diff options
-rw-r--r-- | compiler/commands.nim | 10 | ||||
-rw-r--r-- | compiler/importer.nim | 6 | ||||
-rw-r--r-- | compiler/main.nim | 2 | ||||
-rw-r--r-- | compiler/nim.cfg | 2 | ||||
-rw-r--r-- | compiler/options.nim | 15 | ||||
-rw-r--r-- | lib/system.nim | 2 | ||||
-rw-r--r-- | tests/manyloc/keineschweine/lib/vehicles.nim | 2 | ||||
-rw-r--r-- | tests/manyloc/named_argument_bug/main.nim.cfg | 1 | ||||
-rw-r--r-- | tests/manyloc/named_argument_bug/tri_engine/math/circle.nim | 4 | ||||
-rw-r--r-- | tests/manyloc/named_argument_bug/tri_engine/math/vec.nim | 2 | ||||
-rw-r--r-- | web/news.txt | 3 |
11 files changed, 32 insertions, 17 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index e2274f2ad..e9806e6d8 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -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 diff --git a/compiler/importer.nim b/compiler/importer.nim index 86993358b..5ffe12728 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -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: diff --git a/compiler/main.nim b/compiler/main.nim index 4aefbb85a..b1b9006bd 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -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) diff --git a/compiler/nim.cfg b/compiler/nim.cfg index 4f9962ea8..0ff128ba3 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -7,7 +7,7 @@ path:"$projectPath/.." path:"$lib/packages/docutils" define:booting -import:testability +#import:"$projectpath/testability" @if windows: cincludes: "$lib/wrappers/libffi/common" diff --git a/compiler/options.nim b/compiler/options.nim index 2716a98d3..3ef6c6c46 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -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 diff --git a/lib/system.nim b/lib/system.nim index c224535f0..8180f27cd 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2514,7 +2514,7 @@ template newException*(exceptn: typedesc, message: string): expr = e when hostOS == "standalone": - include panicoverride + include "$projectpath/panicoverride" when not declared(sysFatal): when hostOS == "standalone": diff --git a/tests/manyloc/keineschweine/lib/vehicles.nim b/tests/manyloc/keineschweine/lib/vehicles.nim index 94ebf9f57..ddfb43b38 100644 --- a/tests/manyloc/keineschweine/lib/vehicles.nim +++ b/tests/manyloc/keineschweine/lib/vehicles.nim @@ -1,6 +1,6 @@ import sfml, chipmunk, - sg_assets, sfml_stuff, keineschweine + sg_assets, sfml_stuff, "../keineschweine" proc accel*(obj: PVehicle, dt: float) = diff --git a/tests/manyloc/named_argument_bug/main.nim.cfg b/tests/manyloc/named_argument_bug/main.nim.cfg index 27cf8e688..7df7a0e97 100644 --- a/tests/manyloc/named_argument_bug/main.nim.cfg +++ b/tests/manyloc/named_argument_bug/main.nim.cfg @@ -1,2 +1,3 @@ # this file only exists to mark 'main.nim' as the main file +--path:"$projectpath" diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim b/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim index 7e7517998..b95cfa379 100644 --- a/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim +++ b/tests/manyloc/named_argument_bug/tri_engine/math/circle.nim @@ -1,6 +1,6 @@ import - tri_engine/config, - tri_engine/math/vec + ../config, + vec type TCircle* = tuple[p: TV2[TR], r: TR] diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim index 3b57acb8e..926958fe4 100644 --- a/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim +++ b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim @@ -1,6 +1,6 @@ import macros, - tri_engine/config + "../config" type TV2*[T:SomeNumber=TR] = array[0..1, T] diff --git a/web/news.txt b/web/news.txt index 837f30f40..c100c8aee 100644 --- a/web/news.txt +++ b/web/news.txt @@ -42,6 +42,9 @@ Changes affecting backwards compatibility - The procs related to ``random`` number generation in ``math.nim`` have been moved to its own ``random`` module and been reimplemented in pure Nim. +- The path handling changed. The project directory is not added to the + search path automatically anymore. Add this line to your project's + config to get back the old behaviour: ``--path:"$projectdir"``. Library Additions |