changeset 17061:f20e4d76b711

setup: compile hg.exe This implements a new command $ python setup.py build_hgexe -i which places the hg.exe in the root of the source tree.
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 29 Jun 2012 13:10:48 +0200
parents 69fa0459dd3b
children 682a8ad26138
files setup.py
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Fri Jun 29 15:21:35 2012 +0200
+++ b/setup.py	Fri Jun 29 13:10:48 2012 +0200
@@ -335,6 +335,19 @@
         f.write(out)
         f.close()
 
+class buildhgexe(build_ext):
+    description = 'compile hg.exe from mercurial/exewrapper.c'
+
+    def build_extensions(self):
+        if os.name != 'nt':
+            return
+        objects = self.compiler.compile(['mercurial/exewrapper.c'],
+                                         output_dir=self.build_temp)
+        dir = os.path.dirname(self.get_ext_fullpath('dummy'))
+        target = os.path.join(dir, 'hg')
+        self.compiler.link_executable(objects, target,
+                                      output_dir=self.build_temp)
+
 class hginstallscripts(install_scripts):
     '''
     This is a specialization of install_scripts that replaces the @LIBDIR@ with
@@ -386,7 +399,9 @@
             'build_ext': hgbuildext,
             'build_py': hgbuildpy,
             'build_hgextindex': buildhgextindex,
-            'install_scripts': hginstallscripts}
+            'install_scripts': hginstallscripts,
+            'build_hgexe': buildhgexe,
+            }
 
 packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient',
             'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf',