1
1
project (' libffi' , ' c' , version : ' 3.4.4' ,
2
- meson_version : ' >= 0.64.0' ,
3
- default_options : [' buildtype=debugoptimized' ,
2
+ meson_version : ' >= 0.56.0' ,
3
+ default_options : [' debug=true' ,
4
+ ' optimization=3' ,
4
5
' warning_level=1' ])
5
6
6
7
fs = import (' fs' )
7
8
8
9
libtool_version = run_command (' meson-scripts/extract-libtool-version.py' ,
9
10
meson .current_source_dir() / ' libtool-version' ,
10
- check : true ).stdout().split(' :' )
11
+ check : true ).stdout().strip(). split(' :' )
11
12
current = libtool_version[0 ].to_int()
12
13
revision = libtool_version[1 ].to_int()
13
14
age = libtool_version[2 ].to_int()
@@ -20,6 +21,7 @@ host_cpu_family = host_machine.cpu_family()
20
21
host_system = host_machine .system()
21
22
22
23
cc = meson .get_compiler(' c' )
24
+ is_msvc = cc.get_id() == ' msvc'
23
25
is_msvc_like = cc.get_argument_syntax() == ' msvc'
24
26
is_gnu_like = cc.get_argument_syntax() == ' gcc'
25
27
@@ -82,67 +84,72 @@ have_long_double_variant = false
82
84
if host_cpu_family == ' aarch64' and host_system in [' cygwin' , ' windows' ]
83
85
target = ' ARM_WIN64'
84
86
targetdir = ' aarch64'
85
- if is_msvc_like
87
+ if is_msvc
86
88
asm_sources = [' win64_armasm.S' ]
87
89
endif
88
90
elif host_cpu_family == ' aarch64'
89
91
target = ' AARCH64'
90
- elif host_cpu_family.startswith( ' alpha' )
92
+ elif host_cpu_family == ' alpha'
91
93
target = ' ALPHA'
92
94
asm_sources = [' osf.S' ]
93
95
# Support 128-bit long double, changeable via command-line switch.
94
96
have_long_double = ' defined(__LONG_DOUBLE_128__)'
95
- elif host_cpu_family.startswith( ' arc' )
97
+ elif host_cpu_family == ' arc'
96
98
target = ' ARC'
97
99
asm_sources = [' arcompact.S' ]
98
100
elif host_cpu_family == ' arm' and host_system in [' cygwin' , ' windows' ]
99
101
target = ' ARM_WIN32'
100
102
targetdir = ' arm'
101
- if is_msvc_like
103
+ if is_msvc
102
104
asm_sources = [' sysv_msvc_arm32.S' ]
103
105
endif
104
106
elif host_cpu_family == ' arm'
105
107
target = ' ARM'
106
- elif host_cpu_family.startswith( ' avr32 ' )
108
+ elif host_cpu_family == ' avr '
107
109
target = ' AVR32'
108
- elif host_cpu_family.startswith(' bfin' )
110
+ elif host_cpu_family == ' bfin'
111
+ # FIXME: bfin family is missing in Meson
109
112
target = ' BFIN'
110
113
elif host_cpu_family == ' cris'
114
+ # FIXME: cris family is missing in Meson
111
115
target = ' LIBFFI_CRIS'
112
116
targetdir = ' cris'
113
117
elif host_cpu_family == ' csky'
114
118
target = ' CSKY'
115
119
elif host_cpu_family == ' frv'
120
+ # FIXME: frv family is missing in Meson
116
121
target = ' FRV'
117
122
asm_sources = [' eabi.S' ]
118
- elif (host_cpu_family.startswith(' hppa' ) and host_system in [' linux' , ' openbsd' ]) or \
119
- (host_cpu_family.startswith(' parisc' ) and host_system == ' linux' )
123
+ elif (host_cpu_family in [' hppa' , ' hppa64' ] and host_system in [' linux' , ' openbsd' ]) or \
124
+ (host_cpu_family == ' parisc' and host_system == ' linux' )
125
+ # FIXME: hppa family is missing in Meson
120
126
target = ' PA_LINUX'
121
127
targetdir = ' pa'
122
128
asm_sources = [' linux.S' ]
123
- elif host_cpu_family.startswith(' hppa' ) and not ' 64' in host_cpu_family and host_system in [' hpux' ]
129
+ elif host_cpu_family == ' hppa' and host_system in [' hpux' ]
130
+ # FIXME: hppa family is missing in Meson
124
131
target = ' PA_HPUX'
125
132
targetdir = ' pa'
126
133
asm_sources = [' hpux32.S' ]
127
134
elif host_cpu_family == ' x86' and host_system in [' freebsd' , ' openbsd' ]
128
135
target = ' X86_FREEBSD'
129
136
targetdir = ' x86'
130
- if is_msvc_like
137
+ if is_msvc
131
138
asm_sources = [' sysv_intel.S' ]
132
139
endif
133
140
elif (host_cpu_family == ' x86' and host_system in [' cygwin' , ' windows' , ' os2' , ' interix' ]) or \
134
141
(host_cpu_family == ' x86_64' and host_system in [' cygwin' , ' windows' ])
135
142
targetdir = ' x86'
136
143
if size_t == 4
137
144
target = ' X86_WIN32'
138
- if is_msvc_like
145
+ if is_msvc
139
146
asm_sources = [' sysv_intel.S' ]
140
147
masm_args += ' /safeseh'
141
148
endif
142
149
else
143
150
target = ' X86_WIN64'
144
151
c_sources = [' ffiw64.c' ]
145
- if is_msvc_like
152
+ if is_msvc
146
153
asm_sources = [' win64_intel.S' ]
147
154
else
148
155
asm_sources = [' win64.S' ]
@@ -152,7 +159,7 @@ elif host_cpu_family in ['x86', 'x86_64'] and host_system in ['darwin', 'ios']
152
159
targetdir = ' x86'
153
160
if size_t == 4
154
161
target = ' X86_DARWIN'
155
- if is_msvc_like
162
+ if is_msvc
156
163
asm_sources = [' sysv_intel.S' ]
157
164
endif
158
165
else
@@ -169,7 +176,7 @@ elif host_cpu_family in ['x86', 'x86_64']
169
176
asm_sources = [' unix64.S' , ' win64.S' ]
170
177
else
171
178
target = ' X86'
172
- if is_msvc_like
179
+ if is_msvc
173
180
asm_sources = [' sysv_intel.S' ]
174
181
endif
175
182
endif
@@ -178,10 +185,11 @@ elif host_cpu_family in ['x86', 'x86_64']
178
185
c_sources = [' ffi64.c' , ' ffiw64.c' ]
179
186
asm_sources = [' unix64.S' , ' win64.S' ]
180
187
endif
181
- elif host_cpu_family.startswith( ' ia64' )
188
+ elif host_cpu_family == ' ia64'
182
189
target = ' IA64'
183
190
asm_sources = [' unix.S' ]
184
191
elif host_cpu_family == ' kvx'
192
+ # FIXME: kvx family is missing in Meson
185
193
target = ' KVX'
186
194
elif host_cpu_family == ' loongarch64'
187
195
target = ' LOONGARCH64'
@@ -190,76 +198,84 @@ elif host_cpu_family.startswith('m32r')
190
198
elif host_cpu_family == ' m68k'
191
199
target = ' M68K'
192
200
elif host_cpu_family == ' m88k'
201
+ # FIXME: m88k family is missing in Meson
193
202
target = ' M88K'
194
203
asm_sources = [' obsd.S' ]
195
- elif host_cpu_family.startswith( ' microblaze' )
204
+ elif host_cpu_family == ' microblaze'
196
205
target = ' MICROBLAZE'
197
206
elif host_cpu_family == ' moxie'
207
+ # This CPU family is used in CI cross compilation
198
208
target = ' MOXIE'
199
209
asm_sources = [' eabi.S' ]
200
210
elif host_cpu_family == ' metag'
211
+ # FIXME: metag family is missing in Meson
201
212
target = ' METAG'
202
- elif host_cpu_family.startswith( ' mips' ) and \
213
+ elif host_cpu_family in [ ' mips' , ' mips64 ' ] and \
203
214
(host_system.startswith(' irix5.' ) or host_system.startswith(' irix6.' ) or host_system.startswith(' rtems' ))
204
215
target = ' MIPS'
205
216
asm_sources = [' o32.S' , ' n32.S' ]
206
- elif host_cpu_family.startswith( ' mips' ) and host_system in [' linux' , ' openbsd' , ' freebsd' ]
217
+ elif host_cpu_family in [ ' mips' , ' mips64 ' ] and host_system in [' linux' , ' openbsd' , ' freebsd' ]
207
218
target = ' MIPS'
208
219
asm_sources = [' o32.S' , ' n32.S' ]
209
220
# Support 128-bit long double for NewABI.
210
221
have_long_double = ' defined(__mips64)'
211
- elif host_cpu_family.startswith(' nios2' ) and host_system == ' linux'
222
+ elif host_cpu_family == ' nios2' and host_system == ' linux'
223
+ # FIXME: nios2 family is missing in Meson
212
224
target = ' NIOS2'
213
- elif host_cpu_family.startswith(' or1k' )
225
+ elif host_cpu_family == ' or1k'
226
+ # FIXME: or1k family is missing in Meson
214
227
target = ' OR1K'
215
- elif (host_cpu_family.startswith( ' powerpc ' ) and \
228
+ elif (host_cpu_family in [ ' ppc ' , ' ppc64 ' ] and \
216
229
host_system in [' linux' , ' sysv' , ' amigaos' , ' eabi' , ' beos' , ' rtems' ]) or \
217
- (host_cpu_family in [ ' powerpc64 ' , ' powerpc64le ' ] and host_system == ' freebsd' )
230
+ (host_cpu_family == ' ppc64 ' and host_system == ' freebsd' )
218
231
target = ' POWERPC'
219
232
c_sources = [' ffi.c' , ' ffi_sysv.c' , ' ffi_linux64.c' ]
220
233
asm_sources = [' sysv.S' , ' ppc_closure.S' , ' linux64.S' , ' linux64_closure.S' ]
221
234
have_long_double_variant = true
222
- elif host_cpu_family.startswith( ' powerpc ' ) and host_system == ' darwin'
235
+ elif host_cpu_family in [ ' ppc ' , ' ppc64 ' ] and host_system == ' darwin'
223
236
target = ' POWERPC_DARWIN'
224
237
targetdir = ' powerpc'
225
238
c_sources = [' ffi_darwin.c' ]
226
239
asm_sources = [' darwin.S' , ' darwin_closure.S' ]
227
- elif host_cpu_family in [' powerpc ' , ' rs6000' ] and host_system in [' darwin' , ' aix' ]
240
+ elif host_cpu_family in [' ppc ' , ' rs6000' ] and host_system in [' darwin' , ' aix' ]
228
241
target = ' POWERPC_AIX'
229
242
targetdir = ' powerpc'
230
243
c_sources = [' ffi_darwin.c' ]
231
244
asm_sources = [' aix.S aix_closure.S' ]
232
- elif host_cpu_family == ' powerpc ' and host_system in [' freebsd' , ' openbsd' , ' netbsd' ]
245
+ elif host_cpu_family == ' ppc ' and host_system in [' freebsd' , ' openbsd' , ' netbsd' ]
233
246
target = ' POWERPC_FREEBSD'
234
247
targetdir = ' powerpc'
235
248
c_sources = [' ffi.c' , ' ffi_sysv.c' ]
236
249
asm_sources = [' sysv.S' , ' pc_closure.S' ]
237
- have_long_double_variant = true
238
- elif host_cpu_family == ' powerpcspe' and host_system == ' freebsd'
239
- target = ' POWERPC_FREEBSD'
240
- targetdir = ' powerpc'
241
- c_sources = [' ffi.c' , ' ffi_sysv.c' ]
242
- asm_sources = [' sysv.S' , ' pc_closure.S' ]
243
- add_project_arguments (' -D__NO_FPRS__' , language : ' c' )
244
- elif host_cpu_family.startswith(' riscv' )
250
+ if cc.get_define(' __SPE__' ) != ''
251
+ add_project_arguments (' -D__NO_FPRS__' , language : ' c' )
252
+ else
253
+ have_long_double_variant = true
254
+ endif
255
+ elif host_cpu_family in [' riscv32' , ' riscv64' ]
245
256
target = ' RISCV'
246
- elif host_cpu_family.startswith( ' s390' )
257
+ elif host_cpu_family in [ ' s390' , ' s390x ' ]
247
258
target = ' S390'
248
259
elif host_cpu_family == ' sh64' or host_cpu_family.startswith(' sh5' )
260
+ # FIXME: Meson only has sh4 family
249
261
target = ' SH64'
250
262
elif host_cpu_family.startswith(' sh' )
263
+ # FIXME: Meson only has sh4 family
251
264
target = ' SH'
252
- elif host_cpu_family.startswith( ' sparc' )
265
+ elif host_cpu_family in [ ' sparc' , ' sparc64 ' ]
253
266
target = ' SPARC'
254
267
c_sources = [' ffi.c' , ' ffi64.c' ]
255
268
asm_sources = [' v8.S' , ' v9.S' ]
256
- elif host_cpu_family.startswith(' tile' )
269
+ elif host_cpu_family == ' tile'
270
+ # FIXME: tile family is missing in Meson
257
271
target = ' TILE'
258
272
asm_sources = [' tile.S' ]
259
273
elif host_cpu_family == ' vax'
274
+ # FIXME: vax family is missing in Meson
260
275
target = ' VAX'
261
276
asm_sources = [' elfbsd.S' ]
262
- elif host_cpu_family.startswith(' xtensa' )
277
+ elif host_cpu_family == ' xtensa'
278
+ # FIXME: xtensa family is missing in Meson
263
279
target = ' XTENSA'
264
280
else
265
281
error (' Unsupported pair: system "@0@", cpu family "@1@"' .format(host_system, host_cpu_family))
@@ -421,7 +437,11 @@ if get_option('doc')
421
437
endif
422
438
423
439
if get_option (' tests' )
424
- subdir (' testsuite' )
440
+ if meson .version().version_compare(' >=0.58.0' )
441
+ subdir (' testsuite' )
442
+ else
443
+ error (' Meson >= 0.58 is required for unit tests' )
444
+ endif
425
445
endif
426
446
427
447
install_man ([
0 commit comments