mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: implement FromLua for Cha instead of AnyUserData
This commit is contained in:
parent
00486521b8
commit
c65bdb3b09
8 changed files with 57 additions and 74 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
[env]
|
[env]
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = "10.11"
|
||||||
|
JEMALLOC_SYS_WITH_LG_PAGE = "16"
|
||||||
|
|
||||||
# environment variable for tikv-jemalloc-sys
|
# environment variable for tikv-jemalloc-sys
|
||||||
#
|
#
|
||||||
# https://jemalloc.net/jemalloc.3.html#opt.narenas
|
# https://jemalloc.net/jemalloc.3.html#opt.narenas
|
||||||
|
|
|
||||||
16
.github/workflows/check.yml
vendored
16
.github/workflows/check.yml
vendored
|
|
@ -21,13 +21,7 @@ jobs:
|
||||||
rustup toolchain install stable --profile minimal
|
rustup toolchain install stable --profile minimal
|
||||||
rustup component add clippy
|
rustup component add clippy
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ubuntu-latest@debug
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
|
|
@ -44,13 +38,7 @@ jobs:
|
||||||
rustup toolchain install nightly --profile minimal
|
rustup toolchain install nightly --profile minimal
|
||||||
rustup component add rustfmt --toolchain nightly
|
rustup component add rustfmt --toolchain nightly
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ubuntu-latest@debug
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Rustfmt
|
- name: Rustfmt
|
||||||
|
|
|
||||||
63
.github/workflows/draft.yml
vendored
63
.github/workflows/draft.yml
vendored
|
|
@ -2,8 +2,8 @@ name: Draft
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches: [main]
|
||||||
- "v[0-9]+.[0-9]+.[0-9]+"
|
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 */6 * * *"
|
- cron: "0 */6 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
@ -26,26 +26,19 @@ jobs:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install gcc-aarch64-linux-gnu
|
- name: Install gcc-aarch64-linux-gnu
|
||||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||||
run: |
|
run: sudo apt-get update && sudo apt-get install -yq gcc-aarch64-linux-gnu
|
||||||
sudo apt-get update && sudo apt-get install -yq gcc-aarch64-linux-gnu
|
|
||||||
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
|
|
||||||
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Setup Rust toolchain
|
- name: Setup Rust toolchain
|
||||||
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
|
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ${{ matrix.target }}@release
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
@ -66,30 +59,23 @@ jobs:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
target: aarch64-pc-windows-msvc
|
target: aarch64-pc-windows-msvc
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
YAZI_GEN_COMPLETIONS: true
|
||||||
|
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: lld-link.exe
|
||||||
|
CARGO_TARGET_AARCH64_PC_WINDOWS_MSVC_LINKER: lld-link.exe
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Rust toolchain
|
- name: Setup Rust toolchain
|
||||||
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
|
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ${{ matrix.target }}@release
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
run: cargo build --release --locked --target ${{ matrix.target }}
|
||||||
YAZI_GEN_COMPLETIONS: true
|
|
||||||
run: |
|
|
||||||
cargo build -p yazi-cli --release --locked --target ${{ matrix.target }}
|
|
||||||
cargo build -p yazi-fm --release --locked --target ${{ matrix.target }}
|
|
||||||
|
|
||||||
- name: Pack artifact
|
- name: Pack artifact
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
env:
|
env:
|
||||||
TARGET_NAME: yazi-${{ matrix.target }}
|
TARGET_NAME: yazi-${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -123,13 +109,7 @@ jobs:
|
||||||
- name: Add musl target
|
- name: Add musl target
|
||||||
run: rustup target add ${{ matrix.target }}
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ${{ matrix.target }}@release
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
@ -142,6 +122,7 @@ jobs:
|
||||||
path: yazi-${{ matrix.target }}.zip
|
path: yazi-${{ matrix.target }}.zip
|
||||||
|
|
||||||
build-snap:
|
build-snap:
|
||||||
|
if: false # Can't make CI pass, disable for now
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
|
@ -151,13 +132,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ${{ matrix.target }}@release
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
@ -173,10 +148,11 @@ jobs:
|
||||||
path: yazi-${{ matrix.target }}.snap
|
path: yazi-${{ matrix.target }}.snap
|
||||||
|
|
||||||
draft:
|
draft:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-unix, build-windows, build-musl, build-snap]
|
needs: [build-unix, build-windows, build-musl]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -184,7 +160,6 @@ jobs:
|
||||||
|
|
||||||
- name: Draft
|
- name: Draft
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
files: |
|
files: |
|
||||||
|
|
@ -193,10 +168,11 @@ jobs:
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|
||||||
nightly:
|
nightly:
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-unix, build-windows, build-musl, build-snap]
|
needs: [build-unix, build-windows, build-musl]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -210,7 +186,6 @@ jobs:
|
||||||
|
|
||||||
- name: Nightly
|
- name: Nightly
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
|
||||||
with:
|
with:
|
||||||
tag_name: nightly
|
tag_name: nightly
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|
|
||||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
|
|
@ -23,13 +23,7 @@ jobs:
|
||||||
- name: Setup Rust toolchain
|
- name: Setup Rust toolchain
|
||||||
run: rustup toolchain install stable --profile minimal
|
run: rustup toolchain install stable --profile minimal
|
||||||
|
|
||||||
- name: Setup Rust cache
|
- name: Setup sccache
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
prefix-key: rust
|
|
||||||
shared-key: ${{ matrix.os }}@debug
|
|
||||||
|
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.6
|
uses: mozilla-actions/sccache-action@v0.0.6
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ set -euo pipefail
|
||||||
|
|
||||||
export ARTIFACT_NAME="yazi-$1"
|
export ARTIFACT_NAME="yazi-$1"
|
||||||
export YAZI_GEN_COMPLETIONS=1
|
export YAZI_GEN_COMPLETIONS=1
|
||||||
export MACOSX_DEPLOYMENT_TARGET="10.11"
|
|
||||||
|
|
||||||
# Build for the target
|
# Build for the target
|
||||||
cargo build --release --locked --target "$1"
|
cargo build --release --locked --target "$1"
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,34 @@ parts:
|
||||||
yazi:
|
yazi:
|
||||||
plugin: rust
|
plugin: rust
|
||||||
source: https://github.com/sxyazi/yazi.git
|
source: https://github.com/sxyazi/yazi.git
|
||||||
|
build-packages:
|
||||||
|
- wget
|
||||||
override-build: |
|
override-build: |
|
||||||
craftctl default
|
craftctl default
|
||||||
craftctl set version=$(git describe --tags --abbrev=0)
|
craftctl set version=$(git describe --tags --abbrev=0)
|
||||||
cargo install fd-find --root $CRAFT_PART_INSTALL
|
|
||||||
cargo install ripgrep --root $CRAFT_PART_INSTALL
|
wget ripgrep-14.1.1-aarch64-unknown-linux-gnu.tar.gz
|
||||||
cargo install zoxide --root $CRAFT_PART_INSTALL
|
tar fxz ripgrep-*.tar.gz
|
||||||
git clone --depth 1 https://github.com/junegunn/fzf.git fzf
|
mv ripgrep-*/rg $CRAFT_PART_INSTALL/bin/
|
||||||
fzf/install --bin && mv fzf/bin/fzf $CRAFT_PART_INSTALL/bin/
|
|
||||||
|
wget https://github.com/sharkdp/fd/releases/download/v10.2.0/fd-v10.2.0-aarch64-unknown-linux-gnu.tar.gz
|
||||||
|
tar fxz fd-*.tar.gz
|
||||||
|
mv fd-*/fd $CRAFT_PART_INSTALL/bin/
|
||||||
|
|
||||||
|
wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64
|
||||||
|
mv jq-linux-amd64 $CRAFT_PART_INSTALL/bin/jq
|
||||||
|
|
||||||
|
wget https://imagemagick.org/archive/binaries/magick
|
||||||
|
mv magick $CRAFT_PART_INSTALL/bin/magick
|
||||||
|
|
||||||
|
wget https://github.com/junegunn/fzf/releases/download/v0.56.2/fzf-0.56.2-linux_amd64.tar.gz
|
||||||
|
tar fxz fzf-*.tar.gz
|
||||||
|
mv fzf $CRAFT_PART_INSTALL/bin/
|
||||||
|
|
||||||
|
wget https://www.7-zip.org/a/7z2408-linux-x64.tar.xz
|
||||||
|
tar fxz 7z*.tar.xz
|
||||||
|
mv 7zz 7zzs $CRAFT_PART_INSTALL/bin/
|
||||||
|
|
||||||
|
wget https://github.com/ajeetdsouza/zoxide/releases/download/v0.9.6/zoxide-0.9.6-x86_64-unknown-linux-musl.tar.gz
|
||||||
|
tar fxz zoxide-*.tar.gz
|
||||||
|
mv zoxide $CRAFT_PART_INSTALL/bin/
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}};
|
use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}};
|
||||||
|
|
||||||
use mlua::{ExternalError, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
|
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
|
||||||
use yazi_shared::fs::ChaKind;
|
use yazi_shared::fs::ChaKind;
|
||||||
|
|
||||||
use crate::RtRef;
|
use crate::RtRef;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, FromLua)]
|
||||||
pub struct Cha(yazi_shared::fs::Cha);
|
pub struct Cha(yazi_shared::fs::Cha);
|
||||||
|
|
||||||
impl Deref for Cha {
|
impl Deref for Cha {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use mlua::{AnyUserData, Lua, Table, UserDataRef};
|
use mlua::{AnyUserData, Lua, Table, UserDataRef};
|
||||||
|
|
||||||
use crate::{bindings::Cast, impl_file_fields, impl_file_methods};
|
use crate::{bindings::{Cast, Cha}, impl_file_fields, impl_file_methods};
|
||||||
|
|
||||||
pub type FileRef = UserDataRef<yazi_shared::fs::File>;
|
pub type FileRef = UserDataRef<yazi_shared::fs::File>;
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl File {
|
||||||
lua.create_function(|lua, t: Table| {
|
lua.create_function(|lua, t: Table| {
|
||||||
Self::cast(lua, yazi_shared::fs::File {
|
Self::cast(lua, yazi_shared::fs::File {
|
||||||
url: t.raw_get::<AnyUserData>("url")?.take()?,
|
url: t.raw_get::<AnyUserData>("url")?.take()?,
|
||||||
cha: t.raw_get::<AnyUserData>("cha")?.take()?,
|
cha: *t.raw_get::<Cha>("cha")?,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
})?,
|
})?,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue