mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
tweaks
This commit is contained in:
parent
7bc6817a30
commit
5149adb2c8
2 changed files with 55 additions and 13 deletions
|
@ -3,6 +3,7 @@ extern crate pretty_assertions;
|
||||||
|
|
||||||
extern crate bumpalo;
|
extern crate bumpalo;
|
||||||
extern crate inlinable_string;
|
extern crate inlinable_string;
|
||||||
|
extern crate roc_build;
|
||||||
extern crate roc_collections;
|
extern crate roc_collections;
|
||||||
extern crate roc_load;
|
extern crate roc_load;
|
||||||
extern crate roc_module;
|
extern crate roc_module;
|
||||||
|
@ -19,6 +20,28 @@ mod cli_run {
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use std::sync::Once;
|
||||||
|
|
||||||
|
static INIT: Once = Once::new();
|
||||||
|
|
||||||
|
pub fn initialize() {
|
||||||
|
let env_path = "";
|
||||||
|
let env_home = "";
|
||||||
|
let emit_bin = "-femit-bin=examples/benchmarks/platform/host.o";
|
||||||
|
let zig_host_src = "examples/benchmarks/platform/host.zig";
|
||||||
|
let zig_str_path = "compiler/builtins/bitcodes/src/str.zig";
|
||||||
|
|
||||||
|
INIT.call_once_force(|_| {
|
||||||
|
roc_build::link::try_build_zig_host(
|
||||||
|
env_path,
|
||||||
|
env_home,
|
||||||
|
emit_bin,
|
||||||
|
zig_host_src,
|
||||||
|
zig_str_path,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
const ALLOW_VALGRIND: bool = true;
|
const ALLOW_VALGRIND: bool = true;
|
||||||
|
|
||||||
|
@ -129,6 +152,9 @@ mod cli_run {
|
||||||
let example = $example;
|
let example = $example;
|
||||||
let file_name = example_file(dir_name, example.filename);
|
let file_name = example_file(dir_name, example.filename);
|
||||||
|
|
||||||
|
// make sure the `benchmarks` platform is already compiled
|
||||||
|
initialize();
|
||||||
|
|
||||||
// Check with and without optimizations
|
// Check with and without optimizations
|
||||||
check_output_with_stdin(
|
check_output_with_stdin(
|
||||||
&file_name,
|
&file_name,
|
||||||
|
@ -249,8 +275,8 @@ mod cli_run {
|
||||||
macro_rules! benchmarks {
|
macro_rules! benchmarks {
|
||||||
($($test_name:ident => $benchmark:expr,)+) => {
|
($($test_name:ident => $benchmark:expr,)+) => {
|
||||||
$(
|
$(
|
||||||
|
// #[serial(benchmark)]
|
||||||
#[test]
|
#[test]
|
||||||
#[serial(benchmark)]
|
|
||||||
fn $test_name() {
|
fn $test_name() {
|
||||||
let benchmark = $benchmark;
|
let benchmark = $benchmark;
|
||||||
let file_name = examples_dir("benchmarks").join(benchmark.filename);
|
let file_name = examples_dir("benchmarks").join(benchmark.filename);
|
||||||
|
@ -389,6 +415,7 @@ mod cli_run {
|
||||||
|
|
||||||
// We test benchmarks separately
|
// We test benchmarks separately
|
||||||
if example_dir_name != "benchmarks" {
|
if example_dir_name != "benchmarks" {
|
||||||
|
dbg!(&examples_dir, &example_dir_name);
|
||||||
all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| {
|
all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| {
|
||||||
panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name);
|
panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name);
|
||||||
});
|
});
|
||||||
|
@ -425,9 +452,15 @@ mod cli_run {
|
||||||
|
|
||||||
// Only app modules in this directory are considered benchmarks.
|
// Only app modules in this directory are considered benchmarks.
|
||||||
if "app".as_bytes() == buf {
|
if "app".as_bytes() == buf {
|
||||||
all_benchmarks.remove(benchmark_file_name.as_str()).unwrap_or_else(|| {
|
match all_benchmarks.remove(benchmark_file_name.as_str()) {
|
||||||
panic!("The benchmark {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", benchmarks_dir, benchmark_file_name);
|
Some(_) => {}
|
||||||
});
|
None => {
|
||||||
|
eprintln!(
|
||||||
|
r"The benchmark {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!",
|
||||||
|
benchmarks_dir, benchmark_file_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,24 @@ fn find_zig_str_path() -> PathBuf {
|
||||||
panic!("cannot find `str.zig`")
|
panic!("cannot find `str.zig`")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
pub fn try_build_zig_host(
|
||||||
fn build_zig_host(
|
|
||||||
env_path: &str,
|
env_path: &str,
|
||||||
env_home: &str,
|
env_home: &str,
|
||||||
emit_bin: &str,
|
emit_bin: &str,
|
||||||
zig_host_src: &str,
|
zig_host_src: &str,
|
||||||
zig_str_path: &str,
|
zig_str_path: &str,
|
||||||
) -> Output {
|
) -> Result<Output, std::io::Error> {
|
||||||
|
build_zig_host_help(env_path, env_home, emit_bin, zig_host_src, zig_str_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
fn build_zig_host_help(
|
||||||
|
env_path: &str,
|
||||||
|
env_home: &str,
|
||||||
|
emit_bin: &str,
|
||||||
|
zig_host_src: &str,
|
||||||
|
zig_str_path: &str,
|
||||||
|
) -> Result<Output, std::io::Error> {
|
||||||
Command::new("zig")
|
Command::new("zig")
|
||||||
.env_clear()
|
.env_clear()
|
||||||
.env("PATH", env_path)
|
.env("PATH", env_path)
|
||||||
|
@ -82,17 +92,16 @@ fn build_zig_host(
|
||||||
"c",
|
"c",
|
||||||
])
|
])
|
||||||
.output()
|
.output()
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn build_zig_host(
|
pub fn build_zig_host_help(
|
||||||
env_path: &str,
|
env_path: &str,
|
||||||
env_home: &str,
|
env_home: &str,
|
||||||
emit_bin: &str,
|
emit_bin: &str,
|
||||||
zig_host_src: &str,
|
zig_host_src: &str,
|
||||||
zig_str_path: &str,
|
zig_str_path: &str,
|
||||||
) -> Output {
|
) -> Result<Output, std::io::Error> {
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
// Run `zig env` to find the location of zig's std/ directory
|
// Run `zig env` to find the location of zig's std/ directory
|
||||||
|
@ -155,7 +164,6 @@ fn build_zig_host(
|
||||||
"c",
|
"c",
|
||||||
])
|
])
|
||||||
.output()
|
.output()
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rebuild_host(host_input_path: &Path) {
|
pub fn rebuild_host(host_input_path: &Path) {
|
||||||
|
@ -185,13 +193,14 @@ pub fn rebuild_host(host_input_path: &Path) {
|
||||||
validate_output(
|
validate_output(
|
||||||
"host.zig",
|
"host.zig",
|
||||||
"zig",
|
"zig",
|
||||||
build_zig_host(
|
try_build_zig_host(
|
||||||
&env_path,
|
&env_path,
|
||||||
&env_home,
|
&env_home,
|
||||||
&emit_bin,
|
&emit_bin,
|
||||||
zig_host_src.to_str().unwrap(),
|
zig_host_src.to_str().unwrap(),
|
||||||
zig_str_path.to_str().unwrap(),
|
zig_str_path.to_str().unwrap(),
|
||||||
),
|
)
|
||||||
|
.unwrap(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Compile host.c
|
// Compile host.c
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue