Skip to content

Commit 2b6ce33

Browse files
committed
move to default whitelisting of unix family, instead of breaking compilation for unsupported os
1 parent 0558cd8 commit 2b6ce33

File tree

2 files changed

+38
-43
lines changed

2 files changed

+38
-43
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ if webbrowser::open("http://github.com").is_ok() {
3636
|----------|-----------|----------|-------------|
3737
| macos || default + [others](https://docs.rs/webbrowser/latest/webbrowser/enum.Browser.html) ||
3838
| windows || default only ||
39-
| linux/wsl/*bsd || default only (respects $BROWSER env var, so can be used with other browsers) ||
39+
| linux/wsl | | default only (respects $BROWSER env var, so can be used with other browsers) ||
4040
| android || default only ||
4141
| ios || default only ||
4242
| wasm || default only ||
43-
| haiku | ✅ (experimental) | default only ||
44-
| aix | ✅ (experimental) | default only ||
45-
| illumos | ✅ (experimental) | default only ||
43+
| unix (*bsd, aix etc.) || default only (respects $BROWSER env var, so can be used with other browsers) | Manual |
4644

4745
## Consistent Behaviour
4846
`webbrowser` defines consistent behaviour on all platforms as follows:

src/lib.rs

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
//! |----------|-----------|----------|-------------|
1919
//! | macos | ✅ | default + [others](https://docs.rs/webbrowser/latest/webbrowser/enum.Browser.html) | ✅ |
2020
//! | windows | ✅ | default only | ✅ |
21-
//! | linux/wsl/*bsd | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | ✅ |
21+
//! | linux/wsl | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | ✅ |
2222
//! | android | ✅ | default only | ✅ |
2323
//! | ios | ✅ | default only | ✅ |
2424
//! | wasm | ✅ | default only | ✅ |
25-
//! | haiku | ✅ (experimental) | default only | ❌ |
26-
//! | aix | ✅ (experimental) | default only | ❌ |
27-
//! | illumos | ✅ (experimental) | default only | ❌ |
25+
//! | unix (*bsd, aix etc.) | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | Manual |
2826
//!
2927
//! ## Consistent Behaviour
3028
//! `webbrowser` defines consistent behaviour on all platforms as follows:
@@ -47,46 +45,33 @@
4745
#[cfg_attr(target_family = "wasm", path = "wasm.rs")]
4846
#[cfg_attr(windows, path = "windows.rs")]
4947
#[cfg_attr(
50-
any(
51-
target_os = "aix",
52-
target_os = "linux",
53-
target_os = "freebsd",
54-
target_os = "netbsd",
55-
target_os = "openbsd",
56-
target_os = "haiku",
57-
target_os = "illumos"
48+
all(
49+
unix,
50+
not(any(
51+
target_os = "ios",
52+
target_os = "tvos",
53+
target_os = "macos",
54+
target_os = "android",
55+
target_family = "wasm",
56+
windows,
57+
)),
5858
),
5959
path = "unix.rs"
6060
)]
6161
mod os;
6262

63-
#[cfg(not(any(
64-
target_os = "aix",
65-
target_os = "android",
66-
target_os = "windows",
67-
target_os = "macos",
68-
target_os = "linux",
69-
target_os = "freebsd",
70-
target_os = "netbsd",
71-
target_os = "openbsd",
72-
target_os = "haiku",
73-
target_os = "illumos",
74-
target_os = "ios",
75-
target_arch = "wasm32"
76-
)))]
77-
compile_error!(
78-
"Only Windows, Mac OS, iOS, Linux, *BSD, Haiku, AIX, illumos and Wasm32 are currently supported"
79-
);
80-
8163
#[cfg(any(
82-
target_os = "aix",
83-
target_os = "linux",
84-
target_os = "freebsd",
85-
target_os = "netbsd",
86-
target_os = "openbsd",
87-
target_os = "haiku",
88-
target_os = "illumos",
89-
target_os = "windows"
64+
windows,
65+
all(
66+
unix,
67+
not(any(
68+
target_os = "ios",
69+
target_os = "tvos",
70+
target_os = "macos",
71+
target_os = "android",
72+
target_family = "wasm",
73+
)),
74+
),
9075
))]
9176
pub(crate) mod common;
9277

@@ -328,7 +313,19 @@ pub fn open_browser_with_options(
328313
));
329314
}
330315

331-
os::open_browser_internal(browser, &target, options)
316+
if cfg!(any(
317+
target_os = "ios",
318+
target_os = "tvos",
319+
target_os = "macos",
320+
target_os = "android",
321+
target_family = "wasm",
322+
windows,
323+
unix,
324+
)) {
325+
os::open_browser_internal(browser, &target, options)
326+
} else {
327+
Err(Error::new(ErrorKind::NotFound, "unsupported platform"))
328+
}
332329
}
333330

334331
/// The link we're trying to open, represented as a URL. Local files get represented

0 commit comments

Comments
 (0)