Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't rely on CARGO environment variables at runtime #68

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/fmod_studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ pub struct FmodStudio(pub Studio);
impl FmodStudio {
pub(crate) fn new(banks_paths: &[&'static str]) -> Self {
let studio = Self::init_studio();
let project_root = var("CARGO_MANIFEST_DIR").unwrap();

banks_paths.iter().for_each(|bank_path| {
let mut path = canonicalize(Path::new(bank_path))
.expect("Failed to canonicalize provided audio banks directory path.");
println!("{} tes test", bank_path);
passivedragon marked this conversation as resolved.
Show resolved Hide resolved
let mut path: PathBuf = bank_path.into();

trace!("Canonicalized audio banks directory path: {:?}", path);
trace!("audio banks directory path: {:?}", path);

if path.is_relative() {
let project_root: PathBuf = match var("CARGO_MANIFEST_DIR") {
Ok(path) => path.into(),
Err(_) => std::env::current_exe()
.expect("unable to resolve executed binary path")
.parent()
.expect("binary must be in a resolvable directory")
.to_path_buf(),
// Err(_) => std::env::current_dir().unwrap(),
passivedragon marked this conversation as resolved.
Show resolved Hide resolved
};

let relative_path = path;
path = PathBuf::new();
path.push(project_root.clone());
Expand All @@ -33,6 +42,9 @@ impl FmodStudio {

debug!("Loading audio banks from: {:?}", path);

let path = canonicalize(path)
.expect("Failed to canonicalize provided audio banks directory path.");

Self::load_bank(&studio, path.as_path());
});

Expand Down