From ff20d332c23c7911b5fb2a370b3ed34869f16bbc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 17 Mar 2022 14:16:36 +0100 Subject: [PATCH 1/4] Make `cargo run` work again I thought I'd tested this, but obviously I didn't. This will let Cargo know, that `cargo run` should run `fj-app`. Please note that the app itself is still broken, as it doesn't understand where the `target/` directory is in the workspace. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index f25cd77d8..07cc0b8bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ members = [ "release-operator", ] +default-members = ["fj-app"] From 99d0ca2b89262afa7f64fd1d507cab2311147dc8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 17 Mar 2022 14:29:08 +0100 Subject: [PATCH 2/4] 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"); From 849563f6c38ea59fc31cccb89ab7970b5325b3d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 17 Mar 2022 14:30:33 +0100 Subject: [PATCH 3/4] Add configuration to specify target directory --- fj-app/src/config.rs | 1 + fj-app/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fj-app/src/config.rs b/fj-app/src/config.rs index 94d6e8967..0d6b64069 100644 --- a/fj-app/src/config.rs +++ b/fj-app/src/config.rs @@ -11,6 +11,7 @@ use serde::Deserialize; pub struct Config { pub default_path: Option, pub default_model: Option, + pub target_dir: Option, } impl Config { diff --git a/fj-app/src/main.rs b/fj-app/src/main.rs index 684126125..85bd4bb9e 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, None)?; + let model = Model::from_path(path, config.target_dir)?; let mut parameters = HashMap::new(); for parameter in args.parameters { From 381a00bb49cef2aa3e7b39babbc0a5efad3af708 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 17 Mar 2022 14:31:07 +0100 Subject: [PATCH 4/4] Fix app not finding `target/` directory --- fj.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fj.toml b/fj.toml index bfbf4af0a..134e4ca75 100644 --- a/fj.toml +++ b/fj.toml @@ -5,3 +5,7 @@ default_path = "models" # The default models that is loaded, if none is specified. If this is a relative # path, it should be relative to `default_path`. default_model = "star" + +# The `target/` directory, where compiled model libraries are located. By +# default, this is expected to be in the model directory. +target_dir = "target"