Skip to content

Commit 225f270

Browse files
authored
Make GTK dependency optional. (#1241)
1 parent 51f480c commit 225f270

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ You can find its changes [documented below](#060---2020-06-01).
8787
- Switch widget: Toggle animation being window refresh rate dependent ([#1145] by [@ForLoveOfCats])
8888
- Multi-click on Windows, partial fix for #859 ([#1157] by [@raphlinus])
8989
- Windows: fix crash on resize from incompatible resources ([#1191 by [@raphlinus]])
90+
- GTK: Related dependencies are now optional, facilitating a pure X11 build. ([#1241] by [@finnerale])
9091

9192
### Visual
9293

@@ -459,6 +460,7 @@ Last release without a changelog :(
459460
[#1231]: https://github.com/linebender/druid/pull/1231
460461
[#1220]: https://github.com/linebender/druid/pull/1220
461462
[#1238]: https://github.com/linebender/druid/pull/1238
463+
[#1241]: https://github.com/linebender/druid/pull/1241
462464

463465
[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
464466
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0

druid-shell/Cargo.toml

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ default-target = "x86_64-pc-windows-msvc"
1515

1616
[features]
1717
x11 = ["x11rb", "nix", "cairo-sys-rs"]
18+
gtk = ["gio", "gdk", "gdk-sys", "glib", "glib-sys", "gtk-sys", "gtk-rs"]
19+
default = ["gtk"]
1820

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

33-
# Optional dependencies
34-
cairo-rs = { version = "0.9.1", default_features = false, optional = true }
35-
cairo-sys-rs = { version = "0.10.0", default_features = false, optional = true }
36-
gio = { version = "0.9.1", optional = true }
37-
gdk = { version = "0.13.2", optional = true }
38-
gdk-sys = { version = "0.10.0", optional = true }
39-
gtk = { version = "0.9.2", optional = true }
40-
glib = { version = "0.10.1", optional = true }
41-
glib-sys = { version = "0.10.0", optional = true }
42-
gtk-sys = { version = "0.10.0", optional = true }
43-
nix = { version = "0.18.0", optional = true }
44-
x11rb = { version = "0.6.0", features = ["allow-unsafe-code", "present", "randr", "xfixes"], optional = true }
45-
4635
[target.'cfg(target_os="windows")'.dependencies]
4736
wio = "0.2.2"
4837

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

62-
# TODO(x11/dependencies): only use feature "xcb" if using X11
6352
[target.'cfg(target_os="linux")'.dependencies]
53+
# TODO(x11/dependencies): only use feature "xcb" if using X11
6454
cairo-rs = { version = "0.9.1", default_features = false, features = ["xcb"] }
65-
gio = "0.9.1"
66-
gdk = "0.13.2"
67-
gdk-sys = "0.10.0"
68-
glib = "0.10.1"
69-
glib-sys = "0.10.0"
70-
gtk-sys = "0.10.0"
71-
gtk = { version = "0.9.2", features = ["v3_22"] }
55+
cairo-sys-rs = { version = "0.10.0", default_features = false, optional = true }
56+
gio = { version = "0.9.1", optional = true }
57+
gdk = { version = "0.13.2", optional = true }
58+
gdk-sys = { version = "0.10.0", optional = true }
59+
# `gtk` gets renamed to `gtk-rs` so that we can use `gtk` as the feature name.
60+
gtk-rs = { version = "0.9.2", features = ["v3_22"], package = "gtk", optional = true }
61+
glib = { version = "0.10.1", optional = true }
62+
glib-sys = { version = "0.10.0", optional = true }
63+
gtk-sys = { version = "0.10.0", optional = true }
64+
nix = { version = "0.18.0", optional = true }
65+
x11rb = { version = "0.6.0", features = ["allow-unsafe-code", "present", "randr", "xfixes"], optional = true }
7266

7367
[target.'cfg(target_arch="wasm32")'.dependencies]
7468
wasm-bindgen = "0.2.67"

druid-shell/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#![allow(clippy::new_without_default)]
3131
#![deny(clippy::trivially_copy_pass_by_ref)]
3232

33+
// Rename `gtk_rs` back to `gtk`.
34+
// This allows us to use `gtk` as the feature name.
35+
// The `target_os` requirement is there to exclude anything `wasm` like.
36+
#[cfg(all(target_os = "linux", feature = "gtk"))]
37+
extern crate gtk_rs as gtk;
38+
3339
pub use kurbo;
3440
pub use piet_common as piet;
3541

druid/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ default-target = "x86_64-pc-windows-msvc"
2121

2222
[features]
2323
x11 = ["druid-shell/x11"]
24+
gtk = ["druid-shell/gtk"]
2425
svg = ["usvg", "harfbuzz-sys"]
26+
default = ["gtk"]
2527

2628
[dependencies]
27-
druid-shell = { version = "0.6.0", path = "../druid-shell" }
29+
druid-shell = { version = "0.6.0", default-features = false, path = "../druid-shell" }
2830
druid-derive = { version = "0.3.1", path = "../druid-derive" }
2931

3032
log = "0.4.11"

0 commit comments

Comments
 (0)