I made a Python script that runs whenever the main binary is changed (using Requires), so at the moment it runs with every build. However, the script can be time consuming in certain cases, and I'm trying to figure out how to run it only if a flag is given.
For example, if I type "scons -script" the script will run after the compilation of the main binary, but typing "scons" will just build the file and do nothing beyond that.
I ended up solving it by using AddOption() to define the flag:
AddOption("--script", action="store_true", help="Run the script")
And writing a method that checks the flag using GetOption() and adds the script to the requirements:
if GetOption("script"):
script = Command(target=...,
source=...,
action=[...])
Requires(script, binary_node)