Skip to main content

Crate witforge_build

Crate witforge_build 

Source
Expand description

Build-script (build.rs) helper for compiling witforge-generated .proto schemas with protox, prost-build, and optional pbjson-build.

witforge-build removes repetitive build.rs boilerplate:

  • Discovers every .proto file under proto_dir in deterministic sorted order while refusing symlinks.
  • Emits cargo:rerun-if-changed directives for proto_dir, every subdirectory, and every discovered .proto file.
  • Compiles descriptors with pure-Rust protox (no external protoc binary required) and generates Rust types via prost-build (plus optional pbjson-build behind the pbjson feature).
  • Writes a consistent prost_include.rs include file whose module layout matches witforge glue for both standalone contracts (v<major>::*) and contracts with deps/ (<namespace>::<package>::v<major>::*), without rewriting unchanged files.

§Example

fn main() -> Result<(), Box<dyn std::error::Error>> {
    witforge_build::compile_protos("src/generated/proto")?;
    Ok(())
}

Structs§

BuildOutput
Summary of the files discovered and generated by Config::compile_protos.
Config
Builder configuring how witforge-generated .proto files are compiled.

Enums§

Error
Error returned when discovering or compiling witforge-generated .proto files fails.

Constants§

DEFAULT_INCLUDE_FILE
Default filename written inside OUT_DIR that includes all generated protobuf modules.

Functions§

compile_protos
Discover and compile every .proto file under proto_dir with default Config.
discover_protos
Discover every .proto file under proto_dir in deterministic sorted order.