mirror of
https://github.com/lexmount/moli.git
synced 2026-11-13 08:08:10 +00:00
Parse the vendored schema with serde_json::Value and serialize compact JSON in build.rs. Embed the generated bytes without request-time processing. Verify the embedded protocol matches the complete vendored schema. Validation on the unchanged final source tree: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast (20,505 passed, 18 existing skips).
15 lines
728 B
Rust
15 lines
728 B
Rust
use std::{env, fs, path::PathBuf};
|
|
|
|
const PROTOCOL_SOURCE: &str = "../vendor/v8-152.2.0/v8/include/js_protocol-1.3.json";
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed={PROTOCOL_SOURCE}");
|
|
let source = fs::read(PROTOCOL_SOURCE).expect("read vendored CDP protocol metadata");
|
|
let protocol: serde_json::Value =
|
|
serde_json::from_slice(&source).expect("parse vendored CDP protocol metadata");
|
|
let compact = serde_json::to_vec(&protocol).expect("serialize compact CDP protocol metadata");
|
|
let destination = PathBuf::from(env::var_os("OUT_DIR").expect("Cargo build output directory"))
|
|
.join("cdp-protocol.json");
|
|
fs::write(destination, compact).expect("write compact CDP protocol metadata");
|
|
}
|