(runner: &Runner, compile: &Compile<'_>, compiler: PathBuf)
| 100 | } |
| 101 | |
| 102 | fn compile(runner: &Runner, compile: &Compile<'_>, compiler: PathBuf) -> Result<()> { |
| 103 | let config = compile.component.deserialize_lang_config::<LangConfig>()?; |
| 104 | |
| 105 | // Compile the C-based bindings to an object file. |
| 106 | let bindings_object = compile.output.with_extension("bindings.o"); |
| 107 | let mut cmd = Command::new(clang(runner)); |
| 108 | cmd.arg( |
| 109 | compile |
| 110 | .bindings_dir |
| 111 | .join(format!("{}.c", compile.component.bindgen.world)), |
| 112 | ) |
| 113 | .arg("-I") |
| 114 | .arg(&compile.bindings_dir) |
| 115 | .arg("-Wall") |
| 116 | .arg("-Wextra") |
| 117 | .arg("-Werror") |
| 118 | .arg("-Wno-unused-parameter") |
| 119 | .arg("-c") |
| 120 | .arg("-o") |
| 121 | .arg(&bindings_object); |
| 122 | for flag in Vec::from(config.cflags.clone()) { |
| 123 | cmd.arg(flag); |
| 124 | } |
| 125 | runner.run_command(&mut cmd)?; |
| 126 | |
| 127 | // Now compile the runner's source code to with the above object and the |
| 128 | // component-type object into a final component. |
| 129 | let output = compile.output.with_extension("core.wasm"); |
| 130 | let mut cmd = Command::new(compiler); |
| 131 | cmd.arg(&compile.component.path) |
| 132 | .arg(&bindings_object) |
| 133 | .arg(compile.bindings_dir.join(format!( |
| 134 | "{}_component_type.o", |
| 135 | compile.component.bindgen.world |
| 136 | ))) |
| 137 | .arg("-I") |
| 138 | .arg(&compile.bindings_dir) |
| 139 | .arg("-Wall") |
| 140 | .arg("-Wextra") |
| 141 | .arg("-Werror") |
| 142 | .arg("-Wc++-compat") |
| 143 | .arg("-Wno-unused-parameter") |
| 144 | .arg("-g") |
| 145 | .arg("-o") |
| 146 | .arg(&output); |
| 147 | for flag in Vec::from(config.cflags) { |
| 148 | cmd.arg(flag); |
| 149 | } |
| 150 | for flag in Vec::from(config.ldflags) { |
| 151 | cmd.arg(flag); |
| 152 | } |
| 153 | cmd.arg("-mexec-model=reactor"); |
| 154 | if produces_component(runner) { |
| 155 | cmd.arg("-Wl,--skip-wit-component"); |
| 156 | } |
| 157 | runner.run_command(&mut cmd)?; |
| 158 | |
| 159 | runner |
no test coverage detected