You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/07/20 13:19:38 UTC

svn commit: r1505124 - in /subversion/trunk/build/generator: gen_base.py gen_win.py

Author: rhuijben
Date: Sat Jul 20 11:19:38 2013
New Revision: 1505124

URL: http://svn.apache.org/r1505124
Log:
Only write subversion/libsvn_subr/errorcode.inc, when its content has changed
instead of on every invocation of gen-make.py.

Visual Studio's dependency checker recompiles files that include this
.inc file (read: libsvn_subr). Which then results in relinking libsvn_subr
and everything that uses it after every gen-make.py invocation.

* build/generator/gen_base.py
  (write_file_if_changed): Move helper function from gen_win.py to here.
  (write_errno_table): To allow using it from this function.

* build/generator/gen_win.py
  (write_file_if_changed): Remove function here.

Modified:
    subversion/trunk/build/generator/gen_base.py
    subversion/trunk/build/generator/gen_win.py

Modified: subversion/trunk/build/generator/gen_base.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_base.py?rev=1505124&r1=1505123&r2=1505124&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_base.py (original)
+++ subversion/trunk/build/generator/gen_base.py Sat Jul 20 11:19:38 2013
@@ -239,6 +239,23 @@ class GeneratorBase:
         except: pass
         os.rename(new_hdrfile, hdrfile)
 
+  def write_file_if_changed(self, fname, new_contents):
+    """Rewrite the file if new_contents are different than its current content.
+
+    If you have your windows projects open and generate the projects
+    it's not a small thing for windows to re-read all projects so
+    only update those that have changed.
+    """
+
+    try:
+      old_contents = open(fname, 'rb').read()
+    except IOError:
+      old_contents = None
+    if old_contents != new_contents:
+      open(fname, 'wb').write(new_contents)
+      print("Wrote: %s" % fname)
+
+
   def write_errno_table(self):
     # ### We generate errorcode.inc at autogen.sh time (here!).
     # ###
@@ -246,21 +263,34 @@ class GeneratorBase:
     # ### functionality ever moves to release builds, it will have to move
     # ### to configure-time.
     import errno
-    fd = open('subversion/libsvn_subr/errorcode.inc', 'w')
-    fd.write('/* This file was generated by build/generator/gen_base.py */\n\n')
+
+    lines = [
+        '/* This file was generated by build/generator/gen_base.py */',
+        ''
+    ]
 
     def write_struct(name, codes):
-      fd.write('static struct {\n'
-               '  int errcode;\n'
-               '  const char *errname;\n'
-               '} %s[] = {\n' % name)
+      lines.extend([
+          'static struct {',
+          '  int errcode;',
+          '  const char *errname;',
+          '} %s[] = {' % (name,),
+        ])
+
       for num, val in sorted(codes):
-        fd.write('  { %d, "%s" },\n' % (num, val))
-      # fd.seek(-2, os.SEEK_CUR); fd.write('\n');
-      fd.write('};\n')
+        lines.extend([
+            '  { %d, "%s" },' % (num, val),
+          ])
+
+       # Remove ',' for c89 compatibility
+      lines[-1] = lines[-1][0:-1]
+
+      lines.extend([
+          '};',
+          '',
+        ])
 
     write_struct('svn__errno', errno.errorcode.items())
-    fd.write('\n')
 
     # Fetch and write apr_errno.h codes.
     aprerr = []
@@ -278,6 +308,9 @@ class GeneratorBase:
     if self.errno_filter(intersection):
         print("WARNING: errno intersects APR error codes: %r" % intersection)
 
+    self.write_file_if_changed('subversion/libsvn_subr/errorcode.inc',
+                               '\n'.join(lines))
+
   def errno_filter(self, codes):
     return codes
 

Modified: subversion/trunk/build/generator/gen_win.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win.py?rev=1505124&r1=1505123&r2=1505124&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_win.py (original)
+++ subversion/trunk/build/generator/gen_win.py Sat Jul 20 11:19:38 2013
@@ -923,22 +923,6 @@ class WinGeneratorBase(gen_win_dependenc
 
     return list(sources.values())
 
-  def write_file_if_changed(self, fname, new_contents):
-    """Rewrite the file if new_contents are different than its current content.
-
-    If you have your windows projects open and generate the projects
-    it's not a small thing for windows to re-read all projects so
-    only update those that have changed.
-    """
-
-    try:
-      old_contents = open(fname, 'rb').read()
-    except IOError:
-      old_contents = None
-    if old_contents != new_contents:
-      open(fname, 'wb').write(new_contents)
-      print("Wrote: %s" % fname)
-
   def write_with_template(self, fname, tname, data):
     fout = StringIO()