Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Bug 751076 - fix $< and $^ for pymake; r=bsmedberg
Browse files Browse the repository at this point in the history
  • Loading branch information
mshal committed Jul 9, 2013
1 parent 9cc9a9e commit 7cad46a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pymake/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,8 +1474,20 @@ def addcommand(self, c):

def getcommands(self, target, makefile):
assert isinstance(target, Target)

return getcommandsforrule(self, target, makefile, self.prerequisites, stem=None)
# Prerequisites are merged if the target contains multiple rules and is
# not a terminal (double colon) rule. See
# https://www.gnu.org/software/make/manual/make.html#Multiple-Targets.
prereqs = []
prereqs.extend(self.prerequisites)

if not self.doublecolon:
for rule in target.rules:
# The current rule comes first, which is already in prereqs so
# we don't need to add it again.
if rule != self:
prereqs.extend(rule.prerequisites)

return getcommandsforrule(self, target, makefile, prereqs, stem=None)
# TODO: $* in non-pattern rules?

class PatternRuleInstance(object):
Expand Down
25 changes: 25 additions & 0 deletions tests/multiple-rules-prerequisite-merge.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# When a target is defined multiple times, the prerequisites should get
# merged.

default: foo bar baz

foo:
test "$<" = "foo.in1"
@echo TEST-PASS

foo: foo.in1

bar: bar.in1
test "$<" = "bar.in1"
test "$^" = "bar.in1 bar.in2"
@echo TEST-PASS

bar: bar.in2

baz: baz.in2
baz: baz.in1
test "$<" = "baz.in1"
test "$^" = "baz.in1 baz.in2"
@echo TEST-PASS

foo.in1 bar.in1 bar.in2 baz.in1 baz.in2:

0 comments on commit 7cad46a

Please sign in to comment.