diff options
-rw-r--r-- | compiler/commands.nim | 21 | ||||
-rw-r--r-- | tests/newconfig/tfoo.nim | 3 | ||||
-rw-r--r-- | tests/newconfig/tfoo.nims | 1 |
3 files changed, 20 insertions, 5 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index 6fdca27fc..1b42a191e 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -272,7 +272,7 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool = proc processPath(path: string, info: TLineInfo, notRelativeToProj = false): string = let p = if notRelativeToProj or os.isAbsolute(path) or - '$' in path or path[0] == '.': + '$' in path: path else: options.gProjectPath / path @@ -282,6 +282,19 @@ proc processPath(path: string, info: TLineInfo, localError(info, "invalid path: " & p) result = p +proc processCfgPath(path: string, info: TLineInfo): string = + let path = if path[0] == '"': strutils.unescape(path) else: path + let basedir = info.toFullPath().splitFile().dir + let p = if os.isAbsolute(path) or '$' in path: + path + else: + basedir / path + try: + result = pathSubs(p, basedir) + except ValueError: + localError(info, "invalid path: " & p) + result = p + proc trackDirty(arg: string, info: TLineInfo) = var a = arg.split(',') if a.len != 4: localError(info, errTokenExpected, @@ -322,7 +335,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; case switch.normalize of "path", "p": expectArg(switch, arg, pass, info) - addPath(processPath(arg, info), info) + addPath(if pass == passPP: processCfgPath(arg, info) else: processPath(arg, info), info) of "nimblepath", "babelpath": # keep the old name for compat if pass in {passCmd2, passPP} and not options.gNoNimblePath: @@ -335,10 +348,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "excludepath": expectArg(switch, arg, pass, info) let path = processPath(arg, info) - + options.searchPaths.keepItIf( cmpPaths(it, path) != 0 ) options.lazyPaths.keepItIf( cmpPaths(it, path) != 0 ) - + if (len(path) > 0) and (path[len(path) - 1] == DirSep): let strippedPath = path[0 .. (len(path) - 2)] options.searchPaths.keepItIf( cmpPaths(it, strippedPath) != 0 ) diff --git a/tests/newconfig/tfoo.nim b/tests/newconfig/tfoo.nim index 2e10167b1..52ea841ee 100644 --- a/tests/newconfig/tfoo.nim +++ b/tests/newconfig/tfoo.nim @@ -7,6 +7,7 @@ discard """ when not defined(definedefine): {.fatal: "wrong nim script configuration".} -import math +import math, mfriends +discard gen[int]() echo "hello world! ", ln 2.0 diff --git a/tests/newconfig/tfoo.nims b/tests/newconfig/tfoo.nims index 057c0ed92..8a709914f 100644 --- a/tests/newconfig/tfoo.nims +++ b/tests/newconfig/tfoo.nims @@ -7,6 +7,7 @@ exec "gcc -v" import ospaths --forceBuild +--path: "../friends" warning("uninit", off) hint("processing", off) |