mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Dynamically load find/make specializations graph if there are no type errors
This commit is contained in:
parent
34c3f266e0
commit
b809d6d452
4 changed files with 153 additions and 12 deletions
|
@ -35,6 +35,13 @@ pub struct BuiltFile {
|
|||
pub interns: Interns,
|
||||
}
|
||||
|
||||
pub enum BuildOrdering {
|
||||
/// Run up through typechecking first; continue building iff that is successful.
|
||||
BuildIfChecks,
|
||||
/// Always build the Roc binary, even if there are type errors.
|
||||
AlwaysBuild,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_file<'a>(
|
||||
arena: &'a Bump,
|
||||
|
@ -48,6 +55,7 @@ pub fn build_file<'a>(
|
|||
precompiled: bool,
|
||||
threading: Threading,
|
||||
wasm_dev_stack_bytes: Option<u32>,
|
||||
order: BuildOrdering,
|
||||
) -> Result<BuiltFile, LoadingProblem<'a>> {
|
||||
let compilation_start = Instant::now();
|
||||
let target_info = TargetInfo::from(target);
|
||||
|
@ -55,12 +63,17 @@ pub fn build_file<'a>(
|
|||
// Step 1: compile the app and generate the .o file
|
||||
let subs_by_module = Default::default();
|
||||
|
||||
let exec_mode = match order {
|
||||
BuildOrdering::BuildIfChecks => ExecutionMode::ExecutableIfCheck,
|
||||
BuildOrdering::AlwaysBuild => ExecutionMode::Executable,
|
||||
};
|
||||
|
||||
let load_config = LoadConfig {
|
||||
target_info,
|
||||
// TODO: expose this from CLI?
|
||||
render: RenderTarget::ColorTerminal,
|
||||
threading,
|
||||
exec_mode: ExecutionMode::Executable,
|
||||
exec_mode,
|
||||
};
|
||||
let loaded = roc_load::load_and_monomorphize(
|
||||
arena,
|
||||
|
|
|
@ -33,6 +33,8 @@ pub mod build;
|
|||
mod format;
|
||||
pub use format::format;
|
||||
|
||||
use crate::build::BuildOrdering;
|
||||
|
||||
const DEFAULT_ROC_FILENAME: &str = "main.roc";
|
||||
|
||||
pub const CMD_BUILD: &str = "build";
|
||||
|
@ -521,6 +523,10 @@ pub fn build(
|
|||
.and_then(|s| s.parse::<u32>().ok())
|
||||
.map(|x| x * 1024);
|
||||
|
||||
let build_ordering = match config {
|
||||
BuildAndRunIfNoErrors => BuildOrdering::BuildIfChecks,
|
||||
_ => BuildOrdering::AlwaysBuild,
|
||||
};
|
||||
let res_binary_path = build_file(
|
||||
&arena,
|
||||
&triple,
|
||||
|
@ -533,6 +539,7 @@ pub fn build(
|
|||
precompiled,
|
||||
threading,
|
||||
wasm_dev_stack_bytes,
|
||||
build_ordering,
|
||||
);
|
||||
|
||||
match res_binary_path {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue