This commit is contained in:
Andreas Rumpf 2017-03-18 13:59:35 +01:00
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, proc processPath(path: string, info: TLineInfo,
notRelativeToProj = false): string = notRelativeToProj = false): string =
let p = if notRelativeToProj or os.isAbsolute(path) or let p = if notRelativeToProj or os.isAbsolute(path) or
'$' in path or path[0] == '.': '$' in path:
path path
else: else:
options.gProjectPath / path options.gProjectPath / path
@ -282,6 +282,19 @@ proc processPath(path: string, info: TLineInfo,
localError(info, "invalid path: " & p) localError(info, "invalid path: " & p)
result = 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) = proc trackDirty(arg: string, info: TLineInfo) =
var a = arg.split(',') var a = arg.split(',')
if a.len != 4: localError(info, errTokenExpected, if a.len != 4: localError(info, errTokenExpected,
@ -322,7 +335,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
case switch.normalize case switch.normalize
of "path", "p": of "path", "p":
expectArg(switch, arg, pass, info) 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": of "nimblepath", "babelpath":
# keep the old name for compat # keep the old name for compat
if pass in {passCmd2, passPP} and not options.gNoNimblePath: if pass in {passCmd2, passPP} and not options.gNoNimblePath:
@ -335,10 +348,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "excludepath": of "excludepath":
expectArg(switch, arg, pass, info) expectArg(switch, arg, pass, info)
let path = processPath(arg, info) let path = processPath(arg, info)
options.searchPaths.keepItIf( cmpPaths(it, path) != 0 ) options.searchPaths.keepItIf( cmpPaths(it, path) != 0 )
options.lazyPaths.keepItIf( cmpPaths(it, path) != 0 ) options.lazyPaths.keepItIf( cmpPaths(it, path) != 0 )
if (len(path) > 0) and (path[len(path) - 1] == DirSep): if (len(path) > 0) and (path[len(path) - 1] == DirSep):
let strippedPath = path[0 .. (len(path) - 2)] let strippedPath = path[0 .. (len(path) - 2)]
options.searchPaths.keepItIf( cmpPaths(it, strippedPath) != 0 ) options.searchPaths.keepItIf( cmpPaths(it, strippedPath) != 0 )

View file

@ -7,6 +7,7 @@ discard """
when not defined(definedefine): when not defined(definedefine):
{.fatal: "wrong nim script configuration".} {.fatal: "wrong nim script configuration".}
import math import math, mfriends
discard gen[int]()
echo "hello world! ", ln 2.0 echo "hello world! ", ln 2.0

View file

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