Commits

anatoly techtonik committed 52611bc

Speed up SCons execution by creating DefaultEnvironment for
SCons.SConf.CreateConfigHBuilder only if necessary.

Comments (0)

Files changed (2)

src/engine/SCons/SConf.py

 def _stringConfigH(target, source, env):
     return "scons: Configure: creating " + str(target[0])
 
+
+def NeedConfigHBuilder():
+    if len(_ac_config_hs) == 0:
+       return False
+    else:
+       return True
+
 def CreateConfigHBuilder(env):
-    """Called just before the building targets phase begins."""
-    if len(_ac_config_hs) == 0:
-        return
+    """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

src/engine/SCons/Script/Main.py

                             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