Debian Codegraph @

test cases/cython/2 generated sources/meson.build

raw
1 project(
2 'generated cython sources',
3 ['cython', 'c'],
4 default_options : ['buildtype=release'],
5 meson_version : '>= 1.10.0',
6 )
7
8 if meson.backend() != 'ninja'
9 error('MESON_SKIP_TEST: Ninja backend required')
10 endif
11
12 fs = import('fs')
13 py3 = import('python').find_installation('python3')
14 py3_dep = py3.dependency(required : false)
15 if not py3_dep.found()
16 error('MESON_SKIP_TEST: Python library not found.')
17 endif
18
19 ct = custom_target(
20 'ct',
21 input : 'gen.py',
22 output : 'ct.pyx',
23 command : [py3, '@INPUT@', '@OUTPUT@'],
24 )
25
26 ct_ext = py3.extension_module('ct', ct)
27
28 test(
29 'custom target',
30 py3,
31 args : [files('test.py'), 'ct'],
32 env : ['PYTHONPATH=' + meson.current_build_dir()]
33 )
34
35 # Test a CustomTargetIndex
36 cti = custom_target(
37 'cti',
38 input : 'gen.py',
39 output : 'cti.pyx',
40 command : [py3, '@INPUT@', '@OUTPUT@'],
41 )
42
43 cti_ext = py3.extension_module('cti', cti[0])
44
45 cf = configure_file(
46 input : 'configure.pyx.in',
47 output : 'cf.pyx',
48 copy : true,
49 )
50
51 cf_ext = py3.extension_module('cf', cf)
52
53 test(
54 'configure file',
55 py3,
56 args : [files('test.py'), 'cf'],
57 env : ['PYTHONPATH=' + meson.current_build_dir()]
58 )
59
60 gen = generator(
61 find_program('generator.py'),
62 arguments : ['@INPUT@', '@OUTPUT@'],
63 output : '@[email protected]',
64 )
65
66 g_ext = py3.extension_module(
67 'g',
68 gen.process('g.in'),
69 )
70
71 test(
72 'generator',
73 py3,
74 args : [files('test.py'), 'g'],
75 env : ['PYTHONPATH=' + meson.current_build_dir()]
76 )
77
78 # A generator whose output is *not* a .pyx file, mixed with a Cython .pyx
79 # source in the same target.
80 gen_c = generator(
81 find_program('generator.py'),
82 arguments : ['@INPUT@', '@OUTPUT@'],
83 output : '@BASENAME@',
84 )
85
86 genc_ext = py3.extension_module(
87 'genc',
88 gen_c.process('genc.pyx.in', 'answer.c.in'),
89 )
90
91 test(
92 'generator with non-pyx output',
93 py3,
94 args : [files('test.py'), 'genc'],
95 env : ['PYTHONPATH=' + meson.current_build_dir()]
96 )
97
98 stuff_pxi = fs.copyfile(
99 'stuff.pxi.in',
100 'stuff.pxi'
101 )
102
103 stuff_pxi_2 = configure_file(
104 input: 'stuff.pxi.in',
105 output: 'stuff.pxi',
106 configuration: configuration_data(),
107 install: false
108 )
109
110 # Need to copy the cython source to the build directory
111 # since meson can only generate the .pxi there
112 includestuff_pyx = fs.copyfile(
113 'includestuff.pyx'
114 )
115
116 stuff_pxi_dep = declare_dependency(sources: [stuff_pxi, stuff_pxi_2])
117
118 includestuff_ext = py3.extension_module(
119 'includestuff',
120 includestuff_pyx,
121 dependencies: stuff_pxi_dep
122 )
123
124 simpleinclude_ext = py3.extension_module(
125 'simpleinclude',
126 'simpleinclude.pyx',
127 )
128
129 subdir('libdir')
130
131 test(
132 'custom target in subdir',
133 py3,
134 args : [files('test.py'), 'ct2'],
135 env : ['PYTHONPATH=' + pydir]
136 )