aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/functions.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-02 19:54:57 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-02 19:54:57 -0600
commitfc56055ecb63ef05b54aa098bde2d3b61c68e8b2 (patch)
tree7a4fb519f0771f80eefb61c9a0aed04de5abae4f /src/makefile/functions.rs
parent77923a4d12717902137f8cd29a512796eff1a3af (diff)
downloadmakers-fc56055ecb63ef05b54aa098bde2d3b61c68e8b2.tar.gz
makers-fc56055ecb63ef05b54aa098bde2d3b61c68e8b2.zip
implement `origin`
Diffstat (limited to 'src/makefile/functions.rs')
-rw-r--r--src/makefile/functions.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index bc244cb..a61a0cf 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -56,6 +56,11 @@ pub fn expand_call(name: &str, args: &[TokenString], macros: &MacroSet) -> Resul
// eval
"eval" => todo!(),
+ "origin" => {
+ assert_eq!(args.len(), 1);
+ origin::origin(macros, &args[0])
+ }
+
// shell
"shell" => todo!(),
@@ -260,6 +265,15 @@ mod call {
}
}
+mod origin {
+ use super::*;
+
+ pub fn origin(macros: &MacroSet, variable: &TokenString) -> Result<String> {
+ let variable = macros.expand(variable)?;
+ Ok(macros.origin(&variable).to_owned())
+ }
+}
+
#[cfg(test)]
mod test {
use super::*;