Commits

Steven Knight  committed 03f2981

Set the SYSTEMROOT environment variable on Windows, use POSIX (forward-slash) paths when checking things out of CVS.

  • Participants
  • Parent commits e0480b2

Comments (0)

Files changed (7)

File doc/man/scons.1

 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
 .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 )
 .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:

File src/CHANGES.txt

 
   - 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

File src/engine/SCons/Platform/win32.py

     
     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'

File src/engine/SCons/Tool/CVS.py

         """ """
         # 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,
     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')

File src/engine/SCons/Util.py

         # 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

File src/engine/SCons/UtilTests.py

                              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
 
 """
 
 import os
+import os.path
 import stat
 
 import TestSCons
 
 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')
 
 
 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'], """
 """ % (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)))
+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)))
 
-test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n")
+# 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', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n")
+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')))
 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")
 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)))
+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)))
 
-test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n")
+# 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', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n")
+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')))
 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()