This commit is contained in:
Dominik Picheta 2016-12-30 12:43:52 +00:00
commit 850304ffcb
2 changed files with 21 additions and 13 deletions

View file

@ -661,10 +661,10 @@ proc build(options: Options) =
let paths = processDeps(pkginfo, options) let paths = processDeps(pkginfo, options)
buildFromDir(pkgInfo, paths, false) buildFromDir(pkgInfo, paths, false)
proc compile(options: Options) = proc execBackend(options: Options) =
let bin = options.action.file let bin = options.action.file
if bin == "": if bin == "":
raise newException(NimbleError, "You need to specify a file to compile.") raise newException(NimbleError, "You need to specify a file.")
if not fileExists(bin): if not fileExists(bin):
raise newException(NimbleError, "Specified file does not exist.") raise newException(NimbleError, "Specified file does not exist.")
@ -684,11 +684,15 @@ proc compile(options: Options) =
else: else:
pkgInfo.backend pkgInfo.backend
display("Compiling", "$1 (from package $2) using $3 backend" % if options.action.typ == actionCompile:
[bin, pkgInfo.name, backend], priority = HighPriority) display("Compiling", "$1 (from package $2) using $3 backend" %
doCmd("\"" & getNimBin() & "\" $# --noBabelPath $# \"$#\"" % [bin, pkgInfo.name, backend], priority = HighPriority)
else:
display("Generating", ("documentation for $1 (from package $2) using $3 " &
"backend") % [bin, pkgInfo.name, backend], priority = HighPriority)
doCmd("\"" & getNimBin() & "\" $# --noNimblePath $# \"$#\"" %
[backend, args, bin]) [backend, args, bin])
display("Success:", "Compilation finished", Success, HighPriority) display("Success:", "Execution finished", Success, HighPriority)
proc search(options: Options) = proc search(options: Options) =
## Searches for matches in ``options.action.search``. ## Searches for matches in ``options.action.search``.
@ -1035,8 +1039,8 @@ proc doAction(options: Options) =
listPaths(options) listPaths(options)
of actionBuild: of actionBuild:
build(options) build(options)
of actionCompile: of actionCompile, actionDoc:
compile(options) execBackend(options)
of actionInit: of actionInit:
init(options) init(options)
of actionPublish: of actionPublish:

View file

@ -23,7 +23,7 @@ type
actionNil, actionRefresh, actionInit, actionDump, actionPublish, actionNil, actionRefresh, actionInit, actionDump, actionPublish,
actionInstall, actionSearch, actionInstall, actionSearch,
actionList, actionBuild, actionPath, actionUninstall, actionCompile, actionList, actionBuild, actionPath, actionUninstall, actionCompile,
actionCustom, actionTasks actionDoc, actionCustom, actionTasks
Action* = object Action* = object
case typ*: ActionType case typ*: ActionType
@ -36,7 +36,7 @@ type
search*: seq[string] # Search string. search*: seq[string] # Search string.
of actionInit, actionDump: of actionInit, actionDump:
projName*: string projName*: string
of actionCompile: of actionCompile, actionDoc:
file*: string file*: string
backend*: string backend*: string
compileOptions*: seq[string] compileOptions*: seq[string]
@ -61,6 +61,8 @@ Commands:
build Builds a package. build Builds a package.
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
to the Nim compiler. to the Nim compiler.
doc, doc2 [opts, ...] f.nim Builds documentation for a file inside a
package. Passes options to the Nim compiler.
refresh [url] Refreshes the package list. A package list URL refresh [url] Refreshes the package list. A package list URL
can be optionally specified. can be optionally specified.
search pkg/tag Searches for a specified package. Search is search pkg/tag Searches for a specified package. Search is
@ -114,6 +116,8 @@ proc parseActionType*(action: string): ActionType =
result = actionBuild result = actionBuild
of "c", "compile", "js", "cpp", "cc": of "c", "compile", "js", "cpp", "cc":
result = actionCompile result = actionCompile
of "doc", "doc2":
result = actionDoc
of "init": of "init":
result = actionInit result = actionInit
of "dump": of "dump":
@ -140,7 +144,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: of actionCompile, actionDoc:
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 = ""
@ -222,7 +226,7 @@ proc parseArgument*(key: string, result: var Options) =
raise newException(NimbleError, raise newException(NimbleError,
"Can only initialize one package at a time.") "Can only initialize one package at a time.")
result.action.projName = key result.action.projName = key
of actionCompile: of actionCompile, actionDoc:
result.action.file = key result.action.file = key
of actionList, actionBuild, actionPublish: of actionList, actionBuild, actionPublish:
writeHelp() writeHelp()
@ -261,7 +265,7 @@ proc parseFlag*(flag, val: string, result: var Options) =
wasFlagHandled = false wasFlagHandled = false
else: else:
case result.action.typ case result.action.typ
of actionCompile: of actionCompile, actionDoc:
if val == "": if val == "":
result.action.compileOptions.add("--" & flag) result.action.compileOptions.add("--" & flag)
else: else: