gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

gdk_backend config flags #995

Closed kinnison closed 4 years ago

kinnison commented 4 years ago

This is a proposed approach for better handling of targets. The pkg-config file defines a targets variable which is whitespace separated. This PR consumes that in build.rs and sets target="x11" and friends as config values.

To demonstrate its use, this then switches gtk::Plug and gtk::Socket to be predicated on target="x11" rather than all(not(windows), not(target_os = "macos"))

@sdroege What do you think of this as an approach? If considered good, it should probably be spread to gtk-sys and possibly other crates.

sdroege commented 4 years ago

Looks like a good solution to me, only makes it more confusing for users if they want to use the API but it does not exist because of their GTK version. With a feature flag we could print some more useful error if the user tries to enable it but it does not exist.

kinnison commented 4 years ago

I've changed the config to gdk_backend="x11" and friends, since that seems more descriptive. I've also added explanatory notes in build.rs

EPashkin commented 4 years ago

Is there no way to add it to gdk-sys?

kinnison commented 4 years ago

@EPashkin Yes, the same work ought to work for gdk-sys if you want to use the capability there for any reason.

EPashkin commented 4 years ago

I want detect flags in gdk-sys and use it here

kinnison commented 4 years ago

@EPashkin Aaah, right, to my knowledge it's not possible for crates to acquire configuration flags from their dependencies. If you know of a way to do this, I'm happy to rework it.

EPashkin commented 4 years ago

I thought about something like "DEP_GDK_BACKEND" from https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key It should works if gtk depends of gdk-sys directly and need "build.rs" in "gtk" too.

kinnison commented 4 years ago

Oh that's interesting, I shall look at doing that because yes, that makes a lot of sense. I think gdk-sys should compute them gtk-sys should propagate them, and gtk can then consume them. Hmm...

kinnison commented 4 years ago

I've pushed the first part of that new variant here - https://github.com/gtk-rs/sys/pull/167 Once that merges, I'll pop a PR up for replacing this calculating with inheriting it from gtk-sys