Use display for external deps and document this new feature.

This commit is contained in:
Dominik Picheta 2017-01-03 16:56:44 +00:00
commit 1c982a7e5f
3 changed files with 51 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import ospaths, distros import ospaths
template thisModuleFile: string = instantiationInfo(fullPaths = true).filename template thisModuleFile: string = instantiationInfo(fullPaths = true).filename
when fileExists(thisModuleFile.parentDir / "src/nimblepkg/common.nim"): when fileExists(thisModuleFile.parentDir / "src/nimblepkg/common.nim"):
@ -22,10 +22,12 @@ srcDir = "src"
requires "nim >= 0.13.0", "compiler#head" requires "nim >= 0.13.0", "compiler#head"
if detectOs(Ubuntu): when defined(nimdistros):
foreignDep "libssl-dev" import distros
elif detectOs(MacOSX): if detectOs(Ubuntu):
foreignDep "openssl" foreignDep "libssl-dev"
else:
foreignDep "openssl"
task test, "Run the Nimble tester!": task test, "Run the Nimble tester!":
withDir "tests": withDir "tests":

View file

@ -31,6 +31,7 @@ Interested in learning **how to create a package**? Skip directly to that sectio
- [Binary packages](#binary-packages) - [Binary packages](#binary-packages)
- [Hybrids](#hybrids) - [Hybrids](#hybrids)
- [Dependencies](#dependencies) - [Dependencies](#dependencies)
- [External dependencies](#external-dependencies)
- [Nim compiler](#nim-compiler) - [Nim compiler](#nim-compiler)
- [Versions](#versions) - [Versions](#versions)
- [Releasing a new version](#releasing-a-new-version) - [Releasing a new version](#releasing-a-new-version)
@ -575,6 +576,44 @@ This is done with the ``#`` character,
for example: ``jester#head``. Which will make your package depend on the for example: ``jester#head``. Which will make your package depend on the
latest commit of Jester. latest commit of Jester.
#### External dependencies
**Warning:** This feature is brand new in Nimble v0.8.0. Breaking changes
related to it are more likely to be introduced than for any other Nimble
features.
Starting with Nimble v0.8.0, you can now specify external dependencies. These
are dependencies which are not managed by Nimble and can only be installed via
your system's package manager or downloaded manually via the internet.
As an example, to specify a dependency on openssl you may put this in your
.nimble file:
```nim
when defined(nimdistros):
import distros
if detectOs(Ubuntu):
foreignDep "libssl-dev"
else:
foreignDep "openssl"
```
The ``when`` branch is important to support installation using older versions
of Nimble.
The [distros module](nim-lang.org/docs/distros.html) in Nim's
standard library contains a list of all the supported Operating Systems and
Linux distributions.
With this inside your .nimble file, Nimble will output the following after
installing your package (on macOS):
```
Hint: This package requires some external dependencies.
Hint: To install them you may be able to run:
Hint: sudo brew install openssl
```
### Nim compiler ### Nim compiler
The Nim compiler cannot read .nimble files. Its knowledge of Nimble is The Nim compiler cannot read .nimble files. Its knowledge of Nimble is

View file

@ -995,9 +995,12 @@ proc doAction(options: Options) =
if options.action.packages.len == 0: if options.action.packages.len == 0:
nimScriptHint(pkgInfo) nimScriptHint(pkgInfo)
if pkgInfo.foreignDeps.len > 0: if pkgInfo.foreignDeps.len > 0:
echo("To finish the installation, run: ") display("Hint:", "This package requires some external dependencies.",
Warning, HighPriority)
display("Hint:", "To install them you may be able to run:",
Warning, HighPriority)
for i in 0..<pkgInfo.foreignDeps.len: for i in 0..<pkgInfo.foreignDeps.len:
echo(pkgInfo.foreignDeps[i]) display("Hint:", " " & pkgInfo.foreignDeps[i], Warning, HighPriority)
of actionUninstall: of actionUninstall:
uninstall(options) uninstall(options)
of actionSearch: of actionSearch: