aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/macro.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/macro.rs
parent77923a4d12717902137f8cd29a512796eff1a3af (diff)
downloadmakers-fc56055ecb63ef05b54aa098bde2d3b61c68e8b2.tar.gz
makers-fc56055ecb63ef05b54aa098bde2d3b61c68e8b2.zip
implement `origin`
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r--src/makefile/macro.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs
index bb4a72d..f788edc 100644
--- a/src/makefile/macro.rs
+++ b/src/makefile/macro.rs
@@ -124,6 +124,19 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> {
Ok(result)
}
+ #[cfg(feature = "full")]
+ pub fn origin(&self, name: &str) -> &'static str {
+ match self.data.get(name) {
+ None => self.parent.map_or("undefined", |p| p.origin(name)),
+ Some((Source::Builtin, _)) => "default",
+ Some((Source::Environment, _)) => "environment",
+ // TODO figure out when to return "environment override"
+ Some((Source::File, _)) => "file",
+ Some((Source::CommandLineOrMakeflags, _)) => "command line",
+ // TODO handle override and automatic
+ }
+ }
+
pub fn with_lookup<'l, 's: 'l>(&'s self, lookup: &'l dyn LookupInternal) -> Set<'s, 'l> {
Set {
parent: Some(self),