[pypy-commit] pypy precompiled-headers: add NMake specific Definition class that does not fix backslashes

mattip noreply at buildbot.pypy.org
Wed Jan 29 12:36:33 CET 2014


Author: Matti Picus <matti.picus at gmail.com>
Branch: precompiled-headers
Changeset: r68990:48a44cf98eff
Date: 2014-01-29 13:35 +0200
http://bitbucket.org/pypy/pypy/changeset/48a44cf98eff/

Log:	add NMake specific Definition class that does not fix backslashes

diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -202,8 +202,7 @@
         def write_list(prefix, lst):
             lst = lst or ['']
             for i, fn in enumerate(lst):
-                if sys.platform != 'win32':
-                    fn = fn.replace('\\', '\\\\')
+                fn = fn.replace('\\', '\\\\')
                 print >> f, prefix, fn,
                 if i < len(lst)-1:
                     print >> f, '\\'
diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -392,6 +392,25 @@
 
         self._handle_error(returncode, stdout, stderr, path.join('make'))
 
+class WinDefinition(posix.Definition):
+    def write(self, f):
+        def write_list(prefix, lst):
+            lst = lst or ['']
+            for i, fn in enumerate(lst):
+                print >> f, prefix, fn,
+                if i < len(lst)-1:
+                    print >> f, '\\'
+                else:
+                    print >> f
+                prefix = ' ' * len(prefix)
+        name, value = self.name, self.value
+        if isinstance(value, str):
+            f.write('%s = %s\n' % (name, value))
+        else:
+            write_list('%s =' % (name,), value)
+        f.write('\n')
+
+
 class NMakefile(posix.GnuMakefile):
     def write(self, out=None):
         # nmake expands macros when it parses rules.
@@ -410,6 +429,14 @@
         if out is None:
             f.close()
 
+    def definition(self, name, value):
+        defs = self.defs
+        defn = WinDefinition(name, value)
+        if name in defs:
+            self.lines[defs[name]] = defn
+        else:
+            defs[name] = len(self.lines)
+            self.lines.append(defn)
 
 class MingwPlatform(posix.BasePosix):
     name = 'mingw32'


More information about the pypy-commit mailing list