aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-10 21:28:27 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-10 21:28:27 -0700
commit07b4b35c44d488fea2916e7d985f60f923ed0e4c (patch)
tree6bc7c516198d35b6dc9bcb2d53083b31a78d4abe /src
parentfca10b517b448b4023ad8c3225e59dcefd4004e4 (diff)
downloadmakers-07b4b35c44d488fea2916e7d985f60f923ed0e4c.tar.gz
makers-07b4b35c44d488fea2916e7d985f60f923ed0e4c.zip
fix that with no default features
Diffstat (limited to 'src')
-rw-r--r--src/makefile/input.rs25
-rw-r--r--src/makefile/macro.rs33
-rw-r--r--src/makefile/mod.rs10
3 files changed, 54 insertions, 14 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index f1d4f70..fccea3b 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -16,6 +16,7 @@ use crate::args::Args;
use super::command_line::CommandLine;
#[cfg(feature = "full")]
use super::conditional::{Line as ConditionalLine, State as ConditionalState};
+#[cfg(feature = "full")]
use super::eval_context::DeferredEvalContext;
use super::inference_rules::InferenceRule;
#[cfg(feature = "full")]
@@ -594,6 +595,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
log::error!("rule-specific macros are not implemented yet");
return Ok(());
}
+ #[cfg(feature = "full")]
let mut deferred_eval_context = DeferredEvalContext::new(self);
let prerequisites = self
.macros
@@ -630,7 +632,12 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
Ok(macro_pieces.join(" "))
})
- .expand(&prerequisites, Some(&mut deferred_eval_context))?;
+ .expand(
+ &prerequisites,
+ #[cfg(feature = "full")]
+ Some(&mut deferred_eval_context),
+ )?;
+ #[cfg(feature = "full")]
for child in deferred_eval_context {
self.extend(child);
}
@@ -903,8 +910,14 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
}
fn expand_macros(&mut self, text: &TokenString) -> Result<String> {
+ #[cfg(feature = "full")]
let mut deferred_eval_context = DeferredEvalContext::new(self);
- let result = self.expand_macros_deferred_eval(text, &mut deferred_eval_context);
+ let result = self.expand_macros_deferred_eval(
+ text,
+ #[cfg(feature = "full")]
+ &mut deferred_eval_context,
+ );
+ #[cfg(feature = "full")]
for child in deferred_eval_context {
self.extend(child);
}
@@ -914,10 +927,14 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
fn expand_macros_deferred_eval(
&self,
text: &TokenString,
- deferred_eval_context: &mut DeferredEvalContext<R>,
+ #[cfg(feature = "full")] deferred_eval_context: &mut DeferredEvalContext<R>,
) -> Result<String> {
self.macros
- .expand(text, Some(deferred_eval_context))
+ .expand(
+ text,
+ #[cfg(feature = "full")]
+ Some(deferred_eval_context),
+ )
.wrap_err_with(|| format!("while expanding \"{}\"", text))
}
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(())
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index c6a8c0a..d1e9729 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -16,11 +16,13 @@ use target::{DynamicTargetSet, Target};
use token::TokenString;
use crate::args::Args;
+#[cfg(feature = "full")]
use crate::makefile::functions::NO_EVAL;
mod command_line;
#[cfg(feature = "full")]
mod conditional;
+#[cfg(feature = "full")]
mod eval_context;
#[cfg(feature = "full")]
mod functions;
@@ -412,9 +414,11 @@ impl<'a> Makefile<'a> {
Ok(macro_pieces.join(" "))
};
- self.macros
- .with_lookup(&lookup_internal)
- .expand(text, NO_EVAL)
+ self.macros.with_lookup(&lookup_internal).expand(
+ text,
+ #[cfg(feature = "full")]
+ NO_EVAL,
+ )
}
}