diff --git a/src/nimble.nim b/src/nimble.nim index 8cc3f1e..95520df 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -635,6 +635,13 @@ proc build(options: Options) = buildFromDir(pkgInfo, paths, false) proc compile(options: Options) = + let bin = options.action.file + if bin == "": + raise newException(NimbleError, "You need to specify a file to compile.") + + if not fileExists(bin): + raise newException(NimbleError, "Specified file does not exist.") + var pkgInfo = getPkgInfo(getCurrentDir(), options) nimScriptHint(pkgInfo) let paths = processDeps(pkginfo, options) @@ -644,20 +651,18 @@ proc compile(options: Options) = for option in options.action.compileOptions: args.add(option & " ") - let bin = options.action.file + let backend = if options.action.backend.len > 0: options.action.backend else: pkgInfo.backend - if bin == "": - raise newException(NimbleError, "You need to specify a file to compile.") - - display("Compiling", "$1 ($2) using $3 backend" % [bin, pkgInfo.name, backend], - priority = HighPriority) + display("Compiling", "$1 (from package $2) using $3 backend" % + [bin, pkgInfo.name, backend], priority = HighPriority) doCmd("\"" & getNimBin() & "\" $# --noBabelPath $# \"$#\"" % [backend, args, bin]) + display("Success:", "Compilation finished", Success, HighPriority) proc search(options: Options) = ## Searches for matches in ``options.action.search``. diff --git a/src/nimblepkg/tools.nim b/src/nimblepkg/tools.nim index 57ed674..d71c3f6 100644 --- a/src/nimblepkg/tools.nim +++ b/src/nimblepkg/tools.nim @@ -28,7 +28,8 @@ proc doCmd*(cmd: string) = if exitCode != QuitSuccess: raise newException(NimbleError, - "Execution failed with exit code " & $exitCode) + "Execution failed with exit code $1\nCommand: $2\nOutput: $3" % + [$exitCode, cmd, output]) proc doCmdEx*(cmd: string): tuple[output: TaintedString, exitCode: int] = let bin = extractBin(cmd)