Skip to content

Commit

Permalink
Allow choosing tokio or async-std for ashpd (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith authored Jan 8, 2024
1 parent 94e3941 commit 79f1254
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Ubuntu XDG
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
flags: '--no-default-features --features xdg-portal'
flags: '--no-default-features --features xdg-portal,tokio'
- name: Windows
os: windows-latest
target: x86_64-pc-windows-msvc
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.13.0
- Users of the `xdg-portal` feature must now also select the `tokio`
or `async-std` feature

## 0.12.1
- Fix `FileHandle::inner` (under feature `file-handle-inner`) on wasm

Expand Down
108 changes: 107 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ default = ["gtk3"]
file-handle-inner = []
gtk3 = ["gtk-sys", "glib-sys", "gobject-sys"]
xdg-portal = ["ashpd", "urlencoding", "pollster"]
# Use async-std for xdg-portal
async-std = ["ashpd?/async-std"]
# Use tokio for xdg-portal
tokio = ["ashpd?/tokio"]
common-controls-v6 = ["windows-sys/Win32_UI_Controls"]

[dev-dependencies]
Expand Down Expand Up @@ -42,7 +46,7 @@ windows-sys = { version = "0.48", features = [

[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
# XDG Desktop Portal
ashpd = { version = "0.6", optional = true }
ashpd = { version = "0.6", optional = true, default-features = false }
urlencoding = { version = "2.1.0", optional = true }
pollster = { version = "0.3", optional = true }
# GTK
Expand Down
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ fn main() {
} else if !gtk && !xdg {
panic!("You need to choose at least one backend: `gtk3` or `xdg-portal` features");
}

if xdg {
let tokio = std::env::var_os("CARGO_FEATURE_TOKIO").is_some();
let async_std = std::env::var_os("CARGO_FEATURE_ASYNC_STD").is_some();
if !tokio && !async_std {
panic!("One of the `tokio` or `async-std` features must be enabled to use `xdg-portal`");
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//!
//! ## XDG Desktop Portal backend
//! The XDG Desktop Portal backend is used when the `gtk3` feature is disabled with
//! [`default-features = false`](https://doc.rust-lang.org/cargo/reference/features.html#dependency-features), and `xdg-portal` is enabled instead. This backend will use either the GTK or KDE file dialog depending on the desktop environment
//! [`default-features = false`](https://doc.rust-lang.org/cargo/reference/features.html#dependency-features), and `xdg-portal` is enabled instead. Either the `tokio` or `async-std` feature must be enabled. This backend will use either the GTK or KDE file dialog depending on the desktop environment
//! in use at runtime. It does not have any non-Rust
//! build dependencies, however it requires the user to have either the
//! [GTK](https://github.com/flatpak/xdg-desktop-portal-gtk),
Expand Down

0 comments on commit 79f1254

Please sign in to comment.