aboutsummaryrefslogtreecommitdiff
path: root/yapymake/makefile/__init__.py
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-25 19:27:20 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-25 19:27:20 -0600
commitfa31fa96b8088e5157cbb9022f3e77664cf7e5d8 (patch)
tree5489a46472ff21804e6082f8444548ed20f56f30 /yapymake/makefile/__init__.py
parent8fc809d03920e8e1215ea4b1e2e079fd9f6ac546 (diff)
downloadyapymake-fa31fa96b8088e5157cbb9022f3e77664cf7e5d8.tar.gz
yapymake-fa31fa96b8088e5157cbb9022f3e77664cf7e5d8.zip
print out everything if asked to
Diffstat (limited to 'yapymake/makefile/__init__.py')
-rw-r--r--yapymake/makefile/__init__.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py
index 70b61d8..ddd049d 100644
--- a/yapymake/makefile/__init__.py
+++ b/yapymake/makefile/__init__.py
@@ -48,6 +48,20 @@ class Makefile:
# TODO either discern command line vs MAKEFLAGS or don't pretend we can
self._macros[name] = (MacroSource.CommandLine, TokenString.text(value))
+ def __str__(self) -> str:
+ def header(text: str) -> str:
+ return text + '\n' + ('=' * len(text))
+ return '\n'.join([
+ header('Inference Rules'),
+ *[str(x) for x in self._inference_rules],
+ '',
+ header('Macros'),
+ *[f'{k}={v}' for k, (_, v) in self._macros.items()],
+ '',
+ header('Targets'),
+ *[str(x) for x in self._targets.values()],
+ ])
+
def read(self, file: TextIO) -> None:
lines_iter: PeekableIterator[str] = PeekableIterator(iter(file))
for line in lines_iter:
@@ -263,6 +277,12 @@ class InferenceRule:
s2: str
commands: List['CommandLine']
+ def __str__(self) -> str:
+ return '\n'.join([
+ f'{self.s1}{self.s2}:',
+ *[f'\t{x}' for x in self.commands],
+ ])
+
@dataclass()
class Target:
name: str
@@ -270,6 +290,12 @@ class Target:
commands: List['CommandLine']
already_updated: bool = False
+ def __str__(self) -> str:
+ return '\n'.join([
+ f'{self.name}: {" ".join(self.prerequisites)}',
+ *[f'\t{x}' for x in self.commands],
+ ])
+
def _path(self) -> ImpurePath:
return ImpurePath(self.name)
@@ -345,6 +371,14 @@ class CommandLine:
first_token.text = first_token.text[1:]
self.execution_line = TokenString(list((first_token, *tokens_iter)))
+ def __str__(self) -> str:
+ return ''.join([
+ '-' if self.ignore_errors else '',
+ '@' if self.silent else '',
+ '+' if self.always_execute else '',
+ str(self.execution_line)
+ ])
+
def execute(self, file: Makefile, current_target: 'Target') -> None:
# POSIX:
# > If the command prefix contains a <hyphen-minus>, or the -i option is present, or the special target .IGNORE