From d12f9f563968ea8471b4929936ac4f8553810428 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 1 Apr 2021 23:10:10 -0600 Subject: put extensions behind a feature --- src/makefile/mod.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/makefile/mod.rs') diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 5be18e0..9038150 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -15,15 +15,19 @@ use regex::Regex; use crate::args::Args; mod command_line; +#[cfg(feature = "full")] mod conditional; +#[cfg(feature = "full")] mod functions; mod inference_rules; mod r#macro; +#[cfg(feature = "full")] mod pattern; mod target; mod token; use command_line::CommandLine; +#[cfg(feature = "full")] use conditional::{Line as ConditionalLine, State as ConditionalState}; use inference_rules::InferenceRule; use r#macro::{Set as MacroSet, Source as MacroSource}; @@ -154,6 +158,7 @@ impl<'a> Makefile<'a> { ) }) .peekable(); + #[cfg(feature = "full")] let mut conditional_stack: Vec = vec![]; while let Some((line_number, line)) = lines_iter.next() { let mut line = line?; @@ -174,6 +179,7 @@ impl<'a> Makefile<'a> { let line = COMMENT.replace(&line, "").into_owned(); // skip lines if we need to + #[cfg(feature = "full")] if conditional_stack .last() .map_or(false, ConditionalState::skipping) @@ -192,16 +198,20 @@ impl<'a> Makefile<'a> { for field in fields { self.and_read_file(field)?; } - } else if let Some(line) = - ConditionalLine::from(&line, |t| self.expand_macros(t, None))? - { + continue; + } + + #[cfg(feature = "full")] + if let Some(line) = ConditionalLine::from(&line, |t| self.expand_macros(t, None))? { line.action( conditional_stack.last(), |name| self.macros.is_defined(name), |t| self.expand_macros(t, None), )? .apply_to(&mut conditional_stack); - } else if line.trim().is_empty() { + continue; + } + if line.trim().is_empty() { // handle blank lines continue; } else { @@ -711,6 +721,7 @@ mod test { } } + #[cfg(feature = "full")] #[test] fn basic_conditionals() -> R { let file = " -- cgit v1.2.3