mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +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
|
@ -2,22 +2,10 @@
|
||||||
name = "valgrind"
|
name = "valgrind"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
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
|
[dev-dependencies]
|
||||||
[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]
|
|
||||||
roc_cli = { path = "../cli" }
|
roc_cli = { path = "../cli" }
|
||||||
cli_utils = { path = "../cli_utils" }
|
cli_utils = { path = "../cli_utils" }
|
||||||
roc_build = { path = "../compiler/build" }
|
roc_build = { path = "../compiler/build" }
|
||||||
|
|
|
@ -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() {}
|
|
|
@ -1,6 +1,35 @@
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
use indoc::indoc;
|
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) {
|
fn valgrind_test(source: &str) {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
@ -18,6 +47,9 @@ fn valgrind_test(source: &str) {
|
||||||
fn valgrind_test_linux(source: &str) {
|
fn valgrind_test_linux(source: &str) {
|
||||||
use roc_cli::build::BuiltFile;
|
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()
|
let pf = std::env::current_dir()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.join("zig-platform/main.roc");
|
.join("zig-platform/main.roc");
|
||||||
|
|
2
crates/valgrind/zig-platform/.gitignore
vendored
Normal file
2
crates/valgrind/zig-platform/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dynhost
|
||||||
|
libapp.so
|
Loading…
Add table
Add a link
Reference in a new issue