[PATCH 1 of 2 V3] setup: test setproctitle before building osutil

Jun Wu quark at fb.com
Sun Nov 13 15:25:45 UTC 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1478897140 0
#      Fri Nov 11 20:45:40 2016 +0000
# Node ID 98761d64eaaf67f3bdb99f3f80a57910e2624b78
# Parent  038547a14d850f14ecd2671852093dc07848a134
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 98761d64eaaf
setup: test setproctitle before building osutil

We are going to use setproctitle (provided by FreeBSD) if it's available in
the next patch. Therefore provide a macro to give some clues to the C
pre-processor so it could choose code path wisely.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -68,4 +68,5 @@ if 'FORCE_SETUPTOOLS' in os.environ:
 else:
     from distutils.core import setup
+from distutils.ccompiler import new_compiler
 from distutils.core import Command, Extension
 from distutils.dist import Distribution
@@ -554,6 +555,12 @@ common_depends = ['mercurial/bitmanipula
                   'mercurial/util.h']
 
+osutil_cflags = []
 osutil_ldflags = []
 
+# platform specific macros: HAVE_SETPROCTITLE
+for plat, func in [(re.compile('freebsd'), 'setproctitle')]:
+    if plat.search(sys.platform) and hasfunction(new_compiler(), func):
+        osutil_cflags.append('-DHAVE_%s' % func.upper())
+
 if sys.platform == 'darwin':
     osutil_ldflags += ['-framework', 'ApplicationServices']
@@ -576,4 +583,5 @@ extmodules = [
               depends=common_depends),
     Extension('mercurial.osutil', ['mercurial/osutil.c'],
+              extra_compile_args=osutil_cflags,
               extra_link_args=osutil_ldflags,
               depends=common_depends),


More information about the Mercurial-devel mailing list