(&self, runner: &mut Runner)
| 98 | } |
| 99 | |
| 100 | fn prepare(&self, runner: &mut Runner) -> Result<()> { |
| 101 | let cwd = env::current_dir()?; |
| 102 | let opts = &runner.opts.rust; |
| 103 | let dir = cwd.join(&runner.opts.artifacts).join("rust"); |
| 104 | let wit_bindgen = dir.join("wit-bindgen"); |
| 105 | |
| 106 | let wit_bindgen_dep = match &opts.rust_wit_bindgen_path { |
| 107 | Some(path) => format!("path = {:?}", cwd.join(path)), |
| 108 | None => { |
| 109 | let version = opts |
| 110 | .rust_wit_bindgen_version |
| 111 | .as_deref() |
| 112 | .unwrap_or(env!("CARGO_PKG_VERSION")); |
| 113 | format!("version = \"{version}\"") |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | super::write_if_different( |
| 118 | &wit_bindgen.join("Cargo.toml"), |
| 119 | &format!( |
| 120 | r#" |
| 121 | [package] |
| 122 | name = "tmp" |
| 123 | |
| 124 | [workspace] |
| 125 | |
| 126 | [dependencies] |
| 127 | wit-bindgen = {{ {wit_bindgen_dep}, features = ['async-spawn', 'inter-task-wakeup', 'futures-stream'] }} |
| 128 | futures = "0.3.31" |
| 129 | |
| 130 | [lib] |
| 131 | path = 'lib.rs' |
| 132 | "#, |
| 133 | ), |
| 134 | )?; |
| 135 | super::write_if_different(&wit_bindgen.join("lib.rs"), "")?; |
| 136 | |
| 137 | println!("Building `wit-bindgen` from crates.io..."); |
| 138 | runner.run_command( |
| 139 | Command::new("cargo") |
| 140 | .current_dir(&wit_bindgen) |
| 141 | .arg("build") |
| 142 | .arg("-pwit-bindgen") |
| 143 | .arg("-pfutures") |
| 144 | .arg("--target") |
| 145 | .arg(&opts.rust_target), |
| 146 | )?; |
| 147 | |
| 148 | let target_out_dir = wit_bindgen |
| 149 | .join("target") |
| 150 | .join(&opts.rust_target) |
| 151 | .join("debug"); |
| 152 | let host_out_dir = wit_bindgen.join("target/debug"); |
| 153 | let wit_bindgen_rlib = target_out_dir.join("libwit_bindgen.rlib"); |
| 154 | let futures_rlib = target_out_dir.join("libfutures.rlib"); |
| 155 | assert!(wit_bindgen_rlib.exists()); |
| 156 | assert!(futures_rlib.exists()); |
| 157 |
nothing calls this directly
no test coverage detected