Skip to content

Commit 5e13001

Browse files
authored
Add support for visionos, watchos, and tvos. (#386)
This patch just adds these `target_os` values to all places that use `target_os = "ios"`.
1 parent 9a7e1be commit 5e13001

File tree

12 files changed

+134
-18
lines changed

12 files changed

+134
-18
lines changed

cap-net-ext/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ fn socket_flags(blocking: Blocking) -> rustix::net::SocketFlags {
655655
target_os = "ios",
656656
target_os = "tvos",
657657
target_os = "watchos",
658+
target_os = "visionos",
658659
target_os = "haiku"
659660
)))]
660661
{
@@ -668,6 +669,7 @@ fn socket_flags(blocking: Blocking) -> rustix::net::SocketFlags {
668669
target_os = "ios",
669670
target_os = "tvos",
670671
target_os = "watchos",
672+
target_os = "visionos",
671673
target_os = "haiku"
672674
)))]
673675
match blocking {
@@ -688,7 +690,8 @@ fn set_socket_flags(fd: &OwnedFd, blocking: Blocking) -> io::Result<()> {
688690
target_os = "macos",
689691
target_os = "ios",
690692
target_os = "tvos",
691-
target_os = "watchos"
693+
target_os = "watchos",
694+
target_os = "visionos",
692695
))]
693696
{
694697
rustix::io::ioctl_fioclex(fd)?;
@@ -699,7 +702,8 @@ fn set_socket_flags(fd: &OwnedFd, blocking: Blocking) -> io::Result<()> {
699702
target_os = "macos",
700703
target_os = "ios",
701704
target_os = "tvos",
702-
target_os = "watchos"
705+
target_os = "watchos",
706+
target_os = "visionos"
703707
))]
704708
match blocking {
705709
Blocking::Yes => (),

cap-primitives/src/rustix/fs/copy_impl.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
use crate::fs::{open, OpenOptions};
66
#[cfg(any(target_os = "android", target_os = "linux"))]
77
use rustix::fs::copy_file_range;
8-
#[cfg(any(target_os = "macos", target_os = "ios"))]
8+
#[cfg(any(
9+
target_os = "macos",
10+
target_os = "ios",
11+
target_os = "tvos",
12+
target_os = "watchos",
13+
target_os = "visionos",
14+
))]
915
use rustix::fs::{
1016
copyfile_state_alloc, copyfile_state_free, copyfile_state_get_copied, copyfile_state_t,
1117
fclonefileat, fcopyfile, CloneFlags, CopyfileFlags,
@@ -78,7 +84,10 @@ fn open_to_and_set_permissions(
7884
target_os = "linux",
7985
target_os = "android",
8086
target_os = "macos",
81-
target_os = "ios"
87+
target_os = "ios",
88+
target_os = "tvos",
89+
target_os = "watchos",
90+
target_os = "visionos",
8291
)))]
8392
pub(crate) fn copy_impl(
8493
from_start: &fs::File,
@@ -159,7 +168,13 @@ pub(crate) fn copy_impl(
159168
Ok(written)
160169
}
161170

162-
#[cfg(any(target_os = "macos", target_os = "ios"))]
171+
#[cfg(any(
172+
target_os = "macos",
173+
target_os = "ios",
174+
target_os = "tvos",
175+
target_os = "watchos",
176+
target_os = "visionos",
177+
))]
163178
#[allow(non_upper_case_globals)]
164179
#[allow(unsafe_code)]
165180
pub(crate) fn copy_impl(

cap-primitives/src/rustix/fs/dir_utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ pub(crate) const fn target_o_path() -> OFlags {
140140
target_os = "dragonfly",
141141
target_os = "ios",
142142
target_os = "macos",
143+
target_os = "tvos",
144+
target_os = "watchos",
145+
target_os = "visionos",
143146
target_os = "netbsd",
144147
target_os = "openbsd",
145148
target_os = "wasi",

cap-primitives/src/rustix/fs/metadata_ext.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ impl ImplMetadataExt {
144144
target_os = "freebsd",
145145
target_os = "openbsd",
146146
target_os = "macos",
147-
target_os = "ios"
147+
target_os = "ios",
148+
target_os = "tvos",
149+
target_os = "watchos",
150+
target_os = "visionos",
148151
))]
149152
created: system_time_from_rustix(
150153
stat.st_birthtime.try_into().unwrap(),
@@ -163,6 +166,9 @@ impl ImplMetadataExt {
163166
target_os = "openbsd",
164167
target_os = "macos",
165168
target_os = "ios",
169+
target_os = "tvos",
170+
target_os = "watchos",
171+
target_os = "visionos",
166172
target_os = "netbsd"
167173
)))]
168174
created: None,

cap-primitives/src/rustix/fs/mod.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ pub(crate) mod errors;
4242
//
4343
// On FreeBSD, use optimized implementations based on
4444
// `O_RESOLVE_BENEATH`/`AT_RESOLVE_BENEATH` and `O_PATH` when available.
45-
#[cfg(any(target_os = "macos", target_os = "ios"))]
45+
#[cfg(any(
46+
target_os = "macos",
47+
target_os = "ios",
48+
target_os = "tvos",
49+
target_os = "watchos",
50+
target_os = "visionos",
51+
))]
4652
pub(crate) use crate::rustix::darwin::fs::*;
4753
#[cfg(target_os = "freebsd")]
4854
pub(crate) use crate::rustix::freebsd::fs::*;
@@ -57,13 +63,22 @@ pub(crate) use crate::fs::{
5763
manually::canonicalize as canonicalize_impl,
5864
via_parent::set_times_nofollow as set_times_nofollow_impl,
5965
};
60-
#[cfg(any(target_os = "macos", target_os = "ios"))]
66+
#[cfg(any(
67+
target_os = "macos",
68+
target_os = "ios",
69+
target_os = "tvos",
70+
target_os = "watchos",
71+
target_os = "visionos",
72+
))]
6173
pub(super) use file_path::file_path_by_ttyname_or_seaching;
6274
#[cfg(not(any(
6375
target_os = "android",
6476
target_os = "linux",
6577
target_os = "macos",
66-
target_os = "ios"
78+
target_os = "ios",
79+
target_os = "tvos",
80+
target_os = "watchos",
81+
target_os = "visionos",
6782
)))]
6883
pub(crate) use file_path::file_path_by_ttyname_or_seaching as file_path;
6984
#[cfg(not(any(

cap-primitives/src/rustix/fs/oflags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub(in super::super) fn compute_oflags(options: &OpenOptions) -> io::Result<OFla
2727
#[cfg(not(any(
2828
target_os = "ios",
2929
target_os = "macos",
30+
target_os = "tvos",
31+
target_os = "watchos",
32+
target_os = "visionos",
3033
target_os = "freebsd",
3134
target_os = "fuchsia"
3235
)))]

cap-primitives/src/rustix/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
44
pub(crate) mod fs;
55

6-
#[cfg(any(target_os = "macos", target_os = "ios"))]
6+
#[cfg(any(
7+
target_os = "macos",
8+
target_os = "ios",
9+
target_os = "tvos",
10+
target_os = "watchos",
11+
target_os = "visionos",
12+
))]
713
mod darwin;
814
#[cfg(target_os = "freebsd")]
915
mod freebsd;

tests/fs.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,16 @@ fn file_test_io_read_write_at() {
340340
// following symlinks.
341341
#[test]
342342
#[cfg(unix)]
343-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), ignore)]
343+
#[cfg_attr(
344+
any(
345+
target_os = "macos",
346+
target_os = "ios",
347+
target_os = "tvos",
348+
target_os = "watchos",
349+
target_os = "visionos",
350+
),
351+
ignore
352+
)]
344353
fn set_get_unix_permissions() {
345354
use cap_std::fs::PermissionsExt;
346355

tests/fs_additional.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,16 @@ fn file_with_trailing_slashdot_ambient() {
571571
assert!(Dir::open_ambient_dir(dir.path().join("file/..."), ambient_authority()).is_err());
572572
}
573573

574-
#[cfg(all(unix, not(any(target_os = "ios", target_os = "macos"))))]
574+
#[cfg(all(
575+
unix,
576+
not(any(
577+
target_os = "ios",
578+
target_os = "macos",
579+
target_os = "tvos",
580+
target_os = "watchos",
581+
target_os = "visionos",
582+
))
583+
))]
575584
#[test]
576585
fn dir_searchable_unreadable() {
577586
use cap_std::fs::{DirBuilder, DirBuilderExt};
@@ -593,7 +602,16 @@ fn dir_searchable_unreadable() {
593602
/// This test is the same as `dir_searchable_unreadable` but uses `std::fs`'
594603
/// ambient API instead of `cap_std`. The purpose of this test is to
595604
/// confirm fundamentally OS-specific differences.
596-
#[cfg(all(unix, not(any(target_os = "ios", target_os = "macos"))))]
605+
#[cfg(all(
606+
unix,
607+
not(any(
608+
target_os = "ios",
609+
target_os = "macos",
610+
target_os = "tvos",
611+
target_os = "watchos",
612+
target_os = "visionos",
613+
))
614+
))]
597615
#[test]
598616
fn dir_searchable_unreadable_ambient() {
599617
use std::fs;
@@ -615,7 +633,13 @@ fn dir_searchable_unreadable_ambient() {
615633

616634
/// On Darwin, we don't have a race-free way to create a subdirectory within
617635
/// a directory that we don't have read access to.
618-
#[cfg(any(target_os = "ios", target_os = "macos"))]
636+
#[cfg(any(
637+
target_os = "ios",
638+
target_os = "macos",
639+
target_os = "tvos",
640+
target_os = "watchos",
641+
target_os = "visionos",
642+
))]
619643
#[test]
620644
fn dir_searchable_unreadable() {
621645
use cap_std::fs::{DirBuilder, DirBuilderExt};

tests/fs_utf8.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,16 @@ fn file_test_io_read_write_at() {
341341
// following symlinks.
342342
#[test]
343343
#[cfg(unix)]
344-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), ignore)]
344+
#[cfg_attr(
345+
any(
346+
target_os = "macos",
347+
target_os = "ios",
348+
target_os = "tvos",
349+
target_os = "watchos",
350+
target_os = "visionos",
351+
),
352+
ignore
353+
)]
345354
fn set_get_unix_permissions() {
346355
use cap_std::fs::PermissionsExt;
347356

0 commit comments

Comments
 (0)