mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
moved building to lib with Once
This commit is contained in:
parent
c8467c1a52
commit
6406834c4e
4 changed files with 37 additions and 43 deletions
|
@ -1,6 +1,35 @@
|
|||
#![cfg(test)]
|
||||
|
||||
use indoc::indoc;
|
||||
use std::sync::Once;
|
||||
|
||||
static BUILD_ONCE: Once = Once::new();
|
||||
|
||||
#[cfg(all(target_os = "linux"))]
|
||||
fn build_host() {
|
||||
use roc_build::link::preprocessed_host_filename;
|
||||
use roc_linker::build_and_preprocess_host;
|
||||
|
||||
let platform_main_roc = std::env::current_dir()
|
||||
.unwrap()
|
||||
.join("zig-platform/main.roc");
|
||||
|
||||
// tests always run on the host
|
||||
let target = target_lexicon::Triple::host();
|
||||
|
||||
// the preprocessed host is stored beside the platform's main.roc
|
||||
let preprocessed_host_path =
|
||||
platform_main_roc.with_file_name(preprocessed_host_filename(&target).unwrap());
|
||||
|
||||
build_and_preprocess_host(
|
||||
roc_mono::ir::OptLevel::Normal,
|
||||
&target,
|
||||
&platform_main_roc,
|
||||
&preprocessed_host_path,
|
||||
vec![String::from("mainForHost")],
|
||||
vec![],
|
||||
);
|
||||
}
|
||||
|
||||
fn valgrind_test(source: &str) {
|
||||
#[cfg(target_os = "linux")]
|
||||
|
@ -18,6 +47,9 @@ fn valgrind_test(source: &str) {
|
|||
fn valgrind_test_linux(source: &str) {
|
||||
use roc_cli::build::BuiltFile;
|
||||
|
||||
// the host is identical for all tests so we only want to build it once
|
||||
BUILD_ONCE.call_once(build_host);
|
||||
|
||||
let pf = std::env::current_dir()
|
||||
.unwrap()
|
||||
.join("zig-platform/main.roc");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue