-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmeson.build
132 lines (118 loc) · 4.87 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# replace the version by running:
# meson rewrite kwargs set project / version $(python scripts/extract_version.py)
project(
'pymmcore-nano',
'cpp',
version : '11.2.1.71.0.dev3',
meson_version : '>= 1.2.0',
default_options : ['cpp_std=c++17']
)
py = import('python').find_installation()
nanobind_dep = dependency('nanobind', static: true)
# Run a command to get the Python include path
python_include_path = run_command(
py.full_path(), ['-c', 'import sysconfig; print(sysconfig.get_paths()["include"])']
).stdout().strip()
# Include directories
include_dirs = include_directories(
'src/mmCoreAndDevices/MMCore',
'src/mmCoreAndDevices/MMCore/Devices',
'src/mmCoreAndDevices/MMCore/LibraryInfo',
'src/mmCoreAndDevices/MMCore/LoadableModules',
'src/mmCoreAndDevices/MMCore/Logging',
'src/mmCoreAndDevices/MMDevice',
python_include_path,
)
mmcore_sources = files(
'src/mmCoreAndDevices/MMCore/CircularBuffer.cpp',
'src/mmCoreAndDevices/MMCore/Configuration.cpp',
'src/mmCoreAndDevices/MMCore/CoreCallback.cpp',
'src/mmCoreAndDevices/MMCore/CoreFeatures.cpp',
'src/mmCoreAndDevices/MMCore/CoreProperty.cpp',
'src/mmCoreAndDevices/MMCore/DeviceManager.cpp',
'src/mmCoreAndDevices/MMCore/Devices/AutoFocusInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/CameraInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/DeviceInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/GalvoInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/HubInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/ImageProcessorInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/MagnifierInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/SerialInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/ShutterInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/SignalIOInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/SLMInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/StageInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/StateInstance.cpp',
'src/mmCoreAndDevices/MMCore/Devices/XYStageInstance.cpp',
'src/mmCoreAndDevices/MMCore/Error.cpp',
'src/mmCoreAndDevices/MMCore/FrameBuffer.cpp',
'src/mmCoreAndDevices/MMCore/LibraryInfo/LibraryPathsUnix.cpp',
'src/mmCoreAndDevices/MMCore/LibraryInfo/LibraryPathsWindows.cpp',
'src/mmCoreAndDevices/MMCore/LoadableModules/LoadedDeviceAdapter.cpp',
'src/mmCoreAndDevices/MMCore/LoadableModules/LoadedModule.cpp',
'src/mmCoreAndDevices/MMCore/LoadableModules/LoadedModuleImpl.cpp',
'src/mmCoreAndDevices/MMCore/LoadableModules/LoadedModuleImplUnix.cpp',
'src/mmCoreAndDevices/MMCore/LoadableModules/LoadedModuleImplWindows.cpp',
'src/mmCoreAndDevices/MMCore/Logging/Metadata.cpp',
'src/mmCoreAndDevices/MMCore/LogManager.cpp',
'src/mmCoreAndDevices/MMCore/MMCore.cpp',
'src/mmCoreAndDevices/MMCore/PluginManager.cpp',
'src/mmCoreAndDevices/MMCore/Semaphore.cpp',
'src/mmCoreAndDevices/MMCore/Task.cpp',
'src/mmCoreAndDevices/MMCore/TaskSet_CopyMemory.cpp',
'src/mmCoreAndDevices/MMCore/TaskSet.cpp',
'src/mmCoreAndDevices/MMCore/ThreadPool.cpp',
'src/mmCoreAndDevices/MMDevice/Debayer.cpp',
'src/mmCoreAndDevices/MMDevice/DeviceUtils.cpp',
'src/mmCoreAndDevices/MMDevice/ImgBuffer.cpp',
'src/mmCoreAndDevices/MMDevice/MMDevice.cpp',
'src/mmCoreAndDevices/MMDevice/ModuleInterface.cpp',
'src/mmCoreAndDevices/MMDevice/Property.cpp',
)
# ---------- patch c++14 to c++17 ----------
run_command(py.full_path(), 'scripts/patch_sources.py', check: true)
# --------------------------
cpp_args = ['-DMMDEVICE_CLIENT_BUILD', '-DMATCH_SWIG']
if host_machine.system() == 'windows'
cpp_args += ['-DNOMINMAX', '-D_CRT_SECURE_NO_WARNINGS']
endif
ext_module = py.extension_module(
'_pymmcore_nano',
sources: ['src/_pymmcore_nano.cc'] + mmcore_sources,
dependencies: [nanobind_dep],
include_directories: include_dirs,
install: true,
cpp_args: cpp_args + ['-DNB_DOMAIN=pmn'],
)
# Create stubs using nanobind.stubgen
custom_target(
'generate_stubs',
build_by_default: true,
input: [ext_module],
output: '_pymmcore_nano.pyi',
command: [
py.full_path(),
meson.project_source_root() + '/scripts/build_stubs.py',
ext_module.full_path(),
meson.project_source_root() + '/src/_pymmcore_nano.pyi',
],
depends: ext_module,
)
# install the Python package into the site-packages directory
install_subdir(
'src/pymmcore_nano',
install_dir: py.get_install_dir() / 'pymmcore_nano',
strip_directory: true,
)
# also install the stubs into the site-packages directory
install_data(
'src/_pymmcore_nano.pyi',
install_dir: py.get_install_dir(),
)
test(
'test_script',
py,
args: ['-m', 'pytest', '--color=yes', '-v'],
workdir: meson.current_source_dir(),
)
meson.add_dist_script(py.full_path(), meson.current_source_dir() / 'scripts/generate_dist.py')