diff options
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r-- | src/makefile/macro.rs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index fc3be51..2dfd84f 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -11,18 +11,11 @@ use regex::Regex; #[cfg(feature = "full")] use super::functions; use super::token::{Token, TokenString}; - -#[derive(Debug, Clone)] -pub enum Source { - File, - CommandLineOrMakeflags, - Environment, - Builtin, -} +use super::ItemSource; #[derive(Debug, Clone)] pub struct Macro { - pub source: Source, + pub source: ItemSource, pub text: TokenString, #[cfg(feature = "full")] pub eagerly_expanded: bool, @@ -121,7 +114,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { self.data.insert( k.into(), Macro { - source: Source::Builtin, + source: ItemSource::Builtin, text: v, #[cfg(feature = "full")] eagerly_expanded: false, @@ -136,7 +129,7 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { self.data.insert( k, Macro { - source: Source::Environment, + source: ItemSource::Environment, text: TokenString::text(v), #[cfg(feature = "full")] eagerly_expanded: false, @@ -277,23 +270,27 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { match self.data.get(name) { None => self.parent.map_or("undefined", |p| p.origin(name)), Some(Macro { - source: Source::Builtin, + source: ItemSource::Builtin, .. }) => "default", Some(Macro { - source: Source::Environment, + source: ItemSource::Environment, .. }) => "environment", // TODO figure out when to return "environment override" Some(Macro { - source: Source::File, + source: ItemSource::File { .. }, .. }) => "file", Some(Macro { - source: Source::CommandLineOrMakeflags, + source: ItemSource::CommandLineOrMakeflags, .. }) => "command line", - // TODO handle override and automatic + // TODO handle override + Some(Macro { + source: ItemSource::FunctionCall, + .. + }) => "automatic", } } @@ -416,7 +413,7 @@ mod test { macros.set( "oof".to_owned(), Macro { - source: Source::File, + source: ItemSource::Builtin, text: TokenString::text("bruh; swag; yeet;"), #[cfg(feature = "full")] eagerly_expanded: false, |