aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/mod.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-01 23:10:10 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-01 23:10:10 -0600
commitd12f9f563968ea8471b4929936ac4f8553810428 (patch)
tree39f8f42eb840c32acb542bfc6314e2950e1e17e0 /src/makefile/mod.rs
parent543124c62c8123bd67e90bbc710aa064c6c5e271 (diff)
downloadmakers-d12f9f563968ea8471b4929936ac4f8553810428.tar.gz
makers-d12f9f563968ea8471b4929936ac4f8553810428.zip
put extensions behind a feature
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r--src/makefile/mod.rs19
1 files changed, 15 insertions, 4 deletions
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<ConditionalState> = 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 = "