Commit 5aa60bcd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e4567bb2
......@@ -29,8 +29,9 @@ import os
import sys
# XXX doc
def _with_includes(what, *argv, **kw):
# _with_defaults calls what(*argv, **kw) with kw amended with default build flags.
# e.g. _with_defaults(_DSO, *argv, **kw)
def _with_defaults(what, *argv, **kw):
kw = kw.copy()
kw['include_dirs'] = [
'.',
......@@ -38,47 +39,59 @@ def _with_includes(what, *argv, **kw):
'./3rdparty/ccan',
'./3rdparty/include',
]
ccdefault = []
if kw.get('language') == 'c':
ccdefault += [
'-std=gnu99', # declarations inside for-loop
'-fplan9-extensions', # anonymous-structs + simple inheritance
# in C99 declaration after statement is ok, and we explicitly compile with -std=gnu99.
# Python >= 3.4 however adds -Werror=declaration-after-statement even for extension
# modules irregardless of their compilation flags:
#
# https://bugs.python.org/issue21121
#
# ensure there is no warnings / errors for decl-after-statements.
'-Wno-declaration-after-statement',
'-Wno-error=declaration-after-statement',
]
else:
ccdefault.append('-std=gnu++11') # not c++11 since we use typeof
# DSOs are not yet annoated for visibility
# XXX pyext besides _bigfile.so also cannot do this because PyMODINIT_FUNC
# does not include export in it. TODO reenable for _bigfile.so
"""
if what != _DSO:
ccdefault.append('-fvisibility=hidden') # by default symbols not visible outside DSO
"""
_ = kw.get('extra_compile_args', [])[:]
_[0:0] = ccdefault
kw['extra_compile_args'] = _
# XXX link default: no-undefined (only for DSO)
lddefault = []
# python extensions cannot be built with -Wl,--no-undefined: at runtime
# they links with either python (without libpython) or libpython. linking
# with both libpython and python would be wrong
if what == _DSO:
lddefault.append('-Wl,--no-undefined') # check DSO for undefined symbols at link time
_ = kw.get('extra_link_args', [])[:]
_[0:0] = lddefault
kw['extra_link_args'] = _
return what(*argv, **kw)
def PyGoExt(*argv, **kw):
return _with_includes(_PyGoExt, *argv, **kw)
return _with_defaults(_PyGoExt, *argv, **kw)
def DSO(*argv, **kw):
return _with_includes(_DSO, *argv, **kw)
#_bigfile = Extension('wendelin.bigfile._bigfile',
_bigfile = PyGoExt('wendelin.bigfile._bigfile',
sources = [
'bigfile/_bigfile.c',
],
define_macros = [('_GNU_SOURCE',None)],
language = 'c',
extra_compile_args = [
'-std=gnu99', # declarations inside for-loop
'-fplan9-extensions', # anonymous-structs + simple inheritance
'-fvisibility=hidden', # by default symbols not visible outside DSO
# in C99 declaration after statement is ok, and we explicitly compile with -std=gnu99.
# Python >= 3.4 however adds -Werror=declaration-after-statement even for extension
# modules irregardless of their compilation flags:
#
# https://bugs.python.org/issue21121
#
# ensure there is no warnings / errors for decl-after-statements.
'-Wno-declaration-after-statement',
'-Wno-error=declaration-after-statement',
],
# can't - at runtime links with either python (without libpython) or libpython
# linking with both libpython and python would be wrong
#extra_link_args = [
# '-Wl,--no-undefined', # check DSO for undefined symbols at link time
#]
dsos = ['wendelin.bigfile.libvirtmem'],
)
return _with_defaults(_DSO, *argv, **kw)
# build_py that
......@@ -250,26 +263,18 @@ setup(
'lib/bug.c',
'lib/utils.c'],
define_macros = [('_GNU_SOURCE',None), ('BUILDING_LIBVIRTMEM',None)], # XXX dup
language = 'c',
extra_compile_args = [ # XXX dup
'-std=gnu99', # declarations inside for-loop
'-fplan9-extensions', # anonymous-structs + simple inheritance
# TODO reenable
#'-fvisibility=hidden', # by default symbols not visible outside DSO
],
extra_link_args = [
'-Wl,--no-undefined', # check DSO for undefined symbols at link time
])],
language = 'c')],
ext_modules = [
_bigfile,
PyGoExt('wendelin.bigfile._bigfile',
['bigfile/_bigfile.c'],
define_macros = [('_GNU_SOURCE',None)],
language = 'c',
dsos = ['wendelin.bigfile.libvirtmem'],
),
PyGoExt('wendelin.bigfile._file_zodb',
['bigfile/_file_zodb.pyx'],
extra_compile_args = [
'-std=gnu++11', # not c++11 since we use typeof
],
dsos=['wendelin.bigfile.libvirtmem']), # XXX needed?
PyGoExt('wendelin.wcfs.internal._wcfs',
......@@ -278,9 +283,6 @@ setup(
'wcfs/internal/wcfs_watchlink.cpp',
'wcfs/internal/wcfs_misc.cpp',
],
extra_compile_args = [
'-std=gnu++11', # not c++11 since we use typeof
],
dsos=['wendelin.bigfile.libvirtmem']),
PyGoExt('wendelin.wcfs.internal.wcfs_test',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment