pub struct Build { /* private fields */ }Expand description
Selects which artifacts to generate from an ExtensionSpec.
Each emit_* method enables an output; nothing is written until
generate is called. Most build.rs files only need
Build::new(ext).emit().generate().
Implementations§
Source§impl Build
impl Build
Sourcepub fn new(extension: ExtensionSpec) -> Self
pub fn new(extension: ExtensionSpec) -> Self
Creates a build for the given extension with no outputs enabled.
Sourcepub fn emit(self) -> Self
pub fn emit(self) -> Self
Enables the default outputs: shorthand for
emit_rust_guest followed by
emit_abi_json.
Sourcepub fn emit_defaults(self) -> Self
pub fn emit_defaults(self) -> Self
Alias for emit.
Sourcepub fn emit_rust_guest(self) -> Self
pub fn emit_rust_guest(self) -> Self
Enables the Rust guest module, written to
$OUT_DIR/ext_<name>.rs for consumption via include!.
Sourcepub fn emit_abi_json(self) -> Self
pub fn emit_abi_json(self) -> Self
Enables the ABI JSON contract, written to
$OUT_DIR/<name>.abi.json. Use
emit_abi_json_to when a stable,
build-independent path is needed.
Sourcepub fn emit_abi_json_to(self, path: impl Into<PathBuf>) -> Self
pub fn emit_abi_json_to(self, path: impl Into<PathBuf>) -> Self
Additionally writes the ABI JSON to the given path (parent directories are created). Useful for checking the contract into the repo or feeding it to the CLI from a stable location.
Sourcepub fn emit_java_host(
self,
out_dir: impl Into<PathBuf>,
package: impl Into<String>,
) -> Self
pub fn emit_java_host( self, out_dir: impl Into<PathBuf>, package: impl Into<String>, ) -> Self
Enables the Java (Chicory) host adapter, written as
<Name>HostFunctions.java under out_dir in the given package’s
directory layout. Note this writes directly into the given Java
source tree from build.rs; running the boomslang-hostgen CLI
against the emitted ABI JSON after the build is generally preferable.
Sourcepub fn emit_rust_host(self, out_dir: impl Into<PathBuf>) -> Self
pub fn emit_rust_host(self, out_dir: impl Into<PathBuf>) -> Self
Enables the Rust (Wasmtime) host adapter, written as
host_<name>.rs under out_dir. As with
emit_java_host, generating hosts via the
CLI after the build is generally preferable.
Sourcepub fn generate(self) -> Result<(), Box<dyn Error>>
pub fn generate(self) -> Result<(), Box<dyn Error>>
Validates the manifest and writes all enabled outputs.
Validation enforces the exact ABI version (currently 1), ASCII
identifier rules for all names, the reserved __async_* function
names, and that async functions return Type::String.
Guest and default ABI JSON outputs require the OUT_DIR environment
variable, which Cargo sets when running build.rs.