[PATCH 1 of 2] setup: compile hg.exe

Adrian Buehlmann adrian at cadifra.com
Fri Jun 29 04:57:53 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1340963615 -7200
# Node ID 77c83a98257a4d77b535f2842a0e1805a8a0dafb
# Parent  fba17a64fa4978bfea19222da5e64a18cfddeecd
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.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -335,6 +335,17 @@
         f.write(out)
         f.close()
 
+class buildhgexe(build_ext):
+    description = 'compile hg.exe from mercurial/exewrapper.c'
+
+    def build_extensions(self):
+        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 +397,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',


More information about the Mercurial-devel mailing list