diff options
Diffstat (limited to 'src/makefile')
-rw-r--r-- | src/makefile/functions.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index 2192d26..c111fba 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -69,6 +69,10 @@ pub fn expand_call( assert_eq!(args.len(), 1); file_name::basename(macros, &args[0]) } + "addsuffix" => { + assert_eq!(args.len(), 2); + file_name::addsuffix(macros, &args[0], &args[1]) + } "addprefix" => { assert_eq!(args.len(), 2); file_name::addprefix(macros, &args[0], &args[1]) @@ -318,6 +322,20 @@ mod file_name { Ok(words.join(" ")) } + pub fn addsuffix( + macros: &MacroSet, + suffix: &TokenString, + targets: &TokenString, + ) -> Result<String> { + let suffix = macros.expand(suffix)?; + let targets = macros.expand(targets)?; + let results = targets + .split_whitespace() + .map(|t| format!("{}{}", t, suffix)) + .collect::<Vec<_>>(); + Ok(results.join(" ")) + } + pub fn addprefix( macros: &MacroSet, prefix: &TokenString, |