Mercurial > hg
comparison setup.py @ 44588:2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
MSVC 2008 still needs declarations at the top of the scope. I added it to the
3rd party code too in case somebody vendors a new version with a problem-
they'll get an early warning. Clang seems to ignore this (at least on 10.14
with Xcode 10), and gcc 7.4 will error out as desired on Ubuntu 18.04. Thanks
to Yuya for remembering the name of the option.
Differential Revision: https://phab.mercurial-scm.org/D8318
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 20 Mar 2020 23:30:23 -0400 |
parents | 06b0aa048007 |
children | 960770add699 |
comparison
equal
deleted
inserted
replaced
44587:090a1a78be4a | 44588:2a98b0cd4995 |
---|---|
1266 'mercurial/compat.h', | 1266 'mercurial/compat.h', |
1267 'mercurial/cext/util.h', | 1267 'mercurial/cext/util.h', |
1268 ] | 1268 ] |
1269 common_include_dirs = ['mercurial'] | 1269 common_include_dirs = ['mercurial'] |
1270 | 1270 |
1271 common_cflags = [] | |
1272 | |
1273 # MSVC 2008 still needs declarations at the top of the scope. | |
1274 if os.name != 'nt': | |
1275 common_cflags = ['-Werror=declaration-after-statement'] | |
1276 | |
1271 osutil_cflags = [] | 1277 osutil_cflags = [] |
1272 osutil_ldflags = [] | 1278 osutil_ldflags = [] |
1273 | 1279 |
1274 # platform specific macros | 1280 # platform specific macros |
1275 for plat, func in [('bsd', 'setproctitle')]: | 1281 for plat, func in [('bsd', 'setproctitle')]: |
1439 extmodules = [ | 1445 extmodules = [ |
1440 Extension( | 1446 Extension( |
1441 'mercurial.cext.base85', | 1447 'mercurial.cext.base85', |
1442 ['mercurial/cext/base85.c'], | 1448 ['mercurial/cext/base85.c'], |
1443 include_dirs=common_include_dirs, | 1449 include_dirs=common_include_dirs, |
1450 extra_compile_args=common_cflags, | |
1444 depends=common_depends, | 1451 depends=common_depends, |
1445 ), | 1452 ), |
1446 Extension( | 1453 Extension( |
1447 'mercurial.cext.bdiff', | 1454 'mercurial.cext.bdiff', |
1448 ['mercurial/bdiff.c', 'mercurial/cext/bdiff.c'] + xdiff_srcs, | 1455 ['mercurial/bdiff.c', 'mercurial/cext/bdiff.c'] + xdiff_srcs, |
1449 include_dirs=common_include_dirs, | 1456 include_dirs=common_include_dirs, |
1457 extra_compile_args=common_cflags, | |
1450 depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers, | 1458 depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers, |
1451 ), | 1459 ), |
1452 Extension( | 1460 Extension( |
1453 'mercurial.cext.mpatch', | 1461 'mercurial.cext.mpatch', |
1454 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'], | 1462 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'], |
1455 include_dirs=common_include_dirs, | 1463 include_dirs=common_include_dirs, |
1464 extra_compile_args=common_cflags, | |
1456 depends=common_depends, | 1465 depends=common_depends, |
1457 ), | 1466 ), |
1458 Extension( | 1467 Extension( |
1459 'mercurial.cext.parsers', | 1468 'mercurial.cext.parsers', |
1460 [ | 1469 [ |
1464 'mercurial/cext/parsers.c', | 1473 'mercurial/cext/parsers.c', |
1465 'mercurial/cext/pathencode.c', | 1474 'mercurial/cext/pathencode.c', |
1466 'mercurial/cext/revlog.c', | 1475 'mercurial/cext/revlog.c', |
1467 ], | 1476 ], |
1468 include_dirs=common_include_dirs, | 1477 include_dirs=common_include_dirs, |
1478 extra_compile_args=common_cflags, | |
1469 depends=common_depends | 1479 depends=common_depends |
1470 + ['mercurial/cext/charencode.h', 'mercurial/cext/revlog.h',], | 1480 + ['mercurial/cext/charencode.h', 'mercurial/cext/revlog.h',], |
1471 ), | 1481 ), |
1472 Extension( | 1482 Extension( |
1473 'mercurial.cext.osutil', | 1483 'mercurial.cext.osutil', |
1474 ['mercurial/cext/osutil.c'], | 1484 ['mercurial/cext/osutil.c'], |
1475 include_dirs=common_include_dirs, | 1485 include_dirs=common_include_dirs, |
1476 extra_compile_args=osutil_cflags, | 1486 extra_compile_args=common_cflags + osutil_cflags, |
1477 extra_link_args=osutil_ldflags, | 1487 extra_link_args=osutil_ldflags, |
1478 depends=common_depends, | 1488 depends=common_depends, |
1479 ), | 1489 ), |
1480 Extension( | 1490 Extension( |
1481 'mercurial.thirdparty.zope.interface._zope_interface_coptimizations', | 1491 'mercurial.thirdparty.zope.interface._zope_interface_coptimizations', |
1482 [ | 1492 [ |
1483 'mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c', | 1493 'mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c', |
1484 ], | 1494 ], |
1495 extra_compile_args=common_cflags, | |
1485 ), | 1496 ), |
1486 Extension( | 1497 Extension( |
1487 'mercurial.thirdparty.sha1dc', | 1498 'mercurial.thirdparty.sha1dc', |
1488 [ | 1499 [ |
1489 'mercurial/thirdparty/sha1dc/cext.c', | 1500 'mercurial/thirdparty/sha1dc/cext.c', |
1490 'mercurial/thirdparty/sha1dc/lib/sha1.c', | 1501 'mercurial/thirdparty/sha1dc/lib/sha1.c', |
1491 'mercurial/thirdparty/sha1dc/lib/ubc_check.c', | 1502 'mercurial/thirdparty/sha1dc/lib/ubc_check.c', |
1492 ], | 1503 ], |
1504 extra_compile_args=common_cflags, | |
1493 ), | 1505 ), |
1494 Extension( | 1506 Extension( |
1495 'hgext.fsmonitor.pywatchman.bser', ['hgext/fsmonitor/pywatchman/bser.c'] | 1507 'hgext.fsmonitor.pywatchman.bser', |
1508 ['hgext/fsmonitor/pywatchman/bser.c'], | |
1509 extra_compile_args=common_cflags, | |
1496 ), | 1510 ), |
1497 RustStandaloneExtension( | 1511 RustStandaloneExtension( |
1498 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3' | 1512 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3' |
1499 ), | 1513 ), |
1500 ] | 1514 ] |
1501 | 1515 |
1502 | 1516 |
1503 sys.path.insert(0, 'contrib/python-zstandard') | 1517 sys.path.insert(0, 'contrib/python-zstandard') |
1504 import setup_zstd | 1518 import setup_zstd |
1505 | 1519 |
1506 extmodules.append( | 1520 zstd = setup_zstd.get_c_extension( |
1507 setup_zstd.get_c_extension( | 1521 name='mercurial.zstd', root=os.path.abspath(os.path.dirname(__file__)) |
1508 name='mercurial.zstd', root=os.path.abspath(os.path.dirname(__file__)) | |
1509 ) | |
1510 ) | 1522 ) |
1523 zstd.extra_compile_args += common_cflags | |
1524 extmodules.append(zstd) | |
1511 | 1525 |
1512 try: | 1526 try: |
1513 from distutils import cygwinccompiler | 1527 from distutils import cygwinccompiler |
1514 | 1528 |
1515 # the -mno-cygwin option has been deprecated for years | 1529 # the -mno-cygwin option has been deprecated for years |