Files
moli/moli-protocol-cdp/build.rs
ldm0 c5d91d50d0 perf(cdp): compact protocol metadata at build time
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).
2026-10-21 23:16:23 +08:00

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");
}