mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-13 15:26:24 +00:00
Merge branch 'main' of https://github.com/rtfeldman/roc into ensure-roc-files
This commit is contained in:
commit
295e1c9d35
5 changed files with 63 additions and 15 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2273,6 +2273,7 @@ dependencies = [
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
"roc_command_utils",
|
"roc_command_utils",
|
||||||
"roc_constrain",
|
"roc_constrain",
|
||||||
|
"roc_debug_flags",
|
||||||
"roc_error_macros",
|
"roc_error_macros",
|
||||||
"roc_gen_dev",
|
"roc_gen_dev",
|
||||||
"roc_gen_llvm",
|
"roc_gen_llvm",
|
||||||
|
|
|
@ -12,6 +12,7 @@ roc_bitcode = { path = "../builtins/bitcode" }
|
||||||
roc_can = { path = "../can" }
|
roc_can = { path = "../can" }
|
||||||
roc_collections = { path = "../collections" }
|
roc_collections = { path = "../collections" }
|
||||||
roc_constrain = { path = "../constrain" }
|
roc_constrain = { path = "../constrain" }
|
||||||
|
roc_debug_flags = { path = "../debug_flags" }
|
||||||
roc_error_macros = { path = "../../error_macros" }
|
roc_error_macros = { path = "../../error_macros" }
|
||||||
roc_gen_dev = { path = "../gen_dev", default-features = false }
|
roc_gen_dev = { path = "../gen_dev", default-features = false }
|
||||||
roc_gen_llvm = { path = "../gen_llvm" }
|
roc_gen_llvm = { path = "../gen_llvm" }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::target::{arch_str, target_zig_str};
|
use crate::target::{arch_str, target_zig_str};
|
||||||
use libloading::{Error, Library};
|
use libloading::{Error, Library};
|
||||||
use roc_command_utils::{cargo, clang, rustup, zig};
|
use roc_command_utils::{cargo, clang, rustup, zig};
|
||||||
|
use roc_debug_flags;
|
||||||
use roc_error_macros::internal_error;
|
use roc_error_macros::internal_error;
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -1067,6 +1068,7 @@ fn link_linux(
|
||||||
"-o",
|
"-o",
|
||||||
output_path.as_path().to_str().unwrap(), // app (or app.so or app.dylib etc.)
|
output_path.as_path().to_str().unwrap(), // app (or app.so or app.dylib etc.)
|
||||||
]);
|
]);
|
||||||
|
debug_print_command(&command);
|
||||||
|
|
||||||
let output = command.spawn()?;
|
let output = command.spawn()?;
|
||||||
|
|
||||||
|
@ -1164,14 +1166,18 @@ fn link_macos(
|
||||||
output_path.to_str().unwrap(), // app
|
output_path.to_str().unwrap(), // app
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
debug_print_command(&ld_command);
|
||||||
|
|
||||||
let mut ld_child = ld_command.spawn()?;
|
let mut ld_child = ld_command.spawn()?;
|
||||||
|
|
||||||
match target.architecture {
|
match target.architecture {
|
||||||
Architecture::Aarch64(_) => {
|
Architecture::Aarch64(_) => {
|
||||||
ld_child.wait()?;
|
ld_child.wait()?;
|
||||||
let codesign_child = Command::new("codesign")
|
|
||||||
.args(["-s", "-", output_path.to_str().unwrap()])
|
let mut codesign_cmd = Command::new("codesign");
|
||||||
.spawn()?;
|
codesign_cmd.args(["-s", "-", output_path.to_str().unwrap()]);
|
||||||
|
debug_print_command(&codesign_cmd);
|
||||||
|
let codesign_child = codesign_cmd.spawn()?;
|
||||||
|
|
||||||
Ok((codesign_child, output_path))
|
Ok((codesign_child, output_path))
|
||||||
}
|
}
|
||||||
|
@ -1180,8 +1186,11 @@ fn link_macos(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_macos_version() -> String {
|
fn get_macos_version() -> String {
|
||||||
let cmd_stdout = Command::new("sw_vers")
|
let mut cmd = Command::new("sw_vers");
|
||||||
.arg("-productVersion")
|
cmd.arg("-productVersion");
|
||||||
|
debug_print_command(&cmd);
|
||||||
|
|
||||||
|
let cmd_stdout = cmd
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to execute command 'sw_vers -productVersion'")
|
.expect("Failed to execute command 'sw_vers -productVersion'")
|
||||||
.stdout;
|
.stdout;
|
||||||
|
@ -1384,15 +1393,11 @@ pub fn preprocess_host_wasm32(host_input_path: &Path, preprocessed_host_path: &P
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_build_command(mut command: Command, file_to_build: &str, flaky_fail_counter: usize) {
|
fn run_build_command(mut command: Command, file_to_build: &str, flaky_fail_counter: usize) {
|
||||||
let mut command_string = std::ffi::OsString::new();
|
let command_string = stringify_command(&command);
|
||||||
command_string.push(command.get_program());
|
let cmd_str = &command_string;
|
||||||
|
roc_debug_flags::dbg_do!(roc_debug_flags::ROC_PRINT_BUILD_COMMANDS, {
|
||||||
for arg in command.get_args() {
|
print_command_str(cmd_str);
|
||||||
command_string.push(" ");
|
});
|
||||||
command_string.push(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
let cmd_str = command_string.to_str().unwrap();
|
|
||||||
let cmd_output = command.output().unwrap();
|
let cmd_output = command.output().unwrap();
|
||||||
let max_flaky_fail_count = 10;
|
let max_flaky_fail_count = 10;
|
||||||
|
|
||||||
|
@ -1430,3 +1435,41 @@ fn run_build_command(mut command: Command, file_to_build: &str, flaky_fail_count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stringify a command for printing
|
||||||
|
/// e.g. `HOME=~ zig build-exe foo.zig -o foo`
|
||||||
|
fn stringify_command(cmd: &Command) -> String {
|
||||||
|
let mut command_string = std::ffi::OsString::new();
|
||||||
|
|
||||||
|
for (name, opt_val) in cmd.get_envs() {
|
||||||
|
command_string.push(name);
|
||||||
|
command_string.push("=");
|
||||||
|
if let Some(val) = opt_val {
|
||||||
|
command_string.push(val);
|
||||||
|
} else {
|
||||||
|
command_string.push("''");
|
||||||
|
}
|
||||||
|
command_string.push(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
command_string.push(cmd.get_program());
|
||||||
|
|
||||||
|
for arg in cmd.get_args() {
|
||||||
|
command_string.push(" ");
|
||||||
|
command_string.push(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
String::from(command_string.to_str().unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
fn print_command_str(s: &str) {
|
||||||
|
println!("\nRoc build command:\n{}\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn debug_print_command(_cmd: &Command) {
|
||||||
|
// This debug macro is compiled out in release mode, so the argument is unused
|
||||||
|
roc_debug_flags::dbg_do!(roc_debug_flags::ROC_PRINT_BUILD_COMMANDS, {
|
||||||
|
print_command_str(&stringify_command(_cmd));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -173,4 +173,7 @@ flags! {
|
||||||
|
|
||||||
/// Don't build and use the subs cache (speeds up compilation of load and previous crates)
|
/// Don't build and use the subs cache (speeds up compilation of load and previous crates)
|
||||||
ROC_SKIP_SUBS_CACHE
|
ROC_SKIP_SUBS_CACHE
|
||||||
|
|
||||||
|
/// Print out shell commands used to buid the Roc and host code
|
||||||
|
ROC_PRINT_BUILD_COMMANDS
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/builtins/List#join">List.first</a></td>
|
<td><a href="/builtins/List#first">List.first</a></td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<li>head</li>
|
<li>head</li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue