mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 11:22:19 +00:00
Provide roc_cache_dir everywhere
This commit is contained in:
parent
13bed30411
commit
721841fa1f
41 changed files with 303 additions and 114 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -3435,6 +3435,7 @@ dependencies = [
|
||||||
"roc_error_macros",
|
"roc_error_macros",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -3656,6 +3657,7 @@ dependencies = [
|
||||||
"roc_highlight",
|
"roc_highlight",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
|
@ -3702,6 +3704,7 @@ dependencies = [
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -3833,6 +3836,7 @@ dependencies = [
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
"roc_std",
|
"roc_std",
|
||||||
"roc_target",
|
"roc_target",
|
||||||
|
@ -3897,6 +3901,7 @@ dependencies = [
|
||||||
"roc_error_macros",
|
"roc_error_macros",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
"serde",
|
"serde",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
|
@ -3913,6 +3918,7 @@ dependencies = [
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
"roc_load_internal",
|
"roc_load_internal",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
"roc_target",
|
"roc_target",
|
||||||
"roc_types",
|
"roc_types",
|
||||||
|
@ -3952,6 +3958,7 @@ dependencies = [
|
||||||
"roc_tracing",
|
"roc_tracing",
|
||||||
"roc_types",
|
"roc_types",
|
||||||
"roc_unify",
|
"roc_unify",
|
||||||
|
"tempfile",
|
||||||
"ven_pretty",
|
"ven_pretty",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4007,6 +4014,7 @@ dependencies = [
|
||||||
"flate2",
|
"flate2",
|
||||||
"indoc",
|
"indoc",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
|
"roc_error_macros",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"tar",
|
"tar",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
@ -4091,6 +4099,7 @@ dependencies = [
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
|
@ -4119,6 +4128,7 @@ dependencies = [
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"roc_repl_eval",
|
"roc_repl_eval",
|
||||||
|
@ -4175,6 +4185,7 @@ dependencies = [
|
||||||
"roc_fmt",
|
"roc_fmt",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -4215,6 +4226,7 @@ dependencies = [
|
||||||
"roc_exhaustive",
|
"roc_exhaustive",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -5025,6 +5037,7 @@ dependencies = [
|
||||||
"roc_derive_key",
|
"roc_derive_key",
|
||||||
"roc_load_internal",
|
"roc_load_internal",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
|
"roc_packaging",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
"roc_solve",
|
"roc_solve",
|
||||||
|
@ -5057,6 +5070,7 @@ dependencies = [
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_parse",
|
"roc_parse",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -5085,6 +5099,7 @@ dependencies = [
|
||||||
"roc_load",
|
"roc_load",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_mono",
|
"roc_mono",
|
||||||
|
"roc_packaging",
|
||||||
"roc_reporting",
|
"roc_reporting",
|
||||||
"roc_target",
|
"roc_target",
|
||||||
"roc_tracing",
|
"roc_tracing",
|
||||||
|
|
|
@ -10,6 +10,7 @@ members = [
|
||||||
"crates/highlight",
|
"crates/highlight",
|
||||||
"crates/error_macros",
|
"crates/error_macros",
|
||||||
"crates/reporting",
|
"crates/reporting",
|
||||||
|
"crates/packaging",
|
||||||
"crates/repl_cli",
|
"crates/repl_cli",
|
||||||
"crates/repl_eval",
|
"crates/repl_eval",
|
||||||
"crates/repl_test",
|
"crates/repl_test",
|
||||||
|
|
|
@ -20,6 +20,7 @@ roc_solve = { path = "../compiler/solve"}
|
||||||
roc_load = { path = "../compiler/load" }
|
roc_load = { path = "../compiler/load" }
|
||||||
roc_target = { path = "../compiler/roc_target" }
|
roc_target = { path = "../compiler/roc_target" }
|
||||||
roc_error_macros = { path = "../error_macros" }
|
roc_error_macros = { path = "../error_macros" }
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
|
|
||||||
ven_graph = { path = "../vendor/pathfinding" }
|
ven_graph = { path = "../vendor/pathfinding" }
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, Threading};
|
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, Threading};
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_reporting::report::DEFAULT_PALETTE;
|
use roc_reporting::report::DEFAULT_PALETTE;
|
||||||
use roc_target::TargetInfo;
|
use roc_target::TargetInfo;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn load_module(src_file: &Path, threading: Threading) -> LoadedModule {
|
pub fn load_module(
|
||||||
|
src_file: &Path,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
|
threading: Threading,
|
||||||
|
) -> LoadedModule {
|
||||||
let subs_by_module = Default::default();
|
let subs_by_module = Default::default();
|
||||||
|
|
||||||
let load_config = LoadConfig {
|
let load_config = LoadConfig {
|
||||||
|
@ -16,8 +21,13 @@ pub fn load_module(src_file: &Path, threading: Threading) -> LoadedModule {
|
||||||
};
|
};
|
||||||
|
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let loaded =
|
let loaded = roc_load::load_and_typecheck(
|
||||||
roc_load::load_and_typecheck(&arena, src_file.to_path_buf(), subs_by_module, load_config);
|
&arena,
|
||||||
|
src_file.to_path_buf(),
|
||||||
|
subs_by_module,
|
||||||
|
roc_cache_dir,
|
||||||
|
load_config,
|
||||||
|
);
|
||||||
|
|
||||||
match loaded {
|
match loaded {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
|
|
|
@ -45,7 +45,6 @@ roc_collections = { path = "../compiler/collections" }
|
||||||
roc_can = { path = "../compiler/can" }
|
roc_can = { path = "../compiler/can" }
|
||||||
roc_docs = { path = "../docs" }
|
roc_docs = { path = "../docs" }
|
||||||
roc_glue = { path = "../glue" }
|
roc_glue = { path = "../glue" }
|
||||||
roc_packaging = { path = "../packaging" }
|
|
||||||
roc_parse = { path = "../compiler/parse" }
|
roc_parse = { path = "../compiler/parse" }
|
||||||
roc_region = { path = "../compiler/region" }
|
roc_region = { path = "../compiler/region" }
|
||||||
roc_module = { path = "../compiler/module" }
|
roc_module = { path = "../compiler/module" }
|
||||||
|
@ -55,6 +54,7 @@ roc_load = { path = "../compiler/load" }
|
||||||
roc_build = { path = "../compiler/build" }
|
roc_build = { path = "../compiler/build" }
|
||||||
roc_fmt = { path = "../compiler/fmt" }
|
roc_fmt = { path = "../compiler/fmt" }
|
||||||
roc_target = { path = "../compiler/roc_target" }
|
roc_target = { path = "../compiler/roc_target" }
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
roc_error_macros = { path = "../error_macros" }
|
roc_error_macros = { path = "../error_macros" }
|
||||||
roc_editor = { path = "../editor", optional = true }
|
roc_editor = { path = "../editor", optional = true }
|
||||||
|
|
|
@ -12,6 +12,7 @@ use roc_load::{
|
||||||
LoadingProblem, Threading,
|
LoadingProblem, Threading,
|
||||||
};
|
};
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
||||||
use roc_target::TargetInfo;
|
use roc_target::TargetInfo;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
@ -67,6 +68,7 @@ pub fn build_file<'a>(
|
||||||
prebuilt: bool,
|
prebuilt: bool,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
wasm_dev_stack_bytes: Option<u32>,
|
wasm_dev_stack_bytes: Option<u32>,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
order: BuildOrdering,
|
order: BuildOrdering,
|
||||||
) -> Result<BuiltFile<'a>, BuildFileError<'a>> {
|
) -> Result<BuiltFile<'a>, BuildFileError<'a>> {
|
||||||
let compilation_start = Instant::now();
|
let compilation_start = Instant::now();
|
||||||
|
@ -92,6 +94,7 @@ pub fn build_file<'a>(
|
||||||
arena,
|
arena,
|
||||||
app_module_path.clone(),
|
app_module_path.clone(),
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
|
roc_cache_dir,
|
||||||
load_config,
|
load_config,
|
||||||
);
|
);
|
||||||
let loaded = match load_result {
|
let loaded = match load_result {
|
||||||
|
@ -464,12 +467,13 @@ fn spawn_rebuild_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn check_file(
|
pub fn check_file<'a>(
|
||||||
arena: &Bump,
|
arena: &'a Bump,
|
||||||
roc_file_path: PathBuf,
|
roc_file_path: PathBuf,
|
||||||
emit_timings: bool,
|
emit_timings: bool,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
) -> Result<(program::Problems, Duration), LoadingProblem> {
|
) -> Result<(program::Problems, Duration), LoadingProblem<'a>> {
|
||||||
let compilation_start = Instant::now();
|
let compilation_start = Instant::now();
|
||||||
|
|
||||||
// only used for generating errors. We don't do code generation, so hardcoding should be fine
|
// only used for generating errors. We don't do code generation, so hardcoding should be fine
|
||||||
|
@ -487,8 +491,13 @@ pub fn check_file(
|
||||||
threading,
|
threading,
|
||||||
exec_mode: ExecutionMode::Check,
|
exec_mode: ExecutionMode::Check,
|
||||||
};
|
};
|
||||||
let mut loaded =
|
let mut loaded = roc_load::load_and_typecheck(
|
||||||
roc_load::load_and_typecheck(arena, roc_file_path, subs_by_module, load_config)?;
|
arena,
|
||||||
|
roc_file_path,
|
||||||
|
subs_by_module,
|
||||||
|
roc_cache_dir,
|
||||||
|
load_config,
|
||||||
|
)?;
|
||||||
|
|
||||||
let buf = &mut String::with_capacity(1024);
|
let buf = &mut String::with_capacity(1024);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ use roc_build::program::{CodeGenBackend, CodeGenOptions, Problems};
|
||||||
use roc_error_macros::{internal_error, user_error};
|
use roc_error_macros::{internal_error, user_error};
|
||||||
use roc_load::{ExpectMetadata, LoadingProblem, Threading};
|
use roc_load::{ExpectMetadata, LoadingProblem, Threading};
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::{CString, OsStr};
|
use std::ffi::{CString, OsStr};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -356,6 +357,7 @@ pub fn test(_matches: &ArgMatches, _triple: Triple) -> io::Result<i32> {
|
||||||
pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
use roc_gen_llvm::llvm::build::LlvmBackendMode;
|
use roc_gen_llvm::llvm::build::LlvmBackendMode;
|
||||||
use roc_load::{ExecutionMode, LoadConfig};
|
use roc_load::{ExecutionMode, LoadConfig};
|
||||||
|
use roc_packaging::cache;
|
||||||
use roc_target::TargetInfo;
|
use roc_target::TargetInfo;
|
||||||
|
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
|
@ -407,6 +409,9 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
let target = &triple;
|
let target = &triple;
|
||||||
let opt_level = opt_level;
|
let opt_level = opt_level;
|
||||||
let target_info = TargetInfo::from(target);
|
let target_info = TargetInfo::from(target);
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
// Step 1: compile the app and generate the .o file
|
// Step 1: compile the app and generate the .o file
|
||||||
let subs_by_module = Default::default();
|
let subs_by_module = Default::default();
|
||||||
|
@ -419,8 +424,13 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
threading,
|
threading,
|
||||||
exec_mode: ExecutionMode::Test,
|
exec_mode: ExecutionMode::Test,
|
||||||
};
|
};
|
||||||
let loaded =
|
let loaded = roc_load::load_and_monomorphize(
|
||||||
roc_load::load_and_monomorphize(arena, path.to_path_buf(), subs_by_module, load_config)
|
arena,
|
||||||
|
path.to_path_buf(),
|
||||||
|
subs_by_module,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
|
load_config,
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut loaded = loaded;
|
let mut loaded = loaded;
|
||||||
|
@ -487,6 +497,7 @@ pub fn build(
|
||||||
matches: &ArgMatches,
|
matches: &ArgMatches,
|
||||||
config: BuildConfig,
|
config: BuildConfig,
|
||||||
triple: Triple,
|
triple: Triple,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
link_type: LinkType,
|
link_type: LinkType,
|
||||||
) -> io::Result<i32> {
|
) -> io::Result<i32> {
|
||||||
use build::build_file;
|
use build::build_file;
|
||||||
|
@ -518,7 +529,7 @@ pub fn build(
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
|
|
||||||
// Rather than building an executable or library, we're building
|
// Rather than building an executable or library, we're building
|
||||||
// a rp1 bundle so this code can be distributed via a HTTPS
|
// a tarball so this code can be distributed via a HTTPS
|
||||||
let filename = roc_packaging::tarball::build(path)?;
|
let filename = roc_packaging::tarball::build(path)?;
|
||||||
let total_time = start_time.elapsed().as_millis();
|
let total_time = start_time.elapsed().as_millis();
|
||||||
let created_path = path.with_file_name(&filename);
|
let created_path = path.with_file_name(&filename);
|
||||||
|
@ -627,6 +638,7 @@ pub fn build(
|
||||||
prebuilt,
|
prebuilt,
|
||||||
threading,
|
threading,
|
||||||
wasm_dev_stack_bytes,
|
wasm_dev_stack_bytes,
|
||||||
|
roc_cache_dir,
|
||||||
build_ordering,
|
build_ordering,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use roc_cli::{
|
||||||
use roc_docs::generate_docs_html;
|
use roc_docs::generate_docs_html;
|
||||||
use roc_error_macros::user_error;
|
use roc_error_macros::user_error;
|
||||||
use roc_load::{LoadingProblem, Threading};
|
use roc_load::{LoadingProblem, Threading};
|
||||||
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use std::fs::{self, FileType};
|
use std::fs::{self, FileType};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -33,10 +34,15 @@ fn main() -> io::Result<()> {
|
||||||
let exit_code = match matches.subcommand() {
|
let exit_code = match matches.subcommand() {
|
||||||
None => {
|
None => {
|
||||||
if matches.is_present(ROC_FILE) {
|
if matches.is_present(ROC_FILE) {
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
build(
|
build(
|
||||||
&matches,
|
&matches,
|
||||||
BuildConfig::BuildAndRunIfNoErrors,
|
BuildConfig::BuildAndRunIfNoErrors,
|
||||||
Triple::host(),
|
Triple::host(),
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
LinkType::Executable,
|
LinkType::Executable,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,10 +53,15 @@ fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
Some((CMD_RUN, matches)) => {
|
Some((CMD_RUN, matches)) => {
|
||||||
if matches.is_present(ROC_FILE) {
|
if matches.is_present(ROC_FILE) {
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
build(
|
build(
|
||||||
matches,
|
matches,
|
||||||
BuildConfig::BuildAndRun,
|
BuildConfig::BuildAndRun,
|
||||||
Triple::host(),
|
Triple::host(),
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
LinkType::Executable,
|
LinkType::Executable,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,10 +81,15 @@ fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
Some((CMD_DEV, matches)) => {
|
Some((CMD_DEV, matches)) => {
|
||||||
if matches.is_present(ROC_FILE) {
|
if matches.is_present(ROC_FILE) {
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
build(
|
build(
|
||||||
matches,
|
matches,
|
||||||
BuildConfig::BuildAndRunIfNoErrors,
|
BuildConfig::BuildAndRunIfNoErrors,
|
||||||
Triple::host(),
|
Triple::host(),
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
LinkType::Executable,
|
LinkType::Executable,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,12 +113,21 @@ fn main() -> io::Result<()> {
|
||||||
Some((CMD_GEN_STUB_LIB, matches)) => {
|
Some((CMD_GEN_STUB_LIB, matches)) => {
|
||||||
let input_path = Path::new(matches.value_of_os(ROC_FILE).unwrap());
|
let input_path = Path::new(matches.value_of_os(ROC_FILE).unwrap());
|
||||||
let target: Target = matches.value_of_t(FLAG_TARGET).unwrap_or_default();
|
let target: Target = matches.value_of_t(FLAG_TARGET).unwrap_or_default();
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
roc_linker::generate_stub_lib(input_path, &target.to_triple())
|
roc_linker::generate_stub_lib(
|
||||||
|
input_path,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
|
&target.to_triple(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Some((CMD_BUILD, matches)) => {
|
Some((CMD_BUILD, matches)) => {
|
||||||
let target: Target = matches.value_of_t(FLAG_TARGET).unwrap_or_default();
|
let target: Target = matches.value_of_t(FLAG_TARGET).unwrap_or_default();
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
let link_type = match (
|
let link_type = match (
|
||||||
matches.is_present(FLAG_LIB),
|
matches.is_present(FLAG_LIB),
|
||||||
matches.is_present(FLAG_NO_LINK),
|
matches.is_present(FLAG_NO_LINK),
|
||||||
|
@ -117,6 +142,7 @@ fn main() -> io::Result<()> {
|
||||||
matches,
|
matches,
|
||||||
BuildConfig::BuildOnly,
|
BuildConfig::BuildOnly,
|
||||||
target.to_triple(),
|
target.to_triple(),
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
link_type,
|
link_type,
|
||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
@ -126,6 +152,9 @@ fn main() -> io::Result<()> {
|
||||||
let emit_timings = matches.is_present(FLAG_TIME);
|
let emit_timings = matches.is_present(FLAG_TIME);
|
||||||
let filename = matches.value_of_os(ROC_FILE).unwrap();
|
let filename = matches.value_of_os(ROC_FILE).unwrap();
|
||||||
let roc_file_path = PathBuf::from(filename);
|
let roc_file_path = PathBuf::from(filename);
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
let threading = match matches
|
let threading = match matches
|
||||||
.value_of(roc_cli::FLAG_MAX_THREADS)
|
.value_of(roc_cli::FLAG_MAX_THREADS)
|
||||||
.and_then(|s| s.parse::<usize>().ok())
|
.and_then(|s| s.parse::<usize>().ok())
|
||||||
|
@ -136,7 +165,13 @@ fn main() -> io::Result<()> {
|
||||||
Some(n) => Threading::AtMost(n),
|
Some(n) => Threading::AtMost(n),
|
||||||
};
|
};
|
||||||
|
|
||||||
match check_file(&arena, roc_file_path, emit_timings, threading) {
|
match check_file(
|
||||||
|
&arena,
|
||||||
|
roc_file_path,
|
||||||
|
emit_timings,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
|
threading,
|
||||||
|
) {
|
||||||
Ok((problems, total_time)) => {
|
Ok((problems, total_time)) => {
|
||||||
println!(
|
println!(
|
||||||
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
|
||||||
|
|
|
@ -13,6 +13,7 @@ roc_can = { path = "../can" }
|
||||||
roc_types = { path = "../types" }
|
roc_types = { path = "../types" }
|
||||||
roc_module = { path = "../module" }
|
roc_module = { path = "../module" }
|
||||||
roc_collections = { path = "../collections" }
|
roc_collections = { path = "../collections" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
|
@ -20,6 +21,7 @@ bumpalo.workspace = true
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
roc_builtins = { path = "../builtins" }
|
roc_builtins = { path = "../builtins" }
|
||||||
roc_module = { path = "../module" }
|
roc_module = { path = "../module" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
roc_target = { path = "../roc_target" }
|
roc_target = { path = "../roc_target" }
|
||||||
roc_can = { path = "../can" }
|
roc_can = { path = "../can" }
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_module::symbol::ModuleId;
|
use roc_module::symbol::ModuleId;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
const ROC_SKIP_SUBS_CACHE: &str = "ROC_SKIP_SUBS_CACHE";
|
const ROC_SKIP_SUBS_CACHE: &str = "ROC_SKIP_SUBS_CACHE";
|
||||||
|
@ -74,7 +75,7 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path:
|
||||||
use roc_load_internal::file::{LoadingProblem, Threading};
|
use roc_load_internal::file::{LoadingProblem, Threading};
|
||||||
|
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let src_dir = PathBuf::from(".");
|
let cwd = std::env::current_dir().unwrap();
|
||||||
let source = roc_builtins::roc::module_source(module_id);
|
let source = roc_builtins::roc::module_source(module_id);
|
||||||
let target_info = roc_target::TargetInfo::default_x86_64();
|
let target_info = roc_target::TargetInfo::default_x86_64();
|
||||||
|
|
||||||
|
@ -82,12 +83,12 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path:
|
||||||
&arena,
|
&arena,
|
||||||
PathBuf::from(filename),
|
PathBuf::from(filename),
|
||||||
source,
|
source,
|
||||||
src_dir,
|
cwd,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
target_info,
|
target_info,
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
roc_reporting::report::DEFAULT_PALETTE,
|
roc_reporting::report::DEFAULT_PALETTE,
|
||||||
roc_cache_dir,
|
RocCacheDir::Disallowed,
|
||||||
Threading::AllAvailable,
|
Threading::AllAvailable,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use bumpalo::Bump;
|
||||||
use roc_can::module::{ExposedByModule, TypeState};
|
use roc_can::module::{ExposedByModule, TypeState};
|
||||||
use roc_collections::all::MutMap;
|
use roc_collections::all::MutMap;
|
||||||
use roc_module::symbol::ModuleId;
|
use roc_module::symbol::ModuleId;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_reporting::report::{Palette, RenderTarget};
|
use roc_reporting::report::{Palette, RenderTarget};
|
||||||
use roc_target::TargetInfo;
|
use roc_target::TargetInfo;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -26,11 +27,19 @@ fn load<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
load_config: LoadConfig,
|
load_config: LoadConfig,
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
let cached_types = read_cached_types();
|
let cached_types = read_cached_types();
|
||||||
|
|
||||||
roc_load_internal::file::load(arena, load_start, exposed_types, cached_types, load_config)
|
roc_load_internal::file::load(
|
||||||
|
arena,
|
||||||
|
load_start,
|
||||||
|
exposed_types,
|
||||||
|
cached_types,
|
||||||
|
roc_cache_dir,
|
||||||
|
load_config,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load using only a single thread; used when compiling to webassembly
|
/// Load using only a single thread; used when compiling to webassembly
|
||||||
|
@ -41,6 +50,7 @@ pub fn load_single_threaded<'a>(
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
exec_mode: ExecutionMode,
|
exec_mode: ExecutionMode,
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
let cached_subs = read_cached_types();
|
let cached_subs = read_cached_types();
|
||||||
|
@ -54,6 +64,7 @@ pub fn load_single_threaded<'a>(
|
||||||
render,
|
render,
|
||||||
palette,
|
palette,
|
||||||
exec_mode,
|
exec_mode,
|
||||||
|
roc_cache_dir,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,24 +98,26 @@ pub fn load_and_monomorphize_from_str<'a>(
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
src_dir: PathBuf,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
load_config: LoadConfig,
|
load_config: LoadConfig,
|
||||||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_str(arena, filename, src, src_dir)?;
|
let load_start = LoadStart::from_str(arena, filename, src, roc_cache_dir, src_dir)?;
|
||||||
|
|
||||||
match load(arena, load_start, exposed_types, load_config)? {
|
match load(arena, load_start, exposed_types, roc_cache_dir, load_config)? {
|
||||||
Monomorphized(module) => Ok(module),
|
Monomorphized(module) => Ok(module),
|
||||||
TypeChecked(_) => unreachable!(""),
|
TypeChecked(_) => unreachable!(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_and_monomorphize(
|
pub fn load_and_monomorphize<'a>(
|
||||||
arena: &Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
load_config: LoadConfig,
|
load_config: LoadConfig,
|
||||||
) -> Result<MonomorphizedModule<'_>, LoadMonomorphizedError<'_>> {
|
) -> Result<MonomorphizedModule<'a>, LoadMonomorphizedError<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(
|
let load_start = LoadStart::from_path(
|
||||||
|
@ -115,18 +128,19 @@ pub fn load_and_monomorphize(
|
||||||
load_config.palette,
|
load_config.palette,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
match load(arena, load_start, exposed_types, load_config)? {
|
match load(arena, load_start, exposed_types, roc_cache_dir, load_config)? {
|
||||||
Monomorphized(module) => Ok(module),
|
Monomorphized(module) => Ok(module),
|
||||||
TypeChecked(module) => Err(LoadMonomorphizedError::ErrorModule(module)),
|
TypeChecked(module) => Err(LoadMonomorphizedError::ErrorModule(module)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_and_typecheck(
|
pub fn load_and_typecheck<'a>(
|
||||||
arena: &Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
load_config: LoadConfig,
|
load_config: LoadConfig,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'_>> {
|
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(
|
let load_start = LoadStart::from_path(
|
||||||
|
@ -137,7 +151,7 @@ pub fn load_and_typecheck(
|
||||||
load_config.palette,
|
load_config.palette,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
match load(arena, load_start, exposed_types, load_config)? {
|
match load(arena, load_start, exposed_types, roc_cache_dir, load_config)? {
|
||||||
Monomorphized(_) => unreachable!(""),
|
Monomorphized(_) => unreachable!(""),
|
||||||
TypeChecked(module) => Ok(module),
|
TypeChecked(module) => Ok(module),
|
||||||
}
|
}
|
||||||
|
@ -152,11 +166,12 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_str(arena, filename, source, src_dir)?;
|
let load_start = LoadStart::from_str(arena, filename, source, roc_cache_dir, src_dir)?;
|
||||||
|
|
||||||
// NOTE: this function is meant for tests, and so we use single-threaded
|
// NOTE: this function is meant for tests, and so we use single-threaded
|
||||||
// solving so we don't use too many threads per-test. That gives higher
|
// solving so we don't use too many threads per-test. That gives higher
|
||||||
|
@ -168,6 +183,7 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
target_info,
|
target_info,
|
||||||
render,
|
render,
|
||||||
palette,
|
palette,
|
||||||
|
roc_cache_dir,
|
||||||
ExecutionMode::Check,
|
ExecutionMode::Check,
|
||||||
)? {
|
)? {
|
||||||
Monomorphized(_) => unreachable!(""),
|
Monomorphized(_) => unreachable!(""),
|
||||||
|
|
|
@ -36,6 +36,7 @@ ven_pretty = { path = "../../vendor/pretty" }
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
crossbeam.workspace = true
|
crossbeam.workspace = true
|
||||||
|
tempfile.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
roc_test_utils = { path = "../../test_utils" }
|
roc_test_utils = { path = "../../test_utils" }
|
||||||
|
|
|
@ -36,7 +36,7 @@ use roc_mono::ir::{
|
||||||
use roc_mono::layout::{
|
use roc_mono::layout::{
|
||||||
CapturesNiche, LambdaName, Layout, LayoutCache, LayoutProblem, STLayoutInterner,
|
CapturesNiche, LambdaName, Layout, LayoutCache, LayoutProblem, STLayoutInterner,
|
||||||
};
|
};
|
||||||
use roc_packaging::cache;
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use roc_parse::ast::{self, Defs, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation};
|
use roc_parse::ast::{self, Defs, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation};
|
||||||
use roc_parse::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent};
|
use roc_parse::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent};
|
||||||
use roc_parse::header::{HeaderFor, ModuleNameEnum, PackageName};
|
use roc_parse::header::{HeaderFor, ModuleNameEnum, PackageName};
|
||||||
|
@ -950,8 +950,6 @@ struct State<'a> {
|
||||||
|
|
||||||
type CachedTypeState = Arc<Mutex<MutMap<ModuleId, TypeState>>>;
|
type CachedTypeState = Arc<Mutex<MutMap<ModuleId, TypeState>>>;
|
||||||
|
|
||||||
const ROC_VERSION: &str = include_str!("../../../../version.txt");
|
|
||||||
|
|
||||||
impl<'a> State<'a> {
|
impl<'a> State<'a> {
|
||||||
fn goal_phase(&self) -> Phase {
|
fn goal_phase(&self) -> Phase {
|
||||||
self.exec_mode.goal_phase()
|
self.exec_mode.goal_phase()
|
||||||
|
@ -1211,7 +1209,7 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
@ -1230,7 +1228,14 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
exec_mode: ExecutionMode::Check,
|
exec_mode: ExecutionMode::Check,
|
||||||
};
|
};
|
||||||
|
|
||||||
match load(arena, load_start, exposed_types, cached_subs, load_config)? {
|
match load(
|
||||||
|
arena,
|
||||||
|
load_start,
|
||||||
|
exposed_types,
|
||||||
|
cached_subs,
|
||||||
|
roc_cache_dir,
|
||||||
|
load_config,
|
||||||
|
)? {
|
||||||
Monomorphized(_) => unreachable!(""),
|
Monomorphized(_) => unreachable!(""),
|
||||||
TypeChecked(module) => Ok(module),
|
TypeChecked(module) => Ok(module),
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1260,7 @@ impl<'a> LoadStart<'a> {
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
) -> Result<Self, LoadingProblem<'a>> {
|
) -> Result<Self, LoadingProblem<'a>> {
|
||||||
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
||||||
|
@ -1387,7 +1392,7 @@ impl<'a> LoadStart<'a> {
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
src_dir: PathBuf,
|
src_dir: PathBuf,
|
||||||
) -> Result<Self, LoadingProblem<'a>> {
|
) -> Result<Self, LoadingProblem<'a>> {
|
||||||
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
||||||
|
@ -1487,6 +1492,7 @@ pub fn load<'a>(
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
cached_types: MutMap<ModuleId, TypeState>,
|
cached_types: MutMap<ModuleId, TypeState>,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
load_config: LoadConfig,
|
load_config: LoadConfig,
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
enum Threads {
|
enum Threads {
|
||||||
|
@ -1513,12 +1519,6 @@ pub fn load<'a>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let roc_cache_dir = if let Some(dir) = cache::roc_cache_dir(ROC_VERSION) {
|
|
||||||
dir
|
|
||||||
} else {
|
|
||||||
return Err(LoadingProblem::CouldNotFindCacheDir);
|
|
||||||
};
|
|
||||||
|
|
||||||
match threads {
|
match threads {
|
||||||
Threads::Single => load_single_threaded(
|
Threads::Single => load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
|
@ -1529,7 +1529,7 @@ pub fn load<'a>(
|
||||||
load_config.render,
|
load_config.render,
|
||||||
load_config.palette,
|
load_config.palette,
|
||||||
load_config.exec_mode,
|
load_config.exec_mode,
|
||||||
&roc_cache_dir,
|
roc_cache_dir,
|
||||||
),
|
),
|
||||||
Threads::Many(threads) => load_multi_threaded(
|
Threads::Many(threads) => load_multi_threaded(
|
||||||
arena,
|
arena,
|
||||||
|
@ -1541,7 +1541,7 @@ pub fn load<'a>(
|
||||||
load_config.palette,
|
load_config.palette,
|
||||||
threads,
|
threads,
|
||||||
load_config.exec_mode,
|
load_config.exec_mode,
|
||||||
&roc_cache_dir,
|
roc_cache_dir,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1557,7 +1557,7 @@ pub fn load_single_threaded<'a>(
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
exec_mode: ExecutionMode,
|
exec_mode: ExecutionMode,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
let LoadStart {
|
let LoadStart {
|
||||||
arc_modules,
|
arc_modules,
|
||||||
|
@ -1618,7 +1618,7 @@ pub fn load_single_threaded<'a>(
|
||||||
&worker_msg_rx,
|
&worker_msg_rx,
|
||||||
&msg_tx,
|
&msg_tx,
|
||||||
&src_dir,
|
&src_dir,
|
||||||
&roc_cache_dir,
|
roc_cache_dir,
|
||||||
target_info,
|
target_info,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1813,7 +1813,7 @@ fn load_multi_threaded<'a>(
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
available_threads: usize,
|
available_threads: usize,
|
||||||
exec_mode: ExecutionMode,
|
exec_mode: ExecutionMode,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
let LoadStart {
|
let LoadStart {
|
||||||
arc_modules,
|
arc_modules,
|
||||||
|
@ -1980,7 +1980,7 @@ fn worker_task_step<'a>(
|
||||||
worker_msg_rx: &crossbeam::channel::Receiver<WorkerMsg>,
|
worker_msg_rx: &crossbeam::channel::Receiver<WorkerMsg>,
|
||||||
msg_tx: &MsgSender<'a>,
|
msg_tx: &MsgSender<'a>,
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
) -> Result<ControlFlow<(), ()>, LoadingProblem<'a>> {
|
) -> Result<ControlFlow<(), ()>, LoadingProblem<'a>> {
|
||||||
match worker_msg_rx.try_recv() {
|
match worker_msg_rx.try_recv() {
|
||||||
|
@ -2055,7 +2055,7 @@ fn worker_task<'a>(
|
||||||
worker_msg_rx: crossbeam::channel::Receiver<WorkerMsg>,
|
worker_msg_rx: crossbeam::channel::Receiver<WorkerMsg>,
|
||||||
msg_tx: MsgSender<'a>,
|
msg_tx: MsgSender<'a>,
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
) -> Result<(), LoadingProblem<'a>> {
|
) -> Result<(), LoadingProblem<'a>> {
|
||||||
// Keep listening until we receive a Shutdown msg
|
// Keep listening until we receive a Shutdown msg
|
||||||
|
@ -3167,7 +3167,7 @@ fn load_platform_module<'a>(
|
||||||
) -> Result<Msg<'a>, LoadingProblem<'a>> {
|
) -> Result<Msg<'a>, LoadingProblem<'a>> {
|
||||||
let module_start_time = Instant::now();
|
let module_start_time = Instant::now();
|
||||||
let file_io_start = Instant::now();
|
let file_io_start = Instant::now();
|
||||||
let file = fs::read(dbg!(filename));
|
let file = fs::read(filename);
|
||||||
let file_io_duration = file_io_start.elapsed();
|
let file_io_duration = file_io_start.elapsed();
|
||||||
|
|
||||||
match file {
|
match file {
|
||||||
|
@ -3304,7 +3304,7 @@ fn load_module<'a>(
|
||||||
module_name: PQModuleName<'a>,
|
module_name: PQModuleName<'a>,
|
||||||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||||
arc_shorthands: Arc<Mutex<MutMap<&'a str, PackageName<'a>>>>,
|
arc_shorthands: Arc<Mutex<MutMap<&'a str, PackageName<'a>>>>,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
ident_ids_by_module: SharedIdentIdsByModule,
|
ident_ids_by_module: SharedIdentIdsByModule,
|
||||||
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
||||||
let module_start_time = Instant::now();
|
let module_start_time = Instant::now();
|
||||||
|
@ -3492,7 +3492,7 @@ fn parse_header<'a>(
|
||||||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||||
ident_ids_by_module: SharedIdentIdsByModule,
|
ident_ids_by_module: SharedIdentIdsByModule,
|
||||||
src_bytes: &'a [u8],
|
src_bytes: &'a [u8],
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
start_time: Instant,
|
start_time: Instant,
|
||||||
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
||||||
let parse_start = Instant::now();
|
let parse_start = Instant::now();
|
||||||
|
@ -3731,7 +3731,7 @@ fn load_filename<'a>(
|
||||||
opt_expected_module_name: Option<PackageQualified<'a, ModuleName>>,
|
opt_expected_module_name: Option<PackageQualified<'a, ModuleName>>,
|
||||||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||||
ident_ids_by_module: SharedIdentIdsByModule,
|
ident_ids_by_module: SharedIdentIdsByModule,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
module_start_time: Instant,
|
module_start_time: Instant,
|
||||||
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
||||||
let file_io_start = Instant::now();
|
let file_io_start = Instant::now();
|
||||||
|
@ -3768,7 +3768,7 @@ fn load_from_str<'a>(
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||||
ident_ids_by_module: SharedIdentIdsByModule,
|
ident_ids_by_module: SharedIdentIdsByModule,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
module_start_time: Instant,
|
module_start_time: Instant,
|
||||||
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
||||||
let file_io_start = Instant::now();
|
let file_io_start = Instant::now();
|
||||||
|
@ -5638,7 +5638,7 @@ fn run_task<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
msg_tx: MsgSender<'a>,
|
msg_tx: MsgSender<'a>,
|
||||||
roc_cache_dir: &Path,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
) -> Result<(), LoadingProblem<'a>> {
|
) -> Result<(), LoadingProblem<'a>> {
|
||||||
use BuildTask::*;
|
use BuildTask::*;
|
||||||
|
|
|
@ -21,6 +21,7 @@ use roc_load_internal::file::{ExecutionMode, LoadConfig, Threading};
|
||||||
use roc_load_internal::file::{LoadResult, LoadStart, LoadedModule, LoadingProblem};
|
use roc_load_internal::file::{LoadResult, LoadStart, LoadedModule, LoadingProblem};
|
||||||
use roc_module::ident::ModuleName;
|
use roc_module::ident::ModuleName;
|
||||||
use roc_module::symbol::{Interns, ModuleId};
|
use roc_module::symbol::{Interns, ModuleId};
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_problem::can::Problem;
|
use roc_problem::can::Problem;
|
||||||
use roc_region::all::LineInfo;
|
use roc_region::all::LineInfo;
|
||||||
use roc_reporting::report::RenderTarget;
|
use roc_reporting::report::RenderTarget;
|
||||||
|
@ -40,7 +41,13 @@ fn load_and_typecheck(
|
||||||
) -> Result<LoadedModule, LoadingProblem> {
|
) -> Result<LoadedModule, LoadingProblem> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(arena, filename, RenderTarget::Generic, DEFAULT_PALETTE)?;
|
let load_start = LoadStart::from_path(
|
||||||
|
arena,
|
||||||
|
filename,
|
||||||
|
RenderTarget::Generic,
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
|
DEFAULT_PALETTE,
|
||||||
|
)?;
|
||||||
let load_config = LoadConfig {
|
let load_config = LoadConfig {
|
||||||
target_info,
|
target_info,
|
||||||
render: RenderTarget::Generic,
|
render: RenderTarget::Generic,
|
||||||
|
@ -54,6 +61,7 @@ fn load_and_typecheck(
|
||||||
load_start,
|
load_start,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Default::default(), // these tests will re-compile the builtins
|
Default::default(), // these tests will re-compile the builtins
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
load_config,
|
load_config,
|
||||||
)? {
|
)? {
|
||||||
Monomorphized(_) => unreachable!(""),
|
Monomorphized(_) => unreachable!(""),
|
||||||
|
|
|
@ -10,6 +10,7 @@ description = "The entry point of Roc's type inference system. Implements type i
|
||||||
roc_collections = { path = "../collections" }
|
roc_collections = { path = "../collections" }
|
||||||
roc_error_macros = { path = "../../error_macros" }
|
roc_error_macros = { path = "../../error_macros" }
|
||||||
roc_exhaustive = { path = "../exhaustive" }
|
roc_exhaustive = { path = "../exhaustive" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_region = { path = "../region" }
|
roc_region = { path = "../region" }
|
||||||
roc_module = { path = "../module" }
|
roc_module = { path = "../module" }
|
||||||
roc_types = { path = "../types" }
|
roc_types = { path = "../types" }
|
||||||
|
|
|
@ -18,6 +18,7 @@ mod solve_expr {
|
||||||
};
|
};
|
||||||
use roc_load::LoadedModule;
|
use roc_load::LoadedModule;
|
||||||
use roc_module::symbol::{Interns, ModuleId};
|
use roc_module::symbol::{Interns, ModuleId};
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_problem::can::Problem;
|
use roc_problem::can::Problem;
|
||||||
use roc_region::all::{LineColumn, LineColumnRegion, LineInfo, Region};
|
use roc_region::all::{LineColumn, LineColumnRegion, LineInfo, Region};
|
||||||
use roc_reporting::report::{can_problem, type_problem, RocDocAllocator};
|
use roc_reporting::report::{can_problem, type_problem, RocDocAllocator};
|
||||||
|
@ -108,6 +109,7 @@ mod solve_expr {
|
||||||
exposed_types,
|
exposed_types,
|
||||||
roc_target::TargetInfo::default_x86_64(),
|
roc_target::TargetInfo::default_x86_64(),
|
||||||
roc_reporting::report::RenderTarget::Generic,
|
roc_reporting::report::RenderTarget::Generic,
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
roc_reporting::report::DEFAULT_PALETTE,
|
roc_reporting::report::DEFAULT_PALETTE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ roc_derive_key = { path = "../derive_key" }
|
||||||
roc_derive = { path = "../derive", features = ["debug-derived-symbols", "open-extension-vars"] }
|
roc_derive = { path = "../derive", features = ["debug-derived-symbols", "open-extension-vars"] }
|
||||||
roc_target = { path = "../roc_target" }
|
roc_target = { path = "../roc_target" }
|
||||||
roc_types = { path = "../types" }
|
roc_types = { path = "../types" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
roc_constrain = { path = "../constrain" }
|
roc_constrain = { path = "../constrain" }
|
||||||
roc_region = { path = "../region" }
|
roc_region = { path = "../region" }
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::fmt::Write as _; // import without risk of name clashing
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use ven_pretty::DocAllocator;
|
use ven_pretty::DocAllocator;
|
||||||
|
|
||||||
use crate::pretty_print::{pretty_print_def, Ctx};
|
use crate::pretty_print::{pretty_print_def, Ctx};
|
||||||
|
@ -490,6 +491,7 @@ where
|
||||||
target_info,
|
target_info,
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
roc_reporting::report::DEFAULT_PALETTE,
|
roc_reporting::report::DEFAULT_PALETTE,
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
Threading::AllAvailable,
|
Threading::AllAvailable,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -30,6 +30,7 @@ roc_unify = { path = "../unify" }
|
||||||
roc_utils = { path = "../../utils" }
|
roc_utils = { path = "../../utils" }
|
||||||
roc_solve = { path = "../solve" }
|
roc_solve = { path = "../solve" }
|
||||||
roc_mono = { path = "../mono" }
|
roc_mono = { path = "../mono" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
roc_load = { path = "../load" }
|
roc_load = { path = "../load" }
|
||||||
roc_can = { path = "../can" }
|
roc_can = { path = "../can" }
|
||||||
|
|
|
@ -9,6 +9,7 @@ use roc_gen_llvm::llvm::externs::add_default_roc_externs;
|
||||||
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult};
|
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult};
|
||||||
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
|
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_region::all::LineInfo;
|
use roc_region::all::LineInfo;
|
||||||
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
||||||
use roc_utils::zig;
|
use roc_utils::zig;
|
||||||
|
@ -80,6 +81,7 @@ fn create_llvm_module<'a>(
|
||||||
module_src,
|
module_src,
|
||||||
src_dir,
|
src_dir,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
load_config,
|
load_config,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ roc_load = { path = "../load" }
|
||||||
roc_can = { path = "../can" }
|
roc_can = { path = "../can" }
|
||||||
roc_mono = { path = "../mono" }
|
roc_mono = { path = "../mono" }
|
||||||
roc_target = { path = "../roc_target" }
|
roc_target = { path = "../roc_target" }
|
||||||
|
roc_packaging = { path = "../../packaging" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
roc_tracing = { path = "../../tracing" }
|
roc_tracing = { path = "../../tracing" }
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,15 @@ extern crate indoc;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
|
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||||
|
|
||||||
|
use roc_collections::all::MutMap;
|
||||||
use roc_load::ExecutionMode;
|
use roc_load::ExecutionMode;
|
||||||
use roc_load::LoadConfig;
|
use roc_load::LoadConfig;
|
||||||
use test_mono_macros::*;
|
|
||||||
|
|
||||||
use roc_collections::all::MutMap;
|
|
||||||
use roc_load::Threading;
|
use roc_load::Threading;
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
use roc_mono::ir::Proc;
|
use roc_mono::ir::Proc;
|
||||||
use roc_mono::ir::ProcLayout;
|
use roc_mono::ir::ProcLayout;
|
||||||
use roc_mono::layout::STLayoutInterner;
|
use roc_mono::layout::STLayoutInterner;
|
||||||
|
use test_mono_macros::*;
|
||||||
|
|
||||||
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
|
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
|
||||||
|
|
||||||
|
@ -76,6 +75,7 @@ fn promote_expr_to_module(src: &str) -> String {
|
||||||
|
|
||||||
fn compiles_to_ir(test_name: &str, src: &str) {
|
fn compiles_to_ir(test_name: &str, src: &str) {
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let arena = &Bump::new();
|
let arena = &Bump::new();
|
||||||
|
@ -107,6 +107,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
|
||||||
module_src,
|
module_src,
|
||||||
src_dir,
|
src_dir,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
load_config,
|
load_config,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ roc_parse = { path = "../compiler/parse" }
|
||||||
roc_target = { path = "../compiler/roc_target" }
|
roc_target = { path = "../compiler/roc_target" }
|
||||||
roc_collections = { path = "../compiler/collections" }
|
roc_collections = { path = "../compiler/collections" }
|
||||||
roc_highlight = { path = "../highlight"}
|
roc_highlight = { path = "../highlight"}
|
||||||
|
roc_packaging = { path = "../packaging"}
|
||||||
roc_reporting = { path = "../reporting"}
|
roc_reporting = { path = "../reporting"}
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
snafu.workspace = true
|
snafu.workspace = true
|
||||||
|
|
|
@ -14,6 +14,7 @@ use roc_load::docs::{DocEntry, TypeAnnotation};
|
||||||
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
|
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
|
||||||
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
||||||
use roc_module::symbol::{IdentIdsByModule, Interns, ModuleId};
|
use roc_module::symbol::{IdentIdsByModule, Interns, ModuleId};
|
||||||
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use roc_parse::ident::{parse_ident, Ident};
|
use roc_parse::ident::{parse_ident, Ident};
|
||||||
use roc_parse::state::State;
|
use roc_parse::state::State;
|
||||||
use roc_region::all::Region;
|
use roc_region::all::Region;
|
||||||
|
@ -452,6 +453,9 @@ fn render_sidebar<'a, I: Iterator<Item = (&'a ModuleDocumentation, Vec<String>)>
|
||||||
|
|
||||||
pub fn load_modules_for_files(filenames: Vec<PathBuf>) -> Vec<LoadedModule> {
|
pub fn load_modules_for_files(filenames: Vec<PathBuf>) -> Vec<LoadedModule> {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
let mut modules = Vec::with_capacity(filenames.len());
|
let mut modules = Vec::with_capacity(filenames.len());
|
||||||
|
|
||||||
for filename in filenames {
|
for filename in filenames {
|
||||||
|
@ -462,7 +466,13 @@ pub fn load_modules_for_files(filenames: Vec<PathBuf>) -> Vec<LoadedModule> {
|
||||||
threading: Threading::AllAvailable,
|
threading: Threading::AllAvailable,
|
||||||
exec_mode: ExecutionMode::Check,
|
exec_mode: ExecutionMode::Check,
|
||||||
};
|
};
|
||||||
match roc_load::load_and_typecheck(&arena, filename, Default::default(), load_config) {
|
match roc_load::load_and_typecheck(
|
||||||
|
&arena,
|
||||||
|
filename,
|
||||||
|
Default::default(),
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
|
load_config,
|
||||||
|
) {
|
||||||
Ok(loaded) => modules.push(loaded),
|
Ok(loaded) => modules.push(loaded),
|
||||||
Err(LoadingProblem::FormattedReport(report)) => {
|
Err(LoadingProblem::FormattedReport(report)) => {
|
||||||
eprintln!("{}", report);
|
eprintln!("{}", report);
|
||||||
|
|
|
@ -30,6 +30,7 @@ roc_problem = { path = "../compiler/problem" }
|
||||||
roc_types = { path = "../compiler/types" }
|
roc_types = { path = "../compiler/types" }
|
||||||
roc_unify = { path = "../compiler/unify" }
|
roc_unify = { path = "../compiler/unify" }
|
||||||
roc_utils = { path = "../utils"}
|
roc_utils = { path = "../utils"}
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
roc_solve = { path = "../compiler/solve" }
|
roc_solve = { path = "../compiler/solve" }
|
||||||
ven_graph = { path = "../vendor/pathfinding" }
|
ven_graph = { path = "../vendor/pathfinding" }
|
||||||
|
|
|
@ -28,6 +28,7 @@ use roc_ast::mem_pool::pool::Pool;
|
||||||
use roc_ast::module::load_module;
|
use roc_ast::module::load_module;
|
||||||
use roc_load::Threading;
|
use roc_load::Threading;
|
||||||
use roc_module::symbol::IdentIds;
|
use roc_module::symbol::IdentIds;
|
||||||
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use roc_types::subs::VarStore;
|
use roc_types::subs::VarStore;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -127,8 +128,15 @@ fn run_event_loop(project_dir_path_opt: Option<&Path>) -> Result<(), Box<dyn Err
|
||||||
println!("Loading file {:?}...", file_path_str);
|
println!("Loading file {:?}...", file_path_str);
|
||||||
|
|
||||||
let file_path = Path::new(&file_path_str);
|
let file_path = Path::new(&file_path_str);
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
|
|
||||||
let loaded_module = load_module(file_path, Threading::AllAvailable);
|
let loaded_module = load_module(
|
||||||
|
file_path,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
|
Threading::AllAvailable,
|
||||||
|
);
|
||||||
|
|
||||||
let mut var_store = VarStore::default();
|
let mut var_store = VarStore::default();
|
||||||
let dep_idents = IdentIds::exposed_builtins(8);
|
let dep_idents = IdentIds::exposed_builtins(8);
|
||||||
|
|
|
@ -237,6 +237,7 @@ pub mod test_ed_model {
|
||||||
use roc_load::{LoadedModule, Threading};
|
use roc_load::{LoadedModule, Threading};
|
||||||
use roc_module::symbol::IdentIds;
|
use roc_module::symbol::IdentIds;
|
||||||
use roc_module::symbol::ModuleIds;
|
use roc_module::symbol::ModuleIds;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_types::subs::VarStore;
|
use roc_types::subs::VarStore;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -329,7 +330,11 @@ pub mod test_ed_model {
|
||||||
writeln!(file, "{}", clean_code_str)
|
writeln!(file, "{}", clean_code_str)
|
||||||
.unwrap_or_else(|_| panic!("Failed to write {:?} to file: {:?}", clean_code_str, file));
|
.unwrap_or_else(|_| panic!("Failed to write {:?} to file: {:?}", clean_code_str, file));
|
||||||
|
|
||||||
let loaded_module = load_module(&temp_file_full_path, Threading::AllAvailable);
|
let loaded_module = load_module(
|
||||||
|
&temp_file_full_path,
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
|
Threading::AllAvailable,
|
||||||
|
);
|
||||||
|
|
||||||
let mut ed_model = init_dummy_model(
|
let mut ed_model = init_dummy_model(
|
||||||
clean_code_str,
|
clean_code_str,
|
||||||
|
|
|
@ -13,6 +13,7 @@ roc_intern = { path = "../compiler/intern" }
|
||||||
roc_mono = { path = "../compiler/mono" }
|
roc_mono = { path = "../compiler/mono" }
|
||||||
roc_load = { path = "../compiler/load" }
|
roc_load = { path = "../compiler/load" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_types = { path = "../compiler/types" }
|
roc_types = { path = "../compiler/types" }
|
||||||
roc_builtins = { path = "../compiler/builtins" }
|
roc_builtins = { path = "../compiler/builtins" }
|
||||||
roc_module = { path = "../compiler/module" }
|
roc_module = { path = "../compiler/module" }
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::types::{Env, Types};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_intern::GlobalInterner;
|
use roc_intern::GlobalInterner;
|
||||||
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
||||||
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
||||||
use roc_target::{Architecture, OperatingSystem, TargetInfo};
|
use roc_target::{Architecture, OperatingSystem, TargetInfo};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -82,7 +83,9 @@ pub fn load_types(
|
||||||
ignore_errors: IgnoreErrors,
|
ignore_errors: IgnoreErrors,
|
||||||
) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
|
) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
|
||||||
let target_info = (&Triple::host()).into();
|
let target_info = (&Triple::host()).into();
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
let arena = &Bump::new();
|
let arena = &Bump::new();
|
||||||
let subs_by_module = Default::default();
|
let subs_by_module = Default::default();
|
||||||
let LoadedModule {
|
let LoadedModule {
|
||||||
|
@ -97,6 +100,7 @@ pub fn load_types(
|
||||||
arena,
|
arena,
|
||||||
full_file_path,
|
full_file_path,
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
LoadConfig {
|
LoadConfig {
|
||||||
target_info,
|
target_info,
|
||||||
render: RenderTarget::Generic,
|
render: RenderTarget::Generic,
|
||||||
|
|
|
@ -17,6 +17,7 @@ roc_build = { path = "../compiler/build" }
|
||||||
roc_collections = { path = "../compiler/collections" }
|
roc_collections = { path = "../compiler/collections" }
|
||||||
roc_error_macros = { path = "../error_macros" }
|
roc_error_macros = { path = "../error_macros" }
|
||||||
roc_load = { path = "../compiler/load" }
|
roc_load = { path = "../compiler/load" }
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
|
|
|
@ -9,6 +9,7 @@ use roc_build::link::{rebuild_host, LinkType};
|
||||||
use roc_error_macros::internal_error;
|
use roc_error_macros::internal_error;
|
||||||
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
|
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -102,7 +103,11 @@ pub fn link_preprocessed_host(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exposed function to load a platform file and generate a stub lib for it.
|
// Exposed function to load a platform file and generate a stub lib for it.
|
||||||
pub fn generate_stub_lib(input_path: &Path, triple: &Triple) -> std::io::Result<i32> {
|
pub fn generate_stub_lib(
|
||||||
|
input_path: &Path,
|
||||||
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
|
triple: &Triple,
|
||||||
|
) -> std::io::Result<i32> {
|
||||||
// Note: this should theoretically just be able to load the host, I think.
|
// Note: this should theoretically just be able to load the host, I think.
|
||||||
// Instead, I am loading an entire app because that was simpler and had example code.
|
// Instead, I am loading an entire app because that was simpler and had example code.
|
||||||
// If this was expected to stay around for the the long term, we should change it.
|
// If this was expected to stay around for the the long term, we should change it.
|
||||||
|
@ -114,6 +119,7 @@ pub fn generate_stub_lib(input_path: &Path, triple: &Triple) -> std::io::Result<
|
||||||
arena,
|
arena,
|
||||||
input_path.to_path_buf(),
|
input_path.to_path_buf(),
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
|
roc_cache_dir,
|
||||||
LoadConfig {
|
LoadConfig {
|
||||||
target_info,
|
target_info,
|
||||||
render: RenderTarget::Generic,
|
render: RenderTarget::Generic,
|
||||||
|
|
|
@ -9,6 +9,7 @@ description = "Functionality for packaging Roc source code - e.g. for distributi
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
roc_parse = { path = "../compiler/parse" }
|
roc_parse = { path = "../compiler/parse" }
|
||||||
|
roc_error_macros = { path = "../error_macros" }
|
||||||
|
|
||||||
tar = "0.4.38" # used for `roc build --tar` so .rp1 files can hold multiple other files
|
tar = "0.4.38" # used for `roc build --tar` so .rp1 files can hold multiple other files
|
||||||
brotli = "3.3.4" # used for decompressing tarballs over HTTPS, if the server supports brotli
|
brotli = "3.3.4" # used for decompressing tarballs over HTTPS, if the server supports brotli
|
||||||
|
|
|
@ -3,15 +3,28 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use roc_error_macros::internal_error;
|
||||||
use tar::Archive;
|
use tar::Archive;
|
||||||
|
use tempfile::TempDir;
|
||||||
|
|
||||||
use crate::https::{self, PackageMetadata, Problem};
|
use crate::https::{self, PackageMetadata, Problem};
|
||||||
|
|
||||||
const MAX_DOWNLOAD_BYTES: u64 = 32 * 1_000_000_000; // GB
|
const MAX_DOWNLOAD_BYTES: u64 = 32 * 1_000_000_000; // GB
|
||||||
const TARBALL_BUFFER_SIZE: usize = 16 * 1_000_000; // MB
|
const TARBALL_BUFFER_SIZE: usize = 16 * 1_000_000; // MB
|
||||||
|
|
||||||
/// Look in the given cache dir to see if we already have an entry for the given URL. If we do,
|
#[derive(Copy, Clone, Debug)]
|
||||||
/// return its info. If we don't already have it, then:
|
pub enum RocCacheDir<'a> {
|
||||||
|
/// Normal scenario: reading from the user's cache dir on disk
|
||||||
|
Persistent(&'a Path),
|
||||||
|
/// For tests and such; we don't want to write to the real cache during a test!
|
||||||
|
Temp(&'a TempDir),
|
||||||
|
/// Pretty much just for build.rs - we should never be downloading anything; blow up if we try!
|
||||||
|
Disallowed,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accepts either a path to the Roc cache dir, or else a TempDir. If a TempDir, always download
|
||||||
|
/// into that dir. If the cache dir on the filesystem, then look into it to see if we already
|
||||||
|
/// have an entry for the given URL. If we do, return its info. If we don't already have it, then:
|
||||||
///
|
///
|
||||||
/// - Download and decompress the compressed tarball from the given URL
|
/// - Download and decompress the compressed tarball from the given URL
|
||||||
/// - Verify its bytes against the hash in the URL
|
/// - Verify its bytes against the hash in the URL
|
||||||
|
@ -20,23 +33,33 @@ const TARBALL_BUFFER_SIZE: usize = 16 * 1_000_000; // MB
|
||||||
/// Returns the path to the installed package (which will be in the cache dir somewhere), as well
|
/// Returns the path to the installed package (which will be in the cache dir somewhere), as well
|
||||||
/// as the requested root module filename (optionally specified via the URL fragment).
|
/// as the requested root module filename (optionally specified via the URL fragment).
|
||||||
pub fn install_package<'a>(
|
pub fn install_package<'a>(
|
||||||
roc_cache_dir: Option<&Path>,
|
roc_cache_dir: RocCacheDir<'_>,
|
||||||
url: &'a str,
|
url: &'a str,
|
||||||
) -> Result<(PathBuf, Option<&'a str>), Problem> {
|
) -> Result<(PathBuf, Option<&'a str>), Problem> {
|
||||||
let metadata = PackageMetadata::try_from(url).map_err(Problem::UrlProblem)?;
|
let metadata = PackageMetadata::try_from(url).map_err(Problem::UrlProblem)?;
|
||||||
let opt_dest_dir = match roc_cache_dir {
|
let dest_dir = match roc_cache_dir {
|
||||||
Some(dir) => {
|
RocCacheDir::Persistent(cache_dir) => {
|
||||||
let dest_dir = path_inside_cache(dir, metadata.cache_subfolder, metadata.content_hash);
|
let dest_dir =
|
||||||
|
path_inside_cache(cache_dir, metadata.cache_subfolder, metadata.content_hash);
|
||||||
|
|
||||||
if dest_dir.exists() {
|
if dest_dir.exists() {
|
||||||
// If the cache dir exists already, we assume it has the correct contents
|
// If the cache dir exists already, we assume it has the correct contents
|
||||||
// (it's a cache, after all!) and don't download anything.
|
// (it's a cache, after all!) and return early without downloading anything.
|
||||||
return Ok((dest_dir, metadata.root_module_filename));
|
return Ok((dest_dir, metadata.root_module_filename));
|
||||||
|
} else {
|
||||||
|
// Create the destination directory, since it didn't exist already.
|
||||||
|
fs::create_dir_all(&dest_dir).map_err(Problem::IoErr)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(dest_dir)
|
dest_dir
|
||||||
|
}
|
||||||
|
RocCacheDir::Temp(temp_dir) => temp_dir.path().to_path_buf(),
|
||||||
|
RocCacheDir::Disallowed => {
|
||||||
|
internal_error!(
|
||||||
|
"Tried to download a package ({:?}) via RocCacheDir::Disallowed - which was explicitly used in order to disallow downloading packages in the current context!",
|
||||||
|
url
|
||||||
|
)
|
||||||
}
|
}
|
||||||
None => None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Download the tarball into memory and verify it. Early return if it fails verification,
|
// Download the tarball into memory and verify it. Early return if it fails verification,
|
||||||
|
@ -49,17 +72,6 @@ pub fn install_package<'a>(
|
||||||
buf
|
buf
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the destination directory if it didn't exist already.
|
|
||||||
// Default to unpacking into a tempdir if no cache dir was provided.
|
|
||||||
let dest_dir = match opt_dest_dir {
|
|
||||||
Some(dir) => {
|
|
||||||
fs::create_dir_all(&dir).map_err(Problem::IoErr)?;
|
|
||||||
|
|
||||||
dir
|
|
||||||
}
|
|
||||||
None => tempfile::tempdir().map_err(Problem::IoErr)?.into_path(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Archive::new(tarball_bytes.as_slice())
|
Archive::new(tarball_bytes.as_slice())
|
||||||
.unpack(&dest_dir)
|
.unpack(&dest_dir)
|
||||||
.map_err(Problem::IoErr)?;
|
.map_err(Problem::IoErr)?;
|
||||||
|
@ -80,6 +92,8 @@ const ROC_CACHE_DIR_NAME: &str = "Roc";
|
||||||
// e.g. the "roc" in ~/.cache/roc
|
// e.g. the "roc" in ~/.cache/roc
|
||||||
const ROC_CACHE_DIR_NAME: &str = "roc";
|
const ROC_CACHE_DIR_NAME: &str = "roc";
|
||||||
|
|
||||||
|
const ROC_VERSION: &str = include_str!("../../../version.txt");
|
||||||
|
|
||||||
/// This looks up environment variables, so it should ideally be called once and then cached!
|
/// This looks up environment variables, so it should ideally be called once and then cached!
|
||||||
///
|
///
|
||||||
/// Returns a path of the form cache_dir_path.join(ROC_CACHE_DIR_NAME) where cache_dir_path is:
|
/// Returns a path of the form cache_dir_path.join(ROC_CACHE_DIR_NAME) where cache_dir_path is:
|
||||||
|
@ -92,14 +106,14 @@ const ROC_CACHE_DIR_NAME: &str = "roc";
|
||||||
///
|
///
|
||||||
/// Returns None if XDG_CACHE_HOME is not set, and also we can't determine the home directory
|
/// Returns None if XDG_CACHE_HOME is not set, and also we can't determine the home directory
|
||||||
/// (or if %APPDATA% is missing on Windows) on this system.
|
/// (or if %APPDATA% is missing on Windows) on this system.
|
||||||
pub fn roc_cache_dir(roc_version: &str) -> Option<PathBuf> {
|
pub fn roc_cache_dir() -> Option<PathBuf> {
|
||||||
// Respect XDG, if the system appears to be using it.
|
// Respect XDG, if the system appears to be using it.
|
||||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
match env::var_os("XDG_CACHE_HOME") {
|
match env::var_os("XDG_CACHE_HOME") {
|
||||||
Some(xdg_cache_home) => Some(
|
Some(xdg_cache_home) => Some(
|
||||||
Path::new(&xdg_cache_home)
|
Path::new(&xdg_cache_home)
|
||||||
.join(ROC_CACHE_DIR_NAME)
|
.join(ROC_CACHE_DIR_NAME)
|
||||||
.join(roc_version),
|
.join(ROC_VERSION),
|
||||||
),
|
),
|
||||||
None => {
|
None => {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use blake3::Hasher;
|
use blake3::Hasher;
|
||||||
use flate2;
|
|
||||||
use std::io::{self, ErrorKind, Read, Write};
|
use std::io::{self, ErrorKind, Read, Write};
|
||||||
|
|
||||||
// gzip should be the most widely supported, and brotli offers the highest compession.
|
// gzip should be the most widely supported, and brotli offers the highest compession.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod cache;
|
pub mod cache;
|
||||||
pub mod https;
|
mod https;
|
||||||
pub mod tarball;
|
pub mod tarball;
|
||||||
|
|
|
@ -21,6 +21,7 @@ roc_module = {path = "../compiler/module"}
|
||||||
roc_mono = {path = "../compiler/mono"}
|
roc_mono = {path = "../compiler/mono"}
|
||||||
roc_parse = {path = "../compiler/parse"}
|
roc_parse = {path = "../compiler/parse"}
|
||||||
roc_region = {path = "../compiler/region"}
|
roc_region = {path = "../compiler/region"}
|
||||||
|
roc_packaging = {path = "../packaging"}
|
||||||
roc_reporting = {path = "../reporting"}
|
roc_reporting = {path = "../reporting"}
|
||||||
roc_std = {path = "../roc_std"}
|
roc_std = {path = "../roc_std"}
|
||||||
roc_target = {path = "../compiler/roc_target"}
|
roc_target = {path = "../compiler/roc_target"}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_load::{ExecutionMode, LoadConfig, Threading};
|
use roc_load::{ExecutionMode, LoadConfig, Threading};
|
||||||
|
use roc_packaging::cache::{self, RocCacheDir};
|
||||||
use roc_reporting::report::{Palette, Severity};
|
use roc_reporting::report::{Palette, Severity};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -53,12 +54,16 @@ pub fn compile_to_mono<'a, 'i, I: Iterator<Item = &'i str>>(
|
||||||
let src_dir = PathBuf::from("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
let (bytes_before_expr, module_src) = promote_expr_to_module(arena, defs, expr);
|
let (bytes_before_expr, module_src) = promote_expr_to_module(arena, defs, expr);
|
||||||
let exposed_types = Default::default();
|
let exposed_types = Default::default();
|
||||||
|
let roc_cache_dir = cache::roc_cache_dir().unwrap_or_else(|| {
|
||||||
|
todo!("Gracefully handle not being able to find default Roc cache dir.")
|
||||||
|
});
|
||||||
let loaded = roc_load::load_and_monomorphize_from_str(
|
let loaded = roc_load::load_and_monomorphize_from_str(
|
||||||
arena,
|
arena,
|
||||||
filename,
|
filename,
|
||||||
module_src,
|
module_src,
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
|
RocCacheDir::Persistent(roc_cache_dir.as_path()),
|
||||||
LoadConfig {
|
LoadConfig {
|
||||||
target_info,
|
target_info,
|
||||||
render: roc_reporting::report::RenderTarget::ColorTerminal,
|
render: roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
|
|
@ -23,6 +23,7 @@ roc_mono = {path = "../compiler/mono"}
|
||||||
roc_parse = {path = "../compiler/parse"}
|
roc_parse = {path = "../compiler/parse"}
|
||||||
roc_module = {path = "../compiler/module"}
|
roc_module = {path = "../compiler/module"}
|
||||||
roc_repl_eval = {path = "../repl_eval"}
|
roc_repl_eval = {path = "../repl_eval"}
|
||||||
|
roc_packaging = {path = "../packaging"}
|
||||||
roc_reporting = {path = "../reporting"}
|
roc_reporting = {path = "../reporting"}
|
||||||
roc_std = {path = "../roc_std"}
|
roc_std = {path = "../roc_std"}
|
||||||
roc_target = {path = "../compiler/roc_target"}
|
roc_target = {path = "../compiler/roc_target"}
|
||||||
|
|
|
@ -88,6 +88,7 @@ mod test {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib};
|
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib};
|
||||||
use roc_load::{ExecutionMode, LoadConfig, Threading};
|
use roc_load::{ExecutionMode, LoadConfig, Threading};
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ mod test {
|
||||||
source,
|
source,
|
||||||
src_dir.path().to_path_buf(),
|
src_dir.path().to_path_buf(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
load_config,
|
load_config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -33,6 +33,7 @@ roc_parse = { path = "../compiler/parse" }
|
||||||
roc_target = { path = "../compiler/roc_target" }
|
roc_target = { path = "../compiler/roc_target" }
|
||||||
roc_test_utils = { path = "../test_utils" }
|
roc_test_utils = { path = "../test_utils" }
|
||||||
roc_solve = { path = "../compiler/solve" }
|
roc_solve = { path = "../compiler/solve" }
|
||||||
|
roc_packaging = { path = "../packaging" }
|
||||||
|
|
||||||
pretty_assertions.workspace = true
|
pretty_assertions.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
|
|
|
@ -15,6 +15,7 @@ mod test_reporting {
|
||||||
use roc_can::expr::PendingDerives;
|
use roc_can::expr::PendingDerives;
|
||||||
use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
|
||||||
use roc_module::symbol::{Interns, ModuleId};
|
use roc_module::symbol::{Interns, ModuleId};
|
||||||
|
use roc_packaging::cache::RocCacheDir;
|
||||||
use roc_region::all::LineInfo;
|
use roc_region::all::LineInfo;
|
||||||
use roc_reporting::report::{
|
use roc_reporting::report::{
|
||||||
can_problem, parse_problem, type_problem, RenderTarget, Report, Severity, ANSI_STYLE_CODES,
|
can_problem, parse_problem, type_problem, RenderTarget, Report, Severity, ANSI_STYLE_CODES,
|
||||||
|
@ -90,8 +91,13 @@ mod test_reporting {
|
||||||
threading: Threading::Single,
|
threading: Threading::Single,
|
||||||
exec_mode: ExecutionMode::Check,
|
exec_mode: ExecutionMode::Check,
|
||||||
};
|
};
|
||||||
let result =
|
let result = roc_load::load_and_typecheck(
|
||||||
roc_load::load_and_typecheck(arena, full_file_path, exposed_types, load_config);
|
arena,
|
||||||
|
full_file_path,
|
||||||
|
exposed_types,
|
||||||
|
RocCacheDir::Disallowed,
|
||||||
|
load_config,
|
||||||
|
);
|
||||||
drop(file);
|
drop(file);
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue