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:
|
||||
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``.
|
||||
if pkgInfo.bin.len == 0:
|
||||
raise newException(NimbleError,
|
||||
"Nothing to build. Did you specify a module to build using the" &
|
||||
" `bin` key in your .nimble file?")
|
||||
let realDir = pkgInfo.getRealDir()
|
||||
let releaseOpt = if forRelease: "-d:release" else: ""
|
||||
var args = ""
|
||||
for path in paths: args.add("--path:\"" & path & "\" ")
|
||||
for path in paths: args.add(" --path:\"" & path & "\" ")
|
||||
for bin in pkgInfo.bin:
|
||||
let outputOpt = "-o:\"" & pkgInfo.getOutputDir(bin) & "\""
|
||||
display("Building", "$1/$2 using $3 backend" %
|
||||
|
|
@ -305,8 +303,8 @@ proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
|||
createDir(outputDir)
|
||||
|
||||
try:
|
||||
doCmd("\"" & getNimBin() & "\" $# $# --noBabelPath $# $# \"$#\"" %
|
||||
[pkgInfo.backend, releaseOpt, args, outputOpt,
|
||||
doCmd("\"" & getNimBin() & "\" $# --noBabelPath $# $# \"$#\"" %
|
||||
[pkgInfo.backend, args, outputOpt,
|
||||
realDir / bin.changeFileExt("nim")])
|
||||
except NimbleError:
|
||||
let currentExc = (ref NimbleError)(getCurrentException())
|
||||
|
|
@ -317,6 +315,10 @@ proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
|||
exc.hint = hint
|
||||
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,
|
||||
filesInstalled, bins: HashSet[string]) =
|
||||
## Saves the specified data into a ``nimblemeta.json`` file inside
|
||||
|
|
@ -635,7 +637,8 @@ proc build(options: Options) =
|
|||
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
||||
nimScriptHint(pkgInfo)
|
||||
let paths = processDeps(pkginfo, options)
|
||||
buildFromDir(pkgInfo, paths, false)
|
||||
var args = join(options.action.compileOptions, " ")
|
||||
buildFromDir(pkgInfo, paths, args)
|
||||
|
||||
proc execBackend(options: Options) =
|
||||
let bin = options.action.file
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ type
|
|||
|
||||
Action* = object
|
||||
case typ*: ActionType
|
||||
of actionNil, actionList, actionBuild, actionPublish, actionTasks: nil
|
||||
of actionNil, actionList, actionPublish, actionTasks: nil
|
||||
of actionRefresh:
|
||||
optionalURL*: string # Overrides default package list.
|
||||
of actionInstall, actionPath, actionUninstall:
|
||||
|
|
@ -39,7 +39,7 @@ type
|
|||
search*: seq[string] # Search string.
|
||||
of actionInit, actionDump:
|
||||
projName*: string
|
||||
of actionCompile, actionDoc:
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
file*: string
|
||||
backend*: string
|
||||
compileOptions*: seq[string]
|
||||
|
|
@ -147,7 +147,7 @@ proc initAction*(options: var Options, key: string) =
|
|||
case options.action.typ
|
||||
of actionInstall, actionPath:
|
||||
options.action.packages = @[]
|
||||
of actionCompile, actionDoc:
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
options.action.compileOptions = @[]
|
||||
options.action.file = ""
|
||||
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.arguments = @[]
|
||||
options.action.flags = newStringTable()
|
||||
of actionBuild, actionPublish, actionList, actionTasks,
|
||||
of actionPublish, actionList, actionTasks,
|
||||
actionNil: discard
|
||||
|
||||
proc prompt*(options: Options, question: string): bool =
|
||||
|
|
@ -269,7 +269,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
|||
result.depsOnly = true
|
||||
else:
|
||||
wasFlagHandled = false
|
||||
of actionCompile, actionDoc:
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
let prefix = if kind == cmdShortOption: "-" else: "--"
|
||||
if val == "":
|
||||
result.action.compileOptions.add(prefix & flag)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue