diff --git a/CHANGES.txt b/CHANGES.txt index ed6905ba7f..97f7be2431 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/RELEASE.txt b/RELEASE.txt index 19927a3c2b..1b823b91d1 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -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 ------------ diff --git a/SCons/Node/Alias.py b/SCons/Node/Alias.py index 4de222999b..6041581781 100644 --- a/SCons/Node/Alias.py +++ b/SCons/Node/Alias.py @@ -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 diff --git a/test/Alias/action.py b/test/Alias/action.py index ecff388c39..7eff1c7787 100644 --- a/test/Alias/action.py +++ b/test/Alias/action.py @@ -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") @@ -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: