summaryrefslogtreecommitdiffstats
path: root/SConstruct
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-03-08 06:16:07 (GMT)
committerSteven Knight <knight@baldmt.com>2004-03-08 06:16:07 (GMT)
commitb7038d877e9a7a641d20d5e9d603e270901ae77b (patch)
treee656d276e2865c700d1b55892d5ff09af5646fc1 /SConstruct
parent29d2eb666f70c270228ff5eeecfbb981395d79fa (diff)
downloadSCons-b7038d877e9a7a641d20d5e9d603e270901ae77b.zip
SCons-b7038d877e9a7a641d20d5e9d603e270901ae77b.tar.gz
SCons-b7038d877e9a7a641d20d5e9d603e270901ae77b.tar.bz2
Speed up SCons packaging builds by eliminating lots of unnecessary string.replace() calls.
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct32
1 files changed, 14 insertions, 18 deletions
diff --git a/SConstruct b/SConstruct
index d2cc7b4..9773efe 100644
--- a/SConstruct
+++ b/SConstruct
@@ -227,24 +227,20 @@ def SCons_revision(target, source, env):
"""
t = str(target[0])
s = source[0].rstr()
- inf = open(s, 'rb')
- outf = open(t, 'wb')
- for line in inf.readlines():
- # Note: We construct the __*__ substitution strings here
- # so that they don't get replaced when this file gets
- # copied into the tree for packaging.
- line = string.replace(line, '__BUILD' + '__', env['BUILD'])
- line = string.replace(line, '__BUILDSYS' + '__', env['BUILDSYS'])
- line = string.replace(line, '__COPYRIGHT' + '__', env['COPYRIGHT'])
- line = string.replace(line, '__DATE' + '__', env['DATE'])
- line = string.replace(line, '__DEVELOPER' + '__', env['DEVELOPER'])
- line = string.replace(line, '__FILE' + '__', str(source[0]))
- line = string.replace(line, '__REVISION' + '__', env['REVISION'])
- line = string.replace(line, '__VERSION' + '__', env['VERSION'])
- line = string.replace(line, '__NULL' + '__', '')
- outf.write(line)
- inf.close()
- outf.close()
+ contents = open(s, 'rb').read()
+ # Note: We construct the __*__ substitution strings here
+ # so that they don't get replaced when this file gets
+ # copied into the tree for packaging.
+ contents = string.replace(contents, '__BUILD' + '__', env['BUILD'])
+ contents = string.replace(contents, '__BUILDSYS' + '__', env['BUILDSYS'])
+ contents = string.replace(contents, '__COPYRIGHT' + '__', env['COPYRIGHT'])
+ contents = string.replace(contents, '__DATE' + '__', env['DATE'])
+ contents = string.replace(contents, '__DEVELOPER' + '__', env['DEVELOPER'])
+ contents = string.replace(contents, '__FILE' + '__', str(source[0]))
+ contents = string.replace(contents, '__REVISION' + '__', env['REVISION'])
+ contents = string.replace(contents, '__VERSION' + '__', env['VERSION'])
+ contents = string.replace(contents, '__NULL' + '__', '')
+ open(t, 'wb').write(contents)
os.chmod(t, os.stat(s)[0])
revbuilder = Builder(action = Action(SCons_revision,