Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if this took seq[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" %
Expand All @@ -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())
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/nimblepkg/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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:
Expand All @@ -36,7 +36,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]
Expand Down Expand Up @@ -144,7 +144,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 = ""
Expand All @@ -163,7 +163,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 =
Expand Down Expand Up @@ -265,7 +265,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)
Expand Down