The cross module inheritance example is now working. Aside from my figuring out waf, there
are two key things that were necessary:
1. We have to turn off the -fvisibility=hidden flag, since this hides the symbols in our
shared libraries from others. There's probably a better way to handle this, but this
is expedient for now.
2. Since I'm testing with GNU compilers & linkers, I have to use the magic lines in python
before importing the inter-dependent modules (see test_cross_module_inheritance.py):
import sys, ctypes
sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
This shouldn't be necessary on all platforms.
This commit is contained in:
1 parent
8b334800da
commit
cd928374b0
3 files changed
+38
-33
No files matched your search
@@ -0,0 +1,9 @@
|
||||
# This bit of magic is required for GNU compilers for now for resolving symbols
|
||||
# across libraries. See many rants online regarding this issue...
|
||||
import sys, ctypes
|
||||
sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
|
||||
|
||||
import A, B
|
||||
|
||||
b = B.Derived()
|
||||
print isinstance(b, A.Base)
|
||||
@@ -2,33 +2,26 @@
|
||||
|
||||
def build(bld):
|
||||
|
||||
for src, tgt in (('Agen.py', 'Amodule.cc'),
|
||||
('Bgen.py', 'Bmodule.cc')):
|
||||
gen = bld.new_task_gen(
|
||||
features='command',
|
||||
source=src,
|
||||
target=tgt,
|
||||
command='${PYTHON} ${SRC[0]} ${TGT[0]}')
|
||||
for src, tgt in (("Agen.py", "Amodule.cc"),
|
||||
("Bgen.py", "Bmodule.cc")):
|
||||
gen = bld.new_task_gen(features="command",
|
||||
source=src,
|
||||
target=tgt,
|
||||
command="${PYTHON} ${SRC[0]} ${TGT[0]}")
|
||||
|
||||
if bld.env['CXX']:
|
||||
# bld.shlib(source = 'Amodule.cc',
|
||||
# target = 'A',
|
||||
# features = 'pyext',
|
||||
# use = ['PYTHON'])
|
||||
# bld.shlib(source = 'Bmodule.cc',
|
||||
# target = 'B',
|
||||
# features = 'pyext',
|
||||
# use = ['PYTHON', 'A'])
|
||||
if bld.env["CXX"]:
|
||||
obj = bld.new_task_gen(features="cxx cxxshlib pyext",
|
||||
source = "Amodule.cc",
|
||||
target = "A",
|
||||
install_path = None, # do not install
|
||||
includes = ".",
|
||||
cxxflags = "-fvisibility=default", # Hack for gcc only -- need to clean up
|
||||
)
|
||||
|
||||
obj = bld.new_task_gen(features=['cxx', 'cxxshlib', 'pyext'])
|
||||
obj.source = ['Amodule.cc']
|
||||
obj.target = 'A'
|
||||
obj.install_path = None # do not install
|
||||
obj.includes = '.'
|
||||
|
||||
obj = bld.new_task_gen(features=['cxx', 'cxxshlib', 'pyext'])
|
||||
obj.source = ['Bmodule.cc']
|
||||
obj.target = 'B'
|
||||
obj.install_path = None # do not install
|
||||
obj.includes = '.'
|
||||
obj.links = ['A']
|
||||
obj = bld.new_task_gen(features="cxx cxxshlib pyext",
|
||||
source = "Bmodule.cc",
|
||||
target = "B",
|
||||
install_path = None, # do not install
|
||||
includes = ".",
|
||||
cxxflags = "-fvisibility=default", # Hack for gcc only -- need to clean up
|
||||
)
|
||||
@@ -286,11 +286,14 @@ def configure(conf):
|
||||
else:
|
||||
conf.env['ENABLE_PYGCCXML'] = True
|
||||
|
||||
# -fvisibility=hidden optimization
|
||||
if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0]
|
||||
and conf.check_compilation_flag('-fvisibility=hidden')):
|
||||
conf.env.append_value('CXXFLAGS_PYEXT', '-fvisibility=hidden')
|
||||
conf.env.append_value('CCFLAGS_PYEXT', '-fvisibility=hidden')
|
||||
# This breaks the ability to use cross-module dependencies (such as shown in
|
||||
# examples/cross_module_inheritance), so I'm turning off the hidden flag for
|
||||
# now. I welcome a better solution!
|
||||
# # -fvisibility=hidden optimization
|
||||
# if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0]
|
||||
# and conf.check_compilation_flag('-fvisibility=hidden')):
|
||||
# conf.env.append_value('CXXFLAGS_PYEXT', '-fvisibility=hidden')
|
||||
# conf.env.append_value('CCFLAGS_PYEXT', '-fvisibility=hidden')
|
||||
|
||||
# Add include path for our stdint.h replacement, if needed (pstdint.h)
|
||||
if not conf.check_nonfatal(header_name='stdint.h'):
|
||||
|
||||
Reference in new issue
Block a user