Skip to content

Error if AddPostAction() on node with no action (e.g., Alias nodes) #2281

Closed

Description

@bdbaddog

This issue was originally created at: 2008-12-21 07:18:51.
This issue was reported by: rhl.

rhl said at 2008-12-21 07:18:51

The following SConstruct file prints, "Hello"

show = Command("show",  "", "@echo Hello")
show = Alias("foo", show)
AddPostAction(show,  "@echo Goodbye")

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.

gregnoel said at 2009-01-08 12:07:58

Should have been assigned to 2.1, not 2.0.

stevenknight said at 2009-11-10 18:00:19

stevenknight => issues@scons

gregnoel said at 2010-06-24 14:21:49

Change subject to reflect decision at bug party.

gregnoel said at 2010-07-21 17:10:33

Bug party triage.

Activity

  1. added this to the milestone on Jan 2, 2018
  2. added and removed on Apr 7, 2021
  3. mwichmann commented on Dec 17, 2023

    @mwichmann
    Collaborator

    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.

  4. bdbaddog commented on Dec 17, 2023

    @bdbaddog
    ContributorAuthor

    Yes. I'll take a look.

  5. ilitzroth commented on Dec 30, 2024

    @ilitzroth

    On Scons 4.8.1
    This SConstruct file

    output_file = File("output_file")
    Command(output_file, [], Touch(output_file))
    Alias("alias1", output_file, "@true")
    AddPostAction("alias1", "@echo running post_action for $TARGET")
    
    Alias("alias2", output_file)
    AddPostAction("alias2", "@echo running post_action for $TARGET")
    
    Default(None)

    Gives this result

    $ scons -Q alias1 && scons -Q -c alias1 && scons -Q alias2 && scons -Q -c alias2
    Touch("output_file")
    running post_action for alias1
    Removed output_file
    Touch("output_file")
    Removed output_file
    

    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.

  6. mwichmann commented on Dec 30, 2024

    @mwichmann
    Collaborator

    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.

  7. added a commit that references this issue on Jan 20, 2025
  8. bdbaddog commented on May 12, 2025

    @bdbaddog
    ContributorAuthor

    Fixed by #4674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions