diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c474f92e6..3419d79ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/druid-shell/Cargo.toml b/druid-shell/Cargo.toml index e75ce1548f..9af3c8da6a 100644 --- a/druid-shell/Cargo.toml +++ b/druid-shell/Cargo.toml @@ -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 @@ -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" @@ -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" diff --git a/druid-shell/src/lib.rs b/druid-shell/src/lib.rs index f2fbd7fcc0..5d3b62425f 100644 --- a/druid-shell/src/lib.rs +++ b/druid-shell/src/lib.rs @@ -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; diff --git a/druid/Cargo.toml b/druid/Cargo.toml index 10d02dec9c..0989fed61e 100644 --- a/druid/Cargo.toml +++ b/druid/Cargo.toml @@ -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"