pub fn compile_multi_file_with_options(
sources: &[SourceFile<'_>],
options: &CompileOptions,
) -> MultiErrorResult<CompileOutput>Expand description
Compile multiple source files to an ELF binary.
This is the main entry point for multi-file compilation. It:
- Parses all files in parallel
- Merges symbols into a unified program
- Performs semantic analysis across all files
- Generates code for the combined program
Cross-file references (function calls, struct/enum usage) are resolved during semantic analysis since all symbols are visible in the merged program.
§Arguments
sources- Slice of source files to compileoptions- Compilation options (target, linker, optimization level, etc.)
§Returns
A CompileOutput containing the ELF binary and any warnings,
or errors if compilation fails.
§Example
ⓘ
use gruel_compiler::{SourceFile, CompileOptions, compile_multi_file_with_options};
use gruel_span::FileId;
let sources = vec![
SourceFile::new("main.gruel", "fn main() -> i32 { helper() }", FileId::new(1)),
SourceFile::new("utils.gruel", "fn helper() -> i32 { 42 }", FileId::new(2)),
];
let options = CompileOptions::default();
let output = compile_multi_file_with_options(&sources, &options)?;