aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/command_line.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-01 22:34:59 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-01 22:34:59 -0600
commite732953c2855cdb68409fd122bf2e519d4eca00a (patch)
treebc88668258d854ef2bc5791eb70b327fd74c387b /src/makefile/command_line.rs
parentfa750e3d195c249cc48a7416b487715c2031428d (diff)
downloadmakers-e732953c2855cdb68409fd122bf2e519d4eca00a.tar.gz
makers-e732953c2855cdb68409fd122bf2e519d4eca00a.zip
catch prefixes that came from macros
Diffstat (limited to 'src/makefile/command_line.rs')
-rw-r--r--src/makefile/command_line.rs27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/makefile/command_line.rs b/src/makefile/command_line.rs
index 8756bc9..ec2c115 100644
--- a/src/makefile/command_line.rs
+++ b/src/makefile/command_line.rs
@@ -72,21 +72,38 @@ impl CommandLine {
}
pub fn execute(&self, file: &Makefile, target: &Target) -> eyre::Result<()> {
- let ignore_error = self.ignore_errors
+ let execution_line = file.expand_macros(&self.execution_line, Some(target))?;
+ let mut self_ignore_errors = self.ignore_errors;
+ let mut self_silent = self.silent;
+ let mut self_always_execute = self.always_execute;
+
+ // apparently some makefiles will just throw this shit in in macros? bruh moment tbh
+ let execution_line: String = {
+ let mut line_chars = execution_line.chars().peekable();
+ while let Some(x) = line_chars.next_if(|x| matches!(x, '-' | '@' | '+')) {
+ match x {
+ '-' => self_ignore_errors = true,
+ '@' => self_silent = true,
+ '+' => self_always_execute = true,
+ _ => unreachable!(),
+ }
+ }
+ line_chars.collect()
+ };
+
+ let ignore_error = self_ignore_errors
|| file.args.ignore_errors
|| file.special_target_has_prereq(".IGNORE", &target.name);
- let silent = (self.silent && !file.args.dry_run)
+ let silent = (self_silent && !file.args.dry_run)
|| file.args.silent
|| file.special_target_has_prereq(".SILENT", &target.name);
- let execution_line = file.expand_macros(&self.execution_line, Some(target))?;
-
if !silent {
println!("{}", execution_line);
}
let should_execute =
- self.always_execute || !(file.args.dry_run || file.args.question || file.args.touch);
+ self_always_execute || !(file.args.dry_run || file.args.question || file.args.touch);
if !should_execute {
return Ok(());
}