From 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Tue, 15 Jun 2010 14:28:22 +0000 Subject: Imported Upstream version 2.0.0 --- src/engine/SCons/Tool/386asm.py | 2 +- src/engine/SCons/Tool/BitKeeper.py | 4 +- src/engine/SCons/Tool/CVS.py | 6 +- src/engine/SCons/Tool/FortranCommon.py | 17 +- src/engine/SCons/Tool/JavaCommon.py | 23 +- src/engine/SCons/Tool/JavaCommonTests.py | 4 +- src/engine/SCons/Tool/MSCommon/__init__.py | 2 +- src/engine/SCons/Tool/MSCommon/arch.py | 4 +- src/engine/SCons/Tool/MSCommon/common.py | 62 +++- src/engine/SCons/Tool/MSCommon/netframework.py | 10 +- src/engine/SCons/Tool/MSCommon/sdk.py | 22 +- src/engine/SCons/Tool/MSCommon/vc.py | 182 +++++++----- src/engine/SCons/Tool/MSCommon/vc.py.bak | 394 ------------------------- src/engine/SCons/Tool/MSCommon/vs.py | 36 +-- src/engine/SCons/Tool/Perforce.py | 7 +- src/engine/SCons/Tool/PharLapCommon.py | 15 +- src/engine/SCons/Tool/PharLapCommonTests.py | 2 +- src/engine/SCons/Tool/RCS.py | 6 +- src/engine/SCons/Tool/SCCS.py | 6 +- src/engine/SCons/Tool/Subversion.py | 6 +- src/engine/SCons/Tool/ToolTests.py | 8 +- src/engine/SCons/Tool/__init__.py | 68 +++-- src/engine/SCons/Tool/__init__.xml | 4 +- src/engine/SCons/Tool/aixc++.py | 2 +- src/engine/SCons/Tool/aixcc.py | 2 +- src/engine/SCons/Tool/aixf77.py | 2 +- src/engine/SCons/Tool/aixlink.py | 2 +- src/engine/SCons/Tool/applelink.py | 2 +- src/engine/SCons/Tool/ar.py | 2 +- src/engine/SCons/Tool/as.py | 2 +- src/engine/SCons/Tool/bcc32.py | 3 +- src/engine/SCons/Tool/c++.py | 2 +- src/engine/SCons/Tool/cc.py | 20 +- src/engine/SCons/Tool/cvf.py | 2 +- src/engine/SCons/Tool/default.py | 2 +- src/engine/SCons/Tool/dmd.py | 5 +- src/engine/SCons/Tool/dvi.py | 2 +- src/engine/SCons/Tool/dvipdf.py | 5 +- src/engine/SCons/Tool/dvips.py | 2 +- src/engine/SCons/Tool/f77.py | 2 +- src/engine/SCons/Tool/f90.py | 2 +- src/engine/SCons/Tool/f95.py | 2 +- src/engine/SCons/Tool/filesystem.py | 6 +- src/engine/SCons/Tool/fortran.py | 3 +- src/engine/SCons/Tool/g++.py | 2 +- src/engine/SCons/Tool/g77.py | 2 +- src/engine/SCons/Tool/gas.py | 2 +- src/engine/SCons/Tool/gcc.py | 2 +- src/engine/SCons/Tool/gfortran.py | 2 +- src/engine/SCons/Tool/gnulink.py | 2 +- src/engine/SCons/Tool/gs.py | 4 +- src/engine/SCons/Tool/hpc++.py | 7 +- src/engine/SCons/Tool/hpcc.py | 2 +- src/engine/SCons/Tool/hplink.py | 2 +- src/engine/SCons/Tool/icc.py | 2 +- src/engine/SCons/Tool/icl.py | 6 +- src/engine/SCons/Tool/ifl.py | 6 +- src/engine/SCons/Tool/ifort.py | 10 +- src/engine/SCons/Tool/ilink.py | 2 +- src/engine/SCons/Tool/ilink32.py | 2 +- src/engine/SCons/Tool/install.py | 16 +- src/engine/SCons/Tool/intelc.py | 42 ++- src/engine/SCons/Tool/ipkg.py | 10 +- src/engine/SCons/Tool/jar.py | 2 +- src/engine/SCons/Tool/javac.py | 36 +-- src/engine/SCons/Tool/javah.py | 7 +- src/engine/SCons/Tool/latex.py | 4 +- src/engine/SCons/Tool/lex.py | 6 +- src/engine/SCons/Tool/link.py | 2 +- src/engine/SCons/Tool/linkloc.py | 4 +- src/engine/SCons/Tool/m4.py | 2 +- src/engine/SCons/Tool/masm.py | 2 +- src/engine/SCons/Tool/midl.py | 8 +- src/engine/SCons/Tool/mingw.py | 5 +- src/engine/SCons/Tool/mslib.py | 2 +- src/engine/SCons/Tool/mslink.py | 14 +- src/engine/SCons/Tool/mssdk.py | 2 +- src/engine/SCons/Tool/msvc.py | 17 +- src/engine/SCons/Tool/msvs.py | 233 ++++++--------- src/engine/SCons/Tool/msvsTests.py | 54 ++-- src/engine/SCons/Tool/mwcc.py | 11 +- src/engine/SCons/Tool/mwld.py | 4 +- src/engine/SCons/Tool/nasm.py | 2 +- src/engine/SCons/Tool/packaging/__init__.py | 32 +- src/engine/SCons/Tool/packaging/ipk.py | 12 +- src/engine/SCons/Tool/packaging/msi.py | 27 +- src/engine/SCons/Tool/packaging/rpm.py | 48 ++- src/engine/SCons/Tool/packaging/src_tarbz2.py | 2 +- src/engine/SCons/Tool/packaging/src_targz.py | 2 +- src/engine/SCons/Tool/packaging/src_zip.py | 2 +- src/engine/SCons/Tool/packaging/tarbz2.py | 2 +- src/engine/SCons/Tool/packaging/targz.py | 2 +- src/engine/SCons/Tool/packaging/zip.py | 2 +- src/engine/SCons/Tool/pdf.py | 2 +- src/engine/SCons/Tool/pdflatex.py | 4 +- src/engine/SCons/Tool/pdftex.py | 6 +- src/engine/SCons/Tool/qt.py | 4 +- src/engine/SCons/Tool/rmic.py | 5 +- src/engine/SCons/Tool/rpcgen.py | 2 +- src/engine/SCons/Tool/rpm.py | 2 +- src/engine/SCons/Tool/sgiar.py | 2 +- src/engine/SCons/Tool/sgic++.py | 2 +- src/engine/SCons/Tool/sgicc.py | 2 +- src/engine/SCons/Tool/sgilink.py | 2 +- src/engine/SCons/Tool/sunar.py | 2 +- src/engine/SCons/Tool/sunc++.py | 2 +- src/engine/SCons/Tool/suncc.py | 2 +- src/engine/SCons/Tool/sunf77.py | 2 +- src/engine/SCons/Tool/sunf90.py | 2 +- src/engine/SCons/Tool/sunf95.py | 2 +- src/engine/SCons/Tool/sunlink.py | 2 +- src/engine/SCons/Tool/swig.py | 20 +- src/engine/SCons/Tool/tar.py | 2 +- src/engine/SCons/Tool/tex.py | 38 +-- src/engine/SCons/Tool/textfile.py | 6 +- src/engine/SCons/Tool/tlib.py | 2 +- src/engine/SCons/Tool/wix.py | 5 +- src/engine/SCons/Tool/yacc.py | 5 +- src/engine/SCons/Tool/zip.py | 13 +- src/engine/SCons/Tool/zip.xml | 5 +- 120 files changed, 680 insertions(+), 1096 deletions(-) delete mode 100644 src/engine/SCons/Tool/MSCommon/vc.py.bak (limited to 'src/engine/SCons/Tool') diff --git a/src/engine/SCons/Tool/386asm.py b/src/engine/SCons/Tool/386asm.py index 0891e96..5b8c8cb 100644 --- a/src/engine/SCons/Tool/386asm.py +++ b/src/engine/SCons/Tool/386asm.py @@ -32,7 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/386asm.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/386asm.py 5023 2010/06/14 22:05:46 scons" from SCons.Tool.PharLapCommon import addPharLapPaths import SCons.Util diff --git a/src/engine/SCons/Tool/BitKeeper.py b/src/engine/SCons/Tool/BitKeeper.py index 121f579..a155a42 100644 --- a/src/engine/SCons/Tool/BitKeeper.py +++ b/src/engine/SCons/Tool/BitKeeper.py @@ -32,7 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/BitKeeper.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/BitKeeper.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder @@ -44,6 +44,8 @@ def generate(env): def BitKeeperFactory(env=env): """ """ + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The BitKeeper() factory is deprecated and there is no replacement.""") act = SCons.Action.Action("$BITKEEPERCOM", "$BITKEEPERCOMSTR") return SCons.Builder.Builder(action = act, env = env) diff --git a/src/engine/SCons/Tool/CVS.py b/src/engine/SCons/Tool/CVS.py index b30c319..bb9f956 100644 --- a/src/engine/SCons/Tool/CVS.py +++ b/src/engine/SCons/Tool/CVS.py @@ -8,7 +8,6 @@ selection method. """ -# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -29,9 +28,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/CVS.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/CVS.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder @@ -43,6 +41,8 @@ def generate(env): def CVSFactory(repos, module='', env=env): """ """ + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The CVS() factory is deprecated and there is no replacement.""") # fail if repos is not an absolute path name? if module != '': # Don't use os.path.join() because the name we fetch might diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index 53c48e4..db89f96 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -27,10 +27,9 @@ Stuff for processing Fortran, common to all fortran dialects. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/FortranCommon.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/FortranCommon.py 5023 2010/06/14 22:05:46 scons" import re -import string import os.path import SCons.Action @@ -73,7 +72,7 @@ def _fortranEmitter(target, source, env): # Convert module name to a .mod filename suffix = env.subst('$FORTRANMODSUFFIX', target=target, source=source) moddir = env.subst('$FORTRANMODDIR', target=target, source=source) - modules = map(lambda x, s=suffix: string.lower(x) + s, modules) + modules = [x.lower() + suffix for x in modules] for m in modules: target.append(env.fs.File(m, moddir)) return (target, source) @@ -91,8 +90,8 @@ def ComputeFortranSuffixes(suffixes, ppsuffixes): pre-processed. Both should be sequences, not strings.""" assert len(suffixes) > 0 s = suffixes[0] - sup = string.upper(s) - upper_suffixes = map(string.upper, suffixes) + sup = s.upper() + upper_suffixes = [_.upper() for _ in suffixes] if SCons.Util.case_sensitive_suffixes(s, sup): ppsuffixes.extend(upper_suffixes) else: @@ -135,17 +134,17 @@ def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0): static_obj.add_emitter(suffix, FortranEmitter) shared_obj.add_emitter(suffix, ShFortranEmitter) - if not env.has_key('%sFLAGS' % dialect): + if '%sFLAGS' % dialect not in env: env['%sFLAGS' % dialect] = SCons.Util.CLVar('') - if not env.has_key('SH%sFLAGS' % dialect): + if 'SH%sFLAGS' % dialect not in env: env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect) # If a tool does not define fortran prefix/suffix for include path, use C ones - if not env.has_key('INC%sPREFIX' % dialect): + if 'INC%sPREFIX' % dialect not in env: env['INC%sPREFIX' % dialect] = '$INCPREFIX' - if not env.has_key('INC%sSUFFIX' % dialect): + if 'INC%sSUFFIX' % dialect not in env: env['INC%sSUFFIX' % dialect] = '$INCSUFFIX' env['_%sINCFLAGS' % dialect] = '$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' % (dialect, dialect, dialect) diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 635659a..bd6a30b 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -27,12 +27,11 @@ Stuff for processing Java. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/JavaCommon.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/JavaCommon.py 5023 2010/06/14 22:05:46 scons" import os import os.path import re -import string java_parsing = 1 @@ -60,7 +59,7 @@ if java_parsing: r'\d*\.\d*|[A-Za-z_][\w\$\.]*|<[A-Za-z_]\w+>|' + r'/\*|\*/|\[\])') - class OuterState: + class OuterState(object): """The initial state for parsing a Java file for classes, interfaces, and anonymous inner classes.""" def __init__(self, version=default_java_version): @@ -68,7 +67,7 @@ if java_parsing: if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6', '5', '6'): msg = "Java version %s not supported" % version - raise NotImplementedError, msg + raise NotImplementedError(msg) self.version = version self.listClasses = [] @@ -127,7 +126,7 @@ if java_parsing: self.brackets = self.brackets - 1 if len(self.stackBrackets) and \ self.brackets == self.stackBrackets[-1]: - self.listOutputs.append(string.join(self.listClasses, '$')) + self.listOutputs.append('$'.join(self.listClasses)) self.localClasses.pop() self.listClasses.pop() self.anonStacksStack.pop() @@ -179,7 +178,7 @@ if java_parsing: self.__getAnonStack()[-1] = self.__getAnonStack()[-1] + 1 for anon in self.__getAnonStack(): className.append(str(anon)) - self.listOutputs.append(string.join(className, '$')) + self.listOutputs.append('$'.join(className)) self.nextAnon = self.nextAnon + 1 self.__getAnonStack().append(0) @@ -187,7 +186,7 @@ if java_parsing: def setPackage(self, package): self.package = package - class AnonClassState: + class AnonClassState(object): """A state that looks for anonymous inner classes.""" def __init__(self, old_state): # outer_state is always an instance of OuterState @@ -222,7 +221,7 @@ if java_parsing: self.outer_state.addAnonClass() return self.old_state.parseToken(token) - class SkipState: + class SkipState(object): """A state that will skip a specified number of tokens before reverting to the previous state.""" def __init__(self, tokens_to_skip, old_state): @@ -234,7 +233,7 @@ if java_parsing: return self.old_state return self - class ClassState: + class ClassState(object): """A state we go into when we hit a class or interface keyword.""" def __init__(self, outer_state): # outer_state is always an instance of OuterState @@ -261,7 +260,7 @@ if java_parsing: self.outer_state.anonStacksStack.append([0]) return self.outer_state - class IgnoreState: + class IgnoreState(object): """A state that will ignore all tokens until it gets to a specified token.""" def __init__(self, ignore_until, old_state): @@ -272,7 +271,7 @@ if java_parsing: return self.old_state return self - class PackageState: + class PackageState(object): """The state we enter when we encounter the package keyword. We assume the next token will be the package name.""" def __init__(self, outer_state): @@ -298,7 +297,7 @@ if java_parsing: currstate = currstate.parseToken(token) if trace: trace(token, currstate) if initial.package: - package = string.replace(initial.package, '.', os.sep) + package = initial.package.replace('.', os.sep) return (package, initial.listOutputs) else: diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 936b474..e900433 100644 --- a/src/engine/SCons/Tool/JavaCommonTests.py +++ b/src/engine/SCons/Tool/JavaCommonTests.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py 5023 2010/06/14 22:05:46 scons" import os.path import sys @@ -569,7 +569,7 @@ if __name__ == "__main__": tclasses = [ parse_javaTestCase ] for tclass in tclasses: names = unittest.getTestCaseNames(tclass, 'test_') - suite.addTests(map(tclass, names)) + suite.addTests(list(map(tclass, names))) if not unittest.TextTestRunner().run(suite).wasSuccessful(): sys.exit(1) diff --git a/src/engine/SCons/Tool/MSCommon/__init__.py b/src/engine/SCons/Tool/MSCommon/__init__.py index a612d9b..6389078 100644 --- a/src/engine/SCons/Tool/MSCommon/__init__.py +++ b/src/engine/SCons/Tool/MSCommon/__init__.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 5023 2010/06/14 22:05:46 scons" __doc__ = """ Common functions for Microsoft Visual Studio and Visual C/C++. diff --git a/src/engine/SCons/Tool/MSCommon/arch.py b/src/engine/SCons/Tool/MSCommon/arch.py index 34de46c..ba6d2d6 100644 --- a/src/engine/SCons/Tool/MSCommon/arch.py +++ b/src/engine/SCons/Tool/MSCommon/arch.py @@ -21,14 +21,14 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py 5023 2010/06/14 22:05:46 scons" __doc__ = """Module to define supported Windows chip architectures. """ import os -class ArchDefinition: +class ArchDefinition(object): """ A class for defining architecture-specific settings and logic. """ diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 2303d2b..ef1aae9 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 5023 2010/06/14 22:05:46 scons" __doc__ = """ Common helper functions for working with the Microsoft tool chain. @@ -99,46 +99,78 @@ def has_reg(value): # Functions for fetching environment variable settings from batch files. -def normalize_env(env, keys): +def normalize_env(env, keys, force=False): """Given a dictionary representing a shell environment, add the variables from os.environ needed for the processing of .bat files; the keys are controlled by the keys argument. It also makes sure the environment values are correctly encoded. - Note: the environment is copied""" + If force=True, then all of the key values that exist are copied + into the returned dictionary. If force=false, values are only + copied if the key does not already exist in the copied dictionary. + + Note: the environment is copied.""" normenv = {} if env: for k in env.keys(): normenv[k] = copy.deepcopy(env[k]).encode('mbcs') for k in keys: - if os.environ.has_key(k): + if k in os.environ and (force or not k in normenv): normenv[k] = os.environ[k].encode('mbcs') return normenv def get_output(vcbat, args = None, env = None): """Parse the output of given bat file, with given args.""" + + if env is None: + # Create a blank environment, for use in launching the tools + env = SCons.Environment.Environment(tools=[]) + + # TODO: This is a hard-coded list of the variables that (may) need + # to be imported from os.environ[] for v[sc]*vars*.bat file + # execution to work. This list should really be either directly + # controlled by vc.py, or else derived from the common_tools_var + # settings in vs.py. + vars = [ + 'COMSPEC', + 'VS90COMNTOOLS', + 'VS80COMNTOOLS', + 'VS71COMNTOOLS', + 'VS70COMNTOOLS', + 'VS60COMNTOOLS', + ] + env['ENV'] = normalize_env(env['ENV'], vars, force=False) + if args: debug("Calling '%s %s'" % (vcbat, args)) - popen = subprocess.Popen('"%s" %s & set' % (vcbat, args), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env) + popen = SCons.Action._subproc(env, + '"%s" %s & set' % (vcbat, args), + stdin = 'devnull', + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) else: debug("Calling '%s'" % vcbat) - popen = subprocess.Popen('"%s" & set' % vcbat, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env) + popen = SCons.Action._subproc(env, + '"%s" & set' % vcbat, + stdin = 'devnull', + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) # Use the .stdout and .stderr attributes directly because the # .communicate() method uses the threading module on Windows # and won't work under Pythons not built with threading. stdout = popen.stdout.read() + stderr = popen.stderr.read() + if stderr: + # TODO: find something better to do with stderr; + # this at least prevents errors from getting swallowed. + import sys + sys.stderr.write(stderr) if popen.wait() != 0: - raise IOError(popen.stderr.read().decode("mbcs")) + raise IOError(stderr.decode("mbcs")) output = stdout.decode("mbcs") return output @@ -147,9 +179,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): # dkeep is a dict associating key: path_list, where key is one item from # keep, and pat_list the associated list of paths - # TODO(1.5): replace with the following list comprehension: - #dkeep = dict([(i, []) for i in keep]) - dkeep = dict(map(lambda i: (i, []), keep)) + dkeep = dict([(i, []) for i in keep]) # rdk will keep the regex to match the .bat file output line starts rdk = {} diff --git a/src/engine/SCons/Tool/MSCommon/netframework.py b/src/engine/SCons/Tool/MSCommon/netframework.py index bd123dc..30be811 100644 --- a/src/engine/SCons/Tool/MSCommon/netframework.py +++ b/src/engine/SCons/Tool/MSCommon/netframework.py @@ -19,16 +19,14 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py 5023 2010/06/14 22:05:46 scons" __doc__ = """ """ import os import re -import string from common import read_reg, debug @@ -58,14 +56,14 @@ def query_versions(): contents = os.listdir(froot) l = re.compile('v[0-9]+.*') - versions = filter(lambda e, l=l: l.match(e), contents) + versions = [e for e in contents if l.match(e)] def versrt(a,b): # since version numbers aren't really floats... aa = a[1:] bb = b[1:] - aal = string.split(aa, '.') - bbl = string.split(bb, '.') + aal = aa.split('.') + bbl = bb.split('.') # sequence comparison in python is lexicographical # which is exactly what we want. # Note we sort backwards so the highest version is first. diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py index 54be8ca..6debeb6 100644 --- a/src/engine/SCons/Tool/MSCommon/sdk.py +++ b/src/engine/SCons/Tool/MSCommon/sdk.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 5023 2010/06/14 22:05:46 scons" __doc__ = """Module to detect the Platform/Windows SDK @@ -58,7 +58,7 @@ _CURINSTALLED_SDK_HKEY_ROOT = \ r"Software\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder" -class SDKDefinition: +class SDKDefinition(object): """ An abstract base class for trying to find installed SDK directories. """ @@ -131,7 +131,7 @@ class WindowsSDK(SDKDefinition): """ HKEY_FMT = r'Software\Microsoft\Microsoft SDKs\Windows\v%s\InstallationFolder' def __init__(self, *args, **kw): - apply(SDKDefinition.__init__, (self,)+args, kw) + SDKDefinition.__init__(self, *args, **kw) self.hkey_data = self.version class PlatformSDK(SDKDefinition): @@ -140,7 +140,7 @@ class PlatformSDK(SDKDefinition): """ HKEY_FMT = r'Software\Microsoft\MicrosoftSDK\InstalledSDKS\%s\Install Dir' def __init__(self, *args, **kw): - apply(SDKDefinition.__init__, (self,)+args, kw) + SDKDefinition.__init__(self, *args, **kw) self.hkey_data = self.uuid # @@ -310,9 +310,9 @@ def get_cur_sdk_dir_from_reg(): return val def get_sdk_by_version(mssdk): - if not SupportedSDKMap.has_key(mssdk): + if mssdk not in SupportedSDKMap: msg = "SDK version %s is not supported" % repr(mssdk) - raise SCons.Errors.UserError, msg + raise SCons.Errors.UserError(msg) get_installed_sdks() return InstalledSDKMap.get(mssdk) @@ -328,22 +328,22 @@ def get_default_sdk(): def mssdk_setup_env(env): debug('sdk.py:mssdk_setup_env()') - if env.has_key('MSSDK_DIR'): + if 'MSSDK_DIR' in env: sdk_dir = env['MSSDK_DIR'] if sdk_dir is None: return sdk_dir = env.subst(sdk_dir) debug('sdk.py:mssdk_setup_env: Using MSSDK_DIR:%s'%sdk_dir) - elif env.has_key('MSSDK_VERSION'): + elif 'MSSDK_VERSION' in env: sdk_version = env['MSSDK_VERSION'] if sdk_version is None: msg = "SDK version %s is not installed" % repr(mssdk) - raise SCons.Errors.UserError, msg + raise SCons.Errors.UserError(msg) sdk_version = env.subst(sdk_version) mssdk = get_sdk_by_version(sdk_version) sdk_dir = mssdk.get_sdk_dir() debug('sdk.py:mssdk_setup_env: Using MSSDK_VERSION:%s'%sdk_dir) - elif env.has_key('MSVS_VERSION'): + elif 'MSVS_VERSION' in env: msvs_version = env['MSVS_VERSION'] debug('sdk.py:mssdk_setup_env:Getting MSVS_VERSION from env:%s'%msvs_version) if msvs_version is None: @@ -382,7 +382,7 @@ def mssdk_exists(version=None): sdks = get_installed_sdks() if version is None: return len(sdks) > 0 - return sdks.has_key(version) + return version in sdks # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 5ea5a53..f07f34c 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -30,15 +30,15 @@ # * test on 64 bits XP + VS 2005 (and VS 6 if possible) # * SDK # * Assembly -__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 5023 2010/06/14 22:05:46 scons" __doc__ = """Module for Visual C/C++ detection and configuration. """ import SCons.compat -import string import os import platform +from string import digits as string_digits import SCons.Warnings @@ -71,13 +71,16 @@ class BatchFileExecutionError(VisualCException): # Dict to 'canonalize' the arch _ARCH_TO_CANONICAL = { - "x86": "x86", - "amd64": "amd64", - "i386": "x86", - "emt64": "amd64", - "x86_64": "amd64", - "itanium": "ia64", - "ia64": "ia64", + "amd64" : "amd64", + "emt64" : "amd64", + "i386" : "x86", + "i486" : "x86", + "i586" : "x86", + "i686" : "x86", + "ia64" : "ia64", + "itanium" : "ia64", + "x86" : "x86", + "x86_64" : "amd64", } # Given a (host, target) tuple, return the argument for the bat file. Both host @@ -91,6 +94,8 @@ _HOST_TARGET_ARCH_TO_BAT_ARCH = { } def get_host_target(env): + debug('vc.py:get_host_target()') + host_platform = env.get('HOST_ARCH') if not host_platform: host_platform = platform.machine() @@ -99,22 +104,29 @@ def get_host_target(env): # PROCESSOR_ARCHITECTURE. if not host_platform: host_platform = os.environ.get('PROCESSOR_ARCHITECTURE', '') - target_platform = env.get('TARGET_ARCH') - if not target_platform: + + # Retain user requested TARGET_ARCH + req_target_platform = env.get('TARGET_ARCH') + debug('vc.py:get_host_target() req_target_platform:%s'%req_target_platform) + + if req_target_platform: + # If user requested a specific platform then only try that one. + target_platform = req_target_platform + else: target_platform = host_platform - + try: - host = _ARCH_TO_CANONICAL[host_platform] + host = _ARCH_TO_CANONICAL[host_platform.lower()] except KeyError, e: msg = "Unrecognized host architecture %s" raise ValueError(msg % repr(host_platform)) try: - target = _ARCH_TO_CANONICAL[target_platform] + target = _ARCH_TO_CANONICAL[target_platform.lower()] except KeyError, e: raise ValueError("Unrecognized target architecture %s" % target_platform) - return (host, target) + return (host, target,req_target_platform) _VCVER = ["10.0", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"] @@ -136,17 +148,19 @@ _VCVER_TO_PRODUCT_DIR = { '6.0': [ r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir'] } - + def msvc_version_to_maj_min(msvc_version): - t = msvc_version.split(".") - if not len(t) == 2: - raise ValueError("Unrecognized version %s" % msvc_version) - try: - maj = int(t[0]) - min = int(t[1]) - return maj, min - except ValueError, e: - raise ValueError("Unrecognized version %s" % msvc_version) + msvc_version_numeric = ''.join([x for x in msvc_version if x in string_digits + '.']) + + t = msvc_version_numeric.split(".") + if not len(t) == 2: + raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric)) + try: + maj = int(t[0]) + min = int(t[1]) + return maj, min + except ValueError, e: + raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric)) def is_host_target_supported(host_target, msvc_version): """Return True if the given (host, target) tuple is supported given the @@ -206,7 +220,7 @@ def find_vc_pdir(msvc_version): raise MissingConfiguration("registry dir %s not found on the filesystem" % comps) return None -def find_batch_file(env,msvc_version): +def find_batch_file(env,msvc_version,host_arch,target_arch): """ Find the location of the batch script which should set up the compiler for any TARGET_ARCH whose compilers were installed by Visual Studio/VCExpress @@ -218,7 +232,7 @@ def find_batch_file(env,msvc_version): debug('vc.py: find_batch_file() pdir:%s'%pdir) # filter out e.g. "Exp" from the version name - msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') + msvc_ver_numeric = ''.join([x for x in msvc_version if x in string_digits + "."]) vernum = float(msvc_ver_numeric) if 7 <= vernum < 8: pdir = os.path.join(pdir, os.pardir, "Common7", "Tools") @@ -234,7 +248,6 @@ def find_batch_file(env,msvc_version): batfilename = None installed_sdks=get_installed_sdks() - (host_arch,target_arch)=get_host_target(env) for _sdk in installed_sdks: sdk_bat_file=_sdk.get_sdk_vc_script(host_arch,target_arch) sdk_bat_file_path=os.path.join(pdir,sdk_bat_file) @@ -330,6 +343,73 @@ def msvc_setup_env_once(env): msvc_setup_env(env) env["MSVC_SETUP_RUN"] = True +def msvc_find_valid_batch_script(env,version): + debug('vc.py:msvc_find_valid_batch_script()') + # Find the host platform, target platform, and if present the requested + # target platform + (host_platform, target_platform,req_target_platform) = get_host_target(env) + + # If the user hasn't specifically requested a TARGET_ARCH, and + # The TARGET_ARCH is amd64 then also try 32 bits if there are no viable + # 64 bit tools installed + try_target_archs = [target_platform] + if not req_target_platform and target_platform=='amd64': + try_target_archs.append('x86') + + d = None + for tp in try_target_archs: + # Set to current arch. + env['TARGET_ARCH']=tp + + debug("vc.py:msvc_find_valid_batch_script() trying target_platform:%s"%tp) + host_target = (host_platform, tp) + if not is_host_target_supported(host_target, version): + warn_msg = "host, target = %s not supported for MSVC version %s" % \ + (host_target, version) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[host_target] + + # Try to locate a batch file for this host/target platform combo + try: + (vc_script,sdk_script) = find_batch_file(env,version,host_platform,tp) + debug('vc.py:msvc_find_valid_batch_script() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) + except VisualCException, e: + msg = str(e) + debug('Caught exception while looking for batch file (%s)' % msg) + warn_msg = "VC version %s not installed. " + \ + "C/C++ compilers are most likely not set correctly.\n" + \ + " Installed versions are: %s" + warn_msg = warn_msg % (version, cached_get_installed_vcs()) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) + continue + + # Try to use the located batch file for this host/target platform combo + debug('vc.py:msvc_find_valid_batch_script() use_script 2 %s, args:%s\n' % (repr(vc_script), arg)) + if vc_script: + try: + d = script_env(vc_script, args=arg) + except BatchFileExecutionError, e: + debug('vc.py:msvc_find_valid_batch_script() use_script 3: failed running VC script %s: %s: Error:%s'%(repr(vc_script),arg,e)) + vc_script=None + if not vc_script and sdk_script: + debug('vc.py:msvc_find_valid_batch_script() use_script 4: trying sdk script: %s'%(sdk_script)) + try: + d = script_env(sdk_script,args=[]) + except BatchFileExecutionError,e: + debug('vc.py:msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e)) + continue + elif not vc_script and not sdk_script: + debug('vc.py:msvc_find_valid_batch_script() use_script 6: Neither VC script nor SDK script found') + continue + + # If we cannot find a viable installed compiler, reset the TARGET_ARCH + # To it's initial value + if not d: + env['TARGET_ARCH']=req_target_platform + + return d + + def msvc_setup_env(env): debug('msvc_setup_env()') @@ -347,50 +427,16 @@ def msvc_setup_env(env): env['MSVS_VERSION'] = version env['MSVS'] = {} - try: - (vc_script,sdk_script) = find_batch_file(env,version) - debug('vc.py:msvc_setup_env() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) - except VisualCException, e: - msg = str(e) - debug('Caught exception while looking for batch file (%s)' % msg) - warn_msg = "VC version %s not installed. " + \ - "C/C++ compilers are most likely not set correctly.\n" + \ - " Installed versions are: %s" - warn_msg = warn_msg % (version, cached_get_installed_vcs()) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) - return None - debug('vc.py:msvc_setup_env() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) use_script = env.get('MSVC_USE_SCRIPT', True) if SCons.Util.is_String(use_script): - debug('use_script 1 %s\n' % repr(use_script)) + debug('vc.py:msvc_setup_env() use_script 1 %s\n' % repr(use_script)) d = script_env(use_script) - elif use_script: - host_platform, target_platform = get_host_target(env) - host_target = (host_platform, target_platform) - if not is_host_target_supported(host_target, version): - warn_msg = "host, target = %s not supported for MSVC version %s" % \ - (host_target, version) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) - arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[host_target] - debug('use_script 2 %s, args:%s\n' % (repr(vc_script), arg)) - if vc_script: - try: - d = script_env(vc_script, args=arg) - except BatchFileExecutionError, e: - debug('use_script 3: failed running VC script %s: %s: Error:%s'%(repr(vc_script),arg,e)) - vc_script=None - if not vc_script and sdk_script: - debug('use_script 4: trying sdk script: %s'%(sdk_script)) - try: - d = script_env(sdk_script,args=[]) - except BatchFileExecutionError,e: - debug('use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e)) - return None - elif not vc_script and not sdk_script: - debug('use_script 6: Neither VC script nor SDK script found') - return None - + elif use_script: + d = msvc_find_valid_batch_script(env,version) + debug('vc.py:msvc_setup_env() use_script 2 %s\n' % d) + if not d: + return d else: debug('MSVC_USE_SCRIPT set to False') warn_msg = "MSVC_USE_SCRIPT set to False, assuming environment " \ diff --git a/src/engine/SCons/Tool/MSCommon/vc.py.bak b/src/engine/SCons/Tool/MSCommon/vc.py.bak deleted file mode 100644 index 1bdd298..0000000 --- a/src/engine/SCons/Tool/MSCommon/vc.py.bak +++ /dev/null @@ -1,394 +0,0 @@ -# -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py.bak 4720 2010/03/24 03:14:11 jars" - -__doc__ = """Module for Visual C/C++ detection and configuration. -""" - -import os -import platform - -import SCons.Warnings - -import common - -debug = common.debug - -class VisualC: - """ - An base class for finding installed versions of Visual C/C++. - """ - def __init__(self, version, **kw): - self.version = version - self.__dict__.update(kw) - self._cache = {} - - def vcbin_arch(self): - if common.is_win64(): - result = { - 'x86_64' : ['amd64', r'BIN\x86_amd64'], - 'ia64' : [r'BIN\ia64'], - }.get(target_arch, []) - else: - result = { - 'x86_64' : ['x86_amd64'], - 'ia64' : ['x86_ia64'], - }.get(target_arch, []) - # TODO(1.5) - #return ';'.join(result) - return string.join(result, ';') - - # Support for searching for an appropriate .bat file. - # The map is indexed by (target_architecture, host_architecture). - # Entries where the host_architecture is None specify the - # cross-platform "default" .bat file if there isn't sn entry - # specific to the current host architecture. - - batch_file_map = { - ('x86_64', 'x86_64') : [ - r'bin\amd64\vcvarsamd64.bat', - r'bin\x86_amd64\vcvarsx86_amd64.bat', - r'bin\vcvarsx86_amd64.bat', - ], - ('x86_64', 'x86') : [ - r'bin\x86_amd64\vcvarsx86_amd64.bat', - ], - ('ia64', 'ia64') : [ - r'bin\ia64\vcvarsia64.bat', - r'bin\x86_ia64\vcvarsx86_ia64.bat', - ], - ('ia64', None) : [ - r'bin\x86_ia64\vcvarsx86_ia64.bat', - ], - ('x86', None) : [ - r'bin\vcvars32.bat', - ], - } - - def find_batch_file(self, target_architecture, host_architecture): - key = (target_architecture, host_architecture) - potential_batch_files = self.batch_file_map.get(key) - if not potential_batch_files: - key = (target_architecture, None) - potential_batch_files = self.batch_file_map.get(key) - if potential_batch_files: - product_dir = self.get_vc_dir() - for batch_file in potential_batch_files: - bf = os.path.join(product_dir, batch_file) - if os.path.isfile(bf): - return bf - return None - - def find_vc_dir(self): - root = 'Software\\' - if common.is_win64(): - root = root + 'Wow6432Node\\' - for key in self.hkeys: - key = root + key - try: - comps = common.read_reg(key) - except WindowsError, e: - debug('find_vc_dir(): no VC registry key %s' % repr(key)) - else: - debug('find_vc_dir(): found VC in registry: %s' % comps) - if os.path.exists(comps): - return comps - else: - debug('find_vc_dir(): reg says dir is %s, but it does not exist. (ignoring)'\ - % comps) - return None - return None - - # - - def get_batch_file(self, target_architecture, host_architecture): - try: - return self._cache['batch_file'] - except KeyError: - batch_file = self.find_batch_file(target_architecture, host_architecture) - self._cache['batch_file'] = batch_file - return batch_file - - def get_vc_dir(self): - try: - return self._cache['vc_dir'] - except KeyError: - vc_dir = self.find_vc_dir() - self._cache['vc_dir'] = vc_dir - return vc_dir - - def reset(self): - self._cache={} - - -# The list of supported Visual C/C++ versions we know how to detect. -# -# The first VC found in the list is the one used by default if there -# are multiple VC installed. Barring good reasons to the contrary, -# this means we should list VC with from most recent to oldest. -# -# If you update this list, update the documentation in Tool/vc.xml. -SupportedVCList = [ - VisualC('9.0', - hkeys=[ - r'Microsoft\VisualStudio\9.0\Setup\VC\ProductDir', - r'Microsoft\VCExpress\9.0\Setup\VC\ProductDir', - ], - default_install=r'Microsoft Visual Studio 9.0\VC', - common_tools_var='VS90COMNTOOLS', - vc_subdir=r'\VC', - batch_file_base='vcvars', - supported_arch=['x86', 'x86_64', 'ia64'], - atlmc_include_subdir = [r'ATLMFC\INCLUDE'], - atlmfc_lib_subdir = { - 'x86' : r'ATLMFC\LIB', - 'x86_64' : r'ATLMFC\LIB\amd64', - 'ia64' : r'ATLMFC\LIB\ia64', - }, - crt_lib_subdir = { - 'x86_64' : r'LIB\amd64', - 'ia64' : r'LIB\ia64', - }, - ), - VisualC('8.0', - hkeys=[ - r'Microsoft\VisualStudio\8.0\Setup\VC\ProductDir', - r'Microsoft\VCExpress\8.0\Setup\VC\ProductDir', - ], - default_install=r'%s\Microsoft Visual Studio 8\VC', - common_tools_var='VS80COMNTOOLS', - vc_subdir=r'\VC', - batch_file_base='vcvars', - supported_arch=['x86', 'x86_64', 'ia64'], - atlmc_include_subdir = [r'ATLMFC\INCLUDE'], - atlmfc_lib_subdir = { - 'x86' : r'ATLMFC\LIB', - 'x86_64' : r'ATLMFC\LIB\amd64', - 'ia64' : r'ATLMFC\LIB\ia64', - }, - crt_lib_subdir = { - 'x86_64' : r'LIB\amd64', - 'ia64' : r'LIB\ia64', - }, - ), - VisualC('7.1', - hkeys=[ - r'Microsoft\VisualStudio\7.1\Setup\VC\ProductDir', - ], - default_install=r'%s\Microsoft Visual Studio 7.1.NET 2003\VC7', - common_tools_var='VS71COMNTOOLS', - vc_subdir=r'\VC7', - batch_file_base='vcvars', - supported_arch=['x86'], - atlmc_include_subdir = [r'ATLMFC\INCLUDE'], - atlmfc_lib_subdir = { - 'x86' : r'ATLMFC\LIB', - }, - ), - VisualC('7.0', - hkeys=[ - r'Microsoft\VisualStudio\7.0\Setup\VC\ProductDir', - ], - default_install=r'%s\Microsoft Visual Studio .NET\VC7', - common_tools_var='VS70COMNTOOLS', - vc_subdir=r'\VC7', - batch_file_base='vcvars', - supported_arch=['x86'], - atlmc_include_subdir = [r'ATLMFC\INCLUDE'], - atlmfc_lib_subdir = { - 'x86' : r'ATLMFC\LIB', - }, - ), - VisualC('6.0', - hkeys=[ - r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir', - ], - default_install=r'%s\Microsoft Visual Studio\VC98', - common_tools_var='VS60COMNTOOLS', - vc_subdir=r'\VC98', - batch_file_base='vcvars', - supported_arch=['x86'], - atlmc_include_subdir = [r'ATL\INCLUDE', r'MFC\INCLUDE'], - atlmfc_lib_subdir = { - 'x86' : r'MFC\LIB', - }, - ), -] - -SupportedVCMap = {} -for vc in SupportedVCList: - SupportedVCMap[vc.version] = vc - - -# Finding installed versions of Visual C/C++ isn't cheap, because it goes -# not only to the registry but also to the disk to sanity-check that there -# is, in fact, something installed there and that the registry entry isn't -# just stale. Find this information once, when requested, and cache it. - -InstalledVCList = None -InstalledVCMap = None - -def get_installed_vcs(): - global InstalledVCList - global InstalledVCMap - if InstalledVCList is None: - InstalledVCList = [] - InstalledVCMap = {} - for vc in SupportedVCList: - debug('trying to find VC %s' % vc.version) - if vc.get_vc_dir(): - debug('found VC %s' % vc.version) - InstalledVCList.append(vc) - InstalledVCMap[vc.version] = vc - return InstalledVCList - - -def set_vc_by_version(env, msvc): - if not SupportedVCMap.has_key(msvc): - msg = "VC version %s is not supported" % repr(msvc) - raise SCons.Errors.UserError, msg - get_installed_vcs() - vc = InstalledVCMap.get(msvc) - if not vc: - msg = "VC version %s is not installed" % repr(msvc) - raise SCons.Errors.UserError, msg - set_vc_by_directory(env, vc.get_vc_dir()) - -# New stuff - -def script_env(script, args=None): - stdout = common.get_output(script, args) - return common.parse_output(stdout) - -def get_default_version(env): - debug('get_default_version()') - - msvc_version = env.get('MSVC_VERSION') - if not msvc_version: - installed_vcs = get_installed_vcs() - debug('InstalledVCMap:%s'%InstalledVCMap) - if not installed_vcs: - msg = 'No installed VCs' - debug('msv %s\n' % repr(msg)) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) - return None - msvc = installed_vcs[0] - msvc_version = msvc.version - debug('msvc_setup_env: using default installed MSVC version %s\n' % repr(msvc_version)) - - return msvc_version - -# Dict to 'canonalize' the arch -_ARCH_TO_CANONICAL = { - "x86": "x86", - "amd64": "amd64", - "i386": "x86", - "emt64": "amd64", - "x86_64": "amd64" -} - -# Given a (host, target) tuple, return the argument for the bat file. Both host -# and targets should be canonalized. -_HOST_TARGET_ARCH_TO_BAT_ARCH = { - ("x86", "x86"): "x86", - ("x86", "amd64"): "x86_amd64", - ("amd64", "amd64"): "amd64", - ("amd64", "x86"): "x86" -} - -def get_host_target(env): - host_platform = env.get('HOST_ARCH') - if not host_platform: - #host_platform = get_default_host_platform() - host_platform = platform.machine() - target_platform = env.get('TARGET_ARCH') - if not target_platform: - target_platform = host_platform - - return (_ARCH_TO_CANONICAL[host_platform], - _ARCH_TO_CANONICAL[target_platform]) - -def msvc_setup_env_once(env): - try: - has_run = env["MSVC_SETUP_RUN"] - except KeyError: - has_run = False - - if not has_run: - msvc_setup_env(env) - env["MSVC_SETUP_RUN"] = False - -def msvc_setup_env(env): - debug('msvc_setup_env()') - - version = get_default_version(env) - host_platform, target_platform = get_host_target(env) - debug('msvc_setup_env: using specified MSVC version %s\n' % repr(version)) - env['MSVC_VERSION'] = version - - msvc = InstalledVCMap.get(version) - if not msvc: - msg = 'VC version %s not installed' % version - debug('msv %s\n' % repr(msg)) - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, msg) - return None - - use_script = env.get('MSVC_USE_SCRIPT', True) - if SCons.Util.is_String(use_script): - debug('use_script 1 %s\n' % repr(use_script)) - d = script_env(use_script) - elif use_script: - # XXX: this is VS 2008 specific, fix this - script = os.path.join(msvc.find_vc_dir(), "vcvarsall.bat") - - arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[(host_platform, target_platform)] - debug('use_script 2 %s, args:%s\n' % (repr(script), arg)) - d = script_env(script, args=arg) - else: - debug('msvc.get_default_env()\n') - d = msvc.get_default_env() - - for k, v in d.items(): - env.PrependENVPath(k, v, delete_existing=True) - -def msvc_exists(version=None): - vcs = get_installed_vcs() - if version is None: - return len(vcs) > 0 - return InstalledVCMap.has_key(version) - - -def reset_installed_vcs(): - global InstalledVCList - global InstalledVCMap - InstalledVCList = None - InstalledVCMap = None - for vc in SupportedVCList: - vc.reset() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index e634a18..06030e2 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 5023 2010/06/14 22:05:46 scons" __doc__ = """Module to detect Visual Studio and/or Visual C/C++ """ @@ -40,7 +40,7 @@ from common import debug, \ import SCons.Tool.MSCommon.vc -class VisualStudio: +class VisualStudio(object): """ An abstract base class for trying to find installed versions of Visual Studio. @@ -385,9 +385,9 @@ def get_vs_by_version(msvs): global SupportedVSMap debug('vs.py:get_vs_by_version()') - if not SupportedVSMap.has_key(msvs): + if msvs not in SupportedVSMap: msg = "Visual Studio version %s is not supported" % repr(msvs) - raise SCons.Errors.UserError, msg + raise SCons.Errors.UserError(msg) get_installed_visual_studios() vs = InstalledVSMap.get(msvs) debug('InstalledVSMap:%s'%InstalledVSMap) @@ -415,15 +415,13 @@ def get_default_version(env): version: str the default version. """ - if not env.has_key('MSVS') or not SCons.Util.is_Dict(env['MSVS']): - # TODO(1.5): - #versions = [vs.version for vs in get_installed_visual_studios()] - versions = map(lambda vs: vs.version, get_installed_visual_studios()) + if 'MSVS' not in env or not SCons.Util.is_Dict(env['MSVS']): + versions = [vs.version for vs in get_installed_visual_studios()] env['MSVS'] = {'VERSIONS' : versions} else: versions = env['MSVS'].get('VERSIONS', []) - if not env.has_key('MSVS_VERSION'): + if 'MSVS_VERSION' not in env: if versions: env['MSVS_VERSION'] = versions[0] #use highest version by default else: @@ -451,7 +449,7 @@ def get_default_arch(env): arch = 'x86' elif not arch in msvs.get_supported_arch(): fmt = "Visual Studio version %s does not support architecture %s" - raise SCons.Errors.UserError, fmt % (env['MSVS_VERSION'], arch) + raise SCons.Errors.UserError(fmt % (env['MSVS_VERSION'], arch)) return arch @@ -473,11 +471,15 @@ def msvs_setup_env(env): vars = ('LIB', 'LIBPATH', 'PATH', 'INCLUDE') msvs_list = get_installed_visual_studios() - # TODO(1.5): - #vscommonvarnames = [ vs.common_tools_var for vs in msvs_list ] - vscommonvarnames = map(lambda vs: vs.common_tools_var, msvs_list) - nenv = normalize_env(env['ENV'], vscommonvarnames + ['COMSPEC']) - output = get_output(batfilename, arch, env=nenv) + vscommonvarnames = [vs.common_tools_var for vs in msvs_list] + save_ENV = env['ENV'] + nenv = normalize_env(env['ENV'], + ['COMSPEC'] + vscommonvarnames, + force=True) + try: + output = get_output(batfilename, arch, env=nenv) + finally: + env['ENV'] = save_ENV vars = parse_output(output, vars) for k, v in vars.items(): @@ -487,9 +489,7 @@ def query_versions(): """Query the system to get available versions of VS. A version is considered when a batfile is found.""" msvs_list = get_installed_visual_studios() - # TODO(1.5) - #versions = [ msvs.version for msvs in msvs_list ] - versions = map(lambda msvs: msvs.version, msvs_list) + versions = [msvs.version for msvs in msvs_list] return versions # Local Variables: diff --git a/src/engine/SCons/Tool/Perforce.py b/src/engine/SCons/Tool/Perforce.py index 08da75b..43d9f6e 100644 --- a/src/engine/SCons/Tool/Perforce.py +++ b/src/engine/SCons/Tool/Perforce.py @@ -8,7 +8,6 @@ selection method. """ -# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -29,9 +28,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/Perforce.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/Perforce.py 5023 2010/06/14 22:05:46 scons" import os @@ -44,7 +42,6 @@ import SCons.Util from SCons.Tool.PharLapCommon import addPathIfNotExists - # Variables that we want to import from the base OS environment. _import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD', 'P4CHARSET', 'P4LANGUAGE', 'SystemRoot' ] @@ -57,6 +54,8 @@ def generate(env): def PerforceFactory(env=env): """ """ + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The Perforce() factory is deprecated and there is no replacement.""") return SCons.Builder.Builder(action = PerforceAction, env = env) #setattr(env, 'Perforce', PerforceFactory) diff --git a/src/engine/SCons/Tool/PharLapCommon.py b/src/engine/SCons/Tool/PharLapCommon.py index 2cfb02a..64dd02f 100644 --- a/src/engine/SCons/Tool/PharLapCommon.py +++ b/src/engine/SCons/Tool/PharLapCommon.py @@ -29,14 +29,13 @@ Phar Lap ETS tool chain. Right now, this is linkloc and # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/PharLapCommon.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/PharLapCommon.py 5023 2010/06/14 22:05:46 scons" import os import os.path import SCons.Errors import SCons.Util import re -import string def getPharLapPath(): """Reads the registry to find the installed path of the Phar Lap ETS @@ -46,7 +45,7 @@ def getPharLapPath(): be found.""" if not SCons.Util.can_read_reg: - raise SCons.Errors.InternalError, "No Windows registry module was found" + raise SCons.Errors.InternalError("No Windows registry module was found") try: k=SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Pharlap\\ETS') @@ -62,7 +61,7 @@ def getPharLapPath(): return os.path.normpath(val) except SCons.Util.RegError: - raise SCons.Errors.UserError, "Cannot find Phar Lap ETS path in the registry. Is it installed properly?" + raise SCons.Errors.UserError("Cannot find Phar Lap ETS path in the registry. Is it installed properly?") REGEX_ETS_VER = re.compile(r'#define\s+ETS_VER\s+([0-9]+)') @@ -79,7 +78,7 @@ def getPharLapVersion(): include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h")) if not os.path.exists(include_path): - raise SCons.Errors.UserError, "Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?" + raise SCons.Errors.UserError("Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?") mo = REGEX_ETS_VER.search(open(include_path, 'r').read()) if mo: return int(mo.group(1)) @@ -97,14 +96,14 @@ def addPathIfNotExists(env_dict, key, path, sep=os.pathsep): is_list = 1 paths = env_dict[key] if not SCons.Util.is_List(env_dict[key]): - paths = string.split(paths, sep) + paths = paths.split(sep) is_list = 0 - if not os.path.normcase(path) in map(os.path.normcase, paths): + if os.path.normcase(path) not in list(map(os.path.normcase, paths)): paths = [ path ] + paths if is_list: env_dict[key] = paths else: - env_dict[key] = string.join(paths, sep) + env_dict[key] = sep.join(paths) except KeyError: env_dict[key] = path diff --git a/src/engine/SCons/Tool/PharLapCommonTests.py b/src/engine/SCons/Tool/PharLapCommonTests.py index bde9835..70b7e69 100644 --- a/src/engine/SCons/Tool/PharLapCommonTests.py +++ b/src/engine/SCons/Tool/PharLapCommonTests.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/PharLapCommonTests.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/PharLapCommonTests.py 5023 2010/06/14 22:05:46 scons" import unittest import os.path diff --git a/src/engine/SCons/Tool/RCS.py b/src/engine/SCons/Tool/RCS.py index 4d14af7..5c5a6bd 100644 --- a/src/engine/SCons/Tool/RCS.py +++ b/src/engine/SCons/Tool/RCS.py @@ -8,7 +8,6 @@ selection method. """ -# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -29,9 +28,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/RCS.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/RCS.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder @@ -43,6 +41,8 @@ def generate(env): def RCSFactory(env=env): """ """ + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The RCS() factory is deprecated and there is no replacement.""") act = SCons.Action.Action('$RCS_COCOM', '$RCS_COCOMSTR') return SCons.Builder.Builder(action = act, env = env) diff --git a/src/engine/SCons/Tool/SCCS.py b/src/engine/SCons/Tool/SCCS.py index 2893291..2983b83 100644 --- a/src/engine/SCons/Tool/SCCS.py +++ b/src/engine/SCons/Tool/SCCS.py @@ -8,7 +8,6 @@ selection method. """ -# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -29,9 +28,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/SCCS.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/SCCS.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder @@ -43,6 +41,8 @@ def generate(env): def SCCSFactory(env=env): """ """ + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The SCCS() factory is deprecated and there is no replacement.""") act = SCons.Action.Action('$SCCSCOM', '$SCCSCOMSTR') return SCons.Builder.Builder(action = act, env = env) diff --git a/src/engine/SCons/Tool/Subversion.py b/src/engine/SCons/Tool/Subversion.py index 51a670a..26ff700 100644 --- a/src/engine/SCons/Tool/Subversion.py +++ b/src/engine/SCons/Tool/Subversion.py @@ -8,7 +8,6 @@ selection method. """ -# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -29,9 +28,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/Subversion.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/Subversion.py 5023 2010/06/14 22:05:46 scons" import os.path @@ -46,6 +44,8 @@ def generate(env): def SubversionFactory(repos, module='', env=env): """ """ # fail if repos is not an absolute path name? + import SCons.Warnings as W + W.warn(W.DeprecatedSourceCodeWarning, """The Subversion() factory is deprecated and there is no replacement.""") if module != '': module = os.path.join(module, '') act = SCons.Action.Action('$SVNCOM', '$SVNCOMSTR') diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py index f2a0964..ea9b475 100644 --- a/src/engine/SCons/Tool/ToolTests.py +++ b/src/engine/SCons/Tool/ToolTests.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ToolTests.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ToolTests.py 5023 2010/06/14 22:05:46 scons" import sys import unittest @@ -32,7 +32,7 @@ import SCons.Tool class ToolTestCase(unittest.TestCase): def test_Tool(self): """Test the Tool() function""" - class Environment: + class Environment(object): def __init__(self): self.dict = {} def Detect(self, progs): @@ -45,8 +45,10 @@ class ToolTestCase(unittest.TestCase): return self.dict[key] def __setitem__(self, key, val): self.dict[key] = val + def __contains__(self, key): + return self.dict.__contains__(key) def has_key(self, key): - return self.dict.has_key(key) + return key in self.dict env = Environment() env['BUILDERS'] = {} env['ENV'] = {} diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 4a41a8c..e38d85f 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -34,9 +34,8 @@ tool definition. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/__init__.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/__init__.py 5023 2010/06/14 22:05:46 scons" import imp import sys @@ -85,7 +84,7 @@ for suffix in LaTeXSuffixes: SourceFileScanner.add_scanner(suffix, LaTeXScanner) SourceFileScanner.add_scanner(suffix, PDFLaTeXScanner) -class Tool: +class Tool(object): def __init__(self, name, toolpath=[], **kw): self.name = name self.toolpath = toolpath + DefaultToolpath @@ -113,7 +112,7 @@ class Tool: file.close() except ImportError, e: if str(e)!="No module named %s"%self.name: - raise SCons.Errors.EnvironmentError, e + raise SCons.Errors.EnvironmentError(e) try: import zipimport except ImportError: @@ -143,7 +142,7 @@ class Tool: return module except ImportError, e: if str(e)!="No module named %s"%self.name: - raise SCons.Errors.EnvironmentError, e + raise SCons.Errors.EnvironmentError(e) try: import zipimport importer = zipimport.zipimporter( sys.modules['SCons.Tool'].__path__[0] ) @@ -152,10 +151,10 @@ class Tool: return module except ImportError, e: m = "No tool named '%s': %s" % (self.name, e) - raise SCons.Errors.EnvironmentError, m + raise SCons.Errors.EnvironmentError(m) except ImportError, e: m = "No tool named '%s': %s" % (self.name, e) - raise SCons.Errors.EnvironmentError, m + raise SCons.Errors.EnvironmentError(m) def __call__(self, env, *args, **kw): if self.init_kw is not None: @@ -170,7 +169,7 @@ class Tool: env.Append(TOOLS = [ self.name ]) if hasattr(self, 'options'): import SCons.Variables - if not env.has_key('options'): + if 'options' not in env: from SCons.Script import ARGUMENTS env['options']=SCons.Variables.Variables(args=ARGUMENTS) opts=env['options'] @@ -178,7 +177,7 @@ class Tool: self.options(opts) opts.Update(env) - apply(self.generate, ( env, ) + args, kw) + self.generate(env, *args, **kw) def __str__(self): return self.name @@ -428,7 +427,7 @@ def CreateJavaFileBuilder(env): env['JAVASUFFIX'] = '.java' return java_file -class ToolInitializerMethod: +class ToolInitializerMethod(object): """ This is added to a construction environment in place of a method(s) normally called for a Builder (env.Object, env.StaticObject, @@ -474,9 +473,9 @@ class ToolInitializerMethod: builder = self.get_builder(env) if builder is None: return [], [] - return apply(builder, args, kw) + return builder(*args, **kw) -class ToolInitializer: +class ToolInitializer(object): """ A class for delayed initialization of Tools modules. @@ -530,9 +529,9 @@ class ToolInitializer: def Initializers(env): ToolInitializer(env, ['install'], ['_InternalInstall', '_InternalInstallAs']) def Install(self, *args, **kw): - return apply(self._InternalInstall, args, kw) + return self._InternalInstall(*args, **kw) def InstallAs(self, *args, **kw): - return apply(self._InternalInstallAs, args, kw) + return self._InternalInstallAs(*args, **kw) env.AddMethod(Install) env.AddMethod(InstallAs) @@ -546,7 +545,7 @@ def FindTool(tools, env): def FindAllTools(tools, env): def ToolExists(tool, env=env): return Tool(tool).exists(env) - return filter (ToolExists, tools) + return list(filter (ToolExists, tools)) def tool_list(platform, env): @@ -646,27 +645,34 @@ def tool_list(platform, env): fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0] ar = FindTool(ars, env) or ars[0] - other_tools = FindAllTools(['BitKeeper', 'CVS', - 'dmd', - 'filesystem', - 'dvipdf', 'dvips', 'gs', - 'jar', 'javac', 'javah', - 'latex', 'lex', - 'm4', #'midl', 'msvs', - 'pdflatex', 'pdftex', 'Perforce', - 'RCS', 'rmic', 'rpcgen', - 'SCCS', - # 'Subversion', - 'swig', - 'tar', 'tex', - 'yacc', 'zip', 'rpm', 'wix']+other_plat_tools, - env) + other_tools = FindAllTools(other_plat_tools + [ + 'dmd', + #TODO: merge 'install' into 'filesystem' and + # make 'filesystem' the default + 'filesystem', + 'm4', + 'wix', #'midl', 'msvs', + # Parser generators + 'lex', 'yacc', + # Foreign function interface + 'rpcgen', 'swig', + # Java + 'jar', 'javac', 'javah', 'rmic', + # TeX + 'dvipdf', 'dvips', 'gs', + 'tex', 'latex', 'pdflatex', 'pdftex', + # Archivers + 'tar', 'zip', 'rpm', + # SourceCode factories + 'BitKeeper', 'CVS', 'Perforce', + 'RCS', 'SCCS', # 'Subversion', + ], env) tools = ([linker, c_compiler, cxx_compiler, fortran_compiler, assembler, ar] + other_tools) - return filter(lambda x: x, tools) + return [x for x in tools if x] # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/__init__.xml b/src/engine/SCons/Tool/__init__.xml index 093ca0c..a8a8507 100644 --- a/src/engine/SCons/Tool/__init__.xml +++ b/src/engine/SCons/Tool/__init__.xml @@ -209,7 +209,7 @@ according to the suffix mappings in the SourceFileScanner object. See the section "Scanner Objects," -below, for a more information. +below, for more information. @@ -305,7 +305,7 @@ according to the suffix mappings in SourceFileScanner object. See the section "Scanner Objects," -below, for a more information. +below, for more information. diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py index 035ece4..62c5ef7 100644 --- a/src/engine/SCons/Tool/aixc++.py +++ b/src/engine/SCons/Tool/aixc++.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/aixc++.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/aixc++.py 5023 2010/06/14 22:05:46 scons" import os.path diff --git a/src/engine/SCons/Tool/aixcc.py b/src/engine/SCons/Tool/aixcc.py index 1c6ae14..bf1de34 100644 --- a/src/engine/SCons/Tool/aixcc.py +++ b/src/engine/SCons/Tool/aixcc.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/aixcc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/aixcc.py 5023 2010/06/14 22:05:46 scons" import os.path diff --git a/src/engine/SCons/Tool/aixf77.py b/src/engine/SCons/Tool/aixf77.py index a5a9d8c..f680247 100644 --- a/src/engine/SCons/Tool/aixf77.py +++ b/src/engine/SCons/Tool/aixf77.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/aixf77.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/aixf77.py 5023 2010/06/14 22:05:46 scons" import os.path diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index 0e1b974..9531a4b 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/aixlink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/aixlink.py 5023 2010/06/14 22:05:46 scons" import os import os.path diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py index a56462d..4b3ae77 100644 --- a/src/engine/SCons/Tool/applelink.py +++ b/src/engine/SCons/Tool/applelink.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/applelink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/applelink.py 5023 2010/06/14 22:05:46 scons" import SCons.Util diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index b0ae76b..68effb1 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ar.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ar.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/as.py b/src/engine/SCons/Tool/as.py index bdd00db..f18ff57 100644 --- a/src/engine/SCons/Tool/as.py +++ b/src/engine/SCons/Tool/as.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/as.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/as.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/bcc32.py b/src/engine/SCons/Tool/bcc32.py index 67325d0..b7c7bf2 100644 --- a/src/engine/SCons/Tool/bcc32.py +++ b/src/engine/SCons/Tool/bcc32.py @@ -27,11 +27,10 @@ XXX # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/bcc32.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/bcc32.py 5023 2010/06/14 22:05:46 scons" import os import os.path -import string import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py index d74cd96..907324d 100644 --- a/src/engine/SCons/Tool/c++.py +++ b/src/engine/SCons/Tool/c++.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/c++.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/c++.py 5023 2010/06/14 22:05:46 scons" import os.path diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py index c565225..c3a6b92 100644 --- a/src/engine/SCons/Tool/cc.py +++ b/src/engine/SCons/Tool/cc.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/cc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/cc.py 5023 2010/06/14 22:05:46 scons" import SCons.Tool import SCons.Defaults @@ -45,7 +45,7 @@ def add_common_cc_variables(env): Add underlying common "C compiler" variables that are used by multiple tools (specifically, c++). """ - if not env.has_key('_CCCOMCOM'): + if '_CCCOMCOM' not in env: env['_CCCOMCOM'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS' # It's a hack to test for darwin here, but the alternative # of creating an applecc.py to contain this seems overkill. @@ -56,10 +56,10 @@ def add_common_cc_variables(env): if env['PLATFORM'] == 'darwin': env['_CCCOMCOM'] = env['_CCCOMCOM'] + ' $_FRAMEWORKPATH' - if not env.has_key('CCFLAGS'): + if 'CCFLAGS' not in env: env['CCFLAGS'] = SCons.Util.CLVar('') - if not env.has_key('SHCCFLAGS'): + if 'SHCCFLAGS' not in env: env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') def generate(env): @@ -73,18 +73,6 @@ def generate(env): shared_obj.add_action(suffix, SCons.Defaults.ShCAction) static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) -#<<<<<<< .working -# -# env['_CCCOMCOM'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS' -# # It's a hack to test for darwin here, but the alternative of creating -# # an applecc.py to contain this seems overkill. Maybe someday the Apple -# # platform will require more setup and this logic will be moved. -# env['FRAMEWORKS'] = SCons.Util.CLVar('') -# env['FRAMEWORKPATH'] = SCons.Util.CLVar('') -# if env['PLATFORM'] == 'darwin': -# env['_CCCOMCOM'] = env['_CCCOMCOM'] + ' $_FRAMEWORKPATH' -#======= -#>>>>>>> .merge-right.r1907 add_common_cc_variables(env) diff --git a/src/engine/SCons/Tool/cvf.py b/src/engine/SCons/Tool/cvf.py index 7930a38..4860241 100644 --- a/src/engine/SCons/Tool/cvf.py +++ b/src/engine/SCons/Tool/cvf.py @@ -27,7 +27,7 @@ Tool-specific initialization for the Compaq Visual Fortran compiler. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/cvf.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/cvf.py 5023 2010/06/14 22:05:46 scons" import fortran diff --git a/src/engine/SCons/Tool/default.py b/src/engine/SCons/Tool/default.py index b477c7b..a2883d7 100644 --- a/src/engine/SCons/Tool/default.py +++ b/src/engine/SCons/Tool/default.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/default.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/default.py 5023 2010/06/14 22:05:46 scons" import SCons.Tool diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index d5dc5c1..a269354 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -54,10 +54,9 @@ Lib tool variables: # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/dmd.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/dmd.py 5023 2010/06/14 22:05:46 scons" import os -import string import SCons.Action import SCons.Builder @@ -112,7 +111,7 @@ def generate(env): # This is merely for the convenience of the dependency scanner. dmd_path = env.WhereIs(dc) if dmd_path: - x = string.rindex(dmd_path, dc) + x = dmd_path.rindex(dc) phobosDir = dmd_path[:x] + '/../src/phobos' if os.path.isdir(phobosDir): env.Append(DPATH = [phobosDir]) diff --git a/src/engine/SCons/Tool/dvi.py b/src/engine/SCons/Tool/dvi.py index ce91cca..7eb9de4 100644 --- a/src/engine/SCons/Tool/dvi.py +++ b/src/engine/SCons/Tool/dvi.py @@ -27,7 +27,7 @@ Common DVI Builder definition for various other Tool modules that use it. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/dvi.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/dvi.py 5023 2010/06/14 22:05:46 scons" import SCons.Builder import SCons.Tool diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index cf6909d..1b352b3 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -29,9 +29,8 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/dvipdf.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/dvipdf.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Defaults @@ -88,7 +87,7 @@ def PDFEmitter(target, source, env): """ def strip_suffixes(n): return not SCons.Util.splitext(str(n))[1] in ['.aux', '.log'] - source = filter(strip_suffixes, source) + source = list(filter(strip_suffixes, source)) return (target, source) def generate(env): diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py index be8a5fe..d6e7006 100644 --- a/src/engine/SCons/Tool/dvips.py +++ b/src/engine/SCons/Tool/dvips.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/dvips.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/dvips.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder diff --git a/src/engine/SCons/Tool/f77.py b/src/engine/SCons/Tool/f77.py index 17e7b6e..d4ec887 100644 --- a/src/engine/SCons/Tool/f77.py +++ b/src/engine/SCons/Tool/f77.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/f77.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/f77.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Scanner.Fortran diff --git a/src/engine/SCons/Tool/f90.py b/src/engine/SCons/Tool/f90.py index 8db5824..b8829b7 100644 --- a/src/engine/SCons/Tool/f90.py +++ b/src/engine/SCons/Tool/f90.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/f90.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/f90.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Scanner.Fortran diff --git a/src/engine/SCons/Tool/f95.py b/src/engine/SCons/Tool/f95.py index fc00566..66be308 100644 --- a/src/engine/SCons/Tool/f95.py +++ b/src/engine/SCons/Tool/f95.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/f95.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/f95.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/filesystem.py b/src/engine/SCons/Tool/filesystem.py index c015390..6bceb14 100644 --- a/src/engine/SCons/Tool/filesystem.py +++ b/src/engine/SCons/Tool/filesystem.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/filesystem.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/filesystem.py 5023 2010/06/14 22:05:46 scons" import SCons from SCons.Tool.install import copyFunc @@ -44,12 +44,12 @@ def copyto_emitter(target, source, env): n_target = [] for t in target: - n_target = n_target + map( lambda s, t=t: t.File( str( s ) ), source ) + n_target = n_target + [t.File( str( s ) ) for s in source] return (n_target, source) def copy_action_func(target, source, env): - assert( len(target) == len(source) ), "\ntarget: %s\nsource: %s" %(map(str, target),map(str, source)) + assert( len(target) == len(source) ), "\ntarget: %s\nsource: %s" %(list(map(str, target)),list(map(str, source))) for t, s in zip(target, source): if copyFunc(t.get_path(), s.get_path(), env): diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py index fea2660..f7b4e8d 100644 --- a/src/engine/SCons/Tool/fortran.py +++ b/src/engine/SCons/Tool/fortran.py @@ -31,10 +31,9 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/fortran.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/fortran.py 5023 2010/06/14 22:05:46 scons" import re -import string import SCons.Action import SCons.Defaults diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index 019939a..fa93329 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/g++.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/g++.py 5023 2010/06/14 22:05:46 scons" import os.path import re diff --git a/src/engine/SCons/Tool/g77.py b/src/engine/SCons/Tool/g77.py index 3b50b6d..c21f34b 100644 --- a/src/engine/SCons/Tool/g77.py +++ b/src/engine/SCons/Tool/g77.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/g77.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/g77.py 5023 2010/06/14 22:05:46 scons" import SCons.Util from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env diff --git a/src/engine/SCons/Tool/gas.py b/src/engine/SCons/Tool/gas.py index 52255ab..0ec021a 100644 --- a/src/engine/SCons/Tool/gas.py +++ b/src/engine/SCons/Tool/gas.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/gas.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/gas.py 5023 2010/06/14 22:05:46 scons" as_module = __import__('as', globals(), locals(), []) diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index 5994854..5d1a7d5 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/gcc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/gcc.py 5023 2010/06/14 22:05:46 scons" import cc import os diff --git a/src/engine/SCons/Tool/gfortran.py b/src/engine/SCons/Tool/gfortran.py index 863e82a..2a3872e 100644 --- a/src/engine/SCons/Tool/gfortran.py +++ b/src/engine/SCons/Tool/gfortran.py @@ -32,7 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/gfortran.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/gfortran.py 5023 2010/06/14 22:05:46 scons" import SCons.Util diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index 71071f1..9845a69 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/gnulink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/gnulink.py 5023 2010/06/14 22:05:46 scons" import SCons.Util diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index 0e6deef..8ab63d7 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/gs.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/gs.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Platform @@ -69,7 +69,7 @@ def generate(env): def exists(env): - if env.has_key('PS2PDF'): + if 'PS2PDF' in env: return env.Detect(env['PS2PDF']) else: return env.Detect(gs) or SCons.Util.WhereIs(gs) diff --git a/src/engine/SCons/Tool/hpc++.py b/src/engine/SCons/Tool/hpc++.py index 28d766f..5be3854 100644 --- a/src/engine/SCons/Tool/hpc++.py +++ b/src/engine/SCons/Tool/hpc++.py @@ -31,10 +31,9 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/hpc++.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/hpc++.py 5023 2010/06/14 22:05:46 scons" import os.path -import string import SCons.Util @@ -67,8 +66,8 @@ def generate(env): env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') # determine version of aCC line = os.popen(acc + ' -V 2>&1').readline().rstrip() - if string.find(line, 'aCC: HP ANSI C++') == 0: - env['CXXVERSION'] = string.split(line)[-1] + if line.find('aCC: HP ANSI C++') == 0: + env['CXXVERSION'] = line.split()[-1] if env['PLATFORM'] == 'cygwin': env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') diff --git a/src/engine/SCons/Tool/hpcc.py b/src/engine/SCons/Tool/hpcc.py index f2ab04f..24b48c7 100644 --- a/src/engine/SCons/Tool/hpcc.py +++ b/src/engine/SCons/Tool/hpcc.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/hpcc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/hpcc.py 5023 2010/06/14 22:05:46 scons" import SCons.Util diff --git a/src/engine/SCons/Tool/hplink.py b/src/engine/SCons/Tool/hplink.py index f6eff45..b2ad1ca 100644 --- a/src/engine/SCons/Tool/hplink.py +++ b/src/engine/SCons/Tool/hplink.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/hplink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/hplink.py 5023 2010/06/14 22:05:46 scons" import os import os.path diff --git a/src/engine/SCons/Tool/icc.py b/src/engine/SCons/Tool/icc.py index 0d4e617..fd5affe 100644 --- a/src/engine/SCons/Tool/icc.py +++ b/src/engine/SCons/Tool/icc.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/icc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/icc.py 5023 2010/06/14 22:05:46 scons" import cc diff --git a/src/engine/SCons/Tool/icl.py b/src/engine/SCons/Tool/icl.py index ce98156..f1da778 100644 --- a/src/engine/SCons/Tool/icl.py +++ b/src/engine/SCons/Tool/icl.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/icl.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/icl.py 5023 2010/06/14 22:05:46 scons" import SCons.Tool.intelc @@ -40,10 +40,10 @@ import SCons.Tool.intelc def generate(*args, **kw): """Add Builders and construction variables for icl to an Environment.""" - return apply(SCons.Tool.intelc.generate, args, kw) + return SCons.Tool.intelc.generate(*args, **kw) def exists(*args, **kw): - return apply(SCons.Tool.intelc.exists, args, kw) + return SCons.Tool.intelc.exists(*args, **kw) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py index 93dc977..17ceb34 100644 --- a/src/engine/SCons/Tool/ifl.py +++ b/src/engine/SCons/Tool/ifl.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ifl.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ifl.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults from SCons.Scanner.Fortran import FortranScan @@ -43,12 +43,12 @@ def generate(env): SCons.Tool.SourceFileScanner.add_scanner('.i', fscan) SCons.Tool.SourceFileScanner.add_scanner('.i90', fscan) - if not env.has_key('FORTRANFILESUFFIXES'): + if 'FORTRANFILESUFFIXES' not in env: env['FORTRANFILESUFFIXES'] = ['.i'] else: env['FORTRANFILESUFFIXES'].append('.i') - if not env.has_key('F90FILESUFFIXES'): + if 'F90FILESUFFIXES' not in env: env['F90FILESUFFIXES'] = ['.i90'] else: env['F90FILESUFFIXES'].append('.i90') diff --git a/src/engine/SCons/Tool/ifort.py b/src/engine/SCons/Tool/ifort.py index 047afba..06bf484 100644 --- a/src/engine/SCons/Tool/ifort.py +++ b/src/engine/SCons/Tool/ifort.py @@ -32,9 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ifort.py 4720 2010/03/24 03:14:11 jars" - -import string +__revision__ = "src/engine/SCons/Tool/ifort.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults from SCons.Scanner.Fortran import FortranScan @@ -48,12 +46,12 @@ def generate(env): SCons.Tool.SourceFileScanner.add_scanner('.i', fscan) SCons.Tool.SourceFileScanner.add_scanner('.i90', fscan) - if not env.has_key('FORTRANFILESUFFIXES'): + if 'FORTRANFILESUFFIXES' not in env: env['FORTRANFILESUFFIXES'] = ['.i'] else: env['FORTRANFILESUFFIXES'].append('.i') - if not env.has_key('F90FILESUFFIXES'): + if 'F90FILESUFFIXES' not in env: env['F90FILESUFFIXES'] = ['.i90'] else: env['F90FILESUFFIXES'].append('.i90') @@ -75,7 +73,7 @@ def generate(env): for dialect in ['F77', 'F90', 'FORTRAN', 'F95']: for var in ['%sCOM' % dialect, '%sPPCOM' % dialect, 'SH%sCOM' % dialect, 'SH%sPPCOM' % dialect]: - env[var] = string.replace(env[var], '-o $TARGET', '-object:$TARGET') + env[var] = env[var].replace('-o $TARGET', '-object:$TARGET') env['FORTRANMODDIRPREFIX'] = "/module:" else: env['FORTRANMODDIRPREFIX'] = "-module " diff --git a/src/engine/SCons/Tool/ilink.py b/src/engine/SCons/Tool/ilink.py index 4d8395f..71025d1 100644 --- a/src/engine/SCons/Tool/ilink.py +++ b/src/engine/SCons/Tool/ilink.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ilink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ilink.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/ilink32.py b/src/engine/SCons/Tool/ilink32.py index 1765193..fb570f8 100644 --- a/src/engine/SCons/Tool/ilink32.py +++ b/src/engine/SCons/Tool/ilink32.py @@ -27,7 +27,7 @@ XXX # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ilink32.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ilink32.py 5023 2010/06/14 22:05:46 scons" import SCons.Tool import SCons.Tool.bcc32 diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index 0d7b9d5..7b61bde 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/install.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/install.py 5023 2010/06/14 22:05:46 scons" import os import shutil @@ -54,7 +54,7 @@ def copyFunc(dest, source, env): if os.path.isdir(source): if os.path.exists(dest): if not os.path.isdir(dest): - raise SCons.Errors.UserError, "cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source)) + raise SCons.Errors.UserError("cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source))) else: parent = os.path.split(dest)[0] if not os.path.exists(parent): @@ -76,7 +76,7 @@ def installFunc(target, source, env): raise SCons.Errors.UserError('Missing INSTALL construction variable.') assert len(target)==len(source), \ - "Installing source %s into target %s: target and source lists must have same length."%(map(str, source), map(str, target)) + "Installing source %s into target %s: target and source lists must have same length."%(list(map(str, source)), list(map(str, target))) for t,s in zip(target,source): if install(t.get_path(),s.get_path(),env): return 1 @@ -108,7 +108,7 @@ def add_targets_to_INSTALLED_FILES(target, source, env): _UNIQUE_INSTALLED_FILES = None return (target, source) -class DESTDIR_factory: +class DESTDIR_factory(object): """ a node factory, where all files will be relative to the dir supplied in the constructor. """ @@ -135,7 +135,7 @@ BaseInstallBuilder = None def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw): if target and dir: import SCons.Errors - raise SCons.Errors.UserError, "Both target and dir defined for Install(), only one may be defined." + raise SCons.Errors.UserError("Both target and dir defined for Install(), only one may be defined.") if not dir: dir=target @@ -149,7 +149,7 @@ def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw): try: dnodes = env.arg2nodes(dir, target_factory.Dir) except TypeError: - raise SCons.Errors.UserError, "Target `%s' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" % str(dir) + raise SCons.Errors.UserError("Target `%s' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" % str(dir)) sources = env.arg2nodes(source, env.fs.Entry) tgt = [] for dnode in dnodes: @@ -159,14 +159,14 @@ def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw): # be relative to the top-level SConstruct directory. target = env.fs.Entry('.'+os.sep+src.name, dnode) #tgt.extend(BaseInstallBuilder(env, target, src, **kw)) - tgt.extend(apply(BaseInstallBuilder, (env, target, src), kw)) + tgt.extend(BaseInstallBuilder(env, target, src, **kw)) return tgt def InstallAsBuilderWrapper(env, target=None, source=None, **kw): result = [] for src, tgt in map(lambda x, y: (x, y), source, target): #result.extend(BaseInstallBuilder(env, tgt, src, **kw)) - result.extend(apply(BaseInstallBuilder, (env, tgt, src), kw)) + result.extend(BaseInstallBuilder(env, tgt, src, **kw)) return result added = None diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index a9b23d3..10e92cd 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -30,15 +30,15 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# +from __future__ import division -__revision__ = "src/engine/SCons/Tool/intelc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/intelc.py 5023 2010/06/14 22:05:46 scons" import math, sys, os.path, glob, string, re is_windows = sys.platform == 'win32' is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or - (os.environ.has_key('PROCESSOR_ARCHITEW6432') and + ('PROCESSOR_ARCHITEW6432' in os.environ and os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64')) is_linux = sys.platform == 'linux2' is_mac = sys.platform == 'darwin' @@ -69,7 +69,7 @@ def uniquify(s): u = {} for x in s: u[x] = 1 - return u.keys() + return list(u.keys()) def linux_ver_normalize(vstr): """Normalize a Linux compiler version number. @@ -81,7 +81,7 @@ def linux_ver_normalize(vstr): m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', vstr) if m: vmaj,vmin,build = m.groups() - return float(vmaj) * 10 + float(vmin) + float(build) / 1000.; + return float(vmaj) * 10. + float(vmin) + float(build) / 1000.; else: f = float(vstr) if is_windows: @@ -117,9 +117,8 @@ def check_abi(abi): try: abi = valid_abis[abi] except KeyError: - raise SCons.Errors.UserError, \ - "Intel compiler: Invalid ABI %s, valid values are %s"% \ - (abi, valid_abis.keys()) + raise SCons.Errors.UserError("Intel compiler: Invalid ABI %s, valid values are %s"% \ + (abi, list(valid_abis.keys()))) return abi def vercmp(a, b): @@ -156,16 +155,14 @@ def get_intel_registry_value(valuename, version=None, abi=None): try: k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K) except SCons.Util.RegError: - raise MissingRegistryError, \ - "%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi) + raise MissingRegistryError("%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi)) # Get the value: try: v = SCons.Util.RegQueryValueEx(k, valuename)[0] return v # or v.encode('iso-8859-1', 'replace') to remove unicode? except SCons.Util.RegError: - raise MissingRegistryError, \ - "%s\\%s was not found in the registry."%(K, valuename) + raise MissingRegistryError("%s\\%s was not found in the registry."%(K, valuename)) def get_all_compiler_versions(): @@ -243,9 +240,7 @@ def get_all_compiler_versions(): m = re.search(r'([0-9.]+)$', d) if m: versions.append(m.group(1)) - versions = uniquify(versions) # remove dups - versions.sort(vercmp) - return versions + return sorted(uniquify(versions)) # remove dups def get_intel_compiler_top(version, abi): """ @@ -257,13 +252,12 @@ def get_intel_compiler_top(version, abi): if is_windows: if not SCons.Util.can_read_reg: - raise NoRegistryModuleError, "No Windows registry module was found" + raise NoRegistryModuleError("No Windows registry module was found") top = get_intel_registry_value('ProductDir', version, abi) # pre-11, icl was in Bin. 11 and later, it's in Bin/ apparently. if not os.path.exists(os.path.join(top, "Bin", "icl.exe")) \ and not os.path.exists(os.path.join(top, "Bin", abi, "icl.exe")): - raise MissingDirError, \ - "Can't find Intel compiler in %s"%(top) + raise MissingDirError("Can't find Intel compiler in %s"%(top)) elif is_mac or is_linux: # first dir is new (>=9.0) style, second is old (8.0) style. dirs=('/opt/intel/cc/%s', '/opt/intel_cc_%s') @@ -275,8 +269,7 @@ def get_intel_compiler_top(version, abi): top = d%version break if not top: - raise MissingDirError, \ - "Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi) + raise MissingDirError("Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi)) return top @@ -312,9 +305,8 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): # get_version_from_list does that mapping. v = get_version_from_list(version, vlist) if not v: - raise SCons.Errors.UserError, \ - "Invalid Intel compiler version %s: "%version + \ - "installed versions are %s"%(', '.join(vlist)) + raise SCons.Errors.UserError("Invalid Intel compiler version %s: "%version + \ + "installed versions are %s"%(', '.join(vlist))) version = v # if abi is unspecified, use ia32 @@ -406,7 +398,7 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): # Couldn't get it from registry: use default subdir of topdir env.PrependENVPath(p[0], os.path.join(topdir, p[2])) else: - env.PrependENVPath(p[0], string.split(path, os.pathsep)) + env.PrependENVPath(p[0], path.split(os.pathsep)) # print "ICL %s: %s, final=%s"%(p[0], path, str(env['ENV'][p[0]])) if is_windows: @@ -445,7 +437,7 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): for ld in [envlicdir, reglicdir]: # If the string contains an '@', then assume it's a network # license (port@system) and good by definition. - if ld and (string.find(ld, '@') != -1 or os.path.exists(ld)): + if ld and (ld.find('@') != -1 or os.path.exists(ld)): licdir = ld break if not licdir: diff --git a/src/engine/SCons/Tool/ipkg.py b/src/engine/SCons/Tool/ipkg.py index 3e8d223..c692053 100644 --- a/src/engine/SCons/Tool/ipkg.py +++ b/src/engine/SCons/Tool/ipkg.py @@ -33,10 +33,9 @@ packages fake_root. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/ipkg.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/ipkg.py 5023 2010/06/14 22:05:46 scons" import os -import string import SCons.Builder @@ -53,11 +52,8 @@ def generate(env): env['IPKG'] = 'ipkg-build' env['IPKGCOM'] = '$IPKG $IPKGFLAGS ${SOURCE}' - # TODO(1.5) - #env['IPKGUSER'] = os.popen('id -un').read().strip() - #env['IPKGGROUP'] = os.popen('id -gn').read().strip() - env['IPKGUSER'] = string.strip(os.popen('id -un').read()) - env['IPKGGROUP'] = string.strip(os.popen('id -gn').read()) + env['IPKGUSER'] = os.popen('id -un').read().strip() + env['IPKGGROUP'] = os.popen('id -gn').read().strip() env['IPKGFLAGS'] = SCons.Util.CLVar('-o $IPKGUSER -g $IPKGGROUP') env['IPKGSUFFIX'] = '.ipk' diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index 2aaab96..9cb4eff 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/jar.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/jar.py 5023 2010/06/14 22:05:46 scons" import SCons.Subst import SCons.Util diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index df237a8..66651c3 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -29,13 +29,11 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/javac.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/javac.py 5023 2010/06/14 22:05:46 scons" import os import os.path -import string import SCons.Action import SCons.Builder @@ -45,7 +43,7 @@ import SCons.Util def classname(path): """Turn a string (path name) into a Java class name.""" - return string.replace(os.path.normpath(path), os.sep, '.') + return os.path.normpath(path).replace(os.sep, '.') def emit_java_classes(target, source, env): """Create and return lists of source java files @@ -67,27 +65,25 @@ def emit_java_classes(target, source, env): slist = [] js = _my_normcase(java_suffix) - find_java = lambda n, js=js, ljs=len(js): _my_normcase(n[-ljs:]) == js for entry in source: entry = entry.rentry().disambiguate() if isinstance(entry, SCons.Node.FS.File): slist.append(entry) elif isinstance(entry, SCons.Node.FS.Dir): result = SCons.Util.OrderedDict() - def visit(arg, dirname, names, fj=find_java, dirnode=entry.rdir()): - java_files = filter(fj, names) - # The on-disk entries come back in arbitrary order. Sort - # them so our target and source lists are determinate. - java_files.sort() - mydir = dirnode.Dir(dirname) - java_paths = map(lambda f, d=mydir: d.File(f), java_files) + dirnode = entry.rdir() + def find_java_files(arg, dirpath, filenames): + java_files = sorted([n for n in filenames + if _my_normcase(n).endswith(js)]) + mydir = dirnode.Dir(dirpath) + java_paths = [mydir.File(f) for f in java_files] for jp in java_paths: arg[jp] = True + for dirpath, dirnames, filenames in os.walk(dirnode.get_abspath()): + find_java_files(result, dirpath, filenames) + entry.walk(find_java_files, result) - os.path.walk(entry.rdir().get_abspath(), visit, result) - entry.walk(visit, result) - - slist.extend(result.keys()) + slist.extend(list(result.keys())) else: raise SCons.Errors.UserError("Java source must be File or Dir, not '%s'" % entry.__class__) @@ -139,7 +135,7 @@ JavaBuilder = SCons.Builder.Builder(action = JavaAction, target_factory = SCons.Node.FS.Entry, source_factory = SCons.Node.FS.Entry) -class pathopt: +class pathopt(object): """ Callable object for generating javac-style path options from a construction variable (e.g. -classpath, -sourcepath). @@ -156,8 +152,8 @@ class pathopt: if self.default: path = path + [ env[self.default] ] if path: - return [self.opt, string.join(path, os.pathsep)] - #return self.opt + " " + string.join(path, os.pathsep) + return [self.opt, os.pathsep.join(path)] + #return self.opt + " " + os.pathsep.join(path) else: return [] #return "" @@ -194,7 +190,7 @@ def Java(env, target, source, *args, **kw): b = env.JavaClassFile else: b = env.JavaClassDir - result.extend(apply(b, (t, s) + args, kw)) + result.extend(b(t, s, *args, **kw)) return result diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py index 6a4314c..e92c423 100644 --- a/src/engine/SCons/Tool/javah.py +++ b/src/engine/SCons/Tool/javah.py @@ -31,10 +31,9 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/javah.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/javah.py 5023 2010/06/14 22:05:46 scons" import os.path -import string import SCons.Action import SCons.Builder @@ -93,7 +92,7 @@ def emit_java_headers(target, source, env): target[0]._morph() tlist = [] for s in source: - fname = string.replace(s.attributes.java_classname, '.', '_') + '.h' + fname = s.attributes.java_classname.replace('.', '_') + '.h' t = target[0].File(fname) t.attributes.java_lookupdir = target[0] tlist.append(t) @@ -112,7 +111,7 @@ def JavaHOutFlagGenerator(target, source, env, for_signature): def getJavaHClassPath(env,target, source, for_signature): path = "${SOURCE.attributes.java_classdir}" - if env.has_key('JAVACLASSPATH') and env['JAVACLASSPATH']: + if 'JAVACLASSPATH' in env and env['JAVACLASSPATH']: path = SCons.Util.AppendPath(path, env['JAVACLASSPATH']) return "-classpath %s" % (path) diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py index 56db43f..e4f1a51 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -32,7 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/latex.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/latex.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Defaults @@ -44,7 +44,7 @@ import SCons.Tool.tex def LaTeXAuxFunction(target = None, source= None, env=None): result = SCons.Tool.tex.InternalLaTeXAuxAction( SCons.Tool.tex.LaTeXAction, target, source, env ) if result != 0: - print env['LATEX']," returned an error, check the log file" + SCons.Tool.tex.check_file_error_message(env['LATEX']) return result LaTeXAuxAction = SCons.Action.Action(LaTeXAuxFunction, diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py index 920ff5f..aad5004 100644 --- a/src/engine/SCons/Tool/lex.py +++ b/src/engine/SCons/Tool/lex.py @@ -31,12 +31,10 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/lex.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/lex.py 5023 2010/06/14 22:05:46 scons" import os.path -import string - import SCons.Action import SCons.Tool import SCons.Util @@ -62,7 +60,7 @@ def lexEmitter(target, source, env): if option[:l] == fileGenOption: # A file generating option is present, so add the # file name to the target list. - fileName = string.strip(option[l:]) + fileName = option[l:].strip() target.append(fileName) return (target, source) diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 2b6ccec..5905fe9 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/link.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/link.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/linkloc.py b/src/engine/SCons/Tool/linkloc.py index abf29f4..ab5b735 100644 --- a/src/engine/SCons/Tool/linkloc.py +++ b/src/engine/SCons/Tool/linkloc.py @@ -32,7 +32,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/linkloc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/linkloc.py 5023 2010/06/14 22:05:46 scons" import os.path import re @@ -61,7 +61,7 @@ def repl_linker_command(m): # to find it with recursive substitution return m.group(1) + '#' + m.group(2) -class LinklocGenerator: +class LinklocGenerator(object): def __init__(self, cmdline): self.cmdline = cmdline diff --git a/src/engine/SCons/Tool/m4.py b/src/engine/SCons/Tool/m4.py index 48935cf..f43b594 100644 --- a/src/engine/SCons/Tool/m4.py +++ b/src/engine/SCons/Tool/m4.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/m4.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/m4.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder diff --git a/src/engine/SCons/Tool/masm.py b/src/engine/SCons/Tool/masm.py index a4e91fc..5bb936a 100644 --- a/src/engine/SCons/Tool/masm.py +++ b/src/engine/SCons/Tool/masm.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/masm.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/masm.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py index f1f4375..67660d1 100644 --- a/src/engine/SCons/Tool/midl.py +++ b/src/engine/SCons/Tool/midl.py @@ -31,9 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/midl.py 4720 2010/03/24 03:14:11 jars" - -import string +__revision__ = "src/engine/SCons/Tool/midl.py 5023 2010/06/14 22:05:46 scons" import SCons.Action import SCons.Builder @@ -53,10 +51,10 @@ def midl_emitter(target, source, env): midlcom = env['MIDLCOM'] - if string.find(midlcom, '/proxy') != -1: + if midlcom.find('/proxy') != -1: proxy = base + '_p.c' t.append(proxy) - if string.find(midlcom, '/dlldata') != -1: + if midlcom.find('/dlldata') != -1: dlldata = base + '_data.c' t.append(dlldata) diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py index e93f1ad..6df46e0 100644 --- a/src/engine/SCons/Tool/mingw.py +++ b/src/engine/SCons/Tool/mingw.py @@ -31,11 +31,10 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/mingw.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/mingw.py 5023 2010/06/14 22:05:46 scons" import os import os.path -import string import SCons.Action import SCons.Builder @@ -73,7 +72,7 @@ def shlib_emitter(target, source, env): no_import_lib = env.get('no_import_lib', 0) if not dll: - raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX") + raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) if not no_import_lib and \ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py index c568abd..a2933cb 100644 --- a/src/engine/SCons/Tool/mslib.py +++ b/src/engine/SCons/Tool/mslib.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/mslib.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/mslib.py 5023 2010/06/14 22:05:46 scons" import SCons.Defaults import SCons.Tool diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 36ad2fe..c291ba9 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -31,7 +31,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/mslink.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/mslink.py 5023 2010/06/14 22:05:46 scons" import os.path @@ -103,7 +103,7 @@ def _dllEmitter(target, source, env, paramtp): no_import_lib = env.get('no_import_lib', 0) if not dll: - raise SCons.Errors.UserError, 'A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp) + raise SCons.Errors.UserError('A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp)) insert_def = env.subst("$WINDOWS_INSERT_DEF") if not insert_def in ['', '0', 0] and \ @@ -123,7 +123,7 @@ def _dllEmitter(target, source, env, paramtp): '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, "WINDOWSSHLIBMANIFESTPREFIX", "WINDOWSSHLIBMANIFESTSUFFIX")) - if env.has_key('PDB') and env['PDB']: + if 'PDB' in env and env['PDB']: pdb = env.arg2nodes('$PDB', target=target, source=source)[0] extratargets.append(pdb) target[0].attributes.pdb = pdb @@ -161,7 +161,7 @@ def prog_emitter(target, source, env): exe = env.FindIxes(target, "PROGPREFIX", "PROGSUFFIX") if not exe: - raise SCons.Errors.UserError, "An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX") + raise SCons.Errors.UserError("An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX")) version_num, suite = SCons.Tool.msvs.msvs_parse_version(env.get('MSVS_VERSION', '6.0')) if version_num >= 8.0 and env.get('WINDOWS_INSERT_MANIFEST', 0): @@ -171,7 +171,7 @@ def prog_emitter(target, source, env): "PROGPREFIX", "PROGSUFFIX", "WINDOWSPROGMANIFESTPREFIX", "WINDOWSPROGMANIFESTSUFFIX")) - if env.has_key('PDB') and env['PDB']: + if 'PDB' in env and env['PDB']: pdb = env.arg2nodes('$PDB', target=target, source=source)[0] extratargets.append(pdb) target[0].attributes.pdb = pdb @@ -179,10 +179,10 @@ def prog_emitter(target, source, env): return (target+extratargets,source) def RegServerFunc(target, source, env): - if env.has_key('register') and env['register']: + if 'register' in env and env['register']: ret = regServerAction([target[0]], [source[0]], env) if ret: - raise SCons.Errors.UserError, "Unable to register %s" % target[0] + raise SCons.Errors.UserError("Unable to register %s" % target[0]) else: print "Registered %s sucessfully" % target[0] return ret diff --git a/src/engine/SCons/Tool/mssdk.py b/src/engine/SCons/Tool/mssdk.py index ed5bd5c..08898c6 100644 --- a/src/engine/SCons/Tool/mssdk.py +++ b/src/engine/SCons/Tool/mssdk.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/mssdk.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/mssdk.py 5023 2010/06/14 22:05:46 scons" """engine.SCons.Tool.mssdk diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index f145816..8c13580 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -31,11 +31,10 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/msvc.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/msvc.py 5023 2010/06/14 22:05:46 scons" import os.path import re -import string import sys import SCons.Action @@ -55,11 +54,11 @@ CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] def validate_vars(env): """Validate the PCH and PCHSTOP construction variables.""" - if env.has_key('PCH') and env['PCH']: - if not env.has_key('PCHSTOP'): - raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined." + if 'PCH' in env and env['PCH']: + if 'PCHSTOP' not in env: + raise SCons.Errors.UserError("The PCHSTOP construction must be defined if PCH is defined.") if not SCons.Util.is_String(env['PCHSTOP']): - raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'] + raise SCons.Errors.UserError("The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP']) def pch_emitter(target, source, env): """Adds the object file target.""" @@ -99,7 +98,7 @@ def object_emitter(target, source, env, parent_emitter): # See issue #2505 for a discussion of what to do if it turns # out this assumption causes trouble in the wild: # http://scons.tigris.org/issues/show_bug.cgi?id=2505 - if env.has_key('PCH'): + if 'PCH' in env: pch = env['PCH'] if str(target[0]) != SCons.Util.splitext(str(pch))[0] + '.obj': env.Depends(target, pch) @@ -254,9 +253,9 @@ def generate(env): env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' env['BUILDERS']['PCH'] = pch_builder - if not env.has_key('ENV'): + if 'ENV' not in env: env['ENV'] = {} - if not env['ENV'].has_key('SystemRoot'): # required for dlls in the winsxs folders + if 'SystemRoot' not in env['ENV']: # required for dlls in the winsxs folders env['ENV']['SystemRoot'] = SCons.Platform.win32.get_system_root() def exists(env): diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 17bb9a0..34fc0e7 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,17 +29,18 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/engine/SCons/Tool/msvs.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/engine/SCons/Tool/msvs.py 5023 2010/06/14 22:05:46 scons" + +import SCons.compat import base64 import hashlib import ntpath import os +# compat layer imports "cPickle" for us if it's available. import pickle import re -import string import sys import SCons.Builder @@ -57,23 +58,10 @@ from SCons.Defaults import processDefines # DSP/DSW/SLN/VCPROJ files. ############################################################################## -def _hexdigest(s): - """Return a string as a string of hex characters. - """ - # NOTE: This routine is a method in the Python 2.0 interface - # of the native md5 module, but we want SCons to operate all - # the way back to at least Python 1.5.2, which doesn't have it. - h = string.hexdigits - r = '' - for c in s: - i = ord(c) - r = r + h[(i >> 4) & 0xF] + h[i & 0xF] - return r - def xmlify(s): - s = string.replace(s, "&", "&") # do this first - s = string.replace(s, "'", "'") - s = string.replace(s, '"', """) + s = s.replace("&", "&") # do this first + s = s.replace("'", "'") + s = s.replace('"', """) return s external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}' @@ -88,9 +76,7 @@ def _generateGUID(slnfile, name): # the generated file has a consistent GUID even if we generate # it on a non-Windows platform. m.update(ntpath.normpath(str(slnfile)) + str(name)) - # TODO(1.5) - #solution = m.hexdigest().upper() - solution = string.upper(_hexdigest(m.digest())) + solution = m.hexdigest().upper() # convert most of the signature to GUID form (discard the rest) solution = "{" + solution[:8] + "-" + solution[8:12] + "-" + solution[12:16] + "-" + solution[16:20] + "-" + solution[20:32] + "}" return solution @@ -116,7 +102,7 @@ def msvs_parse_version(s): # which works regardless of how we were invoked. def getExecScriptMain(env, xml=None): scons_home = env.get('SCONS_HOME') - if not scons_home and os.environ.has_key('SCONS_LIB_DIR'): + if not scons_home and 'SCONS_LIB_DIR' in os.environ: scons_home = os.environ['SCONS_LIB_DIR'] if scons_home: exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % scons_home @@ -139,7 +125,7 @@ else: python_executable = os.path.join('$$(PYTHON_ROOT)', os.path.split(sys.executable)[1]) -class Config: +class Config(object): pass def splitFully(path): @@ -161,7 +147,7 @@ def makeHierarchy(sources): if len(path): dict = hierarchy for part in path[:-1]: - if not dict.has_key(part): + if part not in dict: dict[part] = {} dict = dict[part] dict[path[-1]] = file @@ -169,7 +155,7 @@ def makeHierarchy(sources): # print 'Warning: failed to decompose path for '+str(file) return hierarchy -class _DSPGenerator: +class _DSPGenerator(object): """ Base class for DSP generators """ srcargs = [ @@ -188,23 +174,21 @@ class _DSPGenerator: else: self.dspabs = get_abspath() - if not env.has_key('variant'): - raise SCons.Errors.InternalError, \ - "You must specify a 'variant' argument (i.e. 'Debug' or " +\ - "'Release') to create an MSVSProject." + if 'variant' not in env: + raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\ + "'Release') to create an MSVSProject.") elif SCons.Util.is_String(env['variant']): variants = [env['variant']] elif SCons.Util.is_List(env['variant']): variants = env['variant'] - if not env.has_key('buildtarget') or env['buildtarget'] == None: + if 'buildtarget' not in env or env['buildtarget'] == None: buildtarget = [''] elif SCons.Util.is_String(env['buildtarget']): buildtarget = [env['buildtarget']] elif SCons.Util.is_List(env['buildtarget']): if len(env['buildtarget']) != len(variants): - raise SCons.Errors.InternalError, \ - "Sizes of 'buildtarget' and 'variant' lists must be the same." + raise SCons.Errors.InternalError("Sizes of 'buildtarget' and 'variant' lists must be the same.") buildtarget = [] for bt in env['buildtarget']: if SCons.Util.is_String(bt): @@ -219,14 +203,13 @@ class _DSPGenerator: for _ in variants: buildtarget.append(bt) - if not env.has_key('outdir') or env['outdir'] == None: + if 'outdir' not in env or env['outdir'] == None: outdir = [''] elif SCons.Util.is_String(env['outdir']): outdir = [env['outdir']] elif SCons.Util.is_List(env['outdir']): if len(env['outdir']) != len(variants): - raise SCons.Errors.InternalError, \ - "Sizes of 'outdir' and 'variant' lists must be the same." + raise SCons.Errors.InternalError("Sizes of 'outdir' and 'variant' lists must be the same.") outdir = [] for s in env['outdir']: if SCons.Util.is_String(s): @@ -241,14 +224,13 @@ class _DSPGenerator: for v in variants: outdir.append(s) - if not env.has_key('runfile') or env['runfile'] == None: + if 'runfile' not in env or env['runfile'] == None: runfile = buildtarget[-1:] elif SCons.Util.is_String(env['runfile']): runfile = [env['runfile']] elif SCons.Util.is_List(env['runfile']): if len(env['runfile']) != len(variants): - raise SCons.Errors.InternalError, \ - "Sizes of 'runfile' and 'variant' lists must be the same." + raise SCons.Errors.InternalError("Sizes of 'runfile' and 'variant' lists must be the same.") runfile = [] for s in env['runfile']: if SCons.Util.is_String(s): @@ -269,7 +251,7 @@ class _DSPGenerator: self.env = env - if self.env.has_key('name'): + if 'name' in self.env: self.name = self.env['name'] else: self.name = os.path.basename(SCons.Util.splitext(self.dspfile)[0]) @@ -289,14 +271,14 @@ class _DSPGenerator: self.configs = {} self.nokeep = 0 - if env.has_key('nokeep') and env['variant'] != 0: + if 'nokeep' in env and env['variant'] != 0: self.nokeep = 1 if self.nokeep == 0 and os.path.exists(self.dspabs): self.Parse() for t in zip(sourcenames,self.srcargs): - if self.env.has_key(t[1]): + if t[1] in self.env: if SCons.Util.is_List(self.env[t[1]]): for i in self.env[t[1]]: if not i in self.sources[t[0]]: @@ -306,9 +288,9 @@ class _DSPGenerator: self.sources[t[0]].append(self.env[t[1]]) for n in sourcenames: - # TODO(1.5): - #self.sources[n].sort(lambda a, b: cmp(a.lower(), b.lower())) - self.sources[n].sort(lambda a, b: cmp(string.lower(a), string.lower(b))) + #TODO 2.4: compat layer supports sorted(key=) but not sort(key=) + #TODO 2.4: self.sources[n].sort(key=lambda a: a.lower()) + self.sources[n] = sorted(self.sources[n], key=lambda a: a.lower()) def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile): config = Config() @@ -367,8 +349,7 @@ class _GenerateV6DSP(_DSPGenerator): def PrintHeader(self): # pick a default config - confkeys = self.configs.keys() - confkeys.sort() + confkeys = sorted(self.configs.keys()) name = self.name confkey = confkeys[0] @@ -388,8 +369,7 @@ class _GenerateV6DSP(_DSPGenerator): '# PROP Scc_LocalPath ""\n\n') first = 1 - confkeys = self.configs.keys() - confkeys.sort() + confkeys = sorted(self.configs.keys()) for kind in confkeys: outdir = self.configs[kind].outdir buildtarget = self.configs[kind].buildtarget @@ -399,7 +379,7 @@ class _GenerateV6DSP(_DSPGenerator): else: self.file.write('\n!ELSEIF "$(CFG)" == "%s - Win32 %s"\n\n' % (name, kind)) - env_has_buildtarget = self.env.has_key('MSVSBUILDTARGET') + env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: self.env['MSVSBUILDTARGET'] = buildtarget @@ -407,9 +387,7 @@ class _GenerateV6DSP(_DSPGenerator): for base in ("BASE ",""): self.file.write('# PROP %sUse_MFC 0\n' '# PROP %sUse_Debug_Libraries ' % (base, base)) - # TODO(1.5): - #if kind.lower().find('debug') < 0: - if string.find(string.lower(kind), 'debug') < 0: + if kind.lower().find('debug') < 0: self.file.write('0\n') else: self.file.write('1\n') @@ -459,18 +437,12 @@ class _GenerateV6DSP(_DSPGenerator): 'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe', 'Other Files': ''} - cats = categories.keys() - # TODO(1.5): - #cats.sort(lambda a, b: cmp(a.lower(), b.lower())) - cats.sort(lambda a, b: cmp(string.lower(a), string.lower(b))) - for kind in cats: + for kind in sorted(categories.keys(), key=lambda a: a.lower()): if not self.sources[kind]: continue # skip empty groups self.file.write('# Begin Group "' + kind + '"\n\n') - # TODO(1.5) - #typelist = categories[kind].replace('|', ';') - typelist = string.replace(categories[kind], '|', ';') + typelist = categories[kind].replace('|', ';') self.file.write('# PROP Default_Filter "' + typelist + '"\n') for file in self.sources[kind]: @@ -493,9 +465,7 @@ class _GenerateV6DSP(_DSPGenerator): line = dspfile.readline() while line: - # TODO(1.5): - #if line.find("# End Project") > -1: - if string.find(line, "# End Project") > -1: + if line.find("# End Project") > -1: break line = dspfile.readline() @@ -539,7 +509,7 @@ class _GenerateV6DSP(_DSPGenerator): try: self.file = open(self.dspabs,'w') except IOError, detail: - raise SCons.Errors.InternalError, 'Unable to open "' + self.dspabs + '" for writing:' + str(detail) + raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail)) else: self.PrintHeader() self.PrintProject() @@ -664,8 +634,7 @@ class _GenerateV7DSP(_DSPGenerator): def PrintProject(self): self.file.write('\t\n') - confkeys = self.configs.keys() - confkeys.sort() + confkeys = sorted(self.configs.keys()) for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform @@ -674,7 +643,7 @@ class _GenerateV7DSP(_DSPGenerator): runfile = self.configs[kind].runfile cmdargs = self.configs[kind].cmdargs - env_has_buildtarget = self.env.has_key('MSVSBUILDTARGET') + env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: self.env['MSVSBUILDTARGET'] = buildtarget @@ -687,11 +656,8 @@ class _GenerateV7DSP(_DSPGenerator): rebuildcmd = xmlify(starting + self.env.subst('$MSVSREBUILDCOM', 1) + cmdargs) cleancmd = xmlify(starting + self.env.subst('$MSVSCLEANCOM', 1) + cmdargs) - # TODO(1.5) - #preprocdefs = xmlify(';'.join(self.env.get('CPPDEFINES', []))) - #includepath = xmlify(';'.join(self.env.get('CPPPATH', []))) - preprocdefs = xmlify(string.join(processDefines(self.env.get('CPPDEFINES', [])), ';')) - includepath = xmlify(string.join(self.env.get('CPPPATH', []), ';')) + preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) + includepath = xmlify(';'.join(self.env.get('CPPPATH', []))) if not env_has_buildtarget: del self.env['MSVSBUILDTARGET'] @@ -718,10 +684,7 @@ class _GenerateV7DSP(_DSPGenerator): self.file.write(pdata + '-->\n') def printSources(self, hierarchy, commonprefix): - sorteditems = hierarchy.items() - # TODO(1.5): - #sorteditems.sort(lambda a, b: cmp(a[0].lower(), b[0].lower())) - sorteditems.sort(lambda a, b: cmp(string.lower(a[0]), string.lower(b[0]))) + sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -751,11 +714,8 @@ class _GenerateV7DSP(_DSPGenerator): self.file.write('\t\n') - cats = categories.keys() - # TODO(1.5) - #cats.sort(lambda a, b: cmp(a.lower(), b.lower())) - cats.sort(lambda a, b: cmp(string.lower(a), string.lower(b))) - cats = filter(lambda k, s=self: s.sources[k], cats) + cats = sorted([k for k in categories.keys() if self.sources[k]], + key=lambda a: a.lower()) for kind in cats: if len(cats) > 1: self.file.write('\t\t 1: - s = map(os.path.normpath, sources) + s = list(map(os.path.normpath, sources)) # take the dirname because the prefix may include parts # of the filenames (e.g. if you have 'dir\abcd' and # 'dir\acde' then the cp will be 'dir\a' ) cp = os.path.dirname( os.path.commonprefix(s) ) if cp and s[0][len(cp)] == os.sep: # +1 because the filename starts after the separator - sources = map(lambda s, l=len(cp)+1: s[l:], sources) + sources = [s[len(cp)+1:] for s in sources] commonprefix = cp elif len(sources) == 1: commonprefix = os.path.dirname( sources[0] ) @@ -803,9 +763,7 @@ class _GenerateV7DSP(_DSPGenerator): line = dspfile.readline() while line: - # TODO(1.5) - #if line.find('