Skip to content

Commit

Permalink
Merge pull request #373 from hannobraun/run
Browse files Browse the repository at this point in the history
Make `cargo run` work again
  • Loading branch information
hannobraun authored Mar 17, 2022
2 parents e05119e + 381a00b commit 4aeaa38
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ members = [

"release-operator",
]
default-members = ["fj-app"]
1 change: 1 addition & 0 deletions fj-app/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::Deserialize;
pub struct Config {
pub default_path: Option<PathBuf>,
pub default_model: Option<PathBuf>,
pub target_dir: Option<PathBuf>,
}

impl Config {
Expand Down
2 changes: 1 addition & 1 deletion fj-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions fj-app/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ pub struct Model {
}

impl Model {
pub fn from_path(path: PathBuf) -> io::Result<Self> {
pub fn from_path(
path: PathBuf,
target_dir: Option<PathBuf>,
) -> io::Result<Self> {
let name = {
// Can't panic. It only would, if the path ends with "..", and we
// are canonicalizing it here to prevent that.
Expand All @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions fj.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 4aeaa38

Please sign in to comment.