Skip to content

Commit

Permalink
point cargo-steel-lib to proper location for steel home
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Aug 31, 2024
1 parent c9acd4e commit fef98b8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/cargo-steel-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dependencies]
cargo_metadata = "0.15.3"
home = "0.5.9"

# Keeps the MSRV at v1.70.0
cargo-platform = "=0.1.7"
27 changes: 26 additions & 1 deletion crates/cargo-steel-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,33 @@ TODO:
- Specify target architecture
*/

pub fn steel_home() -> Option<PathBuf> {
std::env::var("STEEL_HOME")
.ok()
.map(PathBuf::from)
.or_else(|| {
let home = home::home_dir();

home.map(|mut x: PathBuf| {
x.push(".steel");

// Just go ahead and initialize the directory, even though
// this is probably not the best place to do this. This almost
// assuredly could be lifted out of this check since failing here
// could cause some annoyance.
if !x.exists() {
if let Err(_) = std::fs::create_dir(&x) {
eprintln!("Unable to create steel home directory {:?}", x)
}
}

x
})
})
}

pub fn run() -> Result<(), Box<dyn Error>> {
let mut steel_home = PathBuf::from(std::env::var("STEEL_HOME")?);
let mut steel_home = steel_home().expect("Unable to find STEEL_HOME");

steel_home.push("native");

Expand Down

0 comments on commit fef98b8

Please sign in to comment.