Provide roc_cache_dir everywhere

This commit is contained in:
Richard Feldman 2022-11-20 17:03:17 -05:00
parent 13bed30411
commit 721841fa1f
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
41 changed files with 303 additions and 114 deletions

15
Cargo.lock generated
View file

@ -3435,6 +3435,7 @@ dependencies = [
"roc_error_macros",
"roc_load",
"roc_module",
"roc_packaging",
"roc_parse",
"roc_problem",
"roc_region",
@ -3656,6 +3657,7 @@ dependencies = [
"roc_highlight",
"roc_load",
"roc_module",
"roc_packaging",
"roc_parse",
"roc_region",
"roc_reporting",
@ -3702,6 +3704,7 @@ dependencies = [
"roc_collections",
"roc_load",
"roc_module",
"roc_packaging",
"roc_parse",
"roc_problem",
"roc_region",
@ -3833,6 +3836,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_packaging",
"roc_reporting",
"roc_std",
"roc_target",
@ -3897,6 +3901,7 @@ dependencies = [
"roc_error_macros",
"roc_load",
"roc_mono",
"roc_packaging",
"roc_reporting",
"serde",
"target-lexicon",
@ -3913,6 +3918,7 @@ dependencies = [
"roc_collections",
"roc_load_internal",
"roc_module",
"roc_packaging",
"roc_reporting",
"roc_target",
"roc_types",
@ -3952,6 +3958,7 @@ dependencies = [
"roc_tracing",
"roc_types",
"roc_unify",
"tempfile",
"ven_pretty",
]
@ -4007,6 +4014,7 @@ dependencies = [
"flate2",
"indoc",
"pretty_assertions",
"roc_error_macros",
"roc_parse",
"tar",
"tempfile",
@ -4091,6 +4099,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_packaging",
"roc_parse",
"roc_region",
"roc_reporting",
@ -4119,6 +4128,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_packaging",
"roc_parse",
"roc_region",
"roc_repl_eval",
@ -4175,6 +4185,7 @@ dependencies = [
"roc_fmt",
"roc_load",
"roc_module",
"roc_packaging",
"roc_parse",
"roc_problem",
"roc_region",
@ -4215,6 +4226,7 @@ dependencies = [
"roc_exhaustive",
"roc_load",
"roc_module",
"roc_packaging",
"roc_parse",
"roc_problem",
"roc_region",
@ -5025,6 +5037,7 @@ dependencies = [
"roc_derive_key",
"roc_load_internal",
"roc_module",
"roc_packaging",
"roc_region",
"roc_reporting",
"roc_solve",
@ -5057,6 +5070,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_packaging",
"roc_parse",
"roc_problem",
"roc_region",
@ -5085,6 +5099,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_packaging",
"roc_reporting",
"roc_target",
"roc_tracing",

View file

@ -10,6 +10,7 @@ members = [
"crates/highlight",
"crates/error_macros",
"crates/reporting",
"crates/packaging",
"crates/repl_cli",
"crates/repl_eval",
"crates/repl_test",

View file

@ -20,6 +20,7 @@ roc_solve = { path = "../compiler/solve"}
roc_load = { path = "../compiler/load" }
roc_target = { path = "../compiler/roc_target" }
roc_error_macros = { path = "../error_macros" }
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
ven_graph = { path = "../vendor/pathfinding" }

View file

@ -1,10 +1,15 @@
use bumpalo::Bump;
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, Threading};
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::DEFAULT_PALETTE;
use roc_target::TargetInfo;
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 load_config = LoadConfig {
@ -16,8 +21,13 @@ pub fn load_module(src_file: &Path, threading: Threading) -> LoadedModule {
};
let arena = Bump::new();
let loaded =
roc_load::load_and_typecheck(&arena, src_file.to_path_buf(), subs_by_module, load_config);
let loaded = roc_load::load_and_typecheck(
&arena,
src_file.to_path_buf(),
subs_by_module,
roc_cache_dir,
load_config,
);
match loaded {
Ok(x) => x,

View file

@ -45,7 +45,6 @@ roc_collections = { path = "../compiler/collections" }
roc_can = { path = "../compiler/can" }
roc_docs = { path = "../docs" }
roc_glue = { path = "../glue" }
roc_packaging = { path = "../packaging" }
roc_parse = { path = "../compiler/parse" }
roc_region = { path = "../compiler/region" }
roc_module = { path = "../compiler/module" }
@ -55,6 +54,7 @@ roc_load = { path = "../compiler/load" }
roc_build = { path = "../compiler/build" }
roc_fmt = { path = "../compiler/fmt" }
roc_target = { path = "../compiler/roc_target" }
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
roc_error_macros = { path = "../error_macros" }
roc_editor = { path = "../editor", optional = true }

View file

@ -12,6 +12,7 @@ use roc_load::{
LoadingProblem, Threading,
};
use roc_mono::ir::OptLevel;
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use roc_target::TargetInfo;
use std::time::{Duration, Instant};
@ -67,6 +68,7 @@ pub fn build_file<'a>(
prebuilt: bool,
threading: Threading,
wasm_dev_stack_bytes: Option<u32>,
roc_cache_dir: RocCacheDir<'_>,
order: BuildOrdering,
) -> Result<BuiltFile<'a>, BuildFileError<'a>> {
let compilation_start = Instant::now();
@ -92,6 +94,7 @@ pub fn build_file<'a>(
arena,
app_module_path.clone(),
subs_by_module,
roc_cache_dir,
load_config,
);
let loaded = match load_result {
@ -464,12 +467,13 @@ fn spawn_rebuild_thread(
}
#[allow(clippy::too_many_arguments)]
pub fn check_file(
arena: &Bump,
pub fn check_file<'a>(
arena: &'a Bump,
roc_file_path: PathBuf,
emit_timings: bool,
roc_cache_dir: RocCacheDir<'_>,
threading: Threading,
) -> Result<(program::Problems, Duration), LoadingProblem> {
) -> Result<(program::Problems, Duration), LoadingProblem<'a>> {
let compilation_start = Instant::now();
// 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,
exec_mode: ExecutionMode::Check,
};
let mut loaded =
roc_load::load_and_typecheck(arena, roc_file_path, subs_by_module, load_config)?;
let mut loaded = roc_load::load_and_typecheck(
arena,
roc_file_path,
subs_by_module,
roc_cache_dir,
load_config,
)?;
let buf = &mut String::with_capacity(1024);

View file

@ -11,6 +11,7 @@ use roc_build::program::{CodeGenBackend, CodeGenOptions, Problems};
use roc_error_macros::{internal_error, user_error};
use roc_load::{ExpectMetadata, LoadingProblem, Threading};
use roc_mono::ir::OptLevel;
use roc_packaging::cache::RocCacheDir;
use std::env;
use std::ffi::{CString, OsStr};
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> {
use roc_gen_llvm::llvm::build::LlvmBackendMode;
use roc_load::{ExecutionMode, LoadConfig};
use roc_packaging::cache;
use roc_target::TargetInfo;
let start_time = Instant::now();
@ -407,6 +409,9 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
let target = &triple;
let opt_level = opt_level;
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
let subs_by_module = Default::default();
@ -419,9 +424,14 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
threading,
exec_mode: ExecutionMode::Test,
};
let loaded =
roc_load::load_and_monomorphize(arena, path.to_path_buf(), subs_by_module, load_config)
.unwrap();
let loaded = roc_load::load_and_monomorphize(
arena,
path.to_path_buf(),
subs_by_module,
RocCacheDir::Persistent(roc_cache_dir.as_path()),
load_config,
)
.unwrap();
let mut loaded = loaded;
let mut expectations = std::mem::take(&mut loaded.expectations);
@ -487,6 +497,7 @@ pub fn build(
matches: &ArgMatches,
config: BuildConfig,
triple: Triple,
roc_cache_dir: RocCacheDir<'_>,
link_type: LinkType,
) -> io::Result<i32> {
use build::build_file;
@ -518,7 +529,7 @@ pub fn build(
let start_time = Instant::now();
// 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 total_time = start_time.elapsed().as_millis();
let created_path = path.with_file_name(&filename);
@ -627,6 +638,7 @@ pub fn build(
prebuilt,
threading,
wasm_dev_stack_bytes,
roc_cache_dir,
build_ordering,
);

View file

@ -10,6 +10,7 @@ use roc_cli::{
use roc_docs::generate_docs_html;
use roc_error_macros::user_error;
use roc_load::{LoadingProblem, Threading};
use roc_packaging::cache::{self, RocCacheDir};
use std::fs::{self, FileType};
use std::io;
use std::path::{Path, PathBuf};
@ -33,10 +34,15 @@ fn main() -> io::Result<()> {
let exit_code = match matches.subcommand() {
None => {
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(
&matches,
BuildConfig::BuildAndRunIfNoErrors,
Triple::host(),
RocCacheDir::Persistent(roc_cache_dir.as_path()),
LinkType::Executable,
)
} else {
@ -47,10 +53,15 @@ fn main() -> io::Result<()> {
}
Some((CMD_RUN, matches)) => {
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(
matches,
BuildConfig::BuildAndRun,
Triple::host(),
RocCacheDir::Persistent(roc_cache_dir.as_path()),
LinkType::Executable,
)
} else {
@ -70,10 +81,15 @@ fn main() -> io::Result<()> {
}
Some((CMD_DEV, matches)) => {
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(
matches,
BuildConfig::BuildAndRunIfNoErrors,
Triple::host(),
RocCacheDir::Persistent(roc_cache_dir.as_path()),
LinkType::Executable,
)
} else {
@ -97,12 +113,21 @@ fn main() -> io::Result<()> {
Some((CMD_GEN_STUB_LIB, matches)) => {
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 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)) => {
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 (
matches.is_present(FLAG_LIB),
matches.is_present(FLAG_NO_LINK),
@ -117,6 +142,7 @@ fn main() -> io::Result<()> {
matches,
BuildConfig::BuildOnly,
target.to_triple(),
RocCacheDir::Persistent(roc_cache_dir.as_path()),
link_type,
)?)
}
@ -126,6 +152,9 @@ fn main() -> io::Result<()> {
let emit_timings = matches.is_present(FLAG_TIME);
let filename = matches.value_of_os(ROC_FILE).unwrap();
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
.value_of(roc_cli::FLAG_MAX_THREADS)
.and_then(|s| s.parse::<usize>().ok())
@ -136,7 +165,13 @@ fn main() -> io::Result<()> {
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)) => {
println!(
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",

View file

@ -13,6 +13,7 @@ roc_can = { path = "../can" }
roc_types = { path = "../types" }
roc_module = { path = "../module" }
roc_collections = { path = "../collections" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
bumpalo.workspace = true
@ -20,6 +21,7 @@ bumpalo.workspace = true
[build-dependencies]
roc_builtins = { path = "../builtins" }
roc_module = { path = "../module" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_target = { path = "../roc_target" }
roc_can = { path = "../can" }

View file

@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
#[cfg(not(windows))]
use bumpalo::Bump;
use roc_module::symbol::ModuleId;
use roc_packaging::cache::RocCacheDir;
#[cfg(not(windows))]
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};
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 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,
PathBuf::from(filename),
source,
src_dir,
cwd,
Default::default(),
target_info,
roc_reporting::report::RenderTarget::ColorTerminal,
roc_reporting::report::DEFAULT_PALETTE,
roc_cache_dir,
RocCacheDir::Disallowed,
Threading::AllAvailable,
);

View file

@ -4,6 +4,7 @@ use bumpalo::Bump;
use roc_can::module::{ExposedByModule, TypeState};
use roc_collections::all::MutMap;
use roc_module::symbol::ModuleId;
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{Palette, RenderTarget};
use roc_target::TargetInfo;
use std::path::PathBuf;
@ -26,11 +27,19 @@ fn load<'a>(
arena: &'a Bump,
load_start: LoadStart<'a>,
exposed_types: ExposedByModule,
roc_cache_dir: RocCacheDir<'_>,
load_config: LoadConfig,
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
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
@ -41,6 +50,7 @@ pub fn load_single_threaded<'a>(
target_info: TargetInfo,
render: RenderTarget,
palette: Palette,
roc_cache_dir: RocCacheDir<'_>,
exec_mode: ExecutionMode,
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
let cached_subs = read_cached_types();
@ -54,6 +64,7 @@ pub fn load_single_threaded<'a>(
render,
palette,
exec_mode,
roc_cache_dir,
)
}
@ -87,24 +98,26 @@ pub fn load_and_monomorphize_from_str<'a>(
src: &'a str,
src_dir: PathBuf,
exposed_types: ExposedByModule,
roc_cache_dir: RocCacheDir<'_>,
load_config: LoadConfig,
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
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),
TypeChecked(_) => unreachable!(""),
}
}
pub fn load_and_monomorphize(
arena: &Bump,
pub fn load_and_monomorphize<'a>(
arena: &'a Bump,
filename: PathBuf,
exposed_types: ExposedByModule,
roc_cache_dir: RocCacheDir<'_>,
load_config: LoadConfig,
) -> Result<MonomorphizedModule<'_>, LoadMonomorphizedError<'_>> {
) -> Result<MonomorphizedModule<'a>, LoadMonomorphizedError<'a>> {
use LoadResult::*;
let load_start = LoadStart::from_path(
@ -115,18 +128,19 @@ pub fn load_and_monomorphize(
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),
TypeChecked(module) => Err(LoadMonomorphizedError::ErrorModule(module)),
}
}
pub fn load_and_typecheck(
arena: &Bump,
pub fn load_and_typecheck<'a>(
arena: &'a Bump,
filename: PathBuf,
exposed_types: ExposedByModule,
roc_cache_dir: RocCacheDir<'_>,
load_config: LoadConfig,
) -> Result<LoadedModule, LoadingProblem<'_>> {
) -> Result<LoadedModule, LoadingProblem<'a>> {
use LoadResult::*;
let load_start = LoadStart::from_path(
@ -137,7 +151,7 @@ pub fn load_and_typecheck(
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!(""),
TypeChecked(module) => Ok(module),
}
@ -152,11 +166,12 @@ pub fn load_and_typecheck_str<'a>(
exposed_types: ExposedByModule,
target_info: TargetInfo,
render: RenderTarget,
roc_cache_dir: RocCacheDir<'_>,
palette: Palette,
) -> Result<LoadedModule, LoadingProblem<'a>> {
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
// 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,
render,
palette,
roc_cache_dir,
ExecutionMode::Check,
)? {
Monomorphized(_) => unreachable!(""),

View file

@ -36,6 +36,7 @@ ven_pretty = { path = "../../vendor/pretty" }
bumpalo.workspace = true
parking_lot.workspace = true
crossbeam.workspace = true
tempfile.workspace = true
[dev-dependencies]
roc_test_utils = { path = "../../test_utils" }

View file

@ -36,7 +36,7 @@ use roc_mono::ir::{
use roc_mono::layout::{
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::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent};
use roc_parse::header::{HeaderFor, ModuleNameEnum, PackageName};
@ -950,8 +950,6 @@ struct State<'a> {
type CachedTypeState = Arc<Mutex<MutMap<ModuleId, TypeState>>>;
const ROC_VERSION: &str = include_str!("../../../../version.txt");
impl<'a> State<'a> {
fn goal_phase(&self) -> Phase {
self.exec_mode.goal_phase()
@ -1211,7 +1209,7 @@ pub fn load_and_typecheck_str<'a>(
target_info: TargetInfo,
render: RenderTarget,
palette: Palette,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
threading: Threading,
) -> Result<LoadedModule, LoadingProblem<'a>> {
use LoadResult::*;
@ -1230,7 +1228,14 @@ pub fn load_and_typecheck_str<'a>(
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!(""),
TypeChecked(module) => Ok(module),
}
@ -1255,7 +1260,7 @@ impl<'a> LoadStart<'a> {
arena: &'a Bump,
filename: PathBuf,
render: RenderTarget,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
palette: Palette,
) -> Result<Self, LoadingProblem<'a>> {
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
@ -1387,7 +1392,7 @@ impl<'a> LoadStart<'a> {
arena: &'a Bump,
filename: PathBuf,
src: &'a str,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
src_dir: PathBuf,
) -> Result<Self, LoadingProblem<'a>> {
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
@ -1487,6 +1492,7 @@ pub fn load<'a>(
load_start: LoadStart<'a>,
exposed_types: ExposedByModule,
cached_types: MutMap<ModuleId, TypeState>,
roc_cache_dir: RocCacheDir<'_>,
load_config: LoadConfig,
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
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 {
Threads::Single => load_single_threaded(
arena,
@ -1529,7 +1529,7 @@ pub fn load<'a>(
load_config.render,
load_config.palette,
load_config.exec_mode,
&roc_cache_dir,
roc_cache_dir,
),
Threads::Many(threads) => load_multi_threaded(
arena,
@ -1541,7 +1541,7 @@ pub fn load<'a>(
load_config.palette,
threads,
load_config.exec_mode,
&roc_cache_dir,
roc_cache_dir,
),
}
}
@ -1557,7 +1557,7 @@ pub fn load_single_threaded<'a>(
render: RenderTarget,
palette: Palette,
exec_mode: ExecutionMode,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
let LoadStart {
arc_modules,
@ -1618,7 +1618,7 @@ pub fn load_single_threaded<'a>(
&worker_msg_rx,
&msg_tx,
&src_dir,
&roc_cache_dir,
roc_cache_dir,
target_info,
);
@ -1813,7 +1813,7 @@ fn load_multi_threaded<'a>(
palette: Palette,
available_threads: usize,
exec_mode: ExecutionMode,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
let LoadStart {
arc_modules,
@ -1980,7 +1980,7 @@ fn worker_task_step<'a>(
worker_msg_rx: &crossbeam::channel::Receiver<WorkerMsg>,
msg_tx: &MsgSender<'a>,
src_dir: &Path,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
target_info: TargetInfo,
) -> Result<ControlFlow<(), ()>, LoadingProblem<'a>> {
match worker_msg_rx.try_recv() {
@ -2055,7 +2055,7 @@ fn worker_task<'a>(
worker_msg_rx: crossbeam::channel::Receiver<WorkerMsg>,
msg_tx: MsgSender<'a>,
src_dir: &Path,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
target_info: TargetInfo,
) -> Result<(), LoadingProblem<'a>> {
// Keep listening until we receive a Shutdown msg
@ -3167,7 +3167,7 @@ fn load_platform_module<'a>(
) -> Result<Msg<'a>, LoadingProblem<'a>> {
let module_start_time = 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();
match file {
@ -3304,7 +3304,7 @@ fn load_module<'a>(
module_name: PQModuleName<'a>,
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
arc_shorthands: Arc<Mutex<MutMap<&'a str, PackageName<'a>>>>,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
ident_ids_by_module: SharedIdentIdsByModule,
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
let module_start_time = Instant::now();
@ -3492,7 +3492,7 @@ fn parse_header<'a>(
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
ident_ids_by_module: SharedIdentIdsByModule,
src_bytes: &'a [u8],
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
start_time: Instant,
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
let parse_start = Instant::now();
@ -3731,7 +3731,7 @@ fn load_filename<'a>(
opt_expected_module_name: Option<PackageQualified<'a, ModuleName>>,
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
ident_ids_by_module: SharedIdentIdsByModule,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
module_start_time: Instant,
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
let file_io_start = Instant::now();
@ -3768,7 +3768,7 @@ fn load_from_str<'a>(
src: &'a str,
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
ident_ids_by_module: SharedIdentIdsByModule,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
module_start_time: Instant,
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
let file_io_start = Instant::now();
@ -5638,7 +5638,7 @@ fn run_task<'a>(
arena: &'a Bump,
src_dir: &Path,
msg_tx: MsgSender<'a>,
roc_cache_dir: &Path,
roc_cache_dir: RocCacheDir<'_>,
target_info: TargetInfo,
) -> Result<(), LoadingProblem<'a>> {
use BuildTask::*;

View file

@ -21,6 +21,7 @@ use roc_load_internal::file::{ExecutionMode, LoadConfig, Threading};
use roc_load_internal::file::{LoadResult, LoadStart, LoadedModule, LoadingProblem};
use roc_module::ident::ModuleName;
use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir;
use roc_problem::can::Problem;
use roc_region::all::LineInfo;
use roc_reporting::report::RenderTarget;
@ -40,7 +41,13 @@ fn load_and_typecheck(
) -> Result<LoadedModule, LoadingProblem> {
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 {
target_info,
render: RenderTarget::Generic,
@ -54,6 +61,7 @@ fn load_and_typecheck(
load_start,
exposed_types,
Default::default(), // these tests will re-compile the builtins
RocCacheDir::Disallowed,
load_config,
)? {
Monomorphized(_) => unreachable!(""),

View file

@ -10,6 +10,7 @@ description = "The entry point of Roc's type inference system. Implements type i
roc_collections = { path = "../collections" }
roc_error_macros = { path = "../../error_macros" }
roc_exhaustive = { path = "../exhaustive" }
roc_packaging = { path = "../../packaging" }
roc_region = { path = "../region" }
roc_module = { path = "../module" }
roc_types = { path = "../types" }

View file

@ -18,6 +18,7 @@ mod solve_expr {
};
use roc_load::LoadedModule;
use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir;
use roc_problem::can::Problem;
use roc_region::all::{LineColumn, LineColumnRegion, LineInfo, Region};
use roc_reporting::report::{can_problem, type_problem, RocDocAllocator};
@ -108,6 +109,7 @@ mod solve_expr {
exposed_types,
roc_target::TargetInfo::default_x86_64(),
roc_reporting::report::RenderTarget::Generic,
RocCacheDir::Disallowed,
roc_reporting::report::DEFAULT_PALETTE,
);

View file

@ -20,6 +20,7 @@ roc_derive_key = { path = "../derive_key" }
roc_derive = { path = "../derive", features = ["debug-derived-symbols", "open-extension-vars"] }
roc_target = { path = "../roc_target" }
roc_types = { path = "../types" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_constrain = { path = "../constrain" }
roc_region = { path = "../region" }

View file

@ -2,6 +2,7 @@ use std::fmt::Write as _; // import without risk of name clashing
use std::path::PathBuf;
use bumpalo::Bump;
use roc_packaging::cache::RocCacheDir;
use ven_pretty::DocAllocator;
use crate::pretty_print::{pretty_print_def, Ctx};
@ -490,6 +491,7 @@ where
target_info,
roc_reporting::report::RenderTarget::ColorTerminal,
roc_reporting::report::DEFAULT_PALETTE,
RocCacheDir::Disallowed,
Threading::AllAvailable,
)
.unwrap();

View file

@ -30,6 +30,7 @@ roc_unify = { path = "../unify" }
roc_utils = { path = "../../utils" }
roc_solve = { path = "../solve" }
roc_mono = { path = "../mono" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_load = { path = "../load" }
roc_can = { path = "../can" }

View file

@ -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_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
use roc_mono::ir::OptLevel;
use roc_packaging::cache::RocCacheDir;
use roc_region::all::LineInfo;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use roc_utils::zig;
@ -80,6 +81,7 @@ fn create_llvm_module<'a>(
module_src,
src_dir,
Default::default(),
RocCacheDir::Disallowed,
load_config,
);

View file

@ -18,6 +18,7 @@ roc_load = { path = "../load" }
roc_can = { path = "../can" }
roc_mono = { path = "../mono" }
roc_target = { path = "../roc_target" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_tracing = { path = "../../tracing" }

View file

@ -13,16 +13,15 @@ extern crate indoc;
#[allow(dead_code)]
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
use roc_collections::all::MutMap;
use roc_load::ExecutionMode;
use roc_load::LoadConfig;
use test_mono_macros::*;
use roc_collections::all::MutMap;
use roc_load::Threading;
use roc_module::symbol::Symbol;
use roc_mono::ir::Proc;
use roc_mono::ir::ProcLayout;
use roc_mono::layout::STLayoutInterner;
use test_mono_macros::*;
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) {
use bumpalo::Bump;
use roc_packaging::cache::RocCacheDir;
use std::path::PathBuf;
let arena = &Bump::new();
@ -107,6 +107,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
module_src,
src_dir,
Default::default(),
RocCacheDir::Disallowed,
load_config,
);

View file

@ -20,6 +20,7 @@ roc_parse = { path = "../compiler/parse" }
roc_target = { path = "../compiler/roc_target" }
roc_collections = { path = "../compiler/collections" }
roc_highlight = { path = "../highlight"}
roc_packaging = { path = "../packaging"}
roc_reporting = { path = "../reporting"}
bumpalo.workspace = true
snafu.workspace = true

View file

@ -14,6 +14,7 @@ use roc_load::docs::{DocEntry, TypeAnnotation};
use roc_load::docs::{Documentation, ModuleDocumentation, RecordField};
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_module::symbol::{IdentIdsByModule, Interns, ModuleId};
use roc_packaging::cache::{self, RocCacheDir};
use roc_parse::ident::{parse_ident, Ident};
use roc_parse::state::State;
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> {
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());
for filename in filenames {
@ -462,7 +466,13 @@ pub fn load_modules_for_files(filenames: Vec<PathBuf>) -> Vec<LoadedModule> {
threading: Threading::AllAvailable,
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),
Err(LoadingProblem::FormattedReport(report)) => {
eprintln!("{}", report);

View file

@ -30,6 +30,7 @@ roc_problem = { path = "../compiler/problem" }
roc_types = { path = "../compiler/types" }
roc_unify = { path = "../compiler/unify" }
roc_utils = { path = "../utils"}
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
roc_solve = { path = "../compiler/solve" }
ven_graph = { path = "../vendor/pathfinding" }

View file

@ -28,6 +28,7 @@ use roc_ast::mem_pool::pool::Pool;
use roc_ast::module::load_module;
use roc_load::Threading;
use roc_module::symbol::IdentIds;
use roc_packaging::cache::{self, RocCacheDir};
use roc_types::subs::VarStore;
use std::collections::HashSet;
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);
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 dep_idents = IdentIds::exposed_builtins(8);

View file

@ -237,6 +237,7 @@ pub mod test_ed_model {
use roc_load::{LoadedModule, Threading};
use roc_module::symbol::IdentIds;
use roc_module::symbol::ModuleIds;
use roc_packaging::cache::RocCacheDir;
use roc_types::subs::VarStore;
use std::fs;
use std::fs::File;
@ -329,7 +330,11 @@ pub mod test_ed_model {
writeln!(file, "{}", clean_code_str)
.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(
clean_code_str,

View file

@ -13,6 +13,7 @@ roc_intern = { path = "../compiler/intern" }
roc_mono = { path = "../compiler/mono" }
roc_load = { path = "../compiler/load" }
roc_reporting = { path = "../reporting" }
roc_packaging = { path = "../packaging" }
roc_types = { path = "../compiler/types" }
roc_builtins = { path = "../compiler/builtins" }
roc_module = { path = "../compiler/module" }

View file

@ -3,6 +3,7 @@ use crate::types::{Env, Types};
use bumpalo::Bump;
use roc_intern::GlobalInterner;
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_packaging::cache::{self, RocCacheDir};
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use roc_target::{Architecture, OperatingSystem, TargetInfo};
use std::fs::File;
@ -82,7 +83,9 @@ pub fn load_types(
ignore_errors: IgnoreErrors,
) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
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 subs_by_module = Default::default();
let LoadedModule {
@ -97,6 +100,7 @@ pub fn load_types(
arena,
full_file_path,
subs_by_module,
RocCacheDir::Persistent(roc_cache_dir.as_path()),
LoadConfig {
target_info,
render: RenderTarget::Generic,

View file

@ -17,6 +17,7 @@ roc_build = { path = "../compiler/build" }
roc_collections = { path = "../compiler/collections" }
roc_error_macros = { path = "../error_macros" }
roc_load = { path = "../compiler/load" }
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
bumpalo.workspace = true

View file

@ -9,6 +9,7 @@ use roc_build::link::{rebuild_host, LinkType};
use roc_error_macros::internal_error;
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, Threading};
use roc_mono::ir::OptLevel;
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use std::cmp::Ordering;
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.
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.
// 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.
@ -114,6 +119,7 @@ pub fn generate_stub_lib(input_path: &Path, triple: &Triple) -> std::io::Result<
arena,
input_path.to_path_buf(),
subs_by_module,
roc_cache_dir,
LoadConfig {
target_info,
render: RenderTarget::Generic,

View file

@ -9,6 +9,7 @@ description = "Functionality for packaging Roc source code - e.g. for distributi
[dependencies]
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
brotli = "3.3.4" # used for decompressing tarballs over HTTPS, if the server supports brotli

View file

@ -3,15 +3,28 @@ use std::{
path::{Path, PathBuf},
};
use roc_error_macros::internal_error;
use tar::Archive;
use tempfile::TempDir;
use crate::https::{self, PackageMetadata, Problem};
const MAX_DOWNLOAD_BYTES: u64 = 32 * 1_000_000_000; // GB
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,
/// return its info. If we don't already have it, then:
#[derive(Copy, Clone, Debug)]
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
/// - 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
/// as the requested root module filename (optionally specified via the URL fragment).
pub fn install_package<'a>(
roc_cache_dir: Option<&Path>,
roc_cache_dir: RocCacheDir<'_>,
url: &'a str,
) -> Result<(PathBuf, Option<&'a str>), Problem> {
let metadata = PackageMetadata::try_from(url).map_err(Problem::UrlProblem)?;
let opt_dest_dir = match roc_cache_dir {
Some(dir) => {
let dest_dir = path_inside_cache(dir, metadata.cache_subfolder, metadata.content_hash);
let dest_dir = match roc_cache_dir {
RocCacheDir::Persistent(cache_dir) => {
let dest_dir =
path_inside_cache(cache_dir, metadata.cache_subfolder, metadata.content_hash);
if dest_dir.exists() {
// 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));
} 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,
@ -49,17 +72,6 @@ pub fn install_package<'a>(
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())
.unpack(&dest_dir)
.map_err(Problem::IoErr)?;
@ -80,6 +92,8 @@ const ROC_CACHE_DIR_NAME: &str = "Roc";
// e.g. the "roc" in ~/.cache/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!
///
/// 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
/// (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.
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
match env::var_os("XDG_CACHE_HOME") {
Some(xdg_cache_home) => Some(
Path::new(&xdg_cache_home)
.join(ROC_CACHE_DIR_NAME)
.join(roc_version),
.join(ROC_VERSION),
),
None => {
#[cfg(windows)]

View file

@ -1,5 +1,4 @@
use blake3::Hasher;
use flate2;
use std::io::{self, ErrorKind, Read, Write};
// gzip should be the most widely supported, and brotli offers the highest compession.

View file

@ -1,3 +1,3 @@
pub mod cache;
pub mod https;
mod https;
pub mod tarball;

View file

@ -21,6 +21,7 @@ roc_module = {path = "../compiler/module"}
roc_mono = {path = "../compiler/mono"}
roc_parse = {path = "../compiler/parse"}
roc_region = {path = "../compiler/region"}
roc_packaging = {path = "../packaging"}
roc_reporting = {path = "../reporting"}
roc_std = {path = "../roc_std"}
roc_target = {path = "../compiler/roc_target"}

View file

@ -1,5 +1,6 @@
use bumpalo::Bump;
use roc_load::{ExecutionMode, LoadConfig, Threading};
use roc_packaging::cache::{self, RocCacheDir};
use roc_reporting::report::{Palette, Severity};
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 (bytes_before_expr, module_src) = promote_expr_to_module(arena, defs, expr);
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(
arena,
filename,
module_src,
src_dir,
exposed_types,
RocCacheDir::Persistent(roc_cache_dir.as_path()),
LoadConfig {
target_info,
render: roc_reporting::report::RenderTarget::ColorTerminal,

View file

@ -23,6 +23,7 @@ roc_mono = {path = "../compiler/mono"}
roc_parse = {path = "../compiler/parse"}
roc_module = {path = "../compiler/module"}
roc_repl_eval = {path = "../repl_eval"}
roc_packaging = {path = "../packaging"}
roc_reporting = {path = "../reporting"}
roc_std = {path = "../roc_std"}
roc_target = {path = "../compiler/roc_target"}

View file

@ -88,6 +88,7 @@ mod test {
use pretty_assertions::assert_eq;
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib};
use roc_load::{ExecutionMode, LoadConfig, Threading};
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use target_lexicon::Triple;
@ -124,6 +125,7 @@ mod test {
source,
src_dir.path().to_path_buf(),
Default::default(),
RocCacheDir::Disallowed,
load_config,
)
.unwrap();

View file

@ -33,6 +33,7 @@ roc_parse = { path = "../compiler/parse" }
roc_target = { path = "../compiler/roc_target" }
roc_test_utils = { path = "../test_utils" }
roc_solve = { path = "../compiler/solve" }
roc_packaging = { path = "../packaging" }
pretty_assertions.workspace = true
indoc.workspace = true

View file

@ -15,6 +15,7 @@ mod test_reporting {
use roc_can::expr::PendingDerives;
use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_module::symbol::{Interns, ModuleId};
use roc_packaging::cache::RocCacheDir;
use roc_region::all::LineInfo;
use roc_reporting::report::{
can_problem, parse_problem, type_problem, RenderTarget, Report, Severity, ANSI_STYLE_CODES,
@ -90,8 +91,13 @@ mod test_reporting {
threading: Threading::Single,
exec_mode: ExecutionMode::Check,
};
let result =
roc_load::load_and_typecheck(arena, full_file_path, exposed_types, load_config);
let result = roc_load::load_and_typecheck(
arena,
full_file_path,
exposed_types,
RocCacheDir::Disallowed,
load_config,
);
drop(file);
result