You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error if AddPostAction() on node with no action (e.g., Alias nodes) #2281
I.e. the AddPostAction is accepted, but does nothing; if you comment the Alias line you get the expected "Hello" and "Goodbye".
IMHO, scons should either handle this case, or flag an error.
gregnoel said at 2008-12-26 15:25:19
What's happening is that the AddPostAction() is being applied to the alias Node, not the file Node, where it is ignored. I believe the only possible place that an action can be validly extended is on a file Node (with a non-Null Executor?), so it ought to be possible to detect when it is not and generate an error.
In the case here, the workaround is to use different variable names for the file Node and the alias Node and use AddPostAction() on the file Node.
stevenknight said at 2009-01-07 19:03:57
Bug party triage: Decided that SCons should issue an error (or perhaps a warning?) if you issue AddPostAction() on a Node that has no existing action.
gives this output which seems to show that the postactions are only run when the
the aliases have an attached action. Just attaching the the action to the alias by calling Alias(alias2", [], "@echo running post_action for $TARGET")
does run this action. I find this behaviour inconsistent. We are using scons to build an
extensible build system, and we would like to use AddPost, AddPre to allow the builds to
be extended by users in a simple way.
Aliases are a little funky in that they're their own node type, and AddPostAction doesn't distinguish - it just adds the new action to the chain for the node it's called on. That "works" for an alias node with an action because that is already a kind of post-action and the added one can chain onto that. The complication is that aliases don't have a sense of completion - you can keep adding to them via multiple calls, so you might call AddPostAction on an alias that isn't yet associated with the real target you wanted the post action associated with. In fact, many people use a kind of global alias, where everywhere in their build an exectable-type target is created, it is added to the alias so you can eventually "build everything" by giving that alias on the command line. Would an AddPostAction apply to all of those, or to just a single one? So much for internal details...
So yes, it's inconsistent from an expectation sense; the docs say nothing about a limitation. Looks like we were going to look into at least letting you know this wasn't going to do what you expect, but it still hasn't happened.
Activity
mwichmann commentedon Dec 17, 2023
Does this one have a straightforward way of moving forward. Seems like it was decided to have this situation cause error/warn, but it never happened.
bdbaddog commentedon Dec 17, 2023
Yes. I'll take a look.
ilitzroth commentedon Dec 30, 2024
On Scons 4.8.1
This SConstruct file
Gives this result
gives this output which seems to show that the postactions are only run when the
the aliases have an attached action. Just attaching the the action to the alias by calling
Alias(alias2", [], "@echo running post_action for $TARGET")does run this action. I find this behaviour inconsistent. We are using scons to build an
extensible build system, and we would like to use AddPost, AddPre to allow the builds to
be extended by users in a simple way.
mwichmann commentedon Dec 30, 2024
Aliases are a little funky in that they're their own node type, and
AddPostActiondoesn't distinguish - it just adds the new action to the chain for the node it's called on. That "works" for an alias node with an action because that is already a kind of post-action and the added one can chain onto that. The complication is that aliases don't have a sense of completion - you can keep adding to them via multiple calls, so you might callAddPostActionon an alias that isn't yet associated with the real target you wanted the post action associated with. In fact, many people use a kind of global alias, where everywhere in their build an exectable-type target is created, it is added to the alias so you can eventually "build everything" by giving that alias on the command line. Would an AddPostAction apply to all of those, or to just a single one? So much for internal details...So yes, it's inconsistent from an expectation sense; the docs say nothing about a limitation. Looks like we were going to look into at least letting you know this wasn't going to do what you expect, but it still hasn't happened.
Manpage: note pre/post actions effect on an alias [skip appveyor]
Manpage: note pre/post actions effect on an alias [skip appveyor]
Fix Issue SCons#2281, post and pre actions were being ignored when ad…
Manpage: note pre/post actions effect on an alias [skip appveyor]
Manpage: note pre/post actions effect on an alias [skip appveyor]
Manpage: note pre/post actions effect on an alias [skip appveyor]
bdbaddog commentedon May 12, 2025
Fixed by #4674