Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GTK dependency optional. #1241

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ You can find its changes [documented below](#060---2020-06-01).
- Switch widget: Toggle animation being window refresh rate dependent ([#1145] by [@ForLoveOfCats])
- Multi-click on Windows, partial fix for #859 ([#1157] by [@raphlinus])
- Windows: fix crash on resize from incompatible resources ([#1191 by [@raphlinus]])
- GTK: Related dependencies are now optional, facilitating a pure X11 build. ([#1241] by [@finnerale])

### Visual

Expand Down Expand Up @@ -459,6 +460,7 @@ Last release without a changelog :(
[#1231]: https://github.com/linebender/druid/pull/1231
[#1220]: https://github.com/linebender/druid/pull/1220
[#1238]: https://github.com/linebender/druid/pull/1238
[#1241]: https://github.com/linebender/druid/pull/1241

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
36 changes: 15 additions & 21 deletions druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ default-target = "x86_64-pc-windows-msvc"

[features]
x11 = ["x11rb", "nix", "cairo-sys-rs"]
gtk = ["gio", "gdk", "gdk-sys", "glib", "glib-sys", "gtk-sys", "gtk-rs"]
default = ["gtk"]

[dependencies]
# NOTE: When changing the piet or kurbo versions, ensure that
Expand All @@ -30,19 +32,6 @@ instant = { version = "0.1.6", features = ["wasm-bindgen"] }
anyhow = "1.0.32"
keyboard-types = { version = "0.5.0", default_features = false }

# Optional dependencies
cairo-rs = { version = "0.9.1", default_features = false, optional = true }
cairo-sys-rs = { version = "0.10.0", default_features = false, optional = true }
gio = { version = "0.9.1", optional = true }
gdk = { version = "0.13.2", optional = true }
gdk-sys = { version = "0.10.0", optional = true }
gtk = { version = "0.9.2", optional = true }
glib = { version = "0.10.1", optional = true }
glib-sys = { version = "0.10.0", optional = true }
gtk-sys = { version = "0.10.0", optional = true }
nix = { version = "0.18.0", optional = true }
x11rb = { version = "0.6.0", features = ["allow-unsafe-code", "present", "randr", "xfixes"], optional = true }

[target.'cfg(target_os="windows")'.dependencies]
wio = "0.2.2"

Expand All @@ -58,17 +47,22 @@ objc = "0.2.7"
core-graphics = "0.22.0"
foreign-types = "0.3.2"
bitflags = "1.2.1"
cairo-rs = { version = "0.9.1", default_features = false, optional = true }

# TODO(x11/dependencies): only use feature "xcb" if using X11
[target.'cfg(target_os="linux")'.dependencies]
# TODO(x11/dependencies): only use feature "xcb" if using X11
cairo-rs = { version = "0.9.1", default_features = false, features = ["xcb"] }
gio = "0.9.1"
gdk = "0.13.2"
gdk-sys = "0.10.0"
glib = "0.10.1"
glib-sys = "0.10.0"
gtk-sys = "0.10.0"
gtk = { version = "0.9.2", features = ["v3_22"] }
cairo-sys-rs = { version = "0.10.0", default_features = false, optional = true }
gio = { version = "0.9.1", optional = true }
gdk = { version = "0.13.2", optional = true }
gdk-sys = { version = "0.10.0", optional = true }
# `gtk` gets renamed to `gtk-rs` so that we can use `gtk` as the feature name.
gtk-rs = { version = "0.9.2", features = ["v3_22"], package = "gtk", optional = true }
glib = { version = "0.10.1", optional = true }
glib-sys = { version = "0.10.0", optional = true }
gtk-sys = { version = "0.10.0", optional = true }
nix = { version = "0.18.0", optional = true }
x11rb = { version = "0.6.0", features = ["allow-unsafe-code", "present", "randr", "xfixes"], optional = true }

[target.'cfg(target_arch="wasm32")'.dependencies]
wasm-bindgen = "0.2.67"
Expand Down
6 changes: 6 additions & 0 deletions druid-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#![allow(clippy::new_without_default)]
#![deny(clippy::trivially_copy_pass_by_ref)]

// Rename `gtk_rs` back to `gtk`.
// This allows us to use `gtk` as the feature name.
// The `target_os` requirement is there to exclude anything `wasm` like.
#[cfg(all(target_os = "linux", feature = "gtk"))]
extern crate gtk_rs as gtk;

pub use kurbo;
pub use piet_common as piet;

Expand Down
4 changes: 3 additions & 1 deletion druid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ default-target = "x86_64-pc-windows-msvc"

[features]
x11 = ["druid-shell/x11"]
gtk = ["druid-shell/gtk"]
svg = ["usvg", "harfbuzz-sys"]
default = ["gtk"]

[dependencies]
druid-shell = { version = "0.6.0", path = "../druid-shell" }
druid-shell = { version = "0.6.0", default-features = false, path = "../druid-shell" }
druid-derive = { version = "0.3.1", path = "../druid-derive" }

log = "0.4.11"
Expand Down