From 99d0ca2b89262afa7f64fd1d507cab2311147dc8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 17 Mar 2022 14:29:08 +0100 Subject: [PATCH] Accept optional `target_dir` in `Model::from_path` --- fj-app/src/main.rs | 2 +- fj-app/src/model.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fj-app/src/main.rs b/fj-app/src/main.rs index 384404ae3..684126125 100644 --- a/fj-app/src/main.rs +++ b/fj-app/src/main.rs @@ -68,7 +68,7 @@ fn main() -> anyhow::Result<()> { } } - let model = Model::from_path(path)?; + let model = Model::from_path(path, None)?; let mut parameters = HashMap::new(); for parameter in args.parameters { diff --git a/fj-app/src/model.rs b/fj-app/src/model.rs index 313d909a8..74000bc00 100644 --- a/fj-app/src/model.rs +++ b/fj-app/src/model.rs @@ -9,7 +9,10 @@ pub struct Model { } impl Model { - pub fn from_path(path: PathBuf) -> io::Result { + pub fn from_path( + path: PathBuf, + target_dir: Option, + ) -> io::Result { let name = { // Can't panic. It only would, if the path ends with "..", and we // are canonicalizing it here to prevent that. @@ -31,7 +34,8 @@ impl Model { format!("lib{}.so", name) }; - path.join("target/debug").join(file) + let target_dir = target_dir.unwrap_or_else(|| path.join("target")); + target_dir.join("debug").join(file) }; let manifest_path = path.join("Cargo.toml");