fixed macos retry zig

This commit is contained in:
Anton-4 2022-11-01 09:32:36 +01:00
parent 4ec43d9964
commit 05d48ec5d4
No known key found for this signature in database
GPG key ID: A13F4A6E21141925

View file

@ -1,7 +1,5 @@
use roc_utils::zig;
use std::convert::AsRef;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::io;
use std::path::Path;
@ -89,12 +87,13 @@ fn generate_object_file(bitcode_path: &Path, zig_object: &str, object_file_name:
println!("Compiling zig object `{}` to: {}", zig_object, src_obj);
if !DEBUG {
run_command(
&bitcode_path,
zig(),
&["build", zig_object, "-Drelease=true"],
0,
);
let mut zig_cmd = zig();
zig_cmd
.current_dir(&bitcode_path)
.args(["build", zig_object, "-Drelease=true"]);
run_command(zig_cmd, 0);
println!("Moving zig object `{}` to: {}", zig_object, dest_obj);
@ -124,12 +123,13 @@ fn generate_bc_file(bitcode_path: &Path, zig_object: &str, file_name: &str) {
#[cfg(target_os = "macos")]
let _ = fs::remove_dir_all("./bitcode/zig-cache");
run_command(
&bitcode_path,
zig(),
&["build", zig_object, "-Drelease=true"],
0,
);
let mut zig_cmd = zig();
zig_cmd
.current_dir(&bitcode_path)
.args(["build", zig_object, "-Drelease=true"]);
run_command(zig_cmd, 0);
}
pub fn get_lib_dir() -> PathBuf {
@ -198,20 +198,10 @@ fn cp_unless_zig_cache(src_dir: &Path, target_dir: &Path) -> io::Result<()> {
Ok(())
}
fn run_command<S, I: Copy, P: AsRef<Path> + Copy>(
path: P,
mut command: Command,
args: I,
flaky_fail_counter: usize,
) where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let full_command = command.current_dir(path).args(args);
fn run_command(mut command: Command, flaky_fail_counter: usize) {
let command_str = format!("{:?}", &command);
let command_str = format!("{:?}", &full_command);
let output_result = full_command.output();
let output_result = command.output();
match output_result {
Ok(output) => match output.status.success() {
@ -229,7 +219,7 @@ fn run_command<S, I: Copy, P: AsRef<Path> + Copy>(
if flaky_fail_counter == 10 {
panic!("{} failed 10 times in a row. The following error is unlikely to be a flaky error: {}", command_str, error_str);
} else {
run_command(path, command, args, flaky_fail_counter + 1)
run_command(command, flaky_fail_counter + 1)
}
} else {
panic!("{} failed: {}", command_str, error_str);