system-deps
lets you write system dependencies in Cargo.toml
metadata,
rather than programmatically in build.rs
. This makes those dependencies
declarative, so other tools can read them as well.
For now only pkg-config
dependencies are supported but we are planning to
expand it at some point.
system-deps
has been started as a fork of the
metadeps project.
Usage
In your Cargo.toml
, add the following to your [build-dependencies]
:
= "1.1"
Then, to declare a dependency on testlib >= 1.2
, a conditional dependency
on testdata >= 4.5
and a dependency on glib-2.0 >= 2.64
add the following section:
[]
= "1.2"
= { = "4.5", = "use-testdata" }
= { = "glib-2.0", = "2.64" }
In your build.rs
, add:
Dependency versions can also be controlled using features:
[]
= []
= ["v1_4"]
[]
= { = "gstreamer-1.0", = "1.0", = { = "1.2", = "1.4" }}
In this case the highest version among enabled features will be used.