From 6a41b2ac4a2d171917126e56b741b16a184897c7 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 5 Apr 2021 12:05:32 -0600 Subject: implement function `error` --- src/makefile/functions.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index 46caca5..2098334 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -113,6 +113,11 @@ pub fn expand_call( origin(macros, &args[0]) } + "error" => { + assert_eq!(args.len(), 1); + meta::error(macros, &args[0]) + } + "shell" => { assert_eq!(args.len(), 1); shell(macros, &args[0]) @@ -415,6 +420,15 @@ pub fn origin(macros: &MacroSet, variable: &TokenString) -> Result { Ok(macros.origin(&variable).to_owned()) } +mod meta { + use super::*; + + pub fn error(macros: &MacroSet, text: &TokenString) -> Result { + let text = macros.expand(text)?; + bail!("{}", text); + } +} + pub fn shell(macros: &MacroSet, command: &TokenString) -> Result { // TODO bring this in from command_line let command = macros.expand(command)?; -- cgit v1.2.3