diff options
author | Steven Knight <knight@baldmt.com> | 2001-11-24 23:15:01 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-11-24 23:15:01 (GMT) |
commit | 378373defaf150feb90cd54d13626516c6dbe1b4 (patch) | |
tree | fc9783004f1cae3c3558846d6f9a1c589e104a3e /src/engine/SCons | |
parent | 139a0052dc0bff059dc9b8cf1739396304e7c129 (diff) | |
download | SCons-378373defaf150feb90cd54d13626516c6dbe1b4.zip SCons-378373defaf150feb90cd54d13626516c6dbe1b4.tar.gz SCons-378373defaf150feb90cd54d13626516c6dbe1b4.tar.bz2 |
More NT portability fixes.
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Builder.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.py | 19 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 3 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 39 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 79 | ||||
-rw-r--r-- | src/engine/SCons/Taskmaster.py | 6 |
6 files changed, 85 insertions, 65 deletions
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index fc372fa..e36f332 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -85,8 +85,8 @@ elif os.name == 'nt': exts = string.split(exts, os.pathsep) pairs = [] for dir in path: - for e in [None] + exts: - pairs.append(dir, e) + for e in exts: + pairs.append((dir, e)) for dir, ext in pairs: f = os.path.join(dir, cmd) if not ext is None: diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 0bc82eb..be750e4 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -102,6 +102,10 @@ if os.name == 'posix': elif os.name == 'nt': + MVSdir = r'C:\Program Files\Microsoft Visual Studio' + MVSVCdir = r'%s\VC98' % MVSdir + MVSCommondir = r'%s\Common' % MVSdir + ConstructionEnvironment = { 'CC' : 'cl', 'CCFLAGS' : '/nologo', @@ -111,10 +115,10 @@ elif os.name == 'nt': 'CXXCOM' : '$CXX $CXXFLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', 'LINK' : 'link', 'LINKFLAGS' : '', - 'LINKCOM' : '$LINK $LINKFLAGS /out:$TARGET $_LIBDIRFLAGS $_LIBFLAGS $SOURCES', + 'LINKCOM' : '$LINK $LINKFLAGS /OUT:$TARGET $_LIBDIRFLAGS $_LIBFLAGS $SOURCES', 'AR' : 'lib', 'ARFLAGS' : '/nologo', - 'ARCOM' : '$AR $ARFLAGS /out:$TARGET $SOURCES', + 'ARCOM' : '$AR $ARFLAGS /OUT:$TARGET $SOURCES', 'BUILDERS' : [Object, Program, Library], 'SCANNERS' : [CScan], 'OBJPREFIX' : '', @@ -123,14 +127,21 @@ elif os.name == 'nt': 'PROGSUFFIX' : '.exe', 'LIBPREFIX' : '', 'LIBSUFFIX' : '.lib', - 'LIBDIRPREFIX' : '/L', + 'LIBDIRPREFIX' : '/LIBPATH', 'LIBDIRSUFFIX' : '', 'LIBLINKPREFIX' : '', 'LIBLINKSUFFIX' : '$LIBSUFFIX', 'INCPREFIX' : '/I', 'INCSUFFIX' : '', 'ENV' : { - 'PATH' : r'C:\Python20;C:\WINNT\system32;C:\WINNT;C:\Program Files\Microsoft Visual Studio\VC98\Bin\;', + 'INCLUDE' : r'%s\atl\include;%s\mfc\include;%s\include' + % (MVSVCdir, MVSVCdir, MVSVCdir), + 'LIB' : r'%s\mvc\lib;%s\lib' + % (MVSVCdir, MVSVCdir), + 'MSDEVDIR' : r'%s\MSDev98' % MVSCommondir, + 'PATH' : r'C:\Python20;C:\WINNT\system32;C:\WINNT;%s\Tools\WinNT;%s\MSDev98\Bin;%s\Tools;%s\Bin;' + % (MVSCommondir, MVSCommondir, + MVSCommondir, MVSVCdir), 'PATHEXT' : '.COM;.EXE;.BAT;.CMD', }, } diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 812eda7..f85f723 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -32,6 +32,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import copy +import os.path import re import types import SCons.Util @@ -164,7 +165,7 @@ class Environment: suffix ='' self._dict[strVarAuto] = map(lambda x, suff=suffix, pref=prefix: \ - pref + str(x) + suff, + pref + os.path.normpath(str(x)) + suff, src_var) def __cmp__(self, other): diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 75f7c5c..67a5ae7 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -97,13 +97,12 @@ class PathDict(UserDict): def __delitem__(self, key): del(self.data[PathName(key)]) - if not hasattr(UserDict, 'setdefault'): - def setdefault(self, key, value): - try: - return self.data[PathName(key)] - except KeyError: - self.data[PathName(key)] = value - return value + def setdefault(self, key, value): + try: + return self.data[PathName(key)] + except KeyError: + self.data[PathName(key)] = value + return value class FS: def __init__(self, path = None): @@ -120,7 +119,7 @@ class FS: self.Root = PathDict() self.Top = self.__doLookup(Dir, path) self.Top.path = '.' - self.Top.path_ = './' + self.Top.path_ = os.path.join('.', '') self.cwd = self.Top def __doLookup(self, fsclass, name, directory=None): @@ -147,11 +146,16 @@ class FS: # None, raise an exception. drive, tail = os.path.splitdrive(head) - if sys.platform is 'win32' and not drive: - if not directory: - raise OSError, 'No drive letter supplied for absolute path.' - return directory.root() - return self.Root.setdefault(drive, Dir(tail)) + #if sys.platform is 'win32' and not drive: + # if not directory: + # raise OSError, 'No drive letter supplied for absolute path.' + # return directory.root() + dir = Dir(tail) + dir.path = drive + dir.path + dir.path_ = drive + dir.path_ + dir.abspath = drive + dir.abspath + dir.abspath_ = drive + dir.abspath_ + return self.Root.setdefault(drive, dir) if head: # Recursively look up our parent directories. directory = self.__doLookup(Dir, head, directory) @@ -181,7 +185,7 @@ class FS: usually in preparation for a call to doLookup(). If the path name is prepended with a '#', then it is unconditionally - interpreted as replative to the top-level directory of this FS. + interpreted as relative to the top-level directory of this FS. If directory is None, and name is a relative path, then the same applies. @@ -256,7 +260,7 @@ class Entry(SCons.Node.Node): if directory: self.abspath = os.path.join(directory.abspath, name) if str(directory.path) == '.': - self.path = os.path.join(name) + self.path = name else: self.path = os.path.join(directory.path, name) else: @@ -335,9 +339,8 @@ class Dir(Entry): def children(self): #XXX --random: randomize "dependencies?" - kids = map(lambda x, s=self: s.entries[x], - filter(lambda k: k != '.' and k != '..', - self.entries.keys())) + keys = filter(lambda k: k != '.' and k != '..', self.entries.keys()) + kids = map(lambda x, s=self: s.entries[x], keys) def c(one, two): if one.abspath < two.abspath: return -1 diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index fe35d76..4992099 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -92,22 +92,19 @@ class FSTestCase(unittest.TestCase): def Dir_test(lpath, path_, abspath_, up_path_, fileSys=fs, s=sep): dir = fileSys.Dir(string.replace(lpath, '/', s)) + if os.sep != '/': + path_ = string.replace(path_, '/', os.sep) + abspath_ = string.replace(abspath_, '/', os.sep) + up_path_ = string.replace(up_path_, '/', os.sep) + def strip_slash(p): - if p[-1] == '/' and len(p) > 1: + if p[-1] == os.sep and len(p) > 1: p = p[:-1] return p path = strip_slash(path_) abspath = strip_slash(abspath_) up_path = strip_slash(up_path_) - name = string.split(abspath, '/')[-1] - - if os.sep != '/': - path = string.replace(path, '/', os.sep) - path_ = string.replace(path_, '/', os.sep) - abspath = string.replace(abspath, '/', os.sep) - abspath_ = string.replace(abspath_, '/', os.sep) - up_path = string.replace(up_path, '/', os.sep) - up_path_ = string.replace(up_path_, '/', os.sep) + name = string.split(abspath, os.sep)[-1] assert dir.name == name, \ "dir.name %s != expected name %s" % \ @@ -211,53 +208,57 @@ class FSTestCase(unittest.TestCase): f1.build() assert built_it + def match(path, expect): + expect = string.replace(expect, '/', os.sep) + assert path == expect, "path %s != expected %s" % (path, expect) + e1 = fs.Entry("d1") assert e1.__class__.__name__ == 'Dir' - assert e1.path == "d1", e1.path - assert e1.path_ == "d1/", e1.path_ - assert e1.dir.path == ".", e1.dir.path + match(e1.path, "d1") + match(e1.path_, "d1/") + match(e1.dir.path, ".") e2 = fs.Entry("d1/f1") assert e2.__class__.__name__ == 'File' - assert e2.path == "d1/f1", e2.path - assert e2.path_ == "d1/f1", e2.path_ - assert e2.dir.path == "d1", e2.dir.path + match(e2.path, "d1/f1") + match(e2.path_, "d1/f1") + match(e2.dir.path, "d1") e3 = fs.Entry("e3") assert e3.__class__.__name__ == 'Entry' - assert e3.path == "e3", e3.path - assert e3.path_ == "e3", e3.path_ - assert e3.dir.path == ".", e3.dir.path + match(e3.path, "e3") + match(e3.path_, "e3") + match(e3.dir.path, ".") e4 = fs.Entry("d1/e4") assert e4.__class__.__name__ == 'Entry' - assert e4.path == "d1/e4", e4.path - assert e4.path_ == "d1/e4", e4.path_ - assert e4.dir.path == "d1", e4.dir.path + match(e4.path, "d1/e4") + match(e4.path_, "d1/e4") + match(e4.dir.path, "d1") e5 = fs.Entry("e3/e5") assert e3.__class__.__name__ == 'Dir' - assert e3.path == "e3", e3.path - assert e3.path_ == "e3/", e3.path_ - assert e3.dir.path == ".", e3.dir.path + match(e3.path, "e3") + match(e3.path_, "e3/") + match(e3.dir.path, ".") assert e5.__class__.__name__ == 'Entry' - assert e5.path == "e3/e5", e5.path - assert e5.path_ == "e3/e5", e5.path_ - assert e5.dir.path == "e3", e5.dir.path + match(e5.path, "e3/e5") + match(e5.path_, "e3/e5") + match(e5.dir.path, "e3") e6 = fs.Dir("d1/e4") assert e6 is e4 assert e4.__class__.__name__ == 'Dir' - assert e4.path == "d1/e4", e4.path - assert e4.path_ == "d1/e4/", e4.path_ - assert e4.dir.path == "d1", e4.dir.path + match(e4.path, "d1/e4") + match(e4.path_, "d1/e4/") + match(e4.dir.path, "d1") e7 = fs.File("e3/e5") assert e7 is e5 assert e5.__class__.__name__ == 'File' - assert e5.path == "e3/e5", e5.path - assert e5.path_ == "e3/e5", e5.path_ - assert e5.dir.path == "e3", e5.dir.path + match(e5.path, "e3/e5") + match(e5.path_, "e3/e5") + match(e5.dir.path, "e3") e8 = fs.Entry("e8") assert e8.get_bsig() is None, e8.get_bsig() @@ -285,21 +286,21 @@ class FSTestCase(unittest.TestCase): fs.chdir(fs.Dir('subdir')) f11 = fs.File("f11") - assert f11.path == "subdir/f11" + match(f11.path, "subdir/f11") d12 = fs.Dir("d12") - assert d12.path_ == "subdir/d12/" + match(d12.path_, "subdir/d12/") e13 = fs.Entry("subdir/e13") - assert e13.path == "subdir/subdir/e13" + match(e13.path, "subdir/subdir/e13") # Test scanning f1.scanner = Scanner() f1.scan() - assert f1.depends[0].path_ == "d1/f1" + assert f1.depends[0].path_ == os.path.join("d1", "f1") f1.scanner = None f1.depends = [] f1.scanned = 0 f1.scan() - assert f1.depends[0].path_ == "d1/f1" + assert f1.depends[0].path_ == os.path.join("d1", "f1") # Test building a file whose directory is not there yet... f1 = fs.File(test.workpath("foo/bar/baz/ack")) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 2184589..e7dcfc0 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -140,7 +140,11 @@ class Taskmaster: """ def __init__(self, targets=[], tasker=Task, calc=Calc()): - self.walkers = map(SCons.Node.Walker, targets) + def out_of_date(node): + return filter(lambda x: x.get_state() != SCons.Node.up_to_date, + node.children()) + self.walkers = map(lambda x, f=out_of_date: SCons.Node.Walker(x, f), + targets) self.tasker = tasker self.calc = calc self.ready = [] |