Skip to content

Commit

Permalink
Merge pull request #150 from boozook/cargo/respect-sdk-path
Browse files Browse the repository at this point in the history
Set sdk path to env if it was set as `--sdk` argument
  • Loading branch information
boozook authored Oct 1, 2023
2 parents 0290dcb + de60c41 commit 9254f1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.3.5"
version = "0.3.6"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down
13 changes: 7 additions & 6 deletions cargo/src/assets/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ impl<'a, 'cfg> LazyEnvBuilder<'a, 'cfg> {
pub fn get(&'a self) -> CargoResult<&'a Env> {
self.env.try_get_or_create(move || {
let root = self.package.root().display().to_string();
let mut vars = vec![
("CARGO_PKG_NAME", self.package.name().to_string()),
("CARGO_MANIFEST_DIR", root.to_string()),
let vars = vec![
("CARGO_PKG_NAME", self.package.name().to_string()),
("CARGO_MANIFEST_DIR", root.to_string()),
];
if let Some(path) = self.config.sdk_path.as_ref() {
vars.push((SDK_ENV_VAR, path.display().to_string()));
}

let mut env = Env::from_iter(vars.into_iter()).map_err(|err| anyhow::anyhow!("{err}"))?;

Expand All @@ -55,6 +52,10 @@ impl<'a, 'cfg> LazyEnvBuilder<'a, 'cfg> {
}
}

if let Some(path) = self.config.sdk_path.as_ref() {
env.vars.insert(SDK_ENV_VAR.into(), path.display().to_string());
}

Ok::<_, anyhow::Error>(env)
})
}
Expand Down
5 changes: 5 additions & 0 deletions cargo/src/proc/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::*;
use std::env;
use std::process::Command;

use build::consts::SDK_ENV_VAR;
use cargo::CargoResult;
use cargo::Config as CargoConfig;

Expand All @@ -18,6 +19,10 @@ pub fn cargo_proxy_cmd(cfg: &Config, cmd: &Cmd) -> CargoResult<std::process::Com
proc.args(&cfg.args);
proc.args(&rustflags);

if let Some(path) = cfg.sdk_path.as_deref() {
proc.env(SDK_ENV_VAR, path);
}

Ok(proc)
}

Expand Down

0 comments on commit 9254f1d

Please sign in to comment.