aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-13 21:08:51 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-13 21:08:51 -0600
commitb2645ea919d159f7883c0d7001eaee528dddc371 (patch)
tree0b3c2714d33385c8210f24cae4cf7c4271ac8a91 /src
parent7857e9f871caaf0b95f9eba9c4cdefb5046a9b2a (diff)
downloadmakers-b2645ea919d159f7883c0d7001eaee528dddc371.tar.gz
makers-b2645ea919d159f7883c0d7001eaee528dddc371.zip
don't clobber .SUFFIXES when an include finishes
Diffstat (limited to 'src')
-rw-r--r--src/makefile/input.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 6860e80..e2bff65 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -166,6 +166,7 @@ pub struct MakefileReader<'a, 'parent, R: BufRead> {
pub inference_rules: Vec<InferenceRule>,
pub macros: MacroSet<'parent, 'static>,
pub targets: HashMap<String, Target>,
+ built_in_targets: HashMap<String, Target>,
pub first_non_special_target: Option<String>,
pub failed_includes: Vec<String>,
args: &'a Args,
@@ -221,6 +222,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
inference_rules: Vec::new(),
macros,
targets: HashMap::new(),
+ built_in_targets: HashMap::new(),
first_non_special_target: None,
failed_includes: Vec::new(),
args,
@@ -229,9 +231,9 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
#[cfg(feature = "full")]
conditional_stack: Vec::new(),
};
- // TODO be smart about this instead
+ // TODO be smart about this instead, please
if !args.no_builtin_rules {
- reader.targets.insert(
+ reader.built_in_targets.insert(
".SUFFIXES".to_owned(),
Target {
name: ".SUFFIXES".into(),
@@ -528,7 +530,11 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
}
fn special_target_has_prereq(&self, target: &str, name: &str, empty_counts: bool) -> bool {
- match self.targets.get(target) {
+ match self
+ .targets
+ .get(target)
+ .or_else(|| self.built_in_targets.get(target))
+ {
Some(target) => {
(empty_counts && target.prerequisites.is_empty())
|| target.prerequisites.iter().any(|e| e == name)
@@ -683,9 +689,14 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
Some(inference)
} else {
log::info!(
- "looks like {:?} is not a suffix rule because .SUFFIXES is {:?}",
+ "{}:{}: looks like {:?} is not a suffix rule because .SUFFIXES is {:?}",
+ &self.file_name,
+ line_number,
inference,
- self.targets.get(".SUFFIXES").map(|x| &x.prerequisites)
+ self.targets
+ .get(".SUFFIXES")
+ .or_else(|| self.built_in_targets.get(".SUFFIXES"))
+ .map(|x| &x.prerequisites)
);
None
}
@@ -713,6 +724,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
if self.first_non_special_target.is_none() && !target.starts_with('.') {
self.first_non_special_target = Some(target.into());
}
+ // TODO handle appending to built-in (it's Complicated)
match self.targets.get_mut(target) {
Some(old_target)
if commands.is_empty()