summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-07-22 11:38:20 (GMT)
committerSteven Knight <knight@baldmt.com>2003-07-22 11:38:20 (GMT)
commit17f8210401fbaf283fba34e5d87700e4e7431470 (patch)
tree85869e6a0a2ff03ee52b9d34052225d9cc580106 /src
parent1737bf0b826d00d06a62f623e61404795cc65b49 (diff)
downloadSCons-17f8210401fbaf283fba34e5d87700e4e7431470.zip
SCons-17f8210401fbaf283fba34e5d87700e4e7431470.tar.gz
SCons-17f8210401fbaf283fba34e5d87700e4e7431470.tar.bz2
Only create a default Environment when asked to. (Chad Austin)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Defaults.py10
-rw-r--r--src/engine/SCons/Node/FS.py4
-rw-r--r--src/engine/SCons/Script/SConscript.py2
-rw-r--r--src/engine/SCons/Script/__init__.py4
5 files changed, 16 insertions, 7 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index abbf744..33e481d 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -17,6 +17,9 @@ RELEASE 0.XX - XXX
- Give a Value Nodes a timestamp of the system time when they're
created, so they'll work when using timestamp-based signatures.
+ - Add a DefaultEnvironment() function that only creates a default
+ environment on-demand (for fetching source files, e.g.).
+
From Steven Knight:
- Tighten up the scons -H help output.
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index e2bb3b4..aa0fbd9 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -44,6 +44,7 @@ import string
import SCons.Action
import SCons.Builder
+import SCons.Environment
import SCons.Node.Alias
import SCons.Node.FS
import SCons.Scanner.C
@@ -56,6 +57,15 @@ import SCons.Scanner.Prog
# interface.
_default_env = None
+# Lazily instantiate the default environment so the overhead of creating
+# it doesn't apply when it's not needed.
+def DefaultEnvironment():
+ global _default_env
+ if not _default_env:
+ _default_env = SCons.Environment.Environment()
+ return _default_env
+
+
def alias_builder(env, target, source):
pass
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 1f88330..a17cee0 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -168,7 +168,7 @@ def get_DefaultSCCSBuilder():
import SCons.Builder
import SCons.Defaults
DefaultSCCSBuilder = SCons.Builder.Builder(action = '$SCCSCOM',
- env = SCons.Defaults._default_env)
+ env = SCons.Defaults.DefaultEnvironment())
return DefaultSCCSBuilder
def get_DefaultRCSBuilder():
@@ -177,7 +177,7 @@ def get_DefaultRCSBuilder():
import SCons.Builder
import SCons.Defaults
DefaultRCSBuilder = SCons.Builder.Builder(action = '$RCS_COCOM',
- env = SCons.Defaults._default_env)
+ env = SCons.Defaults.DefaultEnvironment())
return DefaultRCSBuilder
#
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 5f7f4b5..313a3f2 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -513,7 +513,6 @@ def BuildDefaultGlobals():
"""
globals = {}
- globals['_default_env'] = SCons.Defaults._default_env
globals['Action'] = SCons.Action.Action
globals['AddPostAction'] = AddPostAction
globals['AddPreAction'] = AddPreAction
@@ -526,6 +525,7 @@ def BuildDefaultGlobals():
globals['Configure'] = SCons.SConf.SConf
globals['CScan'] = SCons.Defaults.CScan
globals['Default'] = Default
+ globals['DefaultEnvironment'] = SCons.Defaults.DefaultEnvironment
globals['Dir'] = SCons.Node.FS.default_fs.Dir
globals['EnsurePythonVersion'] = EnsurePythonVersion
globals['EnsureSConsVersion'] = EnsureSConsVersion
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index fe56568..c171a91 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -750,10 +750,6 @@ def _main(args, parser):
SCons.Node.FS.default_fs.set_toplevel_dir(os.getcwd())
- # Now that the top-level directory has been set,
- # we can initialize the default Environment.
- SCons.Defaults._default_env = SCons.Environment.Environment()
-
scripts = []
if options.file:
scripts.extend(options.file)