Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
167 lines (159 loc) · 4.77 KB
/
Copy pathmeson.build
File metadata and controls
167 lines (159 loc) · 4.77 KB
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
# 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
if host_machine.system() == 'darwin'
coretext = dependency('appleframeworks', modules: 'CoreText')
else
coretext = []
endif
extension_data = {
'_backend_agg': {
'subdir': 'matplotlib/backends',
'sources': files(
'_backend_agg.cpp',
'_backend_agg_wrapper.cpp',
),
'dependencies': [agg_dep, pybind11_dep],
},
'_c_internal_utils': {
'subdir': 'matplotlib',
'sources': files(
'_c_internal_utils.cpp',
),
'dependencies': [pybind11_dep, dl, ole32, shell32, user32, coretext],
},
'ft2font': {
'subdir': 'matplotlib',
'sources': files(
'ft2font.cpp',
'ft2font_wrapper.cpp',
),
'dependencies': [
freetype_dep, libraqm_dep, pybind11_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.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(
'_path_wrapper.cpp',
),
'dependencies': [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],
},
}
if cpp.get_id() == 'msvc'
# This flag fixes some bugs with the macro processing, namely
# https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170#macro-arguments-are-unpacked
if cpp.has_argument('/Zc:preprocessor')
# This flag was added in MSVC 2019 version 16.5, which deprecated the one below.
new_preprocessor = '/Zc:preprocessor'
else
# Since we currently support any version of MSVC 2019 (vc142), we'll stick with the
# older flag, added in MSVC 2017 version 15.8.
new_preprocessor = '/experimental:preprocessor'
endif
else
new_preprocessor = []
endif
# Even though Meson defaults to hidden visibility, our bundled libraries like FreeType
# may themselves export their own symbols individually. So force all symbols other than
# the Python module initialization function to be hidden with a linker version script.
mapfile = 'hidden-symbols.map'
vflag = cc.get_supported_link_arguments([
'-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
])
foreach ext, kwargs : extension_data
additions = {
'cpp_args': [new_preprocessor] + kwargs.get('cpp_args', []),
'link_args': [vflag] + kwargs.get('link_args', []),
'link_depends': [mapfile] + kwargs.get('link_depends', []),
}
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'],
objc_args: ['-fobjc-arc'],
install: true,
)
endif