From 1c43f7f384bf30f6cce14dc9d3d1e485891c7ddd Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 1 Jun 2014 13:29:01 +0300 Subject: Speed up SCons execution by creating DefaultEnvironment for SCons.SConf.CreateConfigHBuilder only if necessary. --- src/engine/SCons/SConf.py | 12 +++++++++--- src/engine/SCons/Script/Main.py | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 6cc8de8..dd93269 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -119,16 +119,22 @@ def _createConfigH(target, source, env): def _stringConfigH(target, source, env): return "scons: Configure: creating " + str(target[0]) -def CreateConfigHBuilder(env): - """Called just before the building targets phase begins.""" + +def NeedConfigHBuilder(): if len(_ac_config_hs) == 0: - return + return False + else: + return True + +def CreateConfigHBuilder(env): + """Called if necessary just before the building targets phase begins.""" action = SCons.Action.Action(_createConfigH, _stringConfigH) sconfigHBld = SCons.Builder.Builder(action=action) env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} ) for k in _ac_config_hs.keys(): env.SConfigHBuilder(k, env.Value(_ac_config_hs[k])) + class SConfWarning(SCons.Warnings.Warning): pass diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index d4dd229..439b869 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -1031,7 +1031,11 @@ def _main(parser): msg % (deprecated_version_string, python_version_string())) if not options.help: - SCons.SConf.CreateConfigHBuilder(SCons.Defaults.DefaultEnvironment()) + # [ ] Clarify why we need to create Builder here at all, and + # why it is created in DefaultEnvironment + # https://bitbucket.org/scons/scons/commits/d27a548aeee8ad5e67ea75c2d19a7d305f784e30 + if SCons.SConf.NeedConfigHBuilder(): + SCons.SConf.CreateConfigHBuilder(SCons.Defaults.DefaultEnvironment()) # Now re-parse the command-line options (any to the left of a '--' # argument, that is) with any user-defined command-line options that -- cgit v0.12