Search code examples
pythonbuildmatchingscons

Scons build system pattern-matching for targets specified on the command line


I am using scons for a data analysis project. Sometimes I would like to only build a subset of targets, for example all figure files (ending e.g. with ".png"). Is there a way to do this directly from the command line, like

scons . **/*.png

A manual solution I found here was adding an Alias, but this would require changing the Sconscript file for each such a subset of targets. Is there a more general way to do this?


Solution

  • Aliases are the model for giving names to target(s) that you can invoke from the command line. You can also use a directory name as a target, and it will build all the known targets that go under that directory. You may not need to make changes everywhere: in your case you might be able to combine the result of calling Glob with a pattern with an alias. Unfortunately, at the moment, Glob is not recursive (it's a wishlist item, needing someone motivated to implement it), so might be a bit of extra work if your targets of a particular type are spread all over the tree.