From 99f17d09ba4162c31cc8299f1b19bdaf35552236 Mon Sep 17 00:00:00 2001 From: martinjrobins Date: Thu, 24 Aug 2023 09:39:16 +0000 Subject: [PATCH] add compile only flag --- src/bin/diffeq.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bin/diffeq.rs b/src/bin/diffeq.rs index 7422d5f..66e6dc3 100644 --- a/src/bin/diffeq.rs +++ b/src/bin/diffeq.rs @@ -19,6 +19,10 @@ struct Args { /// Model to build (only for continuous model files) #[arg(short, long)] model: Option, + + /// Compile object file only + #[arg(short, long)] + compile: bool, } fn main() -> Result<()> { @@ -27,10 +31,13 @@ fn main() -> Result<()> { let inputfile = Path::new(&cli.input); let out = if let Some(out) = cli.out { out.clone() + } else if cli.compile { + "out.o".to_owned() } else { "out".to_owned() }; - let objectname = format!("{}.o", out); + + let objectname = if cli.compile { out.clone() } else { format!("{}.o", out) }; let objectfile = Path::new(objectname.as_str()); let is_discrete = inputfile.extension().unwrap_or(OsStr::new("")).to_str().unwrap() == "ds"; let is_continuous = inputfile.extension().unwrap_or(OsStr::new("")).to_str().unwrap() == "cs"; @@ -68,6 +75,10 @@ fn main() -> Result<()> { compiler.write_object_file(objectfile)?; }; + if cli.compile { + return Ok(()); + } + // compile the object file using clang and our runtime library let output = Command::new("clang") .arg("-o")