diff --git a/src/nimble.nim b/src/nimble.nim index 79f8768..27e4774 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -233,6 +233,7 @@ proc buildFromDir( var args = args let nimblePkgVersion = "-d:NimblePkgVersion=" & pkgInfo.version for path in paths: args.add("--path:\"" & path & "\" ") + var binariesBuilt = 0 for bin in pkgInfo.bin: # Check if this is the only binary that we want to build. if binToBuild.isSome() and binToBuild.get() != bin: @@ -252,6 +253,7 @@ proc buildFromDir( doCmd("\"" & getNimBin() & "\" $# --noNimblePath $# $# $# \"$#\"" % [pkgInfo.backend, nimblePkgVersion, join(args, " "), outputOpt, realDir / bin.changeFileExt("nim")]) + binariesBuilt.inc() except NimbleError: let currentExc = (ref NimbleError)(getCurrentException()) let exc = newException(BuildFailed, "Build failed for package: " & @@ -261,6 +263,11 @@ proc buildFromDir( exc.hint = hint raise exc + if binariesBuilt == 0: + raiseNimbleError( + "No binaries built, did you specify a valid binary name?" + ) + # Handle post-`build` hook. cd realDir: # Make sure `execHook` executes the correct .nimble file. discard execHook(options, actionBuild, false) @@ -1084,7 +1091,7 @@ proc check(options: Options) = proc run(options: Options) = # Verify parameters. - let binary = options.getCompilationBinary().get() + let binary = options.getCompilationBinary().get("") if binary.len == 0: raiseNimbleError("Please specify a binary to run") diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index 72f4a3a..a162a0f 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -85,8 +85,12 @@ Commands: toplevel directory of the Nimble package. uninstall [pkgname, ...] Uninstalls a list of packages. [-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. + 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 to the Nim compiler. test Compiles and executes tests