[PATCH 2 of 2] setup: detect earlier a failure to build inotify

cboos at neuf.fr cboos at neuf.fr
Wed Jun 16 12:30:19 CDT 2010


# HG changeset patch
# User cboos <cboos at neuf.fr>
# Date 1276709262 -7200
# Node ID f4f8b40a3f669af68a8b5fbb29935cbbc95ca176
# Parent  1458d799cc97e1dbb117c56e89500aa2a6d8bdf8
setup: detect earlier a failure to build inotify

diff -r 1458d799cc97 -r f4f8b40a3f66 setup.py
--- a/setup.py	Wed Jun 16 19:27:41 2010 +0200
+++ b/setup.py	Wed Jun 16 19:27:42 2010 +0200
@@ -51,6 +51,10 @@
 def hasfunction(cc, funcname):
     return cancompile(cc, '', '    %s();\n' % funcname)
 
+def hasflags(cc, include, flags):
+    return cancompile(cc, "#include <%s>]\n" % include,
+                      "int flags = %s;\n" % '|'.join(flags))
+
 def cancompile(cc, prelude, body):
     tmpdir = tempfile.mkdtemp(prefix='hg-install-')
     devnull = oldstderr = None
@@ -261,7 +265,9 @@
     # The inotify extension is only usable with Linux 2.6 kernels.
     # You also need a reasonably recent C library.
     cc = new_compiler()
-    if hasfunction(cc, 'inotify_add_watch'):
+    if hasfunction(cc, 'inotify_add_watch') and \
+       hasflags(cc, 'sys/inotify.h',
+                ['IN_ONLYDIR', 'IN_DONT_FOLLOW', 'IN_MASK_ADD']):
         extmodules.append(Extension('hgext.inotify.linux._inotify',
                                      ['hgext/inotify/linux/_inotify.c']))
         packages.extend(['hgext.inotify', 'hgext.inotify.linux'])


More information about the Mercurial-devel mailing list