aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-06 16:29:52 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-06 16:29:52 -0600
commit0b4bdb6dae6dbb3d37695555765acabbf2663849 (patch)
tree966b0b13e6d962c0ffaed9afeb5871b2b1f5d74a /src/makefile
parent1479b2b9a2d5d00e2799a05c3af3bef1508a3e80 (diff)
downloadmakers-0b4bdb6dae6dbb3d37695555765acabbf2663849.tar.gz
makers-0b4bdb6dae6dbb3d37695555765acabbf2663849.zip
implement function `addsuffix`
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/functions.rs18
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,