Skip to content

Commit 4e96341

Browse files
committed
fix: enable unwinding on Windows release builds (#2286)
1 parent 7f1e9b8 commit 4e96341

File tree

9 files changed

+37
-17
lines changed

9 files changed

+37
-17
lines changed

.github/workflows/draft.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ jobs:
9696
uses: mozilla-actions/[email protected]
9797

9898
- name: Build
99-
run: cargo build --release --locked --target ${{ matrix.target }}
99+
run: cargo build --profile release-windows --locked --target ${{ matrix.target }}
100100

101101
- name: Pack artifact
102102
env:
103103
TARGET_NAME: yazi-${{ matrix.target }}
104104
run: |
105105
New-Item -ItemType Directory -Path ${env:TARGET_NAME}
106-
Copy-Item -Path "target\${{ matrix.target }}\release\ya.exe" -Destination ${env:TARGET_NAME}
107-
Copy-Item -Path "target\${{ matrix.target }}\release\yazi.exe" -Destination ${env:TARGET_NAME}
106+
Copy-Item -Path "target\${{ matrix.target }}\release-windows\ya.exe" -Destination ${env:TARGET_NAME}
107+
Copy-Item -Path "target\${{ matrix.target }}\release-windows\yazi.exe" -Destination ${env:TARGET_NAME}
108108
Copy-Item -Path "yazi-boot\completions" -Destination ${env:TARGET_NAME} -Recurse
109109
Copy-Item -Path "README.md", "LICENSE" -Destination ${env:TARGET_NAME}
110110
Compress-Archive -Path ${env:TARGET_NAME} -DestinationPath "${env:TARGET_NAME}.zip"

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ lto = true
99
panic = "abort"
1010
strip = true
1111

12+
[profile.release-windows]
13+
inherits = "release"
14+
panic = "unwind"
15+
1216
[workspace.dependencies]
1317
ansi-to-tui = "7.0.0"
1418
anyhow = "1.0.95"

yazi-core/src/manager/watcher.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use parking_lot::RwLock;
66
use tokio::{fs, pin, sync::{mpsc::{self, UnboundedReceiver}, watch}};
77
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
88
use tracing::error;
9-
use yazi_dds::Pubsub;
10-
use yazi_fs::{Cha, File, Files, FilesOp, mounts::PARTITIONS, realname_unchecked};
9+
use yazi_fs::{Cha, File, Files, FilesOp, realname_unchecked};
1110
use yazi_proxy::WATCHER;
1211
use yazi_shared::{RoCell, url::Url};
1312

@@ -44,7 +43,10 @@ impl Watcher {
4443
}
4544

4645
#[cfg(any(target_os = "linux", target_os = "macos"))]
47-
yazi_fs::mounts::Partitions::monitor(PARTITIONS.clone(), Pubsub::pub_from_mount);
46+
yazi_fs::mounts::Partitions::monitor(
47+
yazi_fs::mounts::PARTITIONS.clone(),
48+
yazi_dds::Pubsub::pub_from_mount,
49+
);
4850

4951
tokio::spawn(Self::fan_out(out_rx));
5052
Self { in_tx, out_tx }

yazi-fm/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std::{env, error::Error};
2+
3+
fn main() -> Result<(), Box<dyn Error>> {
4+
let dir = env::var("OUT_DIR").unwrap();
5+
if dir.contains("\\target\\release\\build\\yazi-fm-") {
6+
panic!(
7+
"Unwinding must be enabled for Windows. Please use `cargo build --profile release-windows --locked` instead to build Yazi."
8+
);
9+
}
10+
11+
Ok(())
12+
}

yazi-fs/src/cha.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ impl Cha {
152152
}
153153

154154
#[inline]
155-
pub fn new_nofollow(path: &Path, meta: Metadata) -> Self {
155+
pub fn new_nofollow(_path: &Path, meta: Metadata) -> Self {
156156
let mut attached = ChaKind::empty();
157157

158158
#[cfg(unix)]
159-
if yazi_shared::url::Urn::new(path).is_hidden() {
159+
if yazi_shared::url::Urn::new(_path).is_hidden() {
160160
attached |= ChaKind::HIDDEN;
161161
}
162162
#[cfg(windows)]

yazi-fs/src/mounts/partition.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ffi::{OsStr, OsString}, path::PathBuf};
1+
use std::{ffi::OsString, path::PathBuf};
22

33
#[derive(Debug, Default)]
44
pub struct Partition {
@@ -19,14 +19,14 @@ impl Partition {
1919

2020
#[rustfmt::skip]
2121
pub fn systemic(&self) -> bool {
22-
let b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes());
22+
let _b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes());
2323
#[cfg(target_os = "linux")]
2424
{
25-
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")
25+
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")
2626
}
2727
#[cfg(target_os = "macos")]
2828
{
29-
b.is_empty()
29+
_b.is_empty()
3030
}
3131
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
3232
{
@@ -38,13 +38,13 @@ impl Partition {
3838
impl Partition {
3939
#[inline]
4040
#[cfg(any(target_os = "linux", target_os = "macos"))]
41-
pub(super) fn new(name: &OsStr) -> Self {
41+
pub(super) fn new(name: &std::ffi::OsStr) -> Self {
4242
Self { src: std::path::Path::new("/dev/").join(name).into(), ..Default::default() }
4343
}
4444

4545
#[inline]
4646
#[cfg(target_os = "linux")]
47-
pub(super) fn dev_name(&self) -> Option<&OsStr> {
47+
pub(super) fn dev_name(&self) -> Option<&std::ffi::OsStr> {
4848
std::path::Path::new(&self.src).strip_prefix("/dev/").ok().map(|p| p.as_os_str())
4949
}
5050
}

yazi-fs/src/mounts/partitions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ impl Partitions {
3232
self.inner.iter().find(|p| p.rdev == Some(dev))
3333
}
3434

35-
pub fn heuristic(&self, cha: Cha) -> bool {
35+
pub fn heuristic(&self, _cha: Cha) -> bool {
3636
#[cfg(any(target_os = "linux", target_os = "macos"))]
3737
{
38-
self.by_dev(cha.dev).is_none_or(|p| p.heuristic())
38+
self.by_dev(_cha.dev).is_none_or(|p| p.heuristic())
3939
}
4040
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
4141
{

yazi-plugin/src/bindings/cha.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ops::{Deref, Not}, time::{Duration, SystemTime, UNIX_EPOCH}};
1+
use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}};
22

33
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
44
use yazi_fs::ChaKind;
@@ -74,6 +74,7 @@ impl UserData for Cha {
7474

7575
#[cfg(unix)]
7676
{
77+
use std::ops::Not;
7778
fields.add_field_method_get("dev", |_, me| Ok(me.is_dummy().not().then_some(me.dev)));
7879
fields.add_field_method_get("uid", |_, me| Ok(me.is_dummy().not().then_some(me.uid)));
7980
fields.add_field_method_get("gid", |_, me| Ok(me.is_dummy().not().then_some(me.gid)));

yazi-plugin/src/utils/user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(unix)]
12
use mlua::{Function, Lua};
23

34
use super::Utils;

0 commit comments

Comments
 (0)