Feat: add -c flag to skip entry-point check

`fluxc -c <file>` compiles a source file without requiring a `main`
function, matching the convention of C compilers. Pass 4 (entry-point
validation) is skipped when `no_main` is set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 15:36:43 +01:00
parent bb5e9e42d9
commit 9aa6b9694b
4 changed files with 34 additions and 24 deletions

View File

@@ -23,6 +23,10 @@ pub fn print_help() {
"-V".bold(),
"--version".bold(),
);
println!(
" {} Compile without requiring a `main` entry point",
"-c".bold(),
);
println!();
println!("{}", "ARGS:".bold().yellow());
println!(
@@ -57,10 +61,13 @@ pub fn io_error(path: &str, err: std::io::Error) -> ! {
pub struct Opts {
pub files: Vec<String>,
/// `-c`: compile without requiring a `main` entry point.
pub no_main: bool,
}
pub fn parse_args() -> Opts {
let mut files = Vec::new();
let mut no_main = false;
for arg in std::env::args().skip(1) {
match arg.as_str() {
@@ -72,6 +79,7 @@ pub fn parse_args() -> Opts {
print_version();
process::exit(0);
}
"-c" => no_main = true,
flag if flag.starts_with('-') => {
fatal(&format!("unknown option `{flag}`"));
}
@@ -83,5 +91,5 @@ pub fn parse_args() -> Opts {
fatal("no input files — at least one source file is required");
}
Opts { files }
Opts { files, no_main }
}