-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeson.build
61 lines (52 loc) · 1.83 KB
/
meson.build
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
project(
'pymmdevice',
'cpp',
version: '0.1.0',
license: 'BSD',
meson_version: '>= 1.1.0',
default_options: [
'cpp_std=c++14',
],
)
py = import('python').find_installation(pure: false)
pybind11_dep = dependency('pybind11')
# Execute the Python script to get the list of include directories
print_include_dirs = '''
import pathlib
m = pathlib.Path('extern/mmCoreAndDevices')
headers = (*(m/'MMDevice').rglob('*.h'), *(m/'MMCore').rglob('*.h'))
print(';'.join({str(x.parent) for x in headers}))
'''
include_dirs_list = run_command(py.full_path(), '-c', print_include_dirs, check: true).stdout().strip().split(';')
include_dirs = include_directories(include_dirs_list, is_system: true)
foreach dir : include_dirs_list
message('Including: ' + dir)
endforeach
# all necessary CPP files
cpp_sources = ['src/bindings/_pymmdevice.cpp']
print_sources = '''
import pathlib
m = pathlib.Path('extern/mmCoreAndDevices')
sources = (*(m/'MMDevice').rglob('*.cpp'), *(m/'MMCore').rglob('*.cpp'))
print(';'.join({str(x) for x in sources if 'unittest' not in str(x)}))
'''
cpp_sources += run_command(py.full_path(), '-c', print_sources, check: true).stdout().strip().split(';')
cpp_args = ['-DMMDEVICE_CLIENT_BUILD']
if host_machine.system() == 'windows'
cpp_args += ['-DNOMINMAX', '-D_CRT_SECURE_NO_WARNINGS']
endif
py.extension_module('_pymmdevice',
files(cpp_sources),
subdir: 'pymmdevice',
install: true,
dependencies : [pybind11_dep],
include_directories: include_dirs,
cpp_args: cpp_args
)
# install the Python package into the site-packages directory
install_subdir('src/pymmdevice', install_dir: py.get_install_dir() / 'pymmdevice', strip_directory: true)
test('test_script',
py,
args: ['-m', 'pytest', '--color=yes', '-v', '--cov=pymmdevice', '--cov-report=xml'],
workdir: meson.current_source_dir()
)