Skip to content

Commit 144af4a

Browse files
authored
Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_post_add_actions
Fix 2281 aliases ignore pre post add actions
2 parents 2e44dda + 6c05400 commit 144af4a

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
9696
specified `local_only`, but the code and tests were using `keep_local`. The functionality
9797
more closely matches local only. NOTE: It doesn't seem like any code in the wild was using
9898
local_only as we'd not received any reports of such until PR #4606 from hedger.
99+
- Fix Issue #2281, AddPreAction() & AddPostAction() were being ignored if no action
100+
was specified when the Alias was initially created.
99101

100102
From Alex James:
101103
- On Darwin, PermissionErrors are now handled while trying to access

RELEASE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ FIXES
176176
more closely matches local only. NOTE: It doesn't seem like any code in the wild was using
177177
local_only as we'd not received any reports of such until PR #4606 from hedger.
178178

179+
- Fix Issue #2281, AddPreAction() & AddPostAction() were being ignored if no action
180+
was specified when the Alias was initially created.
179181

180182
IMPROVEMENTS
181183
------------

SCons/Node/Alias.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ def sconsign(self) -> None:
104104
#
105105
#
106106

107-
def build(self) -> None:
107+
def build(self, **kw) -> None:
108108
"""A "builder" for aliases."""
109-
pass
109+
if len(self.executor.post_actions) + len(self.executor.pre_actions) > 0:
110+
# Only actually call Node's build() if there are any
111+
# pre or post actions.
112+
# Alias nodes will get 1 action and Alias.build()
113+
# This fixes GH Issue #2281
114+
return self.really_build(**kw)
115+
110116

111117
def convert(self) -> None:
112118
try: del self.builder

test/Alias/action.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ def bar(target, source, env):
6969
env.Alias('build-add3', f6)
7070
env.Alias('build-add3', action=foo)
7171
env.Alias('build-add3', action=bar)
72+
73+
74+
f7 = env.Cat('f7.out', 'f6.in')
75+
def build_it(target, source, env):
76+
print("build_it: Goodbye")
77+
return 0
78+
79+
def string_it(target, source, env):
80+
return("string it: Goodbye")
81+
82+
s = Action(build_it, string_it)
83+
env.Alias('add_post_action', f7)
84+
env.AddPostAction('add_post_action', s)
7285
""")
7386

7487
test.write('f1.in', "f1.in 1\n")
@@ -133,6 +146,9 @@ def bar(target, source, env):
133146
test.must_match('foo', "foo(['build-add3'], ['f6.out'])\n")
134147
test.must_match('bar', "bar(['build-add3'], ['f6.out'])\n")
135148

149+
test.run(arguments = 'add_post_action')
150+
test.must_contain_all(test.stdout(), 'string it: Goodbye')
151+
136152
test.pass_test()
137153

138154
# Local Variables:

0 commit comments

Comments
 (0)