diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml index a546cc92..65b1be49 100644 --- a/.github/workflows/draft.yml +++ b/.github/workflows/draft.yml @@ -96,15 +96,15 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.6 - name: Build - run: cargo build --release --locked --target ${{ matrix.target }} + run: cargo build --profile release-windows --locked --target ${{ matrix.target }} - name: Pack artifact env: TARGET_NAME: yazi-${{ matrix.target }} run: | New-Item -ItemType Directory -Path ${env:TARGET_NAME} - Copy-Item -Path "target\${{ matrix.target }}\release\ya.exe" -Destination ${env:TARGET_NAME} - Copy-Item -Path "target\${{ matrix.target }}\release\yazi.exe" -Destination ${env:TARGET_NAME} + Copy-Item -Path "target\${{ matrix.target }}\release-windows\ya.exe" -Destination ${env:TARGET_NAME} + Copy-Item -Path "target\${{ matrix.target }}\release-windows\yazi.exe" -Destination ${env:TARGET_NAME} Copy-Item -Path "yazi-boot\completions" -Destination ${env:TARGET_NAME} -Recurse Copy-Item -Path "README.md", "LICENSE" -Destination ${env:TARGET_NAME} Compress-Archive -Path ${env:TARGET_NAME} -DestinationPath "${env:TARGET_NAME}.zip" diff --git a/Cargo.toml b/Cargo.toml index 06525c6f..64ff965d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ lto = true panic = "abort" strip = true +[profile.release-windows] +inherits = "release" +panic = "unwind" + [workspace.dependencies] ansi-to-tui = "7.0.0" anyhow = "1.0.95" diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/manager/watcher.rs index 300198fb..9b84d823 100644 --- a/yazi-core/src/manager/watcher.rs +++ b/yazi-core/src/manager/watcher.rs @@ -6,8 +6,7 @@ use parking_lot::RwLock; use tokio::{fs, pin, sync::{mpsc::{self, UnboundedReceiver}, watch}}; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use tracing::error; -use yazi_dds::Pubsub; -use yazi_fs::{Cha, File, Files, FilesOp, mounts::PARTITIONS, realname_unchecked}; +use yazi_fs::{Cha, File, Files, FilesOp, realname_unchecked}; use yazi_proxy::WATCHER; use yazi_shared::{RoCell, url::Url}; @@ -44,7 +43,10 @@ impl Watcher { } #[cfg(any(target_os = "linux", target_os = "macos"))] - yazi_fs::mounts::Partitions::monitor(PARTITIONS.clone(), Pubsub::pub_from_mount); + yazi_fs::mounts::Partitions::monitor( + yazi_fs::mounts::PARTITIONS.clone(), + yazi_dds::Pubsub::pub_from_mount, + ); tokio::spawn(Self::fan_out(out_rx)); Self { in_tx, out_tx } diff --git a/yazi-fm/build.rs b/yazi-fm/build.rs new file mode 100644 index 00000000..ec41c9eb --- /dev/null +++ b/yazi-fm/build.rs @@ -0,0 +1,12 @@ +use std::{env, error::Error}; + +fn main() -> Result<(), Box> { + let dir = env::var("OUT_DIR").unwrap(); + if dir.contains("\\target\\release\\build\\yazi-fm-") { + panic!( + "Unwinding must be enabled for Windows. Please use `cargo build --profile release-windows --locked` instead to build Yazi." + ); + } + + Ok(()) +} diff --git a/yazi-fs/src/cha.rs b/yazi-fs/src/cha.rs index 386f8f42..9ac97980 100644 --- a/yazi-fs/src/cha.rs +++ b/yazi-fs/src/cha.rs @@ -152,11 +152,11 @@ impl Cha { } #[inline] - pub fn new_nofollow(path: &Path, meta: Metadata) -> Self { + pub fn new_nofollow(_path: &Path, meta: Metadata) -> Self { let mut attached = ChaKind::empty(); #[cfg(unix)] - if yazi_shared::url::Urn::new(path).is_hidden() { + if yazi_shared::url::Urn::new(_path).is_hidden() { attached |= ChaKind::HIDDEN; } #[cfg(windows)] diff --git a/yazi-fs/src/mounts/partition.rs b/yazi-fs/src/mounts/partition.rs index e2ca7f29..d1eba779 100644 --- a/yazi-fs/src/mounts/partition.rs +++ b/yazi-fs/src/mounts/partition.rs @@ -1,4 +1,4 @@ -use std::{ffi::{OsStr, OsString}, path::PathBuf}; +use std::{ffi::OsString, path::PathBuf}; #[derive(Debug, Default)] pub struct Partition { @@ -19,14 +19,14 @@ impl Partition { #[rustfmt::skip] pub fn systemic(&self) -> bool { - let b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes()); + let _b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes()); #[cfg(target_os = "linux")] { - matches!(b, b"autofs" | b"binfmt_misc" | b"bpf" | b"cgroup2" | b"configfs" | b"debugfs" | b"devpts" | b"devtmpfs" | b"fuse.gvfsd-fuse" | b"fusectl" | b"hugetlbfs" | b"mqueue" | b"proc" | b"pstore" | b"ramfs" | b"securityfs" | b"sysfs" | b"tmpfs" | b"tracefs") + matches!(_b, b"autofs" | b"binfmt_misc" | b"bpf" | b"cgroup2" | b"configfs" | b"debugfs" | b"devpts" | b"devtmpfs" | b"fuse.gvfsd-fuse" | b"fusectl" | b"hugetlbfs" | b"mqueue" | b"proc" | b"pstore" | b"ramfs" | b"securityfs" | b"sysfs" | b"tmpfs" | b"tracefs") } #[cfg(target_os = "macos")] { - b.is_empty() + _b.is_empty() } #[cfg(not(any(target_os = "linux", target_os = "macos")))] { @@ -38,13 +38,13 @@ impl Partition { impl Partition { #[inline] #[cfg(any(target_os = "linux", target_os = "macos"))] - pub(super) fn new(name: &OsStr) -> Self { + pub(super) fn new(name: &std::ffi::OsStr) -> Self { Self { src: std::path::Path::new("/dev/").join(name).into(), ..Default::default() } } #[inline] #[cfg(target_os = "linux")] - pub(super) fn dev_name(&self) -> Option<&OsStr> { + pub(super) fn dev_name(&self) -> Option<&std::ffi::OsStr> { std::path::Path::new(&self.src).strip_prefix("/dev/").ok().map(|p| p.as_os_str()) } } diff --git a/yazi-fs/src/mounts/partitions.rs b/yazi-fs/src/mounts/partitions.rs index 536de288..ef589eec 100644 --- a/yazi-fs/src/mounts/partitions.rs +++ b/yazi-fs/src/mounts/partitions.rs @@ -32,10 +32,10 @@ impl Partitions { self.inner.iter().find(|p| p.rdev == Some(dev)) } - pub fn heuristic(&self, cha: Cha) -> bool { + pub fn heuristic(&self, _cha: Cha) -> bool { #[cfg(any(target_os = "linux", target_os = "macos"))] { - self.by_dev(cha.dev).is_none_or(|p| p.heuristic()) + self.by_dev(_cha.dev).is_none_or(|p| p.heuristic()) } #[cfg(not(any(target_os = "linux", target_os = "macos")))] { diff --git a/yazi-plugin/src/bindings/cha.rs b/yazi-plugin/src/bindings/cha.rs index 75f70845..0ea26008 100644 --- a/yazi-plugin/src/bindings/cha.rs +++ b/yazi-plugin/src/bindings/cha.rs @@ -1,4 +1,4 @@ -use std::{ops::{Deref, Not}, time::{Duration, SystemTime, UNIX_EPOCH}}; +use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods}; use yazi_fs::ChaKind; @@ -74,6 +74,7 @@ impl UserData for Cha { #[cfg(unix)] { + use std::ops::Not; fields.add_field_method_get("dev", |_, me| Ok(me.is_dummy().not().then_some(me.dev))); fields.add_field_method_get("uid", |_, me| Ok(me.is_dummy().not().then_some(me.uid))); fields.add_field_method_get("gid", |_, me| Ok(me.is_dummy().not().then_some(me.gid))); diff --git a/yazi-plugin/src/utils/user.rs b/yazi-plugin/src/utils/user.rs index d219ca3a..79c27917 100644 --- a/yazi-plugin/src/utils/user.rs +++ b/yazi-plugin/src/utils/user.rs @@ -1,3 +1,4 @@ +#[cfg(unix)] use mlua::{Function, Lua}; use super::Utils;