From d838bcdf6f912f35d16ec04e5ed5267daab9c7eb Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 25 Mar 2021 19:41:50 -0600 Subject: avoid duplicating inference rules --- yapymake/makefile/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index 0a272cf..6c7098d 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -144,7 +144,10 @@ class Makefile: special_target_match = re.fullmatch(r'\.[A-Z]+', targets[0]) if len(targets) == 1 and len(prerequisites) == 0 and match is not None and special_target_match is None: # it's an inference rule! - self._inference_rules.append(InferenceRule(match.group('s1'), match.group('s2'), commands)) + new_rule = InferenceRule(match.group('s1'), match.group('s2'), commands) + rules = [r for r in self._inference_rules if (r.s1, r.s2) != (new_rule.s1, new_rule.s2)] + self._inference_rules = rules + self._inference_rules.append(new_rule) else: # it's a target rule! for target in targets: -- cgit v1.2.3