gdesmott / system-deps

Run pkg-config from declarative dependencies in Cargo.toml
Apache License 2.0
89 stars 21 forks source link

Support target specific dependencies #33

Closed svenfoo closed 3 years ago

svenfoo commented 3 years ago

At librsvg we have a dependency on pangoft2 and fontconfig, but not if you are building for Windows. I'd like to be able to express such a target-specific dependency using system_deps. Is that already possible, is such a feature planned?

gdesmott commented 3 years ago

This is currently not supported, no.

I'm open to adding specific API for this but I don't have any experience on any other platform than Linux so may need some help to design it. I know about #[cfg(target_os = "linux")] for conditionally build blocks but I don't think that would do here. Is there any API we could use to fetch the platform info at runtime?

gdesmott commented 3 years ago

We could use std::env::consts::OS.

@svenfoo would something like this fit your use case?

[package.metadata.system-deps]
testdata = { version = "1", os = "linux" }
testlib = { version = "1", os = "macos" }
testmore = { version = "1", os = ["linux", "macos"] }

Or do you also need a way to enable a dep if the OS is not a specific one?

gdesmott commented 3 years ago

I implemented the syntax above in #34 , can you please give it a try and check if that fits your needs?

svenfoo commented 3 years ago

Sorry for ignoring you. The syntax looks useful, but I think it would help to also have the negation.

I will give the change a try on the weekend and get back to you.

gdesmott commented 3 years ago

Negation is now implemented, see https://github.com/gdesmott/system-deps/pull/34#issuecomment-800162607