use md5 instead

This commit is contained in:
Jonathan Kelley 2024-03-06 18:43:07 -08:00
parent f65ded2cb4
commit f073322bb3
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
4 changed files with 15 additions and 16 deletions

1
Cargo.lock generated
View file

@ -2557,6 +2557,7 @@ dependencies = [
"dioxus-core",
"dioxus-html",
"js-sys",
"md5",
"serde",
"sledgehammer_bindgen",
"sledgehammer_utils",

View file

@ -24,6 +24,9 @@ serde = { version = "1.0", features = ["derive"], optional = true }
dioxus-core = { workspace = true, optional = true }
dioxus-html = { workspace = true, optional = true }
[build-dependencies]
md5 = "0.7.0"
[features]
default = []
serialize = ["serde"]

View file

@ -8,12 +8,12 @@ fn main() {
let hash = hash_ts_files();
// If the hash matches the one on disk, we're good and don't need to update bindings
let expected = include_str!("src/js/hash.txt").trim();
let expected = include_str!("./src/js/hash.txt").trim();
if expected == hash.to_string() {
return;
}
panic!("Hashes match, no need to update bindings. {expected} != {hash}",);
// panic!("Hashes match, no need to update bindings. {expected} != {hash}",);
// Otherwise, generate the bindings and write the new hash to disk
// Generate the bindings for both native and web
@ -25,24 +25,19 @@ fn main() {
}
/// Hashes the contents of a directory
fn hash_ts_files() -> u128 {
let mut out = 0;
fn hash_ts_files() -> String {
let mut out = "".to_string();
let files: &[&[u8]] = &[
include_bytes!("src/ts/common.ts"),
include_bytes!("src/ts/native.ts"),
include_bytes!("src/ts/core.ts"),
let files = &[
include_str!("./src/ts/common.ts"),
include_str!("./src/ts/native.ts"),
include_str!("./src/ts/core.ts"),
];
// Let's make the dumbest hasher by summing the bytes of the files
// The location is multiplied by the byte value to make sure that the order of the bytes matters
let mut idx = 0;
for file in files {
for byte in file.iter() {
idx += 1;
out += (*byte as u128) * (idx as u128);
}
out = format!("{out}{:?}", md5::compute(file));
}
out
}

View file

@ -1 +1 @@
12705686530
3bd5a1310ebd728bdedb486881d5ad99151cf07b0006de52240dfd757ea3353e90df122a7ae681f33ff620cf15c47a20