Skip to content

Commit 0fccae1

Browse files
committed
Add experimental wasm bindings
Published to npm as objdiff-wasm
1 parent 8250d26 commit 0fccae1

40 files changed

+4728
-307
lines changed

Cargo.lock

Lines changed: 19 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objdiff-cli/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "objdiff-cli"
3-
version = "2.0.0-beta.4"
3+
version = "2.0.0-beta.5"
44
edition = "2021"
55
rust-version = "1.70"
66
authors = ["Luke Street <[email protected]>"]
@@ -20,7 +20,6 @@ crossterm = "0.27.0"
2020
enable-ansi-support = "0.2.1"
2121
memmap2 = "0.9.4"
2222
objdiff-core = { path = "../objdiff-core", features = ["all"] }
23-
pbjson = "0.7.0"
2423
prost = "0.13.1"
2524
ratatui = "0.26.2"
2625
rayon = "1.10.0"
@@ -30,8 +29,3 @@ supports-color = "3.0.0"
3029
time = { version = "0.3.36", features = ["formatting", "local-offset"] }
3130
tracing = "0.1.40"
3231
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
33-
34-
[build-dependencies]
35-
prost-build = "0.13.1"
36-
pbjson-build = "0.7.0"
37-

objdiff-cli/build.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::path::{Path, PathBuf};
2-
31
fn main() {
42
let output = std::process::Command::new("git")
53
.args(["rev-parse", "HEAD"])
@@ -8,55 +6,4 @@ fn main() {
86
let rev = String::from_utf8(output.stdout).expect("Failed to parse git output");
97
println!("cargo:rustc-env=GIT_COMMIT_SHA={rev}");
108
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
11-
12-
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("protos");
13-
let descriptor_path = root.join("proto_descriptor.bin");
14-
println!("cargo:rerun-if-changed={}", descriptor_path.display());
15-
let descriptor_mtime = std::fs::metadata(&descriptor_path)
16-
.map(|m| m.modified().unwrap())
17-
.unwrap_or(std::time::SystemTime::UNIX_EPOCH);
18-
let mut run_protoc = false;
19-
let proto_files = vec![root.join("report.proto")];
20-
for proto_file in &proto_files {
21-
println!("cargo:rerun-if-changed={}", proto_file.display());
22-
let mtime = match std::fs::metadata(proto_file) {
23-
Ok(m) => m.modified().unwrap(),
24-
Err(e) => panic!("Failed to stat proto file {}: {:?}", proto_file.display(), e),
25-
};
26-
if mtime > descriptor_mtime {
27-
run_protoc = true;
28-
}
29-
}
30-
31-
fn prost_config(descriptor_path: &Path, run_protoc: bool) -> prost_build::Config {
32-
let mut config = prost_build::Config::new();
33-
config.file_descriptor_set_path(descriptor_path);
34-
// If our cached descriptor is up-to-date, we don't need to run protoc.
35-
// This is helpful so that users don't need to have protoc installed
36-
// unless they're updating the protos.
37-
if !run_protoc {
38-
config.skip_protoc_run();
39-
}
40-
config
41-
}
42-
if let Err(e) =
43-
prost_config(&descriptor_path, run_protoc).compile_protos(&proto_files, &[root.as_path()])
44-
{
45-
if e.kind() == std::io::ErrorKind::NotFound && e.to_string().contains("protoc") {
46-
eprintln!("protoc not found, skipping protobuf compilation");
47-
prost_config(&descriptor_path, false)
48-
.compile_protos(&proto_files, &[root.as_path()])
49-
.expect("Failed to compile protos");
50-
} else {
51-
panic!("Failed to compile protos: {e:?}");
52-
}
53-
}
54-
55-
let descriptor_set = std::fs::read(descriptor_path).expect("Failed to read descriptor set");
56-
pbjson_build::Builder::new()
57-
.register_descriptors(&descriptor_set)
58-
.expect("Failed to register descriptors")
59-
.preserve_proto_field_names()
60-
.build(&[".objdiff"])
61-
.expect("Failed to build pbjson");
629
}
-7.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)