Skip to content

Commit

Permalink
Enabled Vita without cfg in RUSTFLAGS and added CI checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Oct 18, 2023
1 parent 099c9c8 commit 792acdd
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 29 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ jobs:
run: cargo install --debug cargo-hack
- name: Check all targets
run: make check_all_targets
CheckTier3Targets:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target: ["armv7-sony-vita-newlibeabihf"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- uses: taiki-e/install-action@cargo-hack
- name: Run check
run: cargo hack check -Z build-std=std,panic_abort --feature-powerset --target ${{ matrix.target }}
Sanitizer:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -160,5 +176,6 @@ jobs:
- Docs
- Rustfmt
- CheckTargets
- CheckTier3Targets
steps:
- run: exit 0
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ net = []

[dependencies]
log = { version = "0.4.8", optional = true }
vitasdk-sys = {version = "0.3.2", features = ["SceNet_stub"]}

[target.'cfg(unix)'.dependencies]
libc = "0.2.149"
Expand All @@ -65,6 +66,7 @@ libc = "0.2.149"
[dev-dependencies]
env_logger = { version = "0.9.3", default-features = false }
rand = "0.8"
vita-newlib-shims = { path = "/home/nikarh/workspace/games/vita/vita-rust/vita-newlib-shims" }

[package.metadata.docs.rs]
all-features = true
Expand Down
9 changes: 5 additions & 4 deletions src/poll.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
use std::os::unix::io::{AsRawFd, RawFd};
#[cfg(all(debug_assertions, not(target_os = "wasi")))]
use std::sync::atomic::{AtomicBool, Ordering};
Expand Down Expand Up @@ -423,7 +423,7 @@ impl Poll {
}
}

#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
impl AsRawFd for Poll {
fn as_raw_fd(&self) -> RawFd {
self.registry.as_raw_fd()
Expand Down Expand Up @@ -710,7 +710,7 @@ impl fmt::Debug for Registry {
}
}

#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
impl AsRawFd for Registry {
fn as_raw_fd(&self) -> RawFd {
self.selector.as_raw_fd()
Expand All @@ -720,7 +720,8 @@ impl AsRawFd for Registry {
cfg_os_poll! {
#[cfg(all(
unix,
not(mio_unsupported_force_poll_poll)
not(mio_unsupported_force_poll_poll),
not(target_os = "vita"),
))]
#[test]
pub fn as_raw_fd() {
Expand Down
6 changes: 3 additions & 3 deletions src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cfg_os_poll! {

cfg_io_source! {
// Both `kqueue` and `epoll` don't need to hold any user space state.
#[cfg(not(mio_unsupported_force_poll_poll))]
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "vita")))]
mod stateless_io_source {
use std::io;
use std::os::unix::io::RawFd;
Expand Down Expand Up @@ -87,10 +87,10 @@ cfg_os_poll! {
}
}

#[cfg(not(mio_unsupported_force_poll_poll))]
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "vita")))]
pub(crate) use self::stateless_io_source::IoSourceState;

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
pub(crate) use self::selector::IoSourceState;
}

Expand Down
4 changes: 2 additions & 2 deletions src/sys/unix/selector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ mod epoll;
))]
pub(crate) use self::epoll::{event, Event, Events, Selector};

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
mod poll;

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
pub(crate) use self::poll::{event, Event, Events, IoSourceState, Selector};

#[cfg(all(
Expand Down
39 changes: 22 additions & 17 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
target_os = "tvos",
target_os = "watchos",
)
))
)),
not(target_os = "vita"),
))]
mod fdbased {
#[cfg(all(
Expand Down Expand Up @@ -61,7 +62,8 @@ mod fdbased {
target_os = "tvos",
target_os = "watchos",
)
))
)),
not(target_os = "vita"),
))]
pub use self::fdbased::Waker;

Expand Down Expand Up @@ -205,6 +207,7 @@ pub use self::kqueue::Waker;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
))]
mod pipe {
use crate::sys::unix::pipe;
Expand Down Expand Up @@ -250,7 +253,7 @@ mod pipe {
}
}

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
pub fn ack_and_reset(&self) {
self.empty();
}
Expand All @@ -275,22 +278,24 @@ mod pipe {
}
}

#[cfg(all(
mio_unsupported_force_poll_poll,
any(
mio_unsupported_force_waker_pipe,
target_os = "aix",
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
)
#[cfg(any(
all(
mio_unsupported_force_poll_poll,
any(
mio_unsupported_force_waker_pipe,
target_os = "aix",
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
)
),
target_os = "vita",
))]
pub(crate) use self::pipe::WakerInternal;

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
mod poll {
use crate::sys::Selector;
use crate::Token;
Expand All @@ -316,5 +321,5 @@ mod poll {
}
}

#[cfg(mio_unsupported_force_poll_poll)]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
pub use self::poll::Waker;
6 changes: 3 additions & 3 deletions tests/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn connect() {
fn read() {
init();

const N: usize = 16 * 1024 * 1024;
const N: usize = 16 * 1024;
struct Data {
amt: usize,
socket: TcpStream,
Expand Down Expand Up @@ -225,7 +225,7 @@ fn read() {
fn peek() {
init();

const N: usize = 16 * 1024 * 1024;
const N: usize = 16 * 1024;
struct Data {
amt: usize,
socket: TcpStream,
Expand Down Expand Up @@ -290,7 +290,7 @@ fn peek() {
fn write() {
init();

const N: usize = 16 * 1024 * 1024;
const N: usize = 16 * 1024;
struct Data {
amt: usize,
socket: TcpStream,
Expand Down
6 changes: 6 additions & 0 deletions tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,18 @@ pub fn temp_file(name: &'static str) -> PathBuf {
}

/// Returns the temporary directory for Mio test files.
#[cfg(not(target_os = "vita"))]
fn temp_dir() -> PathBuf {
let mut path = env::temp_dir();
path.push("mio_tests");
path
}

#[cfg(target_os = "vita")]
fn temp_dir() -> PathBuf {
PathBuf::from("ux0:/data/.tmp")
}

/// A checked {write, send, send_to} macro that ensures the entire buffer is
/// written.
///
Expand Down

0 comments on commit 792acdd

Please sign in to comment.