moved building to lib with Once

This commit is contained in:
Anton-4 2023-01-10 16:48:22 +01:00
parent c8467c1a52
commit 6406834c4e
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
4 changed files with 37 additions and 43 deletions

View file

@ -2,22 +2,10 @@
name = "valgrind"
version = "0.1.0"
edition = "2021"
authors = ["The Roc Contributors"]
license = "UPL-1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
roc_cli = { path = "../cli" }
cli_utils = { path = "../cli_utils" }
roc_build = { path = "../compiler/build" }
roc_mono = { path = "../compiler/mono" }
roc_load = { path = "../compiler/load" }
roc_reporting = { path = "../reporting" }
roc_packaging = { path = "../packaging" }
bumpalo.workspace = true
target-lexicon.workspace = true
tempfile.workspace = true
indoc.workspace = true
[build-dependencies]
[dev-dependencies]
roc_cli = { path = "../cli" }
cli_utils = { path = "../cli_utils" }
roc_build = { path = "../compiler/build" }

View file

@ -1,28 +0,0 @@
#[cfg(all(target_os = "linux"))]
fn main() {
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![],
);
}
#[cfg(not(all(target_os = "linux")))]
fn main() {}

View file

@ -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");

View file

@ -0,0 +1,2 @@
dynhost
libapp.so