mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #3894 from roc-lang/windows-disable-subs-caching
windows disable subs caching statically
This commit is contained in:
commit
35de4c6e6e
2 changed files with 56 additions and 35 deletions
|
@ -16,9 +16,11 @@ roc_collections = { path = "../collections" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
roc_load_internal = { path = "../load_internal" }
|
|
||||||
roc_builtins = { path = "../builtins" }
|
roc_builtins = { path = "../builtins" }
|
||||||
roc_module = { path = "../module" }
|
roc_module = { path = "../module" }
|
||||||
roc_reporting = { path = "../../reporting" }
|
roc_reporting = { path = "../../reporting" }
|
||||||
roc_target = { path = "../roc_target" }
|
roc_target = { path = "../roc_target" }
|
||||||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||||
|
|
||||||
|
[target.'cfg(not(windows))'.build-dependencies]
|
||||||
|
roc_load_internal = { path = "../load_internal" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_load_internal::file::{LoadingProblem, Threading};
|
|
||||||
use roc_module::symbol::ModuleId;
|
use roc_module::symbol::ModuleId;
|
||||||
|
|
||||||
const SKIP_SUBS_CACHE: bool = {
|
const SKIP_SUBS_CACHE: bool = {
|
||||||
|
@ -39,44 +39,63 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) {
|
||||||
.join(filename);
|
.join(filename);
|
||||||
println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap());
|
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)]
|
||||||
|
{
|
||||||
|
let _ = SKIP_SUBS_CACHE;
|
||||||
|
let _ = module_id;
|
||||||
|
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 arena = Bump::new();
|
||||||
let src_dir = PathBuf::from(".");
|
let src_dir = PathBuf::from(".");
|
||||||
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();
|
||||||
|
|
||||||
let mut output_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
let res_module = roc_load_internal::file::load_and_typecheck_str(
|
||||||
output_path.extend(&[filename]);
|
&arena,
|
||||||
output_path.set_extension("dat");
|
PathBuf::from(filename),
|
||||||
|
source,
|
||||||
|
src_dir,
|
||||||
|
Default::default(),
|
||||||
|
target_info,
|
||||||
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
Threading::AllAvailable,
|
||||||
|
);
|
||||||
|
|
||||||
if SKIP_SUBS_CACHE {
|
let module = match res_module {
|
||||||
// write out a dummy file
|
Ok(v) => v,
|
||||||
std::fs::write(output_path, &[]).unwrap();
|
Err(LoadingProblem::FormattedReport(report)) => {
|
||||||
} else {
|
panic!("{}", report);
|
||||||
let res_module = roc_load_internal::file::load_and_typecheck_str(
|
}
|
||||||
&arena,
|
Err(other) => {
|
||||||
PathBuf::from(filename),
|
panic!("build_file failed with error:\n{:?}", other);
|
||||||
source,
|
}
|
||||||
src_dir,
|
};
|
||||||
Default::default(),
|
|
||||||
target_info,
|
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
|
||||||
Threading::AllAvailable,
|
|
||||||
);
|
|
||||||
|
|
||||||
let module = match res_module {
|
let subs = module.solved.inner();
|
||||||
Ok(v) => v,
|
let exposed_vars_by_symbol: Vec<_> = module.exposed_to_host.into_iter().collect();
|
||||||
Err(LoadingProblem::FormattedReport(report)) => {
|
|
||||||
panic!("{}", report);
|
|
||||||
}
|
|
||||||
Err(other) => {
|
|
||||||
panic!("build_file failed with error:\n{:?}", other);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let subs = module.solved.inner();
|
let mut file = std::fs::File::create(&output_path).unwrap();
|
||||||
let exposed_vars_by_symbol: Vec<_> = module.exposed_to_host.into_iter().collect();
|
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