[Scons-users] Non Construction steps in Scons
Mats Wichmann
mats at wichmann.us
Sat May 14 18:48:24 EDT 2022
On 5/14/22 16:18, Duane Ellis wrote:
> Hi – I am new to scons and I am trying to do something Know how to do in
> Make
>
> Example make rule is like this (I hope this shows up in email reasonably)…
>
> =============
>
> Many-things: Step1. Step2. Step3 Step4 Step5
>
> TARGET=allthings
>
> MyApp.ELF: $(OBJECT_FILES)
> $(LINK_STEP) ….
>
> Step1: MyApp.ELF
> Cmd1
>
> Step2:
> Cmd2
>
> Step3:
> Cmd3
>
> Step4:
> Cmd4
>
> Step5:
> Cmd5
>
> Allthings: MyApp.ELF Step1 Step2 Step3
>
> =============
>
> In my case, I am working on an embedded platform.
>
> I am *NOT* always performing “Construction” – I want to do some other
> things.
>
> Scons can build my app wonderfully – but I can’t get it to do the next
> several steps – they are not “construction steps” they are procedural steps
On the whole (as you're finding out), this isn't really what SCons does
and so it's sometimes a bit tricky to set these things up.
The first one, however, is well supported;
> Step 1 – I need to post-process my ELF file to create a BIN file in a
> special way for my board (producing a type of BIN file)
the AddPostAction and AddPreAction methods can help with these needs.
> Step 2 – takes the BIN and ‘packages’ it with special flags unique to
> this application (A generic builder seems wrong here)
There is some "packaging" support - and usually those are indeed
builders - but often things under that term can end up quite
specialized, so that may or may not help you.
> Step 3 – runs a GUI tool in command line mode to “flash” my board, I
> have to specify on the command line the DEVICE address (either a
> comport, or a tftp server)
>
> Step 4 – runs a command to power cycle the board via a SCPI controlled
> power supply
>
> Step 5 – Launches a Python PyExpect test sequence with a rather
> complicated command line.
You can create a "phony" target which runs a script to do all these
things. I use the term phony because normally, to SCons, a target is
something that is tangible that it can construct. This can be a bit
awkward but is certainly doable - for example, people use this concept
to run unit tests.
> Other examples are “building both a Library, and a Doxygen package and
> running the library through a small regression test and “code-formatter”
> I know how to do that with make… but I don’t see a way of doing that with
There is a contributed doxygen tool in the scons-contrib repository.
For tests, see the comment above. For other things, like code
formatting - consider whether you really want those done as part of the
scons process, or elsewhere. For example, you can set up pre-commit and
post-commit hooks in git (conceptually like AddPostAction in SCons), and
you can set up even more sophisticated tasks of this sort in GitHub and
Gitlab, should you be using either of those two platforms. It's just a
thought, not telling you how to solve your problems.
> What I would like know how to do is:
>
>
>
> Create a list of arbitrary commands that I can execute in order, If one
> of those commands fail, I want further progress to stop
>
> I would like to say which step depends on the previous step – this is
> **SPECIFICALLY* not a filename extension thing*
You don't really get to do this: the underlying architectural concept is
that you tell SCons the relationship between things (e.g. a Builder
produces targets from the listed sources), it constructs a node graph of
all those things, and then walks that graph to decide how best to
complete the build. If you need very specific ordering of certain
steps, you need to put them in an external script, or a Python function,
which applies the constraints you need.
> From the command line, I need to be able to reasonably execute one of
> the steps at will (ie: like I can do with “make step4”, or “make
> allthings”)
Generally speaking you can use Alias to set up targets that are easy to
invoke from the command line, and aliases are quite flexible so they can
refer to few or many things, including other Aliases (although there's
an ordering consideration with chaining aliases).
More information about the Scons-users
mailing list