Search code examples
c++scons

Extract compilation time per compilation unit using SCons


I am using SCons to build my C++ application. I would like to extract the time it takes to build every compilation unit individually, such as:

a.cpp -> a.o - took 2.4 seconds
main.cpp -> main.o - took 5.1 seconds

I want to store these times in a database, per compilation unit.

The problem is that SCons comes built in with an Object/Program builder that builds the compilation units and I am not sure how to hook into those to add timing/database saving code. In a sense, I'm looking to wrap the already existing builder maybe.

What is a good way of achieving this?


Solution

  • Wrap scons in a script, then use scons --debug=time and parse the output.