summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-07-21 13:06:51 (GMT)
committerSteven Knight <knight@baldmt.com>2004-07-21 13:06:51 (GMT)
commit6a1ff461cdea7e26330ebcdce821ae5a95e415ce (patch)
treea01ab0baf376aa963ea113ae295c483215f411d7 /src/engine/SCons/Node
parentaf9e270bf0dc34fecff450199f90dc14bb0334de (diff)
downloadSCons-6a1ff461cdea7e26330ebcdce821ae5a95e415ce.zip
SCons-6a1ff461cdea7e26330ebcdce821ae5a95e415ce.tar.gz
SCons-6a1ff461cdea7e26330ebcdce821ae5a95e415ce.tar.bz2
Add a .win32 attribute for FS entries; preserve Literal() attributes when concatenating strings in subst_list(). (Chris Murray)
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/FS.py20
-rw-r--r--src/engine/SCons/Node/FSTests.py10
2 files changed, 24 insertions, 6 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 72ed154..1cb7779 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -348,15 +348,24 @@ class EntryProxy(SCons.Util.Proxy):
entry.name + "_base")
def __get_posix_path(self):
- """Return the path with / as the path separator, regardless
- of platform."""
+ """Return the path with / as the path separator,
+ regardless of platform."""
if os.sep == '/':
return self
else:
entry = self.get()
- return SCons.Util.SpecialAttrWrapper(string.replace(entry.get_path(),
- os.sep, '/'),
- entry.name + "_posix")
+ r = string.replace(entry.get_path(), os.sep, '/')
+ return SCons.Util.SpecialAttrWrapper(r, entry.name + "_posix")
+
+ def __get_win32_path(self):
+ """Return the path with \ as the path separator,
+ regardless of platform."""
+ if os.sep == '\\':
+ return self
+ else:
+ entry = self.get()
+ r = string.replace(entry.get_path(), os.sep, '\\')
+ return SCons.Util.SpecialAttrWrapper(r, entry.name + "_win32")
def __get_srcnode(self):
return EntryProxy(self.get().srcnode())
@@ -379,6 +388,7 @@ class EntryProxy(SCons.Util.Proxy):
dictSpecialAttrs = { "base" : __get_base_path,
"posix" : __get_posix_path,
+ "win32" : __get_win32_path,
"srcpath" : __get_srcnode,
"srcdir" : __get_srcdir,
"dir" : __get_dir,
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 231d736..4a868b9 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1522,7 +1522,6 @@ class prepareTestCase(unittest.TestCase):
assert dir_made == [], dir_made
xyz.set_state(0)
xyz.prepare()
- print "dir_made[0] =", dir_made[0]
assert dir_made[0].path == "new_dir", dir_made[0]
dir = fs.Dir("dir")
@@ -1836,6 +1835,13 @@ class SpecialAttrTestCase(unittest.TestCase):
for_sig = f.posix.for_signature()
assert for_sig == 'baz.blat_posix', for_sig
+ s = str(f.win32)
+ assert s == 'foo\\bar\\baz.blat', repr(s)
+ assert f.win32.is_literal(), f.win32
+ if f.win32 != f:
+ for_sig = f.win32.for_signature()
+ assert for_sig == 'baz.blat_win32', for_sig
+
# And now, combinations!!!
s = str(f.srcpath.base)
assert s == os.path.normpath('foo/bar/baz'), s
@@ -1843,6 +1849,8 @@ class SpecialAttrTestCase(unittest.TestCase):
assert s == str(f.srcdir), s
s = str(f.srcpath.posix)
assert s == 'foo/bar/baz.blat', s
+ s = str(f.srcpath.win32)
+ assert s == 'foo\\bar\\baz.blat', s
# Test what happens with BuildDir()
fs.BuildDir('foo', 'baz')