joshtriplett / metadeps

Run pkg-config from declarative dependencies in Cargo.toml
28 stars 29 forks source link

Consider new APIs to feed dependencies directly in build.rs #5

Closed nox closed 6 years ago

nox commented 6 years ago

I've thought a bit more about the toml bump and realised something: what's even the point of specifying the third-party dependencies in Cargo.toml? That crate should just expose APIs to specify the list of dependencies as code in build.rs directly.

E.g. instead of writing:

[package.metadata.pkg-config]
testlib = "1.2"
testdata = { version = "4.5", feature = "use-testdata" }

One should just do:

extern crate metadeps;

use metadeps::pkg_config;

fn main() {
    pkg_config("testlib", "1.2", None);
    pkg_config("testdata", "4.5", Some("use-testdata"));
}

This way one does not need any parser, and it's not like specifying them in a declarative way in Cargo.toml brings much to the table anyway.

joshtriplett commented 6 years ago

The point of this crate is to expose that metadata in a programmatically readable way, for use by more software than just the build script itself. That's the primary value metadeps adds over using pkg-config directly: declarative dependencies, easily readable and parseable out of Cargo.toml.

nox commented 6 years ago

Is there currently any other tool that make use of this data in Cargo.toml?