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"] 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 384404ae3..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)?; + let model = Model::from_path(path, config.target_dir)?; 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"); 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"