Skip to content

Commit c65bdb3

Browse files
committed
fix: implement FromLua for Cha instead of AnyUserData
1 parent 0048652 commit c65bdb3

File tree

8 files changed

+57
-74
lines changed

8 files changed

+57
-74
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[env]
2+
MACOSX_DEPLOYMENT_TARGET = "10.11"
3+
JEMALLOC_SYS_WITH_LG_PAGE = "16"
4+
25
# environment variable for tikv-jemalloc-sys
36
#
47
# https://jemalloc.net/jemalloc.3.html#opt.narenas

.github/workflows/check.yml

+2-14
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ jobs:
2121
rustup toolchain install stable --profile minimal
2222
rustup component add clippy
2323
24-
- name: Setup Rust cache
25-
uses: Swatinem/rust-cache@v2
26-
with:
27-
prefix-key: rust
28-
shared-key: ubuntu-latest@debug
29-
30-
- name: Run sccache-cache
24+
- name: Setup sccache
3125
uses: mozilla-actions/[email protected]
3226

3327
- name: Clippy
@@ -44,13 +38,7 @@ jobs:
4438
rustup toolchain install nightly --profile minimal
4539
rustup component add rustfmt --toolchain nightly
4640
47-
- name: Setup Rust cache
48-
uses: Swatinem/rust-cache@v2
49-
with:
50-
prefix-key: rust
51-
shared-key: ubuntu-latest@debug
52-
53-
- name: Run sccache-cache
41+
- name: Setup sccache
5442
uses: mozilla-actions/[email protected]
5543

5644
- name: Rustfmt

.github/workflows/draft.yml

+19-44
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Draft
22

33
on:
44
push:
5-
tags:
6-
- "v[0-9]+.[0-9]+.[0-9]+"
5+
branches: [main]
6+
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
77
schedule:
88
- cron: "0 */6 * * *"
99
workflow_dispatch:
@@ -26,26 +26,19 @@ jobs:
2626
- os: macos-latest
2727
target: aarch64-apple-darwin
2828
runs-on: ${{ matrix.os }}
29+
env:
30+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
2931
steps:
3032
- uses: actions/checkout@v4
3133

3234
- name: Install gcc-aarch64-linux-gnu
3335
if: matrix.target == 'aarch64-unknown-linux-gnu'
34-
run: |
35-
sudo apt-get update && sudo apt-get install -yq gcc-aarch64-linux-gnu
36-
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
37-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
36+
run: sudo apt-get update && sudo apt-get install -yq gcc-aarch64-linux-gnu
3837

3938
- name: Setup Rust toolchain
4039
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
4140

42-
- name: Setup Rust cache
43-
uses: Swatinem/rust-cache@v2
44-
with:
45-
prefix-key: rust
46-
shared-key: ${{ matrix.target }}@release
47-
48-
- name: Run sccache-cache
41+
- name: Setup sccache
4942
uses: mozilla-actions/[email protected]
5043

5144
- name: Build
@@ -66,30 +59,23 @@ jobs:
6659
- os: windows-latest
6760
target: aarch64-pc-windows-msvc
6861
runs-on: ${{ matrix.os }}
62+
env:
63+
YAZI_GEN_COMPLETIONS: true
64+
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: lld-link.exe
65+
CARGO_TARGET_AARCH64_PC_WINDOWS_MSVC_LINKER: lld-link.exe
6966
steps:
7067
- uses: actions/checkout@v4
7168

7269
- name: Setup Rust toolchain
7370
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
7471

75-
- name: Setup Rust cache
76-
uses: Swatinem/rust-cache@v2
77-
with:
78-
prefix-key: rust
79-
shared-key: ${{ matrix.target }}@release
80-
81-
- name: Run sccache-cache
72+
- name: Setup sccache
8273
uses: mozilla-actions/[email protected]
8374

8475
- name: Build
85-
env:
86-
YAZI_GEN_COMPLETIONS: true
87-
run: |
88-
cargo build -p yazi-cli --release --locked --target ${{ matrix.target }}
89-
cargo build -p yazi-fm --release --locked --target ${{ matrix.target }}
76+
run: cargo build --release --locked --target ${{ matrix.target }}
9077

9178
- name: Pack artifact
92-
if: matrix.os == 'windows-latest'
9379
env:
9480
TARGET_NAME: yazi-${{ matrix.target }}
9581
run: |
@@ -123,13 +109,7 @@ jobs:
123109
- name: Add musl target
124110
run: rustup target add ${{ matrix.target }}
125111

126-
- name: Setup Rust cache
127-
uses: Swatinem/rust-cache@v2
128-
with:
129-
prefix-key: rust
130-
shared-key: ${{ matrix.target }}@release
131-
132-
- name: Run sccache-cache
112+
- name: Setup sccache
133113
uses: mozilla-actions/[email protected]
134114

135115
- name: Build
@@ -142,6 +122,7 @@ jobs:
142122
path: yazi-${{ matrix.target }}.zip
143123

144124
build-snap:
125+
if: false # Can't make CI pass, disable for now
145126
strategy:
146127
matrix:
147128
include:
@@ -151,13 +132,7 @@ jobs:
151132
steps:
152133
- uses: actions/checkout@v4
153134

154-
- name: Setup Rust cache
155-
uses: Swatinem/rust-cache@v2
156-
with:
157-
prefix-key: rust
158-
shared-key: ${{ matrix.target }}@release
159-
160-
- name: Run sccache-cache
135+
- name: Setup sccache
161136
uses: mozilla-actions/[email protected]
162137

163138
- name: Build
@@ -173,18 +148,18 @@ jobs:
173148
path: yazi-${{ matrix.target }}.snap
174149

175150
draft:
151+
if: startsWith(github.ref, 'refs/tags/')
176152
permissions:
177153
contents: write
178154
runs-on: ubuntu-latest
179-
needs: [build-unix, build-windows, build-musl, build-snap]
155+
needs: [build-unix, build-windows, build-musl]
180156
steps:
181157
- uses: actions/download-artifact@v4
182158
with:
183159
merge-multiple: true
184160

185161
- name: Draft
186162
uses: softprops/action-gh-release@v1
187-
if: startsWith(github.ref, 'refs/tags/')
188163
with:
189164
draft: true
190165
files: |
@@ -193,10 +168,11 @@ jobs:
193168
generate_release_notes: true
194169

195170
nightly:
171+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
196172
permissions:
197173
contents: write
198174
runs-on: ubuntu-latest
199-
needs: [build-unix, build-windows, build-musl, build-snap]
175+
needs: [build-unix, build-windows, build-musl]
200176
steps:
201177
- uses: actions/download-artifact@v4
202178
with:
@@ -210,7 +186,6 @@ jobs:
210186
211187
- name: Nightly
212188
uses: softprops/action-gh-release@v1
213-
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
214189
with:
215190
tag_name: nightly
216191
prerelease: true

.github/workflows/test.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ jobs:
2323
- name: Setup Rust toolchain
2424
run: rustup toolchain install stable --profile minimal
2525

26-
- name: Setup Rust cache
27-
uses: Swatinem/rust-cache@v2
28-
with:
29-
prefix-key: rust
30-
shared-key: ${{ matrix.os }}@debug
31-
32-
- name: Run sccache-cache
26+
- name: Setup sccache
3327
uses: mozilla-actions/[email protected]
3428

3529
- name: Build

scripts/build.sh

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ set -euo pipefail
33

44
export ARTIFACT_NAME="yazi-$1"
55
export YAZI_GEN_COMPLETIONS=1
6-
export MACOSX_DEPLOYMENT_TARGET="10.11"
76

87
# Build for the target
98
cargo build --release --locked --target "$1"

snap/snapcraft.yaml

+28-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,34 @@ parts:
2323
yazi:
2424
plugin: rust
2525
source: https://github.com/sxyazi/yazi.git
26+
build-packages:
27+
- wget
2628
override-build: |
2729
craftctl default
2830
craftctl set version=$(git describe --tags --abbrev=0)
29-
cargo install fd-find --root $CRAFT_PART_INSTALL
30-
cargo install ripgrep --root $CRAFT_PART_INSTALL
31-
cargo install zoxide --root $CRAFT_PART_INSTALL
32-
git clone --depth 1 https://github.com/junegunn/fzf.git fzf
33-
fzf/install --bin && mv fzf/bin/fzf $CRAFT_PART_INSTALL/bin/
31+
32+
wget ripgrep-14.1.1-aarch64-unknown-linux-gnu.tar.gz
33+
tar fxz ripgrep-*.tar.gz
34+
mv ripgrep-*/rg $CRAFT_PART_INSTALL/bin/
35+
36+
wget https://github.com/sharkdp/fd/releases/download/v10.2.0/fd-v10.2.0-aarch64-unknown-linux-gnu.tar.gz
37+
tar fxz fd-*.tar.gz
38+
mv fd-*/fd $CRAFT_PART_INSTALL/bin/
39+
40+
wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64
41+
mv jq-linux-amd64 $CRAFT_PART_INSTALL/bin/jq
42+
43+
wget https://imagemagick.org/archive/binaries/magick
44+
mv magick $CRAFT_PART_INSTALL/bin/magick
45+
46+
wget https://github.com/junegunn/fzf/releases/download/v0.56.2/fzf-0.56.2-linux_amd64.tar.gz
47+
tar fxz fzf-*.tar.gz
48+
mv fzf $CRAFT_PART_INSTALL/bin/
49+
50+
wget https://www.7-zip.org/a/7z2408-linux-x64.tar.xz
51+
tar fxz 7z*.tar.xz
52+
mv 7zz 7zzs $CRAFT_PART_INSTALL/bin/
53+
54+
wget https://github.com/ajeetdsouza/zoxide/releases/download/v0.9.6/zoxide-0.9.6-x86_64-unknown-linux-musl.tar.gz
55+
tar fxz zoxide-*.tar.gz
56+
mv zoxide $CRAFT_PART_INSTALL/bin/

yazi-plugin/src/bindings/cha.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}};
22

3-
use mlua::{ExternalError, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
3+
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
44
use yazi_shared::fs::ChaKind;
55

66
use crate::RtRef;
77

8+
#[derive(Clone, Copy, FromLua)]
89
pub struct Cha(yazi_shared::fs::Cha);
910

1011
impl Deref for Cha {

yazi-plugin/src/file/file.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use mlua::{AnyUserData, Lua, Table, UserDataRef};
22

3-
use crate::{bindings::Cast, impl_file_fields, impl_file_methods};
3+
use crate::{bindings::{Cast, Cha}, impl_file_fields, impl_file_methods};
44

55
pub type FileRef = UserDataRef<yazi_shared::fs::File>;
66

@@ -21,7 +21,7 @@ impl File {
2121
lua.create_function(|lua, t: Table| {
2222
Self::cast(lua, yazi_shared::fs::File {
2323
url: t.raw_get::<AnyUserData>("url")?.take()?,
24-
cha: t.raw_get::<AnyUserData>("cha")?.take()?,
24+
cha: *t.raw_get::<Cha>("cha")?,
2525
..Default::default()
2626
})
2727
})?,

0 commit comments

Comments
 (0)