Skip to content

How can I make an action run if build is successful or unneeded #4582

Answered by mwichmann
mark-summerfield asked this question in Q&A
Discussion options

You must be logged in to vote

At its very simplest, this should work:

prog = Program("hello.c")
pname = str(prog[0])
runit = Command(target=f'r_{pname}', source=prog, action=(f'-./{pname}'))

In this case, Command has a target that uses a made-up name, just prepending something to the name of the Program target, and its source is the built program, and since the action never "creates" that target, it's always out of date and so runs every time.

The more detailed recipe accounts for more complexity, such as when there are multiple programs to run (the accumulating nature of Alias is useful for that), or when the action actually produces something that looks like a target - like an output log (if you use a logfile or oth…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@mark-summerfield
Comment options

Comment options

You must be logged in to vote
1 reply
@mark-summerfield
Comment options

Comment options

You must be logged in to vote
1 reply
@mark-summerfield
Comment options

Answer selected by mark-summerfield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants