From 9dfb39b98b53353520ad5b57ae4bcad21352067e Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Mon, 9 Feb 2026 18:05:25 +0800 Subject: [PATCH 1/4] Change loader extension to `.basisu.ktx2` --- .gitattributes | 1 - .github/workflows/ci.yml | 39 +++++++++++++++++++ README.md | 4 +- ...s.basisu_ktx2 => alpha0_etc1s.basisu.ktx2} | 0 ...=> desk_uastc_hdr_4x4_mips_10.basisu.ktx2} | 0 ...=> desk_uastc_hdr_6x6_mips_10.basisu.ktx2} | 0 ..._skybox_etc1s_cubemap_mips_12.basisu.ktx2} | 0 ..._skybox_uastc_cubemap_mips_12.basisu.ktx2} | 0 ..._ktx2 => kodim20_astc_ldr_8x8.basisu.ktx2} | 0 ...> tough_uastc_ldr_4x4_mips_11.basisu.ktx2} | 0 ...2 => wikipedia_xuastc_ldr_6x6.basisu.ktx2} | 0 crates/basisu_sys/build.rs | 3 +- examples/test_scene/src/lib.rs | 14 +++---- src/lib.rs | 14 ++++--- src/loader.rs | 2 +- typos.toml | 12 ++++++ 16 files changed, 72 insertions(+), 17 deletions(-) rename assets/{alpha0_etc1s.basisu_ktx2 => alpha0_etc1s.basisu.ktx2} (100%) rename assets/{desk_uastc_hdr_4x4_mips_10.basisu_ktx2 => desk_uastc_hdr_4x4_mips_10.basisu.ktx2} (100%) rename assets/{desk_uastc_hdr_6x6_mips_10.basisu_ktx2 => desk_uastc_hdr_6x6_mips_10.basisu.ktx2} (100%) rename assets/{gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2 => gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2} (100%) rename assets/{gl_skybox_uastc_cubemap_mips_12.basisu_ktx2 => gl_skybox_uastc_cubemap_mips_12.basisu.ktx2} (100%) rename assets/{kodim20_astc_ldr_8x8.basisu_ktx2 => kodim20_astc_ldr_8x8.basisu.ktx2} (100%) rename assets/{tough_uastc_ldr_4x4_mips_11.basisu_ktx2 => tough_uastc_ldr_4x4_mips_11.basisu.ktx2} (100%) rename assets/{wikipedia_xuastc_ldr_6x6.basisu_ktx2 => wikipedia_xuastc_ldr_6x6.basisu.ktx2} (100%) create mode 100644 typos.toml diff --git a/.gitattributes b/.gitattributes index a65c2f6..2da5fc0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ *.ktx2 filter=lfs diff=lfs merge=lfs -text -*.basisu_ktx2 filter=lfs diff=lfs merge=lfs -text vendor/basis_universal/**/* filter=lfs diff=lfs merge=lfs -text *.wasm filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3f3bc9..2bb3458 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,45 @@ env: EM_VERSION: 4.0.22 jobs: + toml: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Install taplo + run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo + - name: Run Taplo + id: taplo + run: taplo fmt --check --diff + - name: Taplo info + if: failure() + run: | + echo 'To fix toml fmt, please run `taplo fmt`.' + echo 'To check for a diff, run `taplo fmt --check --diff`.' + echo 'You can find taplo here: https://taplo.tamasfe.dev/' + echo 'Or if you use VSCode, use the `Even Better Toml` extension.' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml' + + typos: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Check for typos + uses: crate-ci/typos@ad3053d3adbcce7f2e3c60fd4ddfc239787d1eff # v1.43.2 + - name: Typos info + if: failure() + run: | + echo 'To fix typos, please run `typos -w`' + echo 'To check for a diff, run `typos`' + echo 'You can find typos here: https://crates.io/crates/typos' + echo 'if you use VSCode, you can also install `Typos Spell Checker' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode' + build-linux-wasm: name: Build linux,wasm runs-on: ubuntu-latest diff --git a/README.md b/README.md index 04daa5c..9479377 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,10 @@ pub fn main() { 1. Load ktx2 basis universal textures. Supports `D2`, `D2Array` and `Cube` texture types. Only supports KTX2 format (zstd compression is supported). No support for `.basis` format. ```rs - let image_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2"); + let image_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2"); ``` -⚠️Note: you have to rename the file extension to `.basisu_ktx2` to load it with this `BasisuLoader`. This is a limitations of bevy because otherwise bevy will load `.ktx2` file with its `ImageLoader`. +⚠️Note: you have to rename the file extension to `.basisu.ktx2` to load it with this `BasisuLoader`. This is a limitations of bevy because otherwise bevy will load `.ktx2` file with its `ImageLoader`. ⚠️Note: The compressed texture dimensions must be a multiplier of block size. See https://github.com/gfx-rs/wgpu/issues/7677 for more context. Also because basisu can transcode to textures with different block size on different platforms, the texture dimensions should satisfy all possible block sizes. For example, XUASTC 6x6 can transcode to ASTC 6x6 and BC7, so its dimensions should be a multiplier of 12. diff --git a/assets/alpha0_etc1s.basisu_ktx2 b/assets/alpha0_etc1s.basisu.ktx2 similarity index 100% rename from assets/alpha0_etc1s.basisu_ktx2 rename to assets/alpha0_etc1s.basisu.ktx2 diff --git a/assets/desk_uastc_hdr_4x4_mips_10.basisu_ktx2 b/assets/desk_uastc_hdr_4x4_mips_10.basisu.ktx2 similarity index 100% rename from assets/desk_uastc_hdr_4x4_mips_10.basisu_ktx2 rename to assets/desk_uastc_hdr_4x4_mips_10.basisu.ktx2 diff --git a/assets/desk_uastc_hdr_6x6_mips_10.basisu_ktx2 b/assets/desk_uastc_hdr_6x6_mips_10.basisu.ktx2 similarity index 100% rename from assets/desk_uastc_hdr_6x6_mips_10.basisu_ktx2 rename to assets/desk_uastc_hdr_6x6_mips_10.basisu.ktx2 diff --git a/assets/gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2 b/assets/gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2 similarity index 100% rename from assets/gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2 rename to assets/gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2 diff --git a/assets/gl_skybox_uastc_cubemap_mips_12.basisu_ktx2 b/assets/gl_skybox_uastc_cubemap_mips_12.basisu.ktx2 similarity index 100% rename from assets/gl_skybox_uastc_cubemap_mips_12.basisu_ktx2 rename to assets/gl_skybox_uastc_cubemap_mips_12.basisu.ktx2 diff --git a/assets/kodim20_astc_ldr_8x8.basisu_ktx2 b/assets/kodim20_astc_ldr_8x8.basisu.ktx2 similarity index 100% rename from assets/kodim20_astc_ldr_8x8.basisu_ktx2 rename to assets/kodim20_astc_ldr_8x8.basisu.ktx2 diff --git a/assets/tough_uastc_ldr_4x4_mips_11.basisu_ktx2 b/assets/tough_uastc_ldr_4x4_mips_11.basisu.ktx2 similarity index 100% rename from assets/tough_uastc_ldr_4x4_mips_11.basisu_ktx2 rename to assets/tough_uastc_ldr_4x4_mips_11.basisu.ktx2 diff --git a/assets/wikipedia_xuastc_ldr_6x6.basisu_ktx2 b/assets/wikipedia_xuastc_ldr_6x6.basisu.ktx2 similarity index 100% rename from assets/wikipedia_xuastc_ldr_6x6.basisu_ktx2 rename to assets/wikipedia_xuastc_ldr_6x6.basisu.ktx2 diff --git a/crates/basisu_sys/build.rs b/crates/basisu_sys/build.rs index 8a5a3b4..092321a 100644 --- a/crates/basisu_sys/build.rs +++ b/crates/basisu_sys/build.rs @@ -21,9 +21,10 @@ const DEFINES: [(&str, &str); 5] = [ ("BASISD_SUPPORT_PVRTC1", "0"), // ("BASISD_SUPPORT_ETC2_EAC_A8", "1"), // ("BASISD_SUPPORT_ASTC", "1"), + // ("BASISD_SUPPORT_XUASTC", "1"), ("BASISD_SUPPORT_ATC", "0"), - // ("BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY", "1"), // ("BASISD_SUPPORT_ETC2_EAC_RG11", "1"), + // ("BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY", "1"), ("BASISD_SUPPORT_FXT1", "0"), ("BASISD_SUPPORT_PVRTC2", "0"), // ("BASISD_SUPPORT_UASTC_HDR", "1"), diff --git a/examples/test_scene/src/lib.rs b/examples/test_scene/src/lib.rs index 27cfce5..5ec4c95 100644 --- a/examples/test_scene/src/lib.rs +++ b/examples/test_scene/src/lib.rs @@ -38,7 +38,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - let skybox_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2"); + let skybox_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2"); // camera commands.spawn(( Camera3d::default(), @@ -56,7 +56,7 @@ fn setup( commands.spawn(( Mesh3d(meshes.add(Rectangle::new(1.0, 1.0).mesh().build())), MeshMaterial3d(materials.add(StandardMaterial { - base_color_texture: Some(asset_server.load("tough_uastc_ldr_4x4_mips_11.basisu_ktx2")), + base_color_texture: Some(asset_server.load("tough_uastc_ldr_4x4_mips_11.basisu.ktx2")), unlit: true, ..Default::default() })), @@ -66,7 +66,7 @@ fn setup( commands.spawn(( Mesh3d(meshes.add(Rectangle::new(0.644 * 3.0, 0.874 * 3.0).mesh().build())), MeshMaterial3d(materials.add(StandardMaterial { - base_color_texture: Some(asset_server.load("desk_uastc_hdr_6x6_mips_10.basisu_ktx2")), + base_color_texture: Some(asset_server.load("desk_uastc_hdr_6x6_mips_10.basisu.ktx2")), unlit: true, ..Default::default() })), @@ -78,7 +78,7 @@ fn setup( MeshMaterial3d(materials.add(StandardMaterial { uv_transform: Affine2::from_scale(Vec2::new(2., 2.)), base_color_texture: Some(asset_server.load_with_settings( - "desk_uastc_hdr_4x4_mips_10.basisu_ktx2", + "desk_uastc_hdr_4x4_mips_10.basisu.ktx2", |s: &mut BasisuLoaderSettings| { s.force_transcode_target = Some(TextureFormat::Rgb9e5Ufloat); s.sampler = @@ -100,7 +100,7 @@ fn setup( Mesh3d(meshes.add(Rectangle::new(1.0, 1.0).mesh().build())), MeshMaterial3d(materials.add(StandardMaterial { base_color_texture: Some(asset_server.load_with_settings( - "alpha0_etc1s.basisu_ktx2", + "alpha0_etc1s.basisu.ktx2", |s: &mut BasisuLoaderSettings| { s.channel_type_hint = bevy_basisu_loader::ChannelType::Rg; }, @@ -115,7 +115,7 @@ fn setup( commands.spawn(( ImageNode { - image: asset_server.load("wikipedia_xuastc_ldr_6x6.basisu_ktx2"), + image: asset_server.load("wikipedia_xuastc_ldr_6x6.basisu.ktx2"), ..Default::default() }, Node { @@ -131,7 +131,7 @@ fn setup( commands.spawn(( ImageNode { - image: asset_server.load("kodim20_astc_ldr_8x8.basisu_ktx2"), + image: asset_server.load("kodim20_astc_ldr_8x8.basisu.ktx2"), ..Default::default() }, Node { diff --git a/src/lib.rs b/src/lib.rs index 14eb9f1..5a6457b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,17 +7,21 @@ pub use loader::*; /// Provides a loader for Basis Universal KTX2 textures. /// -/// The file extension must be `.basisu_ktx2` to use this loader. Supports KTX2 UASTC/ETC1S format. Zstd supercompression is supported even if bevy's zstd feature is disabled. No support for `.basis` files. +/// The file extension must be `.basisu.ktx2` to use this loader. Supports KTX2 UASTC/ETC1S format. Zstd supercompression is supported even if bevy's zstd feature is disabled. No support for `.basis` files. /// /// Transcode Target Selection: -/// - ETC1S: Bc7Rgba/Bc5Rg/Bc4R > Etc2Rgba8/Etc2Rgb8/EacRg11/EacR11 > Rgba8 -/// - UASTC LDR: Astc > Bc7Rgba > Etc2Rgba8/Etc2Rgb8/EacRg11/EacR11 > Rgba8 -/// - UASTC HDR: Astc > Bc6hRgbUfloat > Rgba16Float +/// +/// | BasisU format | target selection | +/// | ------------------------------ | -------------------------------------------------------------- | +/// | ETC1S | Bc7Rgba/Bc5Rg/Bc4R > Etc2Rgba8/Etc2Rgb8/EacRg11/EacR11 > Rgba8 | +/// | UASTC_LDR, ASTC_LDR, XUASTC_LDR| Astc > Bc7Rgba > Etc2Rgba8/Etc2Rgb8/EacRg11/EacR11 > Rgba8 | +/// | UASTC_HDR, ASTC_HDR | Astc > Bc6hRgbUfloat > Rgba16Float | +/// pub struct BasisuLoaderPlugin; impl Plugin for BasisuLoaderPlugin { fn build(&self, app: &mut App) { - app.preregister_asset_loader::(&["basisu_ktx2"]) + app.preregister_asset_loader::(&["basisu.ktx2"]) .add_systems(PreStartup, || { #[cfg(all( target_arch = "wasm32", diff --git a/src/loader.rs b/src/loader.rs index 61a1886..51c9c91 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -222,7 +222,7 @@ impl AssetLoader for BasisuLoader { } fn extensions(&self) -> &[&str] { - &["basisu_ktx2"] + &["basisu.ktx2"] } } diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..a79be43 --- /dev/null +++ b/typos.toml @@ -0,0 +1,12 @@ +[files] +extend-exclude = [ + "*.pbxproj", # metadata file + "*.patch", # Automatically generated files that should not be manually modified. + "*.bin", # Binary files + ".git/", # Version control files + "vendor/basis_universal/*", # BasisU source code +] +ignore-hidden = false + +[default] +locale = "en-us" From b8ab37016ef87bfca3d41b4a60d0f2a7467012ce Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Mon, 9 Feb 2026 18:19:03 +0800 Subject: [PATCH 2/4] Add toml, typos, doc check to CI --- .cargo/config.toml | 2 -- .github/workflows/ci.yml | 16 +++++++++------- .github/workflows/ci_minimal.yml | 7 +++++-- .github/workflows/release.yml | 5 ++--- .github/workflows/static.yml | 7 +++---- 5 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index acc4011..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[target.wasm32-unknown-unknown] -rustflags = ["-Ctarget-feature=+simd128"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bb3458..b43730f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,6 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - name: Install taplo run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - name: Run Taplo @@ -42,8 +40,6 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - name: Check for typos uses: crate-ci/typos@ad3053d3adbcce7f2e3c60fd4ddfc239787d1eff # v1.43.2 - name: Typos info @@ -59,7 +55,7 @@ jobs: name: Build linux,wasm runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true @@ -83,13 +79,19 @@ jobs: - name: Clippy run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - name: Build + - name: Doc + run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going + + - name: Build linux run: cargo build --verbose - name: Build basisu vendor wasm run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -flto=full" --wasm-opt-flags="-Os" - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: path: crates/basisu_sys/wasm/ + + - name: Build wasm + run: cargo build --target wasm32-unknown-unknown diff --git a/.github/workflows/ci_minimal.yml b/.github/workflows/ci_minimal.yml index dd8b736..6d481a2 100644 --- a/.github/workflows/ci_minimal.yml +++ b/.github/workflows/ci_minimal.yml @@ -25,7 +25,7 @@ jobs: os: [macos-latest, windows-latest] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true @@ -37,6 +37,9 @@ jobs: - name: Clippy run: cargo clippy -- -D warnings + - name: Doc + run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going + - name: Build run: cargo build --verbose @@ -44,7 +47,7 @@ jobs: name: Build android runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd9349a..dcd4b5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,8 +30,7 @@ jobs: name: Release ${{ (github.event_name == 'workflow_dispatch' && inputs.dry_run && '(Dry Run)') || '' }} runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true @@ -53,7 +52,7 @@ jobs: run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os" - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: path: | crates/basisu_sys/wasm/basisu_vendor.js diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 19b279a..4d0be72 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -32,8 +32,7 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true @@ -61,7 +60,7 @@ jobs: run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os" - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: path: crates/basisu_sys/wasm/ @@ -78,7 +77,7 @@ jobs: uses: actions/configure-pages@v5 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: web/ From fe505d775d80e6acb6e34cc3ce717aa6a19618b4 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Mon, 9 Feb 2026 18:46:55 +0800 Subject: [PATCH 3/4] Explicitly pass emcc flags to cli --- .github/workflows/ci.yml | 5 ++--- .github/workflows/release.yml | 3 +-- .github/workflows/static.yml | 5 ++--- README.md | 2 +- crates/basisu_sys/build.rs | 1 - crates/basisu_sys/src/bin/build_wasm_cli.rs | 9 +-------- 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b43730f..958e9ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,12 +86,11 @@ jobs: run: cargo build --verbose - name: Build basisu vendor wasm - run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -flto=full" --wasm-opt-flags="-Os" - + run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int" - name: Upload artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: path: crates/basisu_sys/wasm/ - name: Build wasm - run: cargo build --target wasm32-unknown-unknown + run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo build --target wasm32-unknown-unknown diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dcd4b5f..1f36dd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,8 +49,7 @@ jobs: targets: wasm32-unknown-unknown - name: Build basisu vendor wasm - run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os" - + run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int" - name: Upload artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 4d0be72..944191a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -57,15 +57,14 @@ jobs: run: cargo binstall --force wasm-bindgen-cli - name: Build basisu vendor wasm - run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os" - + run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int" - name: Upload artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: path: crates/basisu_sys/wasm/ - name: Build - run: cargo b -p test_scene --target wasm32-unknown-unknown --profile web_release + run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo b -p test_scene --target wasm32-unknown-unknown --profile web_release - name: Wasm bindgen run: wasm-bindgen --out-name wasm_example --out-dir web/target/ --target web target/wasm32-unknown-unknown/web_release/test_scene.wasm diff --git a/README.md b/README.md index 9479377..5524271 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ TLDR: Just build your bevy application to `wasm32-unknown-unknown` normally. The prebuilt wasm in `crates/basisu_sys/wasm` is automatically embedded in binary when building. It was prebuilt through CI with: ```sh -cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os" +cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int" ``` ## Bevy version compatibility diff --git a/crates/basisu_sys/build.rs b/crates/basisu_sys/build.rs index 092321a..f91da41 100644 --- a/crates/basisu_sys/build.rs +++ b/crates/basisu_sys/build.rs @@ -98,7 +98,6 @@ fn compile_basisu_static() { fn gen_wasm_build_cmd() { let wasm_args = [ - "-msimd128", "-sSTRICT", "-sEXPORT_ES6", "-sINCOMING_MODULE_JS_API=wasmBinary", diff --git a/crates/basisu_sys/src/bin/build_wasm_cli.rs b/crates/basisu_sys/src/bin/build_wasm_cli.rs index ed83216..e757ab0 100644 --- a/crates/basisu_sys/src/bin/build_wasm_cli.rs +++ b/crates/basisu_sys/src/bin/build_wasm_cli.rs @@ -44,14 +44,7 @@ pub fn build_wasm_cmd() { if let Some(flags) = user_args.wasm_opt_flags { let mut wasm_opt_cmd = std::process::Command::new("wasm-opt"); - wasm_opt_cmd.args([ - "--enable-simd", - "--enable-bulk-memory-opt", - "--enable-nontrapping-float-to-int", - "wasm/basisu_vendor.wasm", - "-o", - "wasm/basisu_vendor.wasm", - ]); + wasm_opt_cmd.args(["wasm/basisu_vendor.wasm", "-o", "wasm/basisu_vendor.wasm"]); wasm_opt_cmd.args(flags.split(" ").filter(|s| !s.is_empty())); From 85be8f4d8d2d9e57a1f5e62d989da7d625a30a85 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Mon, 9 Feb 2026 19:04:33 +0800 Subject: [PATCH 4/4] Refactor CI workflows --- .github/workflows/ci.yml | 105 +++++++++++++++++-------------- .github/workflows/ci_minimal.yml | 71 --------------------- .github/workflows/linter.yml | 48 ++++++++++++++ 3 files changed, 107 insertions(+), 117 deletions(-) delete mode 100644 .github/workflows/ci_minimal.yml create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958e9ca..e26f98a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,54 +14,48 @@ concurrency: env: CARGO_TERM_COLOR: always EM_VERSION: 4.0.22 + ANDROID_NDK_VERSION: 28.1.13356709 jobs: - toml: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Install taplo - run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - - name: Run Taplo - id: taplo - run: taplo fmt --check --diff - - name: Taplo info - if: failure() - run: | - echo 'To fix toml fmt, please run `taplo fmt`.' - echo 'To check for a diff, run `taplo fmt --check --diff`.' - echo 'You can find taplo here: https://taplo.tamasfe.dev/' - echo 'Or if you use VSCode, use the `Even Better Toml` extension.' - echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml' + build-lib: + name: Build ${{matrix.os}} + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] - typos: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Check for typos - uses: crate-ci/typos@ad3053d3adbcce7f2e3c60fd4ddfc239787d1eff # v1.43.2 - - name: Typos info - if: failure() - run: | - echo 'To fix typos, please run `typos -w`' - echo 'To check for a diff, run `typos`' - echo 'You can find typos here: https://crates.io/crates/typos' - echo 'if you use VSCode, you can also install `Typos Spell Checker' - echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode' - - build-linux-wasm: - name: Build linux,wasm - runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: lfs: true - name: Install Linux dependencies + if: ${{ matrix.os == 'ubuntu-latest' }} uses: ./.github/actions/install-linux-deps + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Clippy + run: cargo clippy -- -D warnings + + - name: Doc + run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going + + - name: Build + run: cargo build --verbose + + build-wasm: + name: Build wasm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + lfs: true + - name: Install rust toolchain uses: dtolnay/rust-toolchain@master with: @@ -76,17 +70,9 @@ jobs: - name: Install wasm-opt run: wget https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-linux.tar.gz && tar -xvf binaryen-version_125-x86_64-linux.tar.gz && sudo cp binaryen-version_125/bin/wasm-opt /usr/local/bin/ && rm -r binaryen-version_125 && rm binaryen-version_125-x86_64-linux.tar.gz - - name: Clippy - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - - name: Doc - run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going - - - name: Build linux - run: cargo build --verbose - - name: Build basisu vendor wasm run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int" + - name: Upload artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: @@ -94,3 +80,30 @@ jobs: - name: Build wasm run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo build --target wasm32-unknown-unknown + + build-android: + name: Build android + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + lfs: true + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: aarch64-linux-android + + - name: Install cargo-binstall + uses: cargo-bins/cargo-binstall@v1.16.6 + + - name: Install Android NDK + run: | + sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager 'ndk;${{env.ANDROID_NDK_VERSION}}' + + - name: Install cargo-ndk + run: cargo binstall cargo-ndk + + - name: Build + run: cargo ndk -t arm64-v8a build --features bevy/android-game-activity diff --git a/.github/workflows/ci_minimal.yml b/.github/workflows/ci_minimal.yml deleted file mode 100644 index 6d481a2..0000000 --- a/.github/workflows/ci_minimal.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Rust CI Minimal - -on: - workflow_dispatch: - push: - branches: ["master"] - pull_request: - branches: ["master"] - -concurrency: - group: ${{github.workflow}}-${{github.ref}} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - ANDROID_NDK_VERSION: 28.1.13356709 - -jobs: - build-macos-windows: - name: Build ${{matrix.os}} - runs-on: ${{matrix.os}} - strategy: - fail-fast: false - matrix: - os: [macos-latest, windows-latest] - - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - lfs: true - - - name: Install rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - - - name: Clippy - run: cargo clippy -- -D warnings - - - name: Doc - run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going - - - name: Build - run: cargo build --verbose - - build-android: - name: Build android - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - lfs: true - - - name: Install rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - targets: aarch64-linux-android - - - name: Install cargo-binstall - uses: cargo-bins/cargo-binstall@v1.16.6 - - - name: Install Android NDK - run: | - sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager 'ndk;${{env.ANDROID_NDK_VERSION}}' - - - name: Install cargo-ndk - run: cargo binstall cargo-ndk - - - name: Build - run: cargo ndk -t arm64-v8a build --features bevy/android-game-activity diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..ab2715f --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,48 @@ +name: Linter + +on: + workflow_dispatch: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + toml: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Install taplo + run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo + - name: Run Taplo + id: taplo + run: taplo fmt --check --diff + - name: Taplo info + if: failure() + run: | + echo 'To fix toml fmt, please run `taplo fmt`.' + echo 'To check for a diff, run `taplo fmt --check --diff`.' + echo 'You can find taplo here: https://taplo.tamasfe.dev/' + echo 'Or if you use VSCode, use the `Even Better Toml` extension.' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml' + + typos: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Check for typos + uses: crate-ci/typos@ad3053d3adbcce7f2e3c60fd4ddfc239787d1eff # v1.43.2 + - name: Typos info + if: failure() + run: | + echo 'To fix typos, please run `typos -w`' + echo 'To check for a diff, run `typos`' + echo 'You can find typos here: https://crates.io/crates/typos' + echo 'if you use VSCode, you can also install `Typos Spell Checker' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'