aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/command_line.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/command_line.rs')
-rw-r--r--src/makefile/command_line.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs
index ec2c115..1b4b4b4 100644
--- a/src/makefile/command_line.rs
+++ b/src/makefile/command_line.rs
@@ -1,16 +1,20 @@
use std::env;
use std::fmt;
-use std::io;
use std::process::{Command, ExitStatus};
-use eyre::bail;
+use eyre::{bail, Error};
-use crate::makefile::target::Target;
-use crate::makefile::token::{Token, TokenString};
-use crate::makefile::Makefile;
+use super::r#macro::Set as MacroSet;
+use super::target::Target;
+use super::token::{Token, TokenString};
+use super::Makefile;
// inspired by python's subprocess module
-fn execute_command_line(command_line: &str, ignore_errors: bool) -> Result<ExitStatus, io::Error> {
+fn execute_command_line(
+ command_line: &str,
+ ignore_errors: bool,
+ macros: &MacroSet,
+) -> Result<ExitStatus, Error> {
let (program, args) = if cfg!(windows) {
let cmd = env::var("COMSPEC").unwrap_or_else(|_| "cmd.exe".into());
let args = vec!["/c", command_line];
@@ -24,7 +28,11 @@ fn execute_command_line(command_line: &str, ignore_errors: bool) -> Result<ExitS
};
(sh, args)
};
- Command::new(program).args(args).status()
+ let mut command = Command::new(program);
+ command.args(args);
+ #[cfg(feature = "full")]
+ command.envs(macros.resolve_exports()?);
+ Ok(command.status()?)
}
#[derive(PartialEq, Eq, Clone, Debug)]
@@ -108,7 +116,7 @@ impl CommandLine {
return Ok(());
}
- let return_value = execute_command_line(&execution_line, ignore_error);
+ let return_value = execute_command_line(&execution_line, ignore_error, &file.macros);
let errored = return_value.map_or(true, |status| !status.success());
if errored {
// apparently there was an error. do we care?