Bug 634596 - On Windows, use hardlinks when --enable-chrome-format=symlink is specified. r=ted
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Tue, 01 Mar 2011 23:58:24 +0530
changeset 63480 77722540b29f131ca3796ac5f51561ef6ff4062b
parent 63479 16432839ea97a68cbc8c571d0061b96181dc3dc8
child 63481 1b92ec727deb9def62ede09410cda315c5830e00
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs634596
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 634596 - On Windows, use hardlinks when --enable-chrome-format=symlink is specified. r=ted
config/JarMaker.py
--- a/config/JarMaker.py
+++ b/config/JarMaker.py
@@ -51,16 +51,19 @@ from time import localtime
 from optparse import OptionParser
 from MozZipFile import ZipFile
 from cStringIO import StringIO
 from datetime import datetime
 
 from utils import pushback_iter, lockFile
 from Preprocessor import Preprocessor
 from buildlist import addEntriesToListFile
+if sys.platform == "win32":
+  from ctypes import windll, WinError
+  CreateHardLink = windll.kernel32.CreateHardLinkA
 
 __all__ = ['JarMaker']
 
 class ZipEntry:
   '''Helper class for jar output.
 
   This class defines a simple file-like object for a zipfile.ZipEntry
   so that we can consecutively write to it and then close it.
@@ -401,17 +404,17 @@ class JarMaker(object):
         pp.do_include(inf)
         outf.close()
         inf.close()
         return
       # copy or symlink if newer or overwrite
       if (m.group('optOverwrite')
           or (getModTime(realsrc) >
               outHelper.getDestModTime(m.group('output')))):
-        if self.outputFormat == 'symlink' and hasattr(os, 'symlink'):
+        if self.outputFormat == 'symlink':
           outHelper.symlink(realsrc, out)
           return
         outf = outHelper.getOutput(out)
         # open in binary mode, this can be images etc
         inf = open(realsrc, 'rb')
         outf.write(inf.read())
         outf.close()
         inf.close()
@@ -463,17 +466,23 @@ class JarMaker(object):
     def symlink(self, src, dest):
       out = self.ensureDirFor(dest)
       # remove previous link or file
       try:
         os.remove(out)
       except OSError, e:
         if e.errno != errno.ENOENT:
           raise
-      os.symlink(src, out)
+      if sys.platform != "win32":
+        os.symlink(src, out)
+      else:
+        # On Win32, use ctypes to create a hardlink
+        rv = CreateHardLink(out, src, None)
+        if rv == 0:
+          raise WinError()
 
 def main():
   jm = JarMaker()
   p = jm.getCommandLineParser()
   (options, args) = p.parse_args()
   jm.processIncludes(options.I)
   jm.outputFormat = options.f
   if options.e: