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