This commit is contained in:
Andreas Rumpf
2017-03-18 13:59:35 +01:00
parent 9f5492becd
commit 242fb3240f
3 changed files with 20 additions and 5 deletions

View File

@@ -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 )

View File

@@ -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

View File

@@ -7,6 +7,7 @@ exec "gcc -v"
import ospaths
--forceBuild
--path: "../friends"
warning("uninit", off)
hint("processing", off)