diff --git a/crates/cli_utils/Cargo.toml b/crates/cli_utils/Cargo.toml index 2530866df5..beec8f917b 100644 --- a/crates/cli_utils/Cargo.toml +++ b/crates/cli_utils/Cargo.toml @@ -14,6 +14,7 @@ roc_load = { path = "../compiler/load" } roc_module = { path = "../compiler/module" } roc_reporting = { path = "../reporting" } roc_command_utils = { path = "../utils/command" } +copy_zig_glue = { path = "../copy_zig_glue" } bumpalo.workspace = true criterion.workspace = true diff --git a/crates/cli_utils/src/helpers.rs b/crates/cli_utils/src/helpers.rs index 6a46b2479e..7bcaeacaa5 100644 --- a/crates/cli_utils/src/helpers.rs +++ b/crates/cli_utils/src/helpers.rs @@ -14,8 +14,11 @@ use std::io::Write; use std::path::PathBuf; use std::process::{Command, ExitStatus, Stdio}; use std::sync::Mutex; +use std::sync::Once; use tempfile::NamedTempFile; +static ZIG_PLATFORM_COPY_GLUE_ONCE: Once = Once::new(); + #[derive(Debug)] pub struct Out { pub cmd_str: OsString, // command with all its arguments, for easy debugging @@ -122,6 +125,8 @@ where roc_cmd.arg(arg); } + initialize_zig_test_platforms(); + for (k, v) in extra_env { roc_cmd.env(k, v); } @@ -473,3 +478,12 @@ pub fn known_bad_file(file_name: &str) -> PathBuf { path } + +/// Copies the glue source files for zig platforms from the roc builtins +/// this is only temporary, see comments in crates/copy_zig_glue/src/main.rs +fn initialize_zig_test_platforms() { + ZIG_PLATFORM_COPY_GLUE_ONCE.call_once(|| { + // initialization code here + copy_zig_glue::copy_zig_glue(); + }); +}