Skip to content

Commit

Permalink
Move to runscript for better syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
LDprg committed May 8, 2024
1 parent 71e454f commit 59ec651
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::path::Path;
use std::process::exit;
use tokio::fs::{self, File};
use tokio::io::AsyncReadExt;
use tokio::process::Command;
use tokio_stream::StreamExt;
use tokio_util::io::StreamReader;
use url::Url;
Expand Down Expand Up @@ -187,58 +186,52 @@ async fn main() {
);

let mut options = ScriptOptions::new();

options.working_directory = Some(output.join(&file_name));

let (code, out, error) = run_script::run_script!(configure_cmd, options).unwrap();

if code != 0 {
error!("Configure failed with code: {}", code);
error!("Configure failed with error: {}", error);
fatal!("Configure failed with output: {}", out);
error!("Setup failed with code: {}", code);
error!("Setup failed with error: {}", error);
fatal!("Setup failed with output: {}", out);
}
bar_build.inc(1);

bar_build.set_message(format!(
"Building {}-{}",
config.general.name, config.source.version
));
let make = Command::new("make")
.current_dir(&output.join(&file_name))
.spawn()
.expect("failed to start build")
.wait()
.await
.expect("failed to run build");

if !make.success() {
error!("Build failed with error: {}", make.code().unwrap());
fatal!("Build command: {}", configure_cmd);
let make_cmd = config.build.setup.replace("%make", "make");

let mut options = ScriptOptions::new();
options.working_directory = Some(output.join(&file_name));

let (code, out, error) = run_script::run_script!(make_cmd, options).unwrap();
if code != 0 {
error!("Build failed with code: {}", code);
error!("Build failed with error: {}", error);
fatal!("Build failed with output: {}", out);
}
bar_build.inc(1);

bar_build.set_message(format!(
"Packaging {}-{}",
config.general.name, config.source.version
));
let make_install = Command::new("make")
.current_dir(&output.join(&file_name))
.args([
format!("DESTDIR={}", output.to_str().unwrap()).as_str(),
"install",
])
.spawn()
.expect("failed to start install")
.wait()
.await
.expect("failed to run install");

if !make_install.success() {
error!(
"Install failed with error: {}",
make_install.code().unwrap()
);
fatal!("Install command: {}", configure_cmd);
let make_install_cmd = config.build.setup.replace(
"%make",
format!("make DESTDIR={} install", output.to_str().unwrap()).trim(),
);

let mut options = ScriptOptions::new();
options.working_directory = Some(output.join(&file_name));

let (code, out, error) = run_script::run_script!(make_install_cmd, options).unwrap();
if code != 0 {
error!("Packaging failed with code: {}", code);
error!("Packaging failed with error: {}", error);
fatal!("Packaging failed with output: {}", out);
}
bar_build.inc(1);

Expand Down

0 comments on commit 59ec651

Please sign in to comment.