diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-25 19:41:50 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-25 19:41:50 -0600 |
commit | d838bcdf6f912f35d16ec04e5ed5267daab9c7eb (patch) | |
tree | 1def7d72b5178b798a637beb2f4dfafbe14bf037 | |
parent | 6d3882840dbbe75820f8f0d36cca3c94079b4b33 (diff) | |
download | yapymake-d838bcdf6f912f35d16ec04e5ed5267daab9c7eb.tar.gz yapymake-d838bcdf6f912f35d16ec04e5ed5267daab9c7eb.zip |
avoid duplicating inference rules
-rw-r--r-- | yapymake/makefile/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
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: |