diff options
author | Steven Knight <knight@baldmt.com> | 2003-04-09 14:54:03 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-04-09 14:54:03 (GMT) |
commit | 357e981118ba9f2528a2a5f3f60a3f928046558b (patch) | |
tree | 9729558c032bad479e9e69e9c25daecd85bc357a | |
parent | 393e4ca7e9d1308803da49bee667f1a874c612db (diff) | |
download | SCons-357e981118ba9f2528a2a5f3f60a3f928046558b.zip SCons-357e981118ba9f2528a2a5f3f60a3f928046558b.tar.gz SCons-357e981118ba9f2528a2a5f3f60a3f928046558b.tar.bz2 |
Set the SYSTEMROOT environment variable on Windows, use POSIX (forward-slash) paths when checking things out of CVS.
-rw-r--r-- | doc/man/scons.1 | 39 | ||||
-rw-r--r-- | src/CHANGES.txt | 8 | ||||
-rw-r--r-- | src/engine/SCons/Platform/win32.py | 13 | ||||
-rw-r--r-- | src/engine/SCons/Tool/CVS.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 7 | ||||
-rw-r--r-- | test/CVS.py | 110 |
7 files changed, 164 insertions, 30 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 54afbb0..75e83d1 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -802,6 +802,21 @@ construction variables in the environment to use and generate file names with prefixes and suffixes appropriate for the platform. +Note that the +.B win32 +platform adds the +.B SYSTEMROOT +variable from the user's external environment +to the construction environment's +.B ENV +dictionary. +This is so that any executed commands +that use sockets to connect with other systems +(such as fetching source files from +external CVS repository specifications like +.BR :pserver:anonymous:@cvs.sourceforge.net:/cvsroot/scons ) +will work on Win32 systems. + The platform argument may be function or callable object, in which case the Environment() method will call the specified argument to update @@ -3379,6 +3394,21 @@ platform keyword of the Environment() method. .ES env = Environment(platform = Platform('win32')) .EE +.IP +Note that the +.B win32 +platform adds the +.B SYSTEMROOT +variable from the user's external environment +to the construction environment's +.B ENV +dictionary. +This is so that any executed commands +that use sockets to connect with other systems +(such as fetching source files from +external CVS repository specifications like +.BR :pserver:anonymous:@cvs.sourceforge.net:/cvsroot/scons ) +will work on Win32 systems. .TP .RI Repository( directory ) @@ -4050,6 +4080,15 @@ Just the file suffix. .IP abspath The absolute path name of the file. +.IP posix +The POSIX form of the path, +with directories separated by +.B / +(forward slashes) +not backslashes. +This is sometimes necessary on Win32 systems +when a path references a file on other (POSIX) systems. + .LP For example, the specified target will expand as follows for the corresponding modifiers: diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a036568..c48b40d 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,6 +14,14 @@ RELEASE 0.14 - XXX - Add support for Java (javac and jar). + - Propagate the external SYSTEMROOT environment variable into ENV on + Win32 systems, so external commands that use sockets will work. + + - Add a .posix attribute to PathList expansions. + + - Check out CVS source files using POSIX path names (forward slashes + as separators) even on Win32. + RELEASE 0.13 - Mon, 31 Mar 2003 20:22:00 -0600 diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 870dd99..3591ac6 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -118,6 +118,19 @@ def generate(env): if not env.has_key('ENV'): env['ENV'] = {} + + # Import things from the external environment to the construction + # environment's ENV. This is a potential slippery slope, because we + # *don't* want to make builds dependent on the user's environment by + # default. We're doing this for SYSTEMROOT, though, because it's + # needed for anything that uses sockets, and seldom changes. Weigh + # the impact carefully before adding other variables to this list. + import_env = [ 'SYSTEMROOT' ] + for var in import_env: + v = os.environ.get(var) + if v: + env['ENV'][var] = v + env['ENV']['PATHEXT'] = '.COM;.EXE;.BAT;.CMD' env['OBJPREFIX'] = '' env['OBJSUFFIX'] = '.obj' diff --git a/src/engine/SCons/Tool/CVS.py b/src/engine/SCons/Tool/CVS.py index b8f6968..9c5dc60 100644 --- a/src/engine/SCons/Tool/CVS.py +++ b/src/engine/SCons/Tool/CVS.py @@ -45,8 +45,10 @@ def generate(env, platform): """ """ # fail if repos is not an absolute path name? if module != '': - module = os.path.join(module, '') - env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS -p $CVSMODULE$TARGET > $TARGET' + # Don't use os.path.join() because the name we fetch might + # be across a network and must use POSIX slashes as separators. + module = module + '/' + env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS -p $CVSMODULE${TARGET.posix} > $TARGET' return SCons.Builder.Builder(action = '$CVSCOM', env = env, overrides = {'CVSREPOSITORY':repos, @@ -57,7 +59,7 @@ def generate(env, platform): env['CVS'] = 'cvs' env['CVSFLAGS'] = '-d $CVSREPOSITORY' env['CVSCOFLAGS'] = '' - env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS $TARGET' + env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS ${TARGET.posix}' def exists(env): return env.Detect('cvs') diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 3bfb79a..b1a8679 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -166,12 +166,19 @@ class PathList(UserList.UserList): # available even if this object is a Lister, not a PathList. return PathList(map(lambda x: updrive(os.path.abspath(x)), self.data)) + def __posix(self): + if os.sep == '/': + return self + else: + return PathList(map(lambda x: string.replace(x, os.sep, '/'), self.data)) + dictSpecialAttrs = { "file" : __getFileName, "base" : __getBasePath, "filebase" : __getBase, "dir" : __getDir, "suffix" : __getSuffix, - "abspath" : __getAbsPath} + "abspath" : __getAbsPath, + "posix" : __posix} def is_literal(self): return 1 diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 890f54d..a176013 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -156,6 +156,13 @@ class UtilTestCase(unittest.TestCase): target=target, source=source) assert newcom == cvt("test %s/foo/blah.cpp"%SCons.Util.updrive(os.getcwd())), newcom + # Note that we don't use the cvt() helper function here, + # because we're testing that the .posix attribute does its own + # conversion of the path name backslashes to slashes. + newcom = scons_subst("test ${TARGET.posix} ${SOURCE.posix}", env, + target=target, source=source) + assert newcom == "test foo/bar.exe foo/blah.cpp", newcom + newcom = scons_subst("test $xxx", env) assert newcom == cvt("test"), newcom diff --git a/test/CVS.py b/test/CVS.py index ff6963f..d8d9da5 100644 --- a/test/CVS.py +++ b/test/CVS.py @@ -29,6 +29,7 @@ Test fetching source files from CVS. """ import os +import os.path import stat import TestSCons @@ -46,6 +47,26 @@ def is_writable(file): test.subdir('CVS', 'import', ['import', 'sub'], 'work1', 'work2') +foo_aaa_in = os.path.join('foo', 'aaa.in') +foo_bbb_in = os.path.join('foo', 'bbb.in') +foo_ccc_in = os.path.join('foo', 'ccc.in') +foo_sub_ddd_in = os.path.join('foo', 'sub', 'ddd.in') +foo_sub_ddd_out = os.path.join('foo', 'sub', 'ddd.out') +foo_sub_eee_in = os.path.join('foo', 'sub', 'eee.in') +foo_sub_eee_out = os.path.join('foo', 'sub', 'eee.out') +foo_sub_fff_in = os.path.join('foo', 'sub', 'fff.in') +foo_sub_fff_out = os.path.join('foo', 'sub', 'fff.out') +foo_sub_all = os.path.join('foo', 'sub', 'all') + +sub_SConscript = os.path.join('sub', 'SConscript') +sub_ddd_in = os.path.join('sub', 'ddd.in') +sub_ddd_out = os.path.join('sub', 'ddd.out') +sub_eee_in = os.path.join('sub', 'eee.in') +sub_eee_out = os.path.join('sub', 'eee.out') +sub_fff_in = os.path.join('sub', 'fff.in') +sub_fff_out = os.path.join('sub', 'fff.out') +sub_all = os.path.join('sub', 'all') + # Set up the CVS repository. cvsroot = test.workpath('CVS') @@ -70,7 +91,7 @@ test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") test.run(chdir = 'import', program = cvs, - arguments = '-q import -m "import" foo v v-r') + arguments = '-q import -m import foo v v-r') # Test the most straightforward CVS checkouts, using the module name. test.write(['work1', 'SConstruct'], """ @@ -104,22 +125,35 @@ cvs -Q -d %s co foo/sub/SConscript """ % (cvsroot), build_str = """\ cvs -Q -d %s co foo/aaa.in -cat("aaa.out", "foo/aaa.in") -cat("bbb.out", "foo/bbb.in") +cat("aaa.out", "%s") +cat("bbb.out", "%s") cvs -Q -d %s co foo/ccc.in -cat("ccc.out", "foo/ccc.in") +cat("ccc.out", "%s") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) cvs -Q -d %s co foo/sub/ddd.in -cat("foo/sub/ddd.out", "foo/sub/ddd.in") -cat("foo/sub/eee.out", "foo/sub/eee.in") +cat("%s", "%s") +cat("%s", "%s") cvs -Q -d %s co foo/sub/fff.in -cat("foo/sub/fff.out", "foo/sub/fff.in") -cat("foo/sub/all", ["foo/sub/ddd.out", "foo/sub/eee.out", "foo/sub/fff.out"]) -""" % (cvsroot, cvsroot, cvsroot, cvsroot))) - -test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") - -test.fail_test(test.read(['work1', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") +cat("%s", "%s") +cat("%s", ["%s", "%s", "%s"]) +""" % (cvsroot, + foo_aaa_in, + foo_bbb_in, + cvsroot, + foo_ccc_in, + cvsroot, + foo_sub_ddd_out, foo_sub_ddd_in, + foo_sub_eee_out, foo_sub_eee_in, + cvsroot, + foo_sub_fff_out, foo_sub_fff_in, + foo_sub_all, foo_sub_ddd_out, foo_sub_eee_out, foo_sub_fff_out))) + +# Checking things back out of CVS apparently messes with the line +# endings, so read the result files in non-binary mode. + +test.fail_test(test.read(['work1', 'all'], 'r') != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") + +test.fail_test(test.read(['work1', 'foo', 'sub', 'all'], 'r') != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") test.fail_test(not is_writable(test.workpath('work1', 'foo', 'sub', 'SConscript'))) test.fail_test(not is_writable(test.workpath('work1', 'foo', 'aaa.in'))) @@ -154,8 +188,8 @@ test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") test.run(chdir = 'work2', arguments = '.', stdout = test.wrap_stdout(read_str = """\ -cvs -q -d %s co -p foo/sub/SConscript > sub/SConscript -""" % (cvsroot), +cvs -q -d %s co -p foo/sub/SConscript > %s +""" % (cvsroot, sub_SConscript), build_str = """\ cvs -q -d %s co -p foo/aaa.in > aaa.in cat("aaa.out", "aaa.in") @@ -163,17 +197,27 @@ cat("bbb.out", "bbb.in") cvs -q -d %s co -p foo/ccc.in > ccc.in cat("ccc.out", "ccc.in") cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -cvs -q -d %s co -p foo/sub/ddd.in > sub/ddd.in -cat("sub/ddd.out", "sub/ddd.in") -cat("sub/eee.out", "sub/eee.in") -cvs -q -d %s co -p foo/sub/fff.in > sub/fff.in -cat("sub/fff.out", "sub/fff.in") -cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""" % (cvsroot, cvsroot, cvsroot, cvsroot))) - -test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") - -test.fail_test(test.read(['work2', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") +cvs -q -d %s co -p foo/sub/ddd.in > %s +cat("%s", "%s") +cat("%s", "%s") +cvs -q -d %s co -p foo/sub/fff.in > %s +cat("%s", "%s") +cat("%s", ["%s", "%s", "%s"]) +""" % (cvsroot, + cvsroot, + cvsroot, sub_ddd_in, + sub_ddd_out, sub_ddd_in, + sub_eee_out, sub_eee_in, + cvsroot, sub_fff_in, + sub_fff_out, sub_fff_in, + sub_all, sub_ddd_out, sub_eee_out, sub_fff_out))) + +# Checking things back out of CVS apparently messes with the line +# endings, so read the result files in non-binary mode. + +test.fail_test(test.read(['work2', 'all'], 'r') != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") + +test.fail_test(test.read(['work2', 'sub', 'all'], 'r') != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") test.fail_test(not is_writable(test.workpath('work2', 'sub', 'SConscript'))) test.fail_test(not is_writable(test.workpath('work2', 'aaa.in'))) @@ -181,4 +225,18 @@ test.fail_test(not is_writable(test.workpath('work2', 'ccc.in'))) test.fail_test(not is_writable(test.workpath('work2', 'sub', 'ddd.in'))) test.fail_test(not is_writable(test.workpath('work2', 'sub', 'fff.in'))) +# Test CVS checkouts from a remote server (SourceForge). +test.subdir(['work3']) + +test.write(['work3', 'SConstruct'], """\ +env = Environment() +env.SourceCode('.', env.CVS(':pserver:anonymous:@cvs.sourceforge.net:/cvsroot/scons')) +env.Install('install', 'scons/SConstruct') +""") + +test.run(chdir = 'work3', arguments = '.') + +test.fail_test(not os.path.exists(test.workpath('work3', 'install', 'SConstruct'))) + + test.pass_test() |