MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / generate_bindings

Method generate_bindings

crates/test/src/lib.rs:1224–1252  ·  view source on GitHub ↗

Generates bindings for `component` into `dir`. Runs `wit-bindgen` in aa subprocess to catch failures such as panics.

(&self, runner: &Runner, bindgen: &Bindgen, dir: &Path)

Source from the content-addressed store, hash-verified

1222 ///
1223 /// Runs `wit-bindgen` in aa subprocess to catch failures such as panics.
1224 fn generate_bindings(&self, runner: &Runner, bindgen: &Bindgen, dir: &Path) -> Result<()> {
1225 let name = match self.bindgen_name() {
1226 Some(name) => name,
1227 None => return Ok(()),
1228 };
1229 self.generate_bindings_prepare(runner, bindgen, dir)?;
1230 let mut cmd = Command::new(&runner.wit_bindgen);
1231 cmd.arg(name)
1232 .arg(&bindgen.wit_path)
1233 .arg("--world")
1234 .arg(format!("%{}", bindgen.world))
1235 .arg("--out-dir")
1236 .arg(dir);
1237
1238 match bindgen.wit_config.default_bindgen_args {
1239 Some(true) | None => {
1240 for arg in self.default_bindgen_args() {
1241 cmd.arg(arg);
1242 }
1243 }
1244 Some(false) => {}
1245 }
1246
1247 for arg in bindgen.args.iter() {
1248 cmd.arg(arg);
1249 }
1250
1251 runner.run_command(&mut cmd)
1252 }
1253
1254 /// Returns the default set of arguments that will be passed to
1255 /// `wit-bindgen`.

Callers 2

codegen_testMethod · 0.45
compile_componentMethod · 0.45

Implementers 8

rust.rscrates/test/src/rust.rs
moonbit.rscrates/test/src/moonbit.rs
c.rscrates/test/src/c.rs
cpp.rscrates/test/src/cpp.rs
go.rscrates/test/src/go.rs
wat.rscrates/test/src/wat.rs
csharp.rscrates/test/src/csharp.rs
custom.rscrates/test/src/custom.rs

Calls 6

newFunction · 0.85
run_commandMethod · 0.80
bindgen_nameMethod · 0.45
default_bindgen_argsMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected