Skip to content

Commit

Permalink
Support WebAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
redstrate committed Nov 1, 2024
1 parent 6e6124a commit f83b201
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ binrw = { version = "0.14", features = ["std"], default-features = false }
tracing = { version = "0.1", features = ["std"], default-features = false }

# used for zlib compression in sqpack files
libz-ng-sys = { version = "1.1" }
libz-sys = { version = "1.1" }

# nice to have features rust is lacking at the moment
modular-bitfield = "0.11"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

fn main() {
// Windows doesn't ship pkgconfig files, typically. At least in our build system.
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(target_family = "wasm")))]
system_deps::Config::new().probe().unwrap();
}
2 changes: 1 addition & 1 deletion src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::ptr::null_mut;

use libz_ng_sys::*;
use libz_sys::*;

// This module's functions are licensed under MIT from https://github.com/rust-lang/flate2-rs
mod flate2_zallocation {
Expand Down
6 changes: 3 additions & 3 deletions src/crc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2023 Joshua Goins <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later

use libz_ng_sys::z_off_t;
use libz_sys::z_off_t;
use std::ops::{Add, AddAssign, BitXor, BitXorAssign};

/// CRC used for filepath hashes in index file
Expand Down Expand Up @@ -45,11 +45,11 @@ impl Jamcrc {
}

fn crc32(crc: u32, s: &[u8]) -> u32 {
unsafe { libz_ng_sys::crc32(crc, s.as_ptr(), s.len() as u32) as u32 }
unsafe { libz_sys::crc32(crc.into(), s.as_ptr(), s.len() as u32) as u32 }
}

fn crc32_combine(crc1: u32, crc2: u32, len2: usize) -> u32 {
unsafe { libz_ng_sys::crc32_combine(crc1, crc2, len2 as z_off_t) as u32 }
unsafe { libz_sys::crc32_combine(crc1.into(), crc2.into(), len2 as z_off_t) as u32 }
}

/// CRC used for shader keys
Expand Down

0 comments on commit f83b201

Please sign in to comment.