Change to pass extra parameters to compiler (#347)
* Change to pass extra parameters to compiler * Add extra space in from of path argument * Fix missing space that caused some nimble commands to fail
This commit is contained in:
parent
cfe68bb441
commit
30d6aaf966
2 changed files with 15 additions and 12 deletions
|
|
@ -285,16 +285,14 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
|
||||||
for i in reverseDeps:
|
for i in reverseDeps:
|
||||||
addRevDep(options, i, pkginfo)
|
addRevDep(options, i, pkginfo)
|
||||||
|
|
||||||
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], args: var string) =
|
||||||
## Builds a package as specified by ``pkgInfo``.
|
## Builds a package as specified by ``pkgInfo``.
|
||||||
if pkgInfo.bin.len == 0:
|
if pkgInfo.bin.len == 0:
|
||||||
raise newException(NimbleError,
|
raise newException(NimbleError,
|
||||||
"Nothing to build. Did you specify a module to build using the" &
|
"Nothing to build. Did you specify a module to build using the" &
|
||||||
" `bin` key in your .nimble file?")
|
" `bin` key in your .nimble file?")
|
||||||
let realDir = pkgInfo.getRealDir()
|
let realDir = pkgInfo.getRealDir()
|
||||||
let releaseOpt = if forRelease: "-d:release" else: ""
|
for path in paths: args.add(" --path:\"" & path & "\" ")
|
||||||
var args = ""
|
|
||||||
for path in paths: args.add("--path:\"" & path & "\" ")
|
|
||||||
for bin in pkgInfo.bin:
|
for bin in pkgInfo.bin:
|
||||||
let outputOpt = "-o:\"" & pkgInfo.getOutputDir(bin) & "\""
|
let outputOpt = "-o:\"" & pkgInfo.getOutputDir(bin) & "\""
|
||||||
display("Building", "$1/$2 using $3 backend" %
|
display("Building", "$1/$2 using $3 backend" %
|
||||||
|
|
@ -305,8 +303,8 @@ proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
||||||
createDir(outputDir)
|
createDir(outputDir)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
doCmd("\"" & getNimBin() & "\" $# $# --noBabelPath $# $# \"$#\"" %
|
doCmd("\"" & getNimBin() & "\" $# --noBabelPath $# $# \"$#\"" %
|
||||||
[pkgInfo.backend, releaseOpt, args, outputOpt,
|
[pkgInfo.backend, args, outputOpt,
|
||||||
realDir / bin.changeFileExt("nim")])
|
realDir / bin.changeFileExt("nim")])
|
||||||
except NimbleError:
|
except NimbleError:
|
||||||
let currentExc = (ref NimbleError)(getCurrentException())
|
let currentExc = (ref NimbleError)(getCurrentException())
|
||||||
|
|
@ -317,6 +315,10 @@ proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
||||||
exc.hint = hint
|
exc.hint = hint
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
|
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
||||||
|
var args = if forRelease: "-d:release" else: ""
|
||||||
|
buildFromDir(pkgInfo, paths, args)
|
||||||
|
|
||||||
proc saveNimbleMeta(pkgDestDir, url, vcsRevision: string,
|
proc saveNimbleMeta(pkgDestDir, url, vcsRevision: string,
|
||||||
filesInstalled, bins: HashSet[string]) =
|
filesInstalled, bins: HashSet[string]) =
|
||||||
## Saves the specified data into a ``nimblemeta.json`` file inside
|
## Saves the specified data into a ``nimblemeta.json`` file inside
|
||||||
|
|
@ -635,7 +637,8 @@ proc build(options: Options) =
|
||||||
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
||||||
nimScriptHint(pkgInfo)
|
nimScriptHint(pkgInfo)
|
||||||
let paths = processDeps(pkginfo, options)
|
let paths = processDeps(pkginfo, options)
|
||||||
buildFromDir(pkgInfo, paths, false)
|
var args = join(options.action.compileOptions, " ")
|
||||||
|
buildFromDir(pkgInfo, paths, args)
|
||||||
|
|
||||||
proc execBackend(options: Options) =
|
proc execBackend(options: Options) =
|
||||||
let bin = options.action.file
|
let bin = options.action.file
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ type
|
||||||
|
|
||||||
Action* = object
|
Action* = object
|
||||||
case typ*: ActionType
|
case typ*: ActionType
|
||||||
of actionNil, actionList, actionBuild, actionPublish, actionTasks: nil
|
of actionNil, actionList, actionPublish, actionTasks: nil
|
||||||
of actionRefresh:
|
of actionRefresh:
|
||||||
optionalURL*: string # Overrides default package list.
|
optionalURL*: string # Overrides default package list.
|
||||||
of actionInstall, actionPath, actionUninstall:
|
of actionInstall, actionPath, actionUninstall:
|
||||||
|
|
@ -39,7 +39,7 @@ type
|
||||||
search*: seq[string] # Search string.
|
search*: seq[string] # Search string.
|
||||||
of actionInit, actionDump:
|
of actionInit, actionDump:
|
||||||
projName*: string
|
projName*: string
|
||||||
of actionCompile, actionDoc:
|
of actionCompile, actionDoc, actionBuild:
|
||||||
file*: string
|
file*: string
|
||||||
backend*: string
|
backend*: string
|
||||||
compileOptions*: seq[string]
|
compileOptions*: seq[string]
|
||||||
|
|
@ -147,7 +147,7 @@ proc initAction*(options: var Options, key: string) =
|
||||||
case options.action.typ
|
case options.action.typ
|
||||||
of actionInstall, actionPath:
|
of actionInstall, actionPath:
|
||||||
options.action.packages = @[]
|
options.action.packages = @[]
|
||||||
of actionCompile, actionDoc:
|
of actionCompile, actionDoc, actionBuild:
|
||||||
options.action.compileOptions = @[]
|
options.action.compileOptions = @[]
|
||||||
options.action.file = ""
|
options.action.file = ""
|
||||||
if keyNorm == "c" or keyNorm == "compile": options.action.backend = ""
|
if keyNorm == "c" or keyNorm == "compile": options.action.backend = ""
|
||||||
|
|
@ -166,7 +166,7 @@ proc initAction*(options: var Options, key: string) =
|
||||||
options.action.command = key
|
options.action.command = key
|
||||||
options.action.arguments = @[]
|
options.action.arguments = @[]
|
||||||
options.action.flags = newStringTable()
|
options.action.flags = newStringTable()
|
||||||
of actionBuild, actionPublish, actionList, actionTasks,
|
of actionPublish, actionList, actionTasks,
|
||||||
actionNil: discard
|
actionNil: discard
|
||||||
|
|
||||||
proc prompt*(options: Options, question: string): bool =
|
proc prompt*(options: Options, question: string): bool =
|
||||||
|
|
@ -269,7 +269,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
||||||
result.depsOnly = true
|
result.depsOnly = true
|
||||||
else:
|
else:
|
||||||
wasFlagHandled = false
|
wasFlagHandled = false
|
||||||
of actionCompile, actionDoc:
|
of actionCompile, actionDoc, actionBuild:
|
||||||
let prefix = if kind == cmdShortOption: "-" else: "--"
|
let prefix = if kind == cmdShortOption: "-" else: "--"
|
||||||
if val == "":
|
if val == "":
|
||||||
result.action.compileOptions.add(prefix & flag)
|
result.action.compileOptions.add(prefix & flag)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue