Fixes some small input validation errors and help text.

This commit is contained in:
Dominik Picheta 2019-09-22 18:11:28 +01:00
commit 1db54cc736
2 changed files with 13 additions and 2 deletions

View file

@ -233,6 +233,7 @@ proc buildFromDir(
var args = args var args = args
let nimblePkgVersion = "-d:NimblePkgVersion=" & pkgInfo.version let nimblePkgVersion = "-d:NimblePkgVersion=" & pkgInfo.version
for path in paths: args.add("--path:\"" & path & "\" ") for path in paths: args.add("--path:\"" & path & "\" ")
var binariesBuilt = 0
for bin in pkgInfo.bin: for bin in pkgInfo.bin:
# Check if this is the only binary that we want to build. # Check if this is the only binary that we want to build.
if binToBuild.isSome() and binToBuild.get() != bin: if binToBuild.isSome() and binToBuild.get() != bin:
@ -252,6 +253,7 @@ proc buildFromDir(
doCmd("\"" & getNimBin() & "\" $# --noNimblePath $# $# $# \"$#\"" % doCmd("\"" & getNimBin() & "\" $# --noNimblePath $# $# $# \"$#\"" %
[pkgInfo.backend, nimblePkgVersion, join(args, " "), outputOpt, [pkgInfo.backend, nimblePkgVersion, join(args, " "), outputOpt,
realDir / bin.changeFileExt("nim")]) realDir / bin.changeFileExt("nim")])
binariesBuilt.inc()
except NimbleError: except NimbleError:
let currentExc = (ref NimbleError)(getCurrentException()) let currentExc = (ref NimbleError)(getCurrentException())
let exc = newException(BuildFailed, "Build failed for package: " & let exc = newException(BuildFailed, "Build failed for package: " &
@ -261,6 +263,11 @@ proc buildFromDir(
exc.hint = hint exc.hint = hint
raise exc raise exc
if binariesBuilt == 0:
raiseNimbleError(
"No binaries built, did you specify a valid binary name?"
)
# Handle post-`build` hook. # Handle post-`build` hook.
cd realDir: # Make sure `execHook` executes the correct .nimble file. cd realDir: # Make sure `execHook` executes the correct .nimble file.
discard execHook(options, actionBuild, false) discard execHook(options, actionBuild, false)
@ -1084,7 +1091,7 @@ proc check(options: Options) =
proc run(options: Options) = proc run(options: Options) =
# Verify parameters. # Verify parameters.
let binary = options.getCompilationBinary().get() let binary = options.getCompilationBinary().get("")
if binary.len == 0: if binary.len == 0:
raiseNimbleError("Please specify a binary to run") raiseNimbleError("Please specify a binary to run")

View file

@ -85,8 +85,12 @@ Commands:
toplevel directory of the Nimble package. toplevel directory of the Nimble package.
uninstall [pkgname, ...] Uninstalls a list of packages. uninstall [pkgname, ...] Uninstalls a list of packages.
[-i, --inclDeps] Uninstall package and dependent package(s). [-i, --inclDeps] Uninstall package and dependent package(s).
build [opts, ...] Builds a package. build [opts, ...] [bin] Builds a package.
run [opts, ...] bin Builds and runs a package. run [opts, ...] bin Builds and runs a package.
A binary name needs
to be specified after any compilation options,
any flags after the binary name are passed to
the binary when it is run.
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.
test Compiles and executes tests test Compiles and executes tests