diff options
-rw-r--r-- | yapymake/makefile/__init__.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index 1f4687c..e46179e 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -5,7 +5,7 @@ from pathlib import Path as ImpurePath, PurePath import re import subprocess import sys -from typing import Dict, List, Optional, TextIO, Tuple +from typing import Dict, List, Optional, Set, TextIO, Tuple, Any, Union from .token import * from ..args import Args @@ -22,6 +22,7 @@ class Makefile: _targets: Dict[str, 'Target'] first_non_special_target: Optional[str] args: Args + _warnings: Set[str] def __init__(self, args: Args): self._inference_rules = [] @@ -29,6 +30,7 @@ class Makefile: self._targets = dict() self.first_non_special_target = None self.args = args + self._warnings = set() if args.builtin_rules: self._inference_rules += BUILTIN_INFERENCE_RULES @@ -66,6 +68,11 @@ class Makefile: *[str(x) for x in self._targets.values()], ]) + def _warn(self, warning: str) -> None: + if warning not in self._warnings: + print(warning) + self._warnings.add(warning) + def read(self, file: TextIO) -> None: lines_iter: PeekableIterator[str] = PeekableIterator(iter(file)) for line in lines_iter: @@ -98,7 +105,7 @@ class Makefile: # > field is taken as the pathname. # (GNU make will include each field separately, so let's do that here) if len(fields) != 1: - print('warning: non-POSIX multi-file include') + self._warn('warning: non-POSIX multi-file include') for included_file in fields: # > The contents of the file specified by the pathname shall be read and processed as if they # > appeared in the makefile in place of the include line. @@ -277,8 +284,8 @@ class Makefile: if ImpurePath(prerequisite_path).exists(): if name in self._targets: # we got here by following GNU - print('warning: non-POSIX use of inference rule', f'{rule.s1}{rule.s2}', - 'on explicit target', name) + self._warn(f'warning: non-POSIX use of inference rule {rule.s1}{rule.s2} on explicit ' + f'target {name}') self._targets[name] = Target(name, [str(prerequisite_path)], rule.commands) break if name not in self._targets: |