Skip to content

Commit

Permalink
Fix compiling when in package subdir via use of FLOW_CONTEXT_DIR env var
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidmackenzie committed May 18, 2022
1 parent 71924a8 commit 1406c0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions flowsamples/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Build script to compile the flow flowsamples in the crate
use std::{fs, io};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::Command;

fn main() -> io::Result<()> {
Expand Down Expand Up @@ -29,9 +29,14 @@ fn main() -> io::Result<()> {
}

fn get_context_root() -> Result<String, String> {
let samples_dir = Path::new(env!("CARGO_MANIFEST_DIR")).parent()
.ok_or("Could not get parent dir")?;
let context_root = samples_dir.join("flowr/src/context");
let context_root = match std::env::var("FLOW_CONTEXT_ROOT") {
Ok(var) => PathBuf::from(&var),
Err(_) => {
let samples_dir = Path::new(env!("CARGO_MANIFEST_DIR")).parent()
.ok_or("Could not get parent dir")?;
samples_dir.join("flowr/src/context")
}
};
assert!(context_root.exists(), "Context root directory '{}' does not exist",
context_root.display());
Ok(context_root.to_str()
Expand Down

0 comments on commit 1406c0f

Please sign in to comment.