aboutsummaryrefslogtreecommitdiff
path: root/yapymake
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-25 20:01:56 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-25 20:01:56 -0600
commitb387cba85947db7101726a9f743f272d6dcea269 (patch)
tree460e84de2cce2bba96ec6bae9953cf26f5620621 /yapymake
parent31aafd958390d3325206c2b9043a380acb49e00d (diff)
downloadyapymake-b387cba85947db7101726a9f743f272d6dcea269.tar.gz
yapymake-b387cba85947db7101726a9f743f272d6dcea269.zip
allow (but lint for) inferring commands on explicit targets
Diffstat (limited to 'yapymake')
-rw-r--r--yapymake/makefile/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py
index 0290e9f..4617047 100644
--- a/yapymake/makefile/__init__.py
+++ b/yapymake/makefile/__init__.py
@@ -254,7 +254,9 @@ class Makefile:
def target(self, name: str) -> 'Target':
# TODO implement .DEFAULT
- if name not in self._targets:
+ # it's not POSIXful, but GNU make will use inference rules for defined targets with no commands,
+ follow_gnu = True # TODO implement .POSIX and scope it properly
+ if name not in self._targets or (follow_gnu and len(self._targets[name].commands) == 0):
# > When no target rule is found to update a target, the inference rules shall be checked. The suffix of
# > the target (.s1) to be built...
suffix = PurePath(name).suffix
@@ -269,6 +271,10 @@ class Makefile:
# > whose prerequisite file ($*.s2) exists.
prerequisite_path = PurePath(name).with_suffix(rule.s2)
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._targets[name] = Target(name, [str(prerequisite_path)], rule.commands)
break
if name not in self._targets: