SCons task execution time determination

I have some goals that need to be built to determine which are some of my other goals. How to inform SCons?

Example:

A script, generate runs in some configuration files. This script creates path and assembly flags based on the information in the configuration files. To create a SCons Object , I need to read the generated files.

I just ran Execute() on generate , but now it has got a lot of files to create, and it takes a lot of time, so I only want to run it when it or the configuration file changes. How can I tell SCons to ask me about build time for some purposes, as soon as this Command done everything it needs to do?

+1
source share
2 answers

ok, first some skinson clarifications. Scons has two phases when building. First, in the analysis phase, all Scons scripts are executed, and the result is a static dependency tree that describes the source and target files for all developers defined in the scripts. Further, on the basis of this tree, the assembly database from the last assembly and the signing of files on the disk, all developers with outdated goals are restored.

Now to your question. If you only want to run generate when necessary (when generate or the configuration files change), then running generate as part of the analysis phase is out of the question. Therefore, do not use Execute() . Instead, generate should be the owner. So far so good.

Now you have two collectors: the first builder generate and the second builder, I call it buildObject . buildObject depends on the goals of generate , but, as you say, generate targets are unknown during analysis (since generate does not start, it is configured only as a builder). Having unknown targets during analysis is a classic challenge with SCons, and there is no easy way to solve it.

I usually solve it using what I call the SCons.pleaser file. In your case, this will be a known target created by generate containing a high-resolution timestamp. Then the creator of buildObject takes this file as the source. Now, if your configuration files have not changed, generate will not start, SCons.pleaser will not change, and buildObject will not buildObject . If you change the configuration files, generate, it starts, SCons.pleaser changes and buildObject also starts.

Hi

+2
source

The solution I went with was to create a new SConstruct that knows how to complete the generation phase, and Execute() at the beginning of my SConscripts before I get to the bit where its output is required. It works well, as it simply builds things as needed with little fixed overhead when calling SCons from within SCons.

0
source

All Articles