WIP: trying to get castxmlparser to pass the unit tests

This commit is contained in:
Gustavo Carneiro
2018-03-04 19:06:08 +00:00
parent 303a1e3756
commit f98f26cb7b
11 changed files with 134 additions and 89 deletions
+1 -1
View File
@@ -17,4 +17,4 @@ doc/figures/work-flow-gccxml.png
.eggs/
PyBindGen.egg-info/
dist/
.venv/
+34 -16
View File
@@ -17,6 +17,8 @@ else:
import os.path
import warnings
import re
import logging
import pygccxml
from pygccxml import parser
from pygccxml import declarations
@@ -52,6 +54,10 @@ import collections
import subprocess
from cxxfilt import demangle
logger = logging.getLogger(__name__)
def check_template (demangled_name, function_name):
index = demangled_name.find(function_name)
end_index = index+len(function_name)
@@ -654,7 +660,8 @@ class ModuleParser(object):
return False
def parse(self, header_files, include_paths=None, whitelist_paths=None, includes=(),
pygen_sink=None, pygen_classifier=None, castxml_options=None):
pygen_sink=None, pygen_classifier=None, castxml_options=None,
gccxml_options=None):
"""
parses a set of header files and returns a pybindgen Module instance.
It is equivalent to calling the following methods:
@@ -666,8 +673,9 @@ class ModuleParser(object):
The documentation for L{ModuleParser.parse_init} explains the parameters.
"""
options = castxml_options or gccxml_options
self.parse_init(header_files, include_paths, whitelist_paths, includes, pygen_sink,
pygen_classifier, castxml_options)
pygen_classifier, options)
self.scan_types()
self.scan_methods()
self.scan_functions()
@@ -676,7 +684,7 @@ class ModuleParser(object):
def parse_init(self, header_files, include_paths=None,
whitelist_paths=None, includes=(), pygen_sink=None, pygen_classifier=None,
castxml_options=None):
castxml_options=None, gccxml_options=None):
"""
Prepares to parse a set of header files. The following
methods should then be called in order to finish the rest of
@@ -729,6 +737,7 @@ class ModuleParser(object):
"""
assert isinstance(header_files, list)
assert isinstance(includes, (list, tuple))
options = castxml_options or gccxml_options
self._pygen = pygen_sink
self._pygen_classifier = pygen_classifier
if isinstance(pygen_sink, list):
@@ -753,16 +762,22 @@ class ModuleParser(object):
assert isinstance(whitelist_paths, list)
self.whitelist_paths = [os.path.abspath(p) for p in whitelist_paths]
if castxml_options is None:
castxml_options = {}
if options is None:
options = {}
else:
options = dict(options)
generator_path, generator_name = find_xml_generator()
options['xml_generator_path'] = generator_path
options['xml_generator'] = generator_name
if include_paths is not None:
assert isinstance(include_paths, list)
warnings.warn("Parameter include_paths is deprecated, use castxml_options instead", DeprecationWarning,
stacklevel=2)
self.castxml_config = parser.xml_generator_configuration_t(include_paths=include_paths, xml_generator_path=generator_path, xml_generator=generator_name, **castxml_options)
else:
self.castxml_config = parser.xml_generator_configuration_t(xml_generator_path=generator_path, xml_generator=generator_name, **castxml_options)
options['include_paths'] = include_paths
logger.debug("castxml options: %r", options)
self.castxml_config = parser.xml_generator_configuration_t(**options)
self.declarations = parser.parse(header_files, self.castxml_config)
self.global_ns = declarations.get_global_namespace(self.declarations)
@@ -771,7 +786,8 @@ class ModuleParser(object):
else:
self.module_namespace = self.global_ns.namespace(self.module_namespace_name)
self.module = Module(self.module_name, cpp_namespace=self.module_namespace.decl_string)
self.module = Module(self.module_name,
cpp_namespace=self.module_namespace.decl_string)
for inc in includes:
self.module.add_include(inc)
@@ -950,6 +966,7 @@ pybindgen.settings.error_handler = ErrorHandler()
def _apply_class_annotations(self, cls, annotations, kwargs):
is_exception = False
logger.debug("cls %s annotations: %r", cls.name, annotations)
for name, value in annotations.items():
if name == 'allow_subclassing':
kwargs.setdefault('allow_subclassing', annotations_scanner.parse_boolean(value))
@@ -1015,6 +1032,7 @@ pybindgen.settings.error_handler = ErrorHandler()
return True
def _scan_namespace_types(self, module, module_namespace, outer_class=None, pygen_register_function_name=None):
logger.debug("_scan_namespace_types(%s, %s)", module, module_namespace)
root_module = module.get_root()
if pygen_register_function_name:
for pygen_sink in self._get_all_pygen_sinks():
@@ -1043,6 +1061,7 @@ pybindgen.settings.error_handler = ErrorHandler()
## all parameters and return values of all functions in this namespace...
for fun in module_namespace.free_functions(function=self.location_filter,
allow_empty=True, recursive=False):
# logger.debug("Saw free function: %s", fun)
if fun.name.startswith('__'):
continue
for dependency in fun.i_depend_on_them(recursive=True):
@@ -1081,6 +1100,7 @@ pybindgen.settings.error_handler = ErrorHandler()
enums.append(enum)
for enum in enums:
# logger.debug("Saw enum: %s", enum)
global_annotations, param_annotations = annotations_scanner.get_annotations(enum)
for hook in self._pre_scan_hooks:
@@ -1103,7 +1123,6 @@ pybindgen.settings.error_handler = ErrorHandler()
module.add_enum(utils.ascii(enum.name), [utils.ascii(name) for name, dummy_val in enum.values],
outer_class=outer_class)
## scan classes
if outer_class is None:
unregistered_classes = [cls for cls in
@@ -1118,7 +1137,7 @@ pybindgen.settings.error_handler = ErrorHandler()
unregistered_classes = []
typedefs = []
for cls in outer_class.castxml_definition.classes(function=self.location_filter,
recursive=False, allow_empty=True):
recursive=False, allow_empty=True):
if outer_class.castxml_definition.find_out_member_access_type(cls) != 'public':
continue
if cls.name.startswith('__'):
@@ -1126,7 +1145,7 @@ pybindgen.settings.error_handler = ErrorHandler()
unregistered_classes.append(cls)
for typedef in outer_class.castxml_definition.typedefs(function=self.location_filter,
recursive=False, allow_empty=True):
recursive=False, allow_empty=True):
if outer_class.castxml_definition.find_out_member_access_type(typedef) != 'public':
continue
if typedef.name.startswith('__'):
@@ -1134,7 +1153,7 @@ pybindgen.settings.error_handler = ErrorHandler()
typedefs.append(typedef)
unregistered_classes.sort(key=lambda c: c.decl_string)
# logger.debug("unregistered_classes: %r", unregistered_classes)
def postpone_class(cls, reason):
## detect the case of a class being postponed many times; that
@@ -1156,8 +1175,7 @@ pybindgen.settings.error_handler = ErrorHandler()
while unregistered_classes:
cls = unregistered_classes.pop(0)
if DEBUG:
print(">>> looking at class ", str(cls), file=sys.stderr)
# logger.debug("Saw class: %s", cls)
typedef = None
kwargs = {}
@@ -1277,7 +1295,7 @@ pybindgen.settings.error_handler = ErrorHandler()
if ignore_class:
continue
if 0: # this is disabled due to ns3
if 1: # this is disabled due to ns3
## if any template argument is a class that is not yet
## registered, postpone scanning/registering the template
## instantiation class until the template argument gets
+5 -1
View File
@@ -33,7 +33,7 @@ class CodeSink(object):
if (true) {
bar();
zbr();
>>> sink = MemoryCodeSink()
>>> sink.writeln("foo();")
>>> sink.writeln()
@@ -97,6 +97,10 @@ class FileCodeSink(CodeSink):
self.file.write('\n'.join(self._format_code(line)))
self.file.write('\n')
def __lt__(self, other):
if isinstance(other, FileCodeSink):
return self.file.name < other.file.name
class MemoryCodeSink(CodeSink):
"""A code sink that keeps the code in memory,
and can later flush the code to another code sink"""
+10 -5
View File
@@ -5,7 +5,7 @@ import re
import pybindgen
from pybindgen import FileCodeSink
from pybindgen.gccxmlparser import ModuleParser
constructor_rx = re.compile("hello_foo_new(_.*)?")
method_rx = re.compile("hello_foo(_.*)?")
@@ -39,13 +39,18 @@ def pre_scan_hook(dummy_module_parser,
def my_module_gen(out_file):
def my_module_gen(out_file, pygccxml_mode):
if pygccxml_mode == 'castxml':
from pybindgen.castxmlparser import ModuleParser
else:
from pybindgen.gccxmlparser import ModuleParser
out = FileCodeSink(out_file)
#pybindgen.write_preamble(out)
out.writeln("#include \"hello.h\"")
module_parser = ModuleParser('hello')
module_parser.add_pre_scan_hook(pre_scan_hook)
module = module_parser.parse(sys.argv[1:])
module = module_parser.parse(sys.argv[2:])
module.generate(out)
@@ -53,7 +58,7 @@ if __name__ == '__main__':
try:
import cProfile as profile
except ImportError:
my_module_gen(sys.stdout)
my_module_gen(sys.stdout, sys.argv[1])
else:
sys.stderr.write("** running under profiler\n")
profile.run('my_module_gen(sys.stdout)', 'hellomodulegen.pstat')
profile.run('my_module_gen(sys.stdout, sys.argv[1])', 'hellomodulegen.pstat')
+1 -1
View File
@@ -19,7 +19,7 @@ def build(bld):
features='command',
source='hellomodulegen.py hello.h',
target='hellomodule.c',
command='${PYTHON} %s ${SRC[0]} ${SRC[1]} > ${TGT[0]}' % (DEPRECATION_ERRORS,))
command='${PYTHON} %s ${SRC[0]} ${PYGCCXML_MODE} ${SRC[1]} > ${TGT[0]}' % (DEPRECATION_ERRORS,))
os.environ["PYTHONPATH"] = os.pathsep.join([os.environ.get("PYTHONPATH", ''), bindgen.path.get_bld().abspath()])
+10 -10
View File
@@ -48,8 +48,8 @@ struct PointerHolder
};
class Foo
// -#- automatic_type_narrowing=True -#-
class Foo
{
std::string m_datum;
bool m_initialized;
@@ -92,8 +92,8 @@ inline bool is_unique(const Foo& foo)
return foo.instance_count == 1;
}
class Zoo
// -#- automatic_type_narrowing=True -#-
class Zoo
{
std::string m_datum;
public:
@@ -137,8 +137,8 @@ public:
// -#- @return(caller_owns_return=true) -#-
Foo* get_hidden_subclass_pointer ();
class Zbr
// -#- incref_method=Ref; decref_method=Unref; peekref_method=GetReferenceCount -#-
class Zbr
{
int m_refcount;
std::string m_datum;
@@ -185,8 +185,8 @@ int invoke_zbr (int x);
void delete_stored_zbr (void);
class Foobar
// -#- allow_subclassing=true -#-
class Foobar
{
Foobar (const Foobar &);
Foobar& operator= (const Foobar &);
@@ -215,8 +215,8 @@ public:
// A nested class
class NestedClass
// -#- automatic_type_narrowing=True -#-
class NestedClass
{
std::string m_datum;
public:
@@ -522,8 +522,8 @@ namespace xpto
struct XptoClass
{
SomeClass* GetSomeClass()
// -#- @return(caller_owns_return=true) -#-
SomeClass* GetSomeClass()
{
return NULL;
}
@@ -540,8 +540,8 @@ void set_foobar_with_other_as_custodian(Foobar *foobar, SomeObject *other);
// -#- @foobar(custodian=-1, transfer_ownership=true); @return(caller_owns_return=true) -#-
SomeObject * set_foobar_with_return_as_custodian(Foobar *foobar);
class SingletonClass
// -#- is_singleton=true -#-
class SingletonClass
{
private:
static SingletonClass *m_instance;
@@ -719,8 +719,8 @@ private:
AbstractBaseClass2 (const AbstractBaseClass2 &other) { other.invoke_protected_virtual(0); }
};
class AbstractXpto
// -#- allow_subclassing=true -#-
class AbstractXpto
{
public:
AbstractXpto () {}
@@ -1171,14 +1171,14 @@ public:
};
struct Error
// -#- exception -#-
struct Error
{
std::string message;
};
struct DomainError : public Error
// -#- exception -#-
struct DomainError : public Error
{
};
+12 -7
View File
@@ -8,22 +8,27 @@ import pybindgen
from pybindgen.typehandlers import base as typehandlers
from pybindgen import (ReturnValue, Parameter, Module, Function, FileCodeSink)
from pybindgen import (CppMethod, CppConstructor, CppClass, Enum)
from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection
from pybindgen.function import CustomFunctionWrapper
from pybindgen.cppmethod import CustomCppMethodWrapper
import foomodulegen_common
class MyPygenClassifier(PygenClassifier):
def classify(self, pygccxml_definition):
if pygccxml_definition.name and pygccxml_definition.name.lower() <= 'l':
return 'foomodulegen_module1'
else:
return 'foomodulegen_module2'
def my_module_gen():
if sys.argv[6] == 'castxml':
from pybindgen.castxmlparser import ModuleParser, PygenClassifier, PygenSection
else:
from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection
class MyPygenClassifier(PygenClassifier):
def classify(self, pygccxml_definition):
if pygccxml_definition.name and pygccxml_definition.name.lower() <= 'l':
return 'foomodulegen_module1'
else:
return 'foomodulegen_module2'
pygen = [
PygenSection('__main__', FileCodeSink(open(sys.argv[3], "wt"))),
PygenSection('foomodulegen_module1', FileCodeSink(open(sys.argv[4], "wt")),
+15 -6
View File
@@ -3,30 +3,38 @@ from __future__ import unicode_literals, print_function, absolute_import
import sys
import os
import logging
import pybindgen
from pybindgen.typehandlers import base as typehandlers
from pybindgen import (ReturnValue, Parameter, Module, Function, FileCodeSink)
from pybindgen import (CppMethod, CppConstructor, CppClass, Enum)
from pybindgen.gccxmlparser import ModuleParser
from pybindgen.function import CustomFunctionWrapper
from pybindgen.cppmethod import CustomCppMethodWrapper
import foomodulegen_common
def my_module_gen():
pygccxml_mode = sys.argv[4]
if pygccxml_mode == 'castxml':
from pybindgen.castxmlparser import ModuleParser
else:
from pybindgen.gccxmlparser import ModuleParser
out = FileCodeSink(sys.stdout)
pygen_file = open(sys.argv[3], "wt")
module_parser = ModuleParser('foo2', '::')
module_parser.enable_anonymous_containers = True
print("PYTHON_INCLUDES:", repr(sys.argv[2]), file=sys.stderr)
gccxml_options = dict(
include_paths=eval(sys.argv[2]),
)
kwargs = {
"{mode}_options".format(mode=pygccxml_mode): dict(
include_paths=eval(sys.argv[2]),
)
}
module_parser.parse_init([sys.argv[1]], includes=['"foo.h"'], pygen_sink=FileCodeSink(pygen_file),
gccxml_options=gccxml_options)
**kwargs)
module = module_parser.module
foomodulegen_common.customize_module_pre(module)
@@ -44,6 +52,7 @@ def my_module_gen():
def main():
logging.basicConfig(level=logging.DEBUG)
if sys.argv[1] == '-d':
del sys.argv[1]
import pdb
+36 -36
View File
@@ -51,7 +51,7 @@ class TestFoo(unittest.TestCase):
del f
f2 = obj.get_foo_ptr()
self.assertEqual(f2.get_datum(), "hello")
def test_pass_foo_shared_ptr(self):
obj = foo.SomeObject("")
f = foo.Foo("hello")
@@ -59,15 +59,15 @@ class TestFoo(unittest.TestCase):
self.assertEqual(f.get_datum(), "hello")
f2 = obj.get_foo_shared_ptr()
self.assertEqual(f2.get_datum(), "hello")
def test_pass_by_reference(self):
obj = foo.SomeObject("")
obj = foo.Sotest_bug455689meObject("")
f = foo.Foo("hello")
obj.set_foo_by_ref(f)
self.assertEqual(f.get_datum(), "hello")
f2 = obj.get_foo_by_ref()
self.assertEqual(f2.get_datum(), "hello")
def test_refcounting(self):
obj = foo.SomeObject("")
z = foo.Zbr("hello")
@@ -93,7 +93,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(zz2.get_datum(), "world")
zz3 = obj.peek_zbr()
self.assertEqual(zz3.get_datum(), "world")
def test_instance_get_attribute(self):
obj = foo.SomeObject("Hello")
self.assertEqual(obj.m_prefix, "Hello")
@@ -128,7 +128,7 @@ class TestFoo(unittest.TestCase):
def test_overloaded_methods(self):
obj = foo.SomeObject("zbr")
v1 = obj.get_int(123.0)
self.assertEqual(v1, 123)
@@ -136,7 +136,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(v2, 123)
self.assertRaises(TypeError, obj.get_int, [123])
if which == 1: # there is no gccxml way to do this
def test_custom_instance_attribute(self):
obj = foo.Foo()
@@ -158,7 +158,7 @@ class TestFoo(unittest.TestCase):
obj.set_foo_ptr(foo.Foo())
foo1 = obj.get_foo_ptr()
self.assertEqual(type(foo1), foo.Foo)
bar2 = foo.Bar()
self.assertEqual(type(bar2), foo.Bar)
obj.set_foo_ptr(bar2)
@@ -265,7 +265,7 @@ class TestFoo(unittest.TestCase):
pass
## check that SomeObject was finally deleted
self.assertEqual(foo.SomeObject.instance_count, count_before)
def test_subclass_with_virtual_transfer_ptr(self):
class Test(foo.SomeObject):
@@ -296,7 +296,7 @@ class TestFoo(unittest.TestCase):
## check that SomeObject was finally deleted
self.assertEqual(foo.SomeObject.instance_count, count_before)
def test_subclassed_store_and_take_back(self):
class Test(foo.SomeObject):
@@ -330,7 +330,7 @@ class TestFoo(unittest.TestCase):
def test_implicit_conversion_method_value(self):
obj = foo.SomeObject("xxx")
zoo1 = foo.Zoo("zpto")
try:
obj.set_foo_value(zoo1)
@@ -339,7 +339,7 @@ class TestFoo(unittest.TestCase):
foo1 = obj.get_foo_value()
self.assertEqual(foo1.get_datum(), "zpto")
def test_implicit_conversion_function_value(self):
zoo1 = foo.Zoo("zpto")
try:
@@ -349,7 +349,7 @@ class TestFoo(unittest.TestCase):
foo1 = foo.function_that_returns_foo()
self.assertEqual(foo1.get_datum(), "zpto")
def test_implicit_conversion_constructor_value(self):
zoo1 = foo.Zoo("zpto")
try:
@@ -625,7 +625,7 @@ class TestFoo(unittest.TestCase):
def get_something(self, arg=None):
self.arg = arg
return str(arg)
obj = MyObject("")
s1 = obj.get_something()
self.assertEqual(s1, "None")
@@ -678,7 +678,7 @@ class TestFoo(unittest.TestCase):
self.y = y
def get_int(self, x):
return getattr(self, 'y', 0) + x
while gc.collect():
pass
count_before = foo.Zbr.instance_count
@@ -861,7 +861,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(len(values), 10)
for i, value in enumerate(values):
self.assertEqual(value.xpto, i)
rv = foo.set_simple_list(l)
self.assertEqual(rv, sum(range(10)))
@@ -893,7 +893,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(count, 5)
## set
## set
l = []
for i in range(5):
simple = foo.simple_struct_t()
@@ -908,7 +908,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(simple.xpto, i)
count += 1
self.assertEqual(count, 5)
def test_container_param_by_ref(self):
l = []
@@ -971,7 +971,7 @@ class TestFoo(unittest.TestCase):
s3.xpto = 456
self.assertEqual(s3.xpto, 456)
self.assertEqual(s1.xpto, 123)
def test_refcounting_v2(self):
while gc.collect():
@@ -996,14 +996,14 @@ class TestFoo(unittest.TestCase):
def test_refcounting_v3(self):
zbr_count_before = foo.Zbr.instance_count
class MyZbr(foo.Zbr):
pass
z_in = MyZbr()
obj = foo.SomeObject("")
obj.set_zbr_transfer(z_in)
del z_in
z1 = obj.get_zbr()
z2 = obj.get_zbr()
self.assertTrue(z1 is z2)
@@ -1018,14 +1018,14 @@ class TestFoo(unittest.TestCase):
def test_refcounting_v4(self): # same as v3 but using peek_zbr instead of get_zbr
zbr_count_before = foo.Zbr.instance_count
class MyZbr(foo.Zbr):
pass
z_in = MyZbr()
obj = foo.SomeObject("")
obj.set_zbr_transfer(z_in)
del z_in
z1 = obj.peek_zbr()
z2 = obj.peek_zbr()
self.assertTrue(z1 is z2)
@@ -1084,7 +1084,7 @@ class TestFoo(unittest.TestCase):
self.assertTrue(t2 < t3)
self.assertTrue(t2 != t3)
self.assertTrue(not(t2 == t3))
def test_numeric_operators(self):
t1 = foo.Tupl()
@@ -1181,7 +1181,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(len(vec3), len(vec1) + len(vec2))
for (x, xcheck) in zip(list(vec3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 6]):
self.assertEqual(x, xcheck)
# iadd
vec2 = foo.VectorLike()
for i in range(10):
@@ -1190,7 +1190,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(len(vec2), 13)
for (x, xcheck) in zip(list(vec3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 6]):
self.assertEqual(x, xcheck)
# mul
vec2 = 2 * vec1
self.assertEqual(len(vec2), 2*len(vec1))
@@ -1346,9 +1346,9 @@ class TestFoo(unittest.TestCase):
f2 = box.getFoobarInternalPtr()
self.assertEqual(foo.Foobar.instance_count, Foobar_count1+1)
self.assertTrue(f2 is f1)
del f1, f2, box
while gc.collect():
pass
@@ -1366,14 +1366,14 @@ class TestFoo(unittest.TestCase):
f2 = box.m_internalFoobar
self.assertEqual(foo.Foobar.instance_count, Foobar_count1+1)
self.assertTrue(f2 is f1)
del f1, f2, box
while gc.collect():
pass
self.assertEqual(foo.Foobar.instance_count, Foobar_count1)
def test_reference_existing_object_ref(self):
while gc.collect():
@@ -1387,9 +1387,9 @@ class TestFoo(unittest.TestCase):
f2 = box.getFoobarInternalRef()
self.assertEqual(foo.Foobar.instance_count, Foobar_count1+1)
self.assertTrue(f2 is f1)
del f1, f2, box
while gc.collect():
pass
@@ -1411,7 +1411,7 @@ class TestFoo(unittest.TestCase):
f2 = box.getFoobarInternalPtr2()
self.assertEqual(foo.Foobar.instance_count, Foobar_count1+1)
self.assertTrue(f2 is f1)
del f2, box
while gc.collect():
pass
@@ -1427,7 +1427,7 @@ class TestFoo(unittest.TestCase):
self.assertEqual(foo.Foobar.instance_count, Foobar_count1)
self.assertEqual(foo.Box.instance_count, Box_count1)
def test_reference_existing_object_ref2(self):
while gc.collect():
@@ -1444,7 +1444,7 @@ class TestFoo(unittest.TestCase):
f2 = box.getFoobarInternalRef2()
self.assertEqual(foo.Foobar.instance_count, Foobar_count1+1)
self.assertTrue(f2 is f1)
del f2, box
while gc.collect():
pass
+4 -5
View File
@@ -37,8 +37,8 @@ def build(bld):
obj.source = 'test.cc'
if env['CXX_NAME'] == 'gcc':
obj.env.append_value('CXXFLAGS', ['-Werror', '-Wno-unused'])
## manual code generation using simple pybindgen API calls
# manual code generation using simple pybindgen API calls
bindgen = bld(
features='command',
source='foomodulegen.py',
@@ -63,7 +63,7 @@ def build(bld):
features='command',
source='foomodulegen-auto.py foo.h',
target='foomodule2.cc foomodulegen_generated.py',
command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[1]} > ${TGT[0]}' % (DEPRECATION_ERRORS,),
command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[1]} ${PYGCCXML_MODE} > ${TGT[0]}' % (DEPRECATION_ERRORS,),
variables=dict(cpp_path_repr=repr(bindgen.env['INCLUDES']+bindgen.env['INCLUDES_PYEXT'])))
obj = bld(features='cxx cxxshlib pyext')
@@ -102,7 +102,7 @@ def build(bld):
features='command',
source='foomodulegen-auto-split.py foo.h',
target='foomodulegen_split.py foomodulegen_module1.py foomodulegen_module2.py',
command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[0]} ${TGT[1]} ${TGT[2]}' % (DEPRECATION_ERRORS,),
command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[0]} ${TGT[1]} ${TGT[2]} ${PYGCCXML_MODE}' % (DEPRECATION_ERRORS,),
variables=dict(cpp_path_repr=repr(bindgen.env['INCLUDES']+bindgen.env['INCLUDES_PYEXT'])))
bld(
@@ -121,7 +121,6 @@ def build(bld):
],
command='${PYTHON} %s ${SRC[0]} ${TGT[0]}' % (DEPRECATION_ERRORS,))
obj = bld(features='cxx cxxshlib pyext')
obj.source = [
'foo.cc',
+6 -1
View File
@@ -161,8 +161,9 @@ def configure(conf):
conf.check_python_headers()
if not Options.options.disable_pygccxml:
castxml = conf.find_program('castxml', mandatory=False)
gccxml = conf.find_program('gccxml', mandatory=False)
if not gccxml:
if not (gccxml or castxml):
conf.env['ENABLE_PYGCCXML'] = False
else:
try:
@@ -171,6 +172,10 @@ def configure(conf):
conf.env['ENABLE_PYGCCXML'] = False
else:
conf.env['ENABLE_PYGCCXML'] = True
if castxml:
conf.env['PYGCCXML_MODE'] = 'castxml'
else:
conf.env['PYGCCXML_MODE'] = 'gccxml'
# -fvisibility=hidden optimization
if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0]