Debian Codegraph @

tests/wscript

raw
1 ## -*- python -*-
2 #import Action
3 #import Object
4 #import Params
5 #from waflib import Task
6
7 import sys
8 import os.path
9 import os
10 import subprocess
11
12 # uncomment to enable profiling information
13 # epydoc uses the profile data to generate call graphs
14 #os.environ["PYBINDGEN_ENABLE_PROFILING"] = ""
15
16
17 if 0:
18 DEPRECATION_ERRORS = '-Werror::DeprecationWarning' # deprecations become errors
19 else:
20 DEPRECATION_ERRORS = '-Wdefault::DeprecationWarning' # normal python behaviour
21
22
23 def build(bld):
24 env = bld.env
25
26 env['TOP_SRCDIR'] = bld.srcnode.abspath()
27
28 if 0:
29 gen = bld(
30 features='command',
31 source='test-generation.py',
32 target='test.cc',
33 command='${PYTHON} ${SRC[0]} ${TOP_SRCDIR} > ${TGT[0]}')
34
35 if env['CXX']:
36 obj = bld(features='cxx pyext')
37 obj.source = 'test.cc'
38 if env['CXX_NAME'] == 'gcc':
39 obj.env.append_value('CXXFLAGS', ['-Werror', '-Wno-unused'])
40
41 # manual code generation using simple pybindgen API calls
42 bindgen = bld(
43 features='command',
44 source='foomodulegen.py',
45 target='foomodule.cc',
46 command='${PYTHON} %s ${SRC[0]} ${TOP_SRCDIR} > ${TGT[0]}' % (DEPRECATION_ERRORS,))
47
48 if env['CXX']:
49 obj = bld(features='cxx cxxshlib pyext')
50 obj.source = [
51 'foo.cc',
52 'foomodule.cc'
53 ]
54 obj.target = 'foo'
55 obj.install_path = None
56 obj.env.append_value("INCLUDES", '.')
57
58 ## automatic code scanning using gccxml
59 if env['ENABLE_PYGCCXML']:
60 ### Same thing, but using gccxml autoscanning
61
62 bld(
63 features='command',
64 source='foomodulegen-auto.py foo.h',
65 target='foomodule2.cc foomodulegen_generated.py',
66 command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[1]} ${PYGCCXML_MODE} > ${TGT[0]}' % (DEPRECATION_ERRORS,),
67 variables=dict(cpp_path_repr=repr(bindgen.env['INCLUDES']+bindgen.env['INCLUDES_PYEXT'])))
68
69 obj = bld(features='cxx cxxshlib pyext')
70 obj.source = [
71 'foo.cc',
72 'foomodule2.cc'
73 ]
74 obj.target = 'foo2'
75 obj.install_path = None
76 obj.env.append_value("INCLUDES", '.')
77
78 ### Now using the generated python script
79
80 bld(
81 features='command',
82 source='foomodulegen3.py foomodulegen_generated.py',
83 target='foomodule3.cc',
84 command='${PYTHON} %s ${SRC[0]} ${TGT[0]} > ${TGT[0]}' % (DEPRECATION_ERRORS,))
85
86 ## yes, this global manipulation of PYTHONPATH is kind of evil :-/
87 ## TODO: add WAF command-output support for customising command OS environment
88 os.environ["PYTHONPATH"] = os.pathsep.join([os.environ.get("PYTHONPATH", ''), bindgen.path.get_bld().abspath()])
89
90 obj = bld(features='cxx cxxshlib pyext')
91 obj.source = [
92 'foo.cc',
93 'foomodule3.cc'
94 ]
95 obj.target = 'foo3'
96 obj.install_path = None # do not install
97 obj.env.append_value("INCLUDES", '.')
98
99 ## ---
100
101 bld(
102 features='command',
103 source='foomodulegen-auto-split.py foo.h',
104 target='foomodulegen_split.py foomodulegen_module1.py foomodulegen_module2.py',
105 command='${PYTHON} %s ${SRC[0]} ${SRC[1]} ${cpp_path_repr} ${TGT[0]} ${TGT[1]} ${TGT[2]} ${PYGCCXML_MODE}' % (DEPRECATION_ERRORS,),
106 variables=dict(cpp_path_repr=repr(bindgen.env['INCLUDES']+bindgen.env['INCLUDES_PYEXT'])))
107
108 bld(
109 features='command',
110 source=[
111 'foomodulegen4.py',
112 'foomodulegen_split.py',
113 'foomodulegen_module1.py',
114 'foomodulegen_module2.py',
115 ],
116 target=[
117 'foomodule4.cc',
118 'foomodule4.h',
119 'foomodulegen_module1.cc',
120 'foomodulegen_module2.cc',
121 ],
122 command='${PYTHON} %s ${SRC[0]} ${TGT[0]}' % (DEPRECATION_ERRORS,))
123
124 obj = bld(features='cxx cxxshlib pyext')
125 obj.source = [
126 'foo.cc',
127 'foomodule4.cc',
128 'foomodulegen_module1.cc',
129 'foomodulegen_module2.cc',
130 ]
131 obj.target = 'foo4'
132 obj.install_path = None # do not install
133 obj.env.append_value("INCLUDES", '.')
134
135 ## pure C tests
136 bld.recurse('c-hello')
137
138 ## boost tests
139 bld.recurse('boost')