提交 4218fe16 authored 作者: Serhij S's avatar Serhij S

build env

上级 3359db63
...@@ -26,6 +26,8 @@ pub struct Remote { ...@@ -26,6 +26,8 @@ pub struct Remote {
#[derive(Deserialize, Serialize, Default, Debug)] #[derive(Deserialize, Serialize, Default, Debug)]
pub struct Build { pub struct Build {
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub env: BTreeMap<String, String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub cargo: Option<PathBuf>, pub cargo: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
......
...@@ -290,10 +290,20 @@ pub fn flash( ...@@ -290,10 +290,20 @@ pub fn flash(
cargo.display().to_string().yellow(), cargo.display().to_string().yellow(),
args.join(" ").yellow() args.join(" ").yellow()
); );
if !build_config.env.is_empty() {
print!("Environment variables: ");
for (k, v) in &build_config.env {
print!(r#"{}="{}" "#, k, v);
}
println!();
}
println!("Cargo target: {}", cargo_target.yellow()); println!("Cargo target: {}", cargo_target.yellow());
println!("Binary: {}", binary_name.display().to_string().yellow()); println!("Binary: {}", binary_name.display().to_string().yellow());
println!("Compiling..."); println!("Compiling...");
let result = std::process::Command::new(cargo).args(args).status()?; let result = std::process::Command::new(cargo)
.args(args)
.envs(build_config.env)
.status()?;
if !result.success() { if !result.success() {
return Err("Compilation failed".into()); return Err("Compilation failed".into());
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论