aboutsummaryrefslogtreecommitdiff
path: root/test cases/cython/2 generated sources/meson.build
blob: d438d80911e0eb54619649944075e06805352413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
project(
  'generated cython sources',
  ['cython', 'c'],
  default_options : ['buildtype=release'],
)

if meson.backend() != 'ninja'
  error('MESON_SKIP_TEST: Ninja backend required')
endif

fs = import('fs')
py3 = import('python').find_installation('python3')
py3_dep = py3.dependency(required : false)
if not py3_dep.found()
  error('MESON_SKIP_TEST: Python library not found.')
endif

ct = custom_target(
  'ct',
  input : 'gen.py',
  output : 'ct.pyx',
  command : [py3, '@INPUT@', '@OUTPUT@'],
)

ct_ext = py3.extension_module('ct', ct)

test(
  'custom target',
  py3,
  args : [files('test.py'), 'ct'],
  env : ['PYTHONPATH=' + meson.current_build_dir()]
)

# Test a CustomTargetIndex
cti = custom_target(
  'cti',
  input : 'gen.py',
  output : 'cti.pyx',
  command : [py3, '@INPUT@', '@OUTPUT@'],
)

cti_ext = py3.extension_module('cti', cti[0])

cf = configure_file(
  input : 'configure.pyx.in',
  output : 'cf.pyx',
  copy : true,
)

cf_ext = py3.extension_module('cf', cf)

test(
  'configure file',
  py3,
  args : [files('test.py'), 'cf'],
  env : ['PYTHONPATH=' + meson.current_build_dir()]
)

gen = generator(
  find_program('generator.py'),
  arguments : ['@INPUT@', '@OUTPUT@'],
  output : '@BASENAME@.pyx',
)

g_ext = py3.extension_module(
  'g',
  gen.process('g.in'),
)

test(
  'generator',
  py3,
  args : [files('test.py'), 'g'],
  env : ['PYTHONPATH=' + meson.current_build_dir()]
)

stuff_pxi = fs.copyfile(
  'stuff.pxi.in',
  'stuff.pxi'
)

# Need to copy the cython source to the build directory
# since meson can only generate the .pxi there
includestuff_pyx = fs.copyfile(
  'includestuff.pyx'
)

stuff_pxi_dep = declare_dependency(sources: stuff_pxi)

includestuff_ext = py3.extension_module(
  'includestuff',
  includestuff_pyx,
  dependencies: stuff_pxi_dep
)

simpleinclude_ext = py3.extension_module(
  'simpleinclude',
  'simpleinclude.pyx',
)

subdir('libdir')

test(
  'custom target in subdir',
  py3,
  args : [files('test.py'), 'ct2'],
  env : ['PYTHONPATH=' + pydir]
)