Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,35 @@ feat_Tier1 = [
# It is bit complex to deduplicate with other lists
feat_wasm = [
"arch",
"basename",
"base32",
"base64",
"basenc",
"basename",
"cat",
"comm",
"cp",
"csplit",
"cut",
"date",
"dir",
"dircolors",
"dirname",
"echo",
"expand",
"expr",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our CI does not have C toolchain to build onig.

"factor",
"false",
"fmt",
"fold",
"head",
"join",
"link",
"ln",
"ls",
"mkdir",
"mv",
"nl",
"nproc",
"numfmt",
"od",
"paste",
Expand All @@ -206,18 +218,29 @@ feat_wasm = [
"printf",
"ptx",
"pwd",
"readlink",
"realpath",
"rm",
"rmdir",
"seq",
"sort",
"split",
"shred",
"shuf",
"sleep",
"sum",
"tail",
"tee",
"touch",
"tr",
"true",
"truncate",
"tsort",
"uname",
"unexpand",
"uniq",
"unlink",
"vdir",
"wc",
"yes",
# cksum family
Expand Down
6 changes: 6 additions & 0 deletions src/uu/cat/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ pub use self::unix::is_unsafe_overwrite;
#[cfg(windows)]
pub use self::windows::is_unsafe_overwrite;

// WASI: no fstat-based device/inode checks available; assume safe.
#[cfg(target_os = "wasi")]
pub fn is_unsafe_overwrite<I, O>(_input: &I, _output: &O) -> bool {
false
}

#[cfg(unix)]
mod unix;

Expand Down
7 changes: 7 additions & 0 deletions src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ use thiserror::Error;
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::{symlink_dir, symlink_file};
#[cfg(target_os = "wasi")]
fn symlink<P1: AsRef<Path>, P2: AsRef<Path>>(_src: P1, _dst: P2) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
"symlinks not supported on this platform",
))
}
use std::path::{Path, PathBuf};
use uucore::backup_control::{self, BackupMode};
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
Expand Down
28 changes: 28 additions & 0 deletions src/uu/split/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@ pub use self::windows::instantiate_current_writer;
#[cfg(windows)]
pub use self::windows::paths_refer_to_same_file;

// WASI: no process spawning (filter) or device/inode comparison.
#[cfg(target_os = "wasi")]
pub fn paths_refer_to_same_file(_p1: &std::ffi::OsStr, _p2: &std::ffi::OsStr) -> bool {
false
}

#[cfg(target_os = "wasi")]
pub fn instantiate_current_writer(
_filter: Option<&str>,
filename: &str,
is_new: bool,
) -> std::io::Result<std::io::BufWriter<Box<dyn std::io::Write>>> {
let file = if is_new {
std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(std::path::Path::new(filename))?
} else {
std::fs::OpenOptions::new()
.append(true)
.open(std::path::Path::new(filename))?
};
Ok(std::io::BufWriter::new(
Box::new(file) as Box<dyn std::io::Write>
))
}

#[cfg(unix)]
mod unix;

Expand Down
4 changes: 4 additions & 0 deletions src/uu/touch/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,10 @@ fn pathbuf_from_stdout() -> Result<PathBuf, TouchError> {
.map_err(|e| TouchError::WindowsStdoutPathError(e.to_string()))?
.into())
}
#[cfg(target_os = "wasi")]
{
Ok(PathBuf::from("/dev/stdout"))
}
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "wasi",
target_env = "uclibc",
target_os = "freebsd",
))]
Expand Down
Loading