forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
197 lines (190 loc) · 5.78 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# NumPy include directory - needed in all submodules
# The try-except is needed because when things are split across drives on Windows, there
# is no relative path and an exception gets raised. There may be other such cases, so add
# a catch-all and switch to an absolute path. Relative paths are needed when for example
# a virtualenv is placed inside the source tree; Meson rejects absolute paths to places
# inside the source tree.
# For cross-compilation it is often not possible to run the Python interpreter in order
# to retrieve numpy's include directory. It can be specified in the cross file instead:
#
# [properties]
# numpy-include-dir = /abspath/to/host-pythons/site-packages/numpy/core/include
#
# This uses the path as is, and avoids running the interpreter.
incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
if incdir_numpy == 'not-given'
incdir_numpy = run_command(py3,
[
'-c',
'''import os
import numpy as np
try:
incdir = os.path.relpath(np.get_include())
except Exception:
incdir = np.get_include()
print(incdir)'''
],
check: true
).stdout().strip()
endif
numpy_dep = declare_dependency(
compile_args: [
'-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION',
# Allow NumPy's printf format specifiers in C++.
'-D__STDC_FORMAT_MACROS=1',
],
include_directories: include_directories(incdir_numpy),
dependencies: py3_dep,
)
# For cross-compilation it is often not possible to run the Python interpreter in order
# to retrieve the platform-specific /dev/null. It can be specified in the cross file
# instead:
#
# [properties]
# devnull = /dev/null
#
# This uses the value as is, and avoids running the interpreter.
devnull = meson.get_external_property('devnull', 'not-given')
if devnull == 'not-given'
devnull = run_command(py3, '-c', 'import os; print(os.devnull)',
capture: true, check: true).stdout().strip()
endif
# Will only exist on Linux with older glibc.
dl = dependency('dl', required: false)
# With Meson >= 1.2.0, use cpp_winlibs instead of manually searching.
if ['cygwin', 'windows'].contains(host_machine.system())
comctl32 = cc.find_library('comctl32')
ole32 = cc.find_library('ole32')
psapi = cc.find_library('psapi')
shell32 = cc.find_library('shell32')
user32 = cc.find_library('user32')
else
comctl32 = []
ole32 = []
psapi = []
shell32 = []
user32 = []
endif
extension_data = {
'_backend_agg': {
'subdir': 'matplotlib/backends',
'sources': files(
'py_converters.cpp',
'_backend_agg.cpp',
'_backend_agg_wrapper.cpp',
),
'dependencies': [agg_dep, numpy_dep, freetype_dep],
},
'_c_internal_utils': {
'subdir': 'matplotlib',
'sources': files(
'_c_internal_utils.cpp',
),
'dependencies': [pybind11_dep, dl, ole32, shell32, user32],
},
'ft2font': {
'subdir': 'matplotlib',
'sources': files(
'ft2font.cpp',
'ft2font_wrapper.cpp',
'py_converters.cpp',
),
'dependencies': [
freetype_dep, numpy_dep, agg_dep.partial_dependency(includes: true),
],
'cpp_args': [
'-DFREETYPE_BUILD_TYPE="@0@"'.format(
freetype_dep.type_name() == 'internal' ? 'local' : 'system',
),
],
},
'_image': {
'subdir': 'matplotlib',
'sources': files(
'_image_wrapper.cpp',
'py_converters_11.cpp',
),
'dependencies': [
pybind11_dep,
# Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp
agg_dep,
],
},
'_path': {
'subdir': 'matplotlib',
'sources': files(
'py_converters.cpp',
'py_converters_11.cpp',
'_path_wrapper.cpp',
),
'dependencies': [numpy_dep, agg_dep, pybind11_dep],
},
'_qhull': {
'subdir': 'matplotlib',
'sources': files(
'_qhull_wrapper.cpp',
),
'dependencies': [pybind11_dep, qhull_dep],
'c_args': [f'-DMPL_DEVNULL=@devnull@'],
'cpp_args': [f'-DMPL_DEVNULL=@devnull@'],
},
'_tkagg': {
'subdir': 'matplotlib/backends',
'sources': files(
'_tkagg.cpp',
),
'include_directories': include_directories('.'),
# The dl/psapi libraries are needed for finding Tcl/Tk at run time.
'dependencies': [
pybind11_dep, agg_dep.partial_dependency(includes: true), dl, comctl32, psapi,
],
},
'_tri': {
'subdir': 'matplotlib',
'sources': files(
'tri/_tri.cpp',
'tri/_tri_wrapper.cpp',
),
'dependencies': [pybind11_dep],
},
'_ttconv': {
'subdir': 'matplotlib',
'sources': files(
'_ttconv.cpp',
),
'dependencies': [ttconv_dep, pybind11_dep],
},
}
cpp_special_arguments = []
if cpp.get_id() == 'msvc' and get_option('buildtype') != 'plain'
# Disable FH4 Exception Handling implementation so that we don't require
# VCRUNTIME140_1.dll. For more details, see:
# https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/
# https://github.com/joerick/cibuildwheel/issues/423#issuecomment-677763904
cpp_special_arguments += ['/d2FH4-']
endif
foreach ext, kwargs : extension_data
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each extension.
unique_array_api = '-DPY_ARRAY_UNIQUE_SYMBOL=MPL_@0@_ARRAY_API'.format(ext.replace('.', '_'))
additions = {
'c_args': [unique_array_api] + kwargs.get('c_args', []),
'cpp_args': cpp_special_arguments + [unique_array_api] + kwargs.get('cpp_args', []),
}
py3.extension_module(
ext,
install: true,
kwargs: kwargs + additions)
endforeach
if get_option('macosx') and host_machine.system() == 'darwin'
add_languages('objc', native: false)
py3.extension_module(
'_macosx',
subdir: 'matplotlib/backends',
sources: files(
'_macosx.m',
),
dependencies: dependency('appleframeworks', modules: 'Cocoa'),
override_options: ['werror=true'],
install: true,
)
endif