diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-10 21:28:27 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-10 21:28:27 -0700 |
commit | 07b4b35c44d488fea2916e7d985f60f923ed0e4c (patch) | |
tree | 6bc7c516198d35b6dc9bcb2d53083b31a78d4abe /src/makefile/macro.rs | |
parent | fca10b517b448b4023ad8c3225e59dcefd4004e4 (diff) | |
download | makers-07b4b35c44d488fea2916e7d985f60f923ed0e4c.tar.gz makers-07b4b35c44d488fea2916e7d985f60f923ed0e4c.zip |
fix that with no default features
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r-- | src/makefile/macro.rs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs index beae404..b135f42 100644 --- a/src/makefile/macro.rs +++ b/src/makefile/macro.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use std::collections::HashSet; use std::env; use std::fmt; +#[cfg(feature = "full")] use std::io::BufRead; use std::rc::Rc; @@ -10,6 +11,7 @@ use std::rc::Rc; use super::functions; use super::token::{Token, TokenString}; use super::ItemSource; +#[cfg(feature = "full")] use crate::makefile::eval_context::DeferredEvalContext; use eyre::{bail, Result, WrapErr}; #[cfg(not(feature = "full"))] @@ -203,10 +205,10 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { } } - pub fn expand<R: BufRead>( + pub fn expand<#[cfg(feature = "full")] R: BufRead>( &self, text: &TokenString, - mut eval_context: Option<&mut DeferredEvalContext<R>>, + #[cfg(feature = "full")] mut eval_context: Option<&mut DeferredEvalContext<R>>, ) -> Result<String> { let mut result = String::new(); for token in text.tokens() { @@ -214,7 +216,11 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { Token::Text(t) => result.push_str(t), Token::MacroExpansion { name, replacement } => { let name = self - .expand(name, eval_context.as_deref_mut()) + .expand( + name, + #[cfg(feature = "full")] + eval_context.as_deref_mut(), + ) .wrap_err_with(|| format!("while expanding \"{}\"", name))?; let internal_macro_names = &['@', '?', '<', '*', '^'][..]; let internal_macro_suffices = &['D', 'F'][..]; @@ -232,14 +238,22 @@ impl<'parent, 'lookup> Set<'parent, 'lookup> { Ok(String::new()) }, |x| { - self.expand(&x.text, eval_context.as_deref_mut()) - .wrap_err_with(|| format!("while expanding \"{}\"", &x.text)) + self.expand( + &x.text, + #[cfg(feature = "full")] + eval_context.as_deref_mut(), + ) + .wrap_err_with(|| format!("while expanding \"{}\"", &x.text)) }, )? }; let macro_value = match replacement { Some((subst1, subst2)) => { - let subst1 = self.expand(subst1, eval_context.as_deref_mut())?; + let subst1 = self.expand( + subst1, + #[cfg(feature = "full")] + eval_context.as_deref_mut(), + )?; #[cfg(feature = "full")] { let (subst1, subst2) = if subst1.contains('%') { @@ -457,6 +471,7 @@ fn builtins() -> Vec<(&'static str, TokenString)> { #[cfg(test)] mod test { use super::*; + #[cfg(feature = "full")] use crate::makefile::functions::NO_EVAL; type R = Result<()>; @@ -474,7 +489,11 @@ mod test { }, ); assert_eq!( - macros.expand(&"$(oof:;=?)".parse()?, NO_EVAL)?, + macros.expand( + &"$(oof:;=?)".parse()?, + #[cfg(feature = "full")] + NO_EVAL + )?, "bruh? swag? yeet?" ); Ok(()) |