mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
disable subs caching on windows statically
This commit is contained in:
parent
cc24186a10
commit
71e78f77a2
2 changed files with 51 additions and 35 deletions
|
@ -1,7 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use bumpalo::Bump;
|
||||
use roc_load_internal::file::{LoadingProblem, Threading};
|
||||
use roc_module::symbol::ModuleId;
|
||||
|
||||
const SKIP_SUBS_CACHE: bool = {
|
||||
|
@ -39,44 +38,59 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) {
|
|||
.join(filename);
|
||||
println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap());
|
||||
|
||||
let mut output_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
output_path.extend(&[filename]);
|
||||
output_path.set_extension("dat");
|
||||
|
||||
#[cfg(not(windows))]
|
||||
if SKIP_SUBS_CACHE {
|
||||
write_subs_for_module_dummy(&output_path)
|
||||
} else {
|
||||
write_subs_for_module_real(module_id, filename, &output_path)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
write_subs_for_module_dummy(&output_path)
|
||||
}
|
||||
|
||||
fn write_subs_for_module_dummy(output_path: &Path) {
|
||||
// write out a dummy file
|
||||
std::fs::write(output_path, &[]).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn write_subs_for_module_real(module_id: ModuleId, filename: &str, output_path: &Path) {
|
||||
use roc_load_internal::file::{LoadingProblem, Threading};
|
||||
|
||||
let arena = Bump::new();
|
||||
let src_dir = PathBuf::from(".");
|
||||
let source = roc_builtins::roc::module_source(module_id);
|
||||
let target_info = roc_target::TargetInfo::default_x86_64();
|
||||
|
||||
let mut output_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
output_path.extend(&[filename]);
|
||||
output_path.set_extension("dat");
|
||||
let res_module = roc_load_internal::file::load_and_typecheck_str(
|
||||
&arena,
|
||||
PathBuf::from(filename),
|
||||
source,
|
||||
src_dir,
|
||||
Default::default(),
|
||||
target_info,
|
||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||
Threading::AllAvailable,
|
||||
);
|
||||
|
||||
if SKIP_SUBS_CACHE {
|
||||
// write out a dummy file
|
||||
std::fs::write(output_path, &[]).unwrap();
|
||||
} else {
|
||||
let res_module = roc_load_internal::file::load_and_typecheck_str(
|
||||
&arena,
|
||||
PathBuf::from(filename),
|
||||
source,
|
||||
src_dir,
|
||||
Default::default(),
|
||||
target_info,
|
||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||
Threading::AllAvailable,
|
||||
);
|
||||
let module = match res_module {
|
||||
Ok(v) => v,
|
||||
Err(LoadingProblem::FormattedReport(report)) => {
|
||||
panic!("{}", report);
|
||||
}
|
||||
Err(other) => {
|
||||
panic!("build_file failed with error:\n{:?}", other);
|
||||
}
|
||||
};
|
||||
|
||||
let module = match res_module {
|
||||
Ok(v) => v,
|
||||
Err(LoadingProblem::FormattedReport(report)) => {
|
||||
panic!("{}", report);
|
||||
}
|
||||
Err(other) => {
|
||||
panic!("build_file failed with error:\n{:?}", other);
|
||||
}
|
||||
};
|
||||
let subs = module.solved.inner();
|
||||
let exposed_vars_by_symbol: Vec<_> = module.exposed_to_host.into_iter().collect();
|
||||
|
||||
let subs = module.solved.inner();
|
||||
let exposed_vars_by_symbol: Vec<_> = module.exposed_to_host.into_iter().collect();
|
||||
|
||||
let mut file = std::fs::File::create(&output_path).unwrap();
|
||||
subs.serialize(&exposed_vars_by_symbol, &mut file).unwrap();
|
||||
}
|
||||
let mut file = std::fs::File::create(&output_path).unwrap();
|
||||
subs.serialize(&exposed_vars_by_symbol, &mut file).unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue