MCPcopy Create free account
hub / github.com/faern/rustscript / compile

Function compile

src/scriptbuilder.rs:160–181  ·  view source on GitHub ↗
(project_dir: P, verbose: bool)

Source from the content-addressed store, hash-verified

158}
159
160fn compile<P: AsRef<Path>>(project_dir: P, verbose: bool) -> Result<()> {
161 let mut command = Command::new("cargo");
162 command.arg("build")
163 .arg("--release")
164 .current_dir(project_dir);
165 if verbose {
166 command.stdout(Stdio::inherit()).stderr(Stdio::inherit());
167 } else {
168 command.stdout(Stdio::piped()).stderr(Stdio::piped());
169 }
170 let mut child = command.spawn().chain_err(|| "Unable to start the compiler")?;
171 let rustc_result = child.wait().chain_err(|| "cargo crashed")?;
172 if !rustc_result.success() {
173 io::copy(&mut child.stdout.unwrap(), &mut io::stdout())
174 .chain_err(|| "Unable to write compiler stdout")?;
175 io::copy(&mut child.stderr.unwrap(), &mut io::stderr())
176 .chain_err(|| "Unable to write compiler stderr")?;
177 bail!("The script did not compile successfully")
178 } else {
179 Ok(())
180 }
181}

Callers 1

build_script_crateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected