Skip to content

Commit

Permalink
Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_po…
Browse files Browse the repository at this point in the history
…st_add_actions

Fix 2281 aliases ignore pre post add actions
  • Loading branch information
bdbaddog authored Jan 21, 2025
2 parents 2e44dda + 6c05400 commit 144af4a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
specified `local_only`, but the code and tests were using `keep_local`. The functionality
more closely matches local only. NOTE: It doesn't seem like any code in the wild was using
local_only as we'd not received any reports of such until PR #4606 from hedger.
- Fix Issue #2281, AddPreAction() & AddPostAction() were being ignored if no action
was specified when the Alias was initially created.

From Alex James:
- On Darwin, PermissionErrors are now handled while trying to access
Expand Down
2 changes: 2 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ FIXES
more closely matches local only. NOTE: It doesn't seem like any code in the wild was using
local_only as we'd not received any reports of such until PR #4606 from hedger.

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

IMPROVEMENTS
------------
Expand Down
10 changes: 8 additions & 2 deletions SCons/Node/Alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ def sconsign(self) -> None:
#
#

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


def convert(self) -> None:
try: del self.builder
Expand Down
16 changes: 16 additions & 0 deletions test/Alias/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ def bar(target, source, env):
env.Alias('build-add3', f6)
env.Alias('build-add3', action=foo)
env.Alias('build-add3', action=bar)
f7 = env.Cat('f7.out', 'f6.in')
def build_it(target, source, env):
print("build_it: Goodbye")
return 0
def string_it(target, source, env):
return("string it: Goodbye")
s = Action(build_it, string_it)
env.Alias('add_post_action', f7)
env.AddPostAction('add_post_action', s)
""")

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

test.run(arguments = 'add_post_action')
test.must_contain_all(test.stdout(), 'string it: Goodbye')

test.pass_test()

# Local Variables:
Expand Down

0 comments on commit 144af4a

Please sign in to comment.