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)
| 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`. |
no test coverage detected