diff options
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r-- | src/makefile/mod.rs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index eb06939..228a170 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -7,6 +7,14 @@ use std::rc::Rc; use eyre::{bail, eyre, Result, WrapErr}; +use command_line::CommandLine; +use inference_rules::InferenceRule; +use input::FinishedMakefileReader; +pub use input::MakefileReader; +use r#macro::{Macro, Set as MacroSet}; +use target::Target; +use token::TokenString; + use crate::args::Args; mod command_line; @@ -21,13 +29,14 @@ mod pattern; mod target; mod token; -use command_line::CommandLine; -use inference_rules::InferenceRule; -use input::FinishedMakefileReader; -pub use input::MakefileReader; -use r#macro::{Macro, Set as MacroSet, Source as MacroSource}; -use target::Target; -use token::TokenString; +#[derive(Debug, Clone, Eq, PartialEq)] +pub enum ItemSource { + File { name: String, line: usize }, + CommandLineOrMakeflags, + Environment, + Builtin, + FunctionCall, +} pub struct Makefile<'a> { inference_rules: Vec<InferenceRule>, @@ -63,7 +72,7 @@ impl<'a> Makefile<'a> { macros.set( name.into(), Macro { - source: MacroSource::CommandLineOrMakeflags, + source: ItemSource::CommandLineOrMakeflags, text: TokenString::text(value), #[cfg(feature = "full")] eagerly_expanded: false, @@ -78,7 +87,7 @@ impl<'a> Makefile<'a> { macros.set( "MAKECMDGOALS".to_owned(), Macro { - source: MacroSource::Builtin, + source: ItemSource::Builtin, text: TokenString::text(make_cmd_goals.join(" ")), #[cfg(feature = "full")] eagerly_expanded: false, @@ -89,7 +98,7 @@ impl<'a> Makefile<'a> { macros.set( "CURDIR".to_owned(), Macro { - source: MacroSource::Builtin, + source: ItemSource::Builtin, text: TokenString::text(curdir.to_string_lossy()), #[cfg(feature = "full")] eagerly_expanded: false, @@ -229,6 +238,7 @@ impl<'a> Makefile<'a> { }) .collect::<Option<Vec<String>>>(); if let Some(prereqs) = prereq_paths { + log::trace!("oh {} is a {:#?}", name, rule); new_target = Some(Target { name: name.into(), prerequisites: prereqs, @@ -264,6 +274,7 @@ impl<'a> Makefile<'a> { false }; if !self.targets.borrow().contains_key(name) || exists_but_infer_anyway { + log::trace!("trying to infer for {}", name); self.infer_target(name, vec![], vec![])?; } @@ -429,6 +440,7 @@ fn builtin_inference_rules() -> Vec<InferenceRule> { $($cmd:literal)+)+} => { vec![$( InferenceRule::new_suffix( + ItemSource::Builtin, prepend_dot!($($second)?).into(), concat!(".", stringify!($first)).into(), vec![$(CommandLine::from($cmd.parse().unwrap())),+], @@ -501,6 +513,7 @@ mod test { fn stem() -> R { let args = Args::empty(); let rule = InferenceRule { + source: ItemSource::Builtin, products: vec!["this-is-a-%-case".to_owned()], prerequisites: vec![], commands: vec![], |