Skip to content

Commit

Permalink
add compile only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Aug 24, 2023
1 parent 49f40ff commit 99f17d0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/bin/diffeq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ struct Args {
/// Model to build (only for continuous model files)
#[arg(short, long)]
model: Option<String>,

/// Compile object file only
#[arg(short, long)]
compile: bool,
}

fn main() -> Result<()> {
Expand All @@ -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";
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 99f17d0

Please sign in to comment.