Skip to content

Commit

Permalink
temp commit for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
randommm committed Feb 18, 2024
1 parent c9d1d95 commit 8e7f8a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ ureq = { version = "2.7", optional = true }
tar = { version = "0.4", optional = true }
flate2 = { version = "1.0", optional = true }
dirs = { version = "5.0", optional = true }
path-absolutize = { version = "3.1", optional = true }

[features]
compile-stan-model = ["ureq", "tar", "flate2", "dirs"]
compile-stan-model = ["ureq", "tar", "flate2", "dirs", "path-absolutize"]

[build-dependencies]
bindgen = "0.69.1"
Expand Down
11 changes: 9 additions & 2 deletions rust/src/download_compile.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::bs_safe::{BridgeStanError, Result};
use flate2::read::GzDecoder;
use path_absolutize::Absolutize;
use std::{
env::temp_dir,
fs,
Expand Down Expand Up @@ -81,14 +82,18 @@ where
None => get_bridgestan_src()?,
};

let stan_file = fs::canonicalize(stan_file)
println!("DEBUG WINDOWS stan_file: {:?}", stan_file.as_ref());
let stan_file = stan_file
.as_ref()
.absolutize()
.map_err(|e| BridgeStanError::ModelCompilingFailed(e.to_string()))?;

println!("DEBUG WINDOWS stan_file: {:?}", stan_file);
if stan_file.extension().unwrap_or_default() != "stan" {
return Err(BridgeStanError::ModelCompilingFailed(
"File must be a .stan file".to_owned(),
));
}
println!("DEBUG WINDOWS stan_file: {:?}", stan_file);

// add _model suffix and change extension to .so
let output = stan_file.with_extension("");
Expand All @@ -97,6 +102,7 @@ where
output.file_name().unwrap_or_default().to_string_lossy()
));
let output = output.with_extension("so");
println!("DEBUG WINDOWS output: {:?}", output);

let stanc_args = [["--include-paths=."].as_slice(), stanc_args.as_slice()].concat();
let stanc_args = stanc_args.join(" ");
Expand All @@ -109,6 +115,7 @@ where
stanc_args.as_slice(),
]
.concat();
println!("DEBUG WINDOWS cmd: {:?}", cmd);

println!("Compiling model");
let proc = std::process::Command::new("make")
Expand Down

0 comments on commit 8e7f8a6

Please sign in to comment.