aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-16 21:37:07 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-16 21:37:07 -0600
commit4a65714f22a4d577bc95a699cf02e64abf39fe05 (patch)
tree860fd86f73a8a56a052b5b4e27560d00584c9587 /src/makefile
parentb40c26502683dc8798c5267a85ad1d4930e742d5 (diff)
downloadmakers-4a65714f22a4d577bc95a699cf02e64abf39fe05.tar.gz
makers-4a65714f22a4d577bc95a699cf02e64abf39fe05.zip
handle macros expanding to multiple command lines gnufully
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/command_line.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs
index b7c3b23..45ac181 100644
--- a/src/makefile/command_line.rs
+++ b/src/makefile/command_line.rs
@@ -3,6 +3,8 @@ use std::fmt;
use std::process::{Command, ExitStatus};
use eyre::{bail, Error};
+use lazy_static::lazy_static;
+use regex::Regex;
use super::r#macro::Set as MacroSet;
use super::target::Target;
@@ -86,6 +88,20 @@ impl CommandLine {
});
log::trace!("executing {}", &self.execution_line);
let execution_line = file.expand_macros(&self.execution_line, Some(target))?;
+ // unfortunately, if we had a multiline macro somewhere with non-escaped newlines, now we have to run each of them as separate lines
+ lazy_static! {
+ static ref UNESCAPED_NEWLINE: Regex = Regex::new(r"([^\\])\n").unwrap();
+ }
+ if UNESCAPED_NEWLINE.is_match(&execution_line) {
+ let lines = UNESCAPED_NEWLINE
+ .split(&execution_line)
+ .map(|x| Self::from(TokenString::text(x.trim_start())));
+ for line in lines {
+ line.execute(file, target)?;
+ }
+ return Ok(());
+ }
+ log::trace!("executing {}", &execution_line);
let mut self_ignore_errors = self.ignore_errors;
let mut self_silent = self.silent;
let mut self_always_execute = self.always_execute;