Patchwork setup: check if mercurial/util.h has been modified when building extesions

login
register
mail settings
Submitter elson.wei@gmail.com
Date Sept. 13, 2013, 2:16 a.m.
Message ID <f3beb092c0285cd118c4.1379038588@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/2432/
State Accepted
Headers show

Comments

elson.wei@gmail.com - Sept. 13, 2013, 2:16 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1379037657 -28800
#      Fri Sep 13 10:00:57 2013 +0800
# Node ID f3beb092c0285cd118c4af05688495f05aca8f3a
# Parent  2568e12faa83466c0a350eb6fe64ba5ce7eaa77d
setup: check if mercurial/util.h has been modified when building extesions

If mercurial/utils.h has been modified but *.c don't, No extesion is built.
Bryan O'Sullivan - Sept. 16, 2013, 6:23 p.m.
On Thu, Sep 12, 2013 at 7:16 PM, <elson.wei@gmail.com> wrote:

> setup: check if mercurial/util.h has been modified when building extesions
>

Applied, thanks.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -423,14 +423,21 @@ 
 
 pymodules = []
 
+common_depends = ['mercurial/util.h']
+
 extmodules = [
-    Extension('mercurial.base85', ['mercurial/base85.c']),
-    Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
-    Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
-    Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
+    Extension('mercurial.base85', ['mercurial/base85.c'],
+              depends=common_depends),
+    Extension('mercurial.bdiff', ['mercurial/bdiff.c'],
+              depends=common_depends),
+    Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],
+              depends=common_depends),
+    Extension('mercurial.mpatch', ['mercurial/mpatch.c'],
+              depends=common_depends),
     Extension('mercurial.parsers', ['mercurial/dirs.c',
                                     'mercurial/parsers.c',
-                                    'mercurial/pathencode.c']),
+                                    'mercurial/pathencode.c'],
+              depends=common_depends),
     ]
 
 osutil_ldflags = []
@@ -443,7 +450,8 @@ 
     pymodules.append('mercurial.pure.osutil')
 else:
     extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c'],
-                                extra_link_args=osutil_ldflags))
+                                extra_link_args=osutil_ldflags,
+                                depends=common_depends))
 
 # the -mno-cygwin option has been deprecated for years
 Mingw32CCompiler = cygwinccompiler.Mingw32CCompiler
@@ -467,7 +475,8 @@ 
     if hasfunction(cc, 'inotify_add_watch'):
         inotify = Extension('hgext.inotify.linux._inotify',
                             ['hgext/inotify/linux/_inotify.c'],
-                            ['mercurial'])
+                            ['mercurial'],
+                            depends=common_depends)
         inotify.optional = True
         extmodules.append(inotify)
         packages.extend(['hgext.inotify', 'hgext.inotify.linux'])