... |
... |
@@ -13,9 +13,10 @@ |
13
|
13
|
|
14
|
14
|
|
15
|
15
|
project('freetype2', 'c',
|
16
|
|
- version: '2.10.4',
|
17
|
16
|
meson_version: '>= 0.55.0',
|
18
|
17
|
default_options: ['default_library=both'],
|
|
18
|
+ version: run_command('builds/meson/extract_freetype_version.py',
|
|
19
|
+ 'include/freetype/freetype.h').stdout().strip(),
|
19
|
20
|
)
|
20
|
21
|
|
21
|
22
|
#
|
... |
... |
@@ -29,16 +30,12 @@ project('freetype2', 'c', |
29
|
30
|
python = import('python')
|
30
|
31
|
python_exe = python.find_installation(required: true)
|
31
|
32
|
|
32
|
|
-ft2_version = run_command(python_exe,
|
33
|
|
- files('builds/meson/extract_freetype_version.py'),
|
34
|
|
- files('include/freetype/freetype.h')).stdout().strip()
|
35
|
|
-
|
36
|
33
|
ft2_so_version = run_command(python_exe,
|
37
|
34
|
files('builds/meson/extract_libtool_version.py'),
|
38
|
35
|
'--soversion',
|
39
|
36
|
files('builds/unix/configure.raw')).stdout().strip()
|
40
|
37
|
|
41
|
|
-ft2_libtool_version = run_command(python_exe,
|
|
38
|
+ft2_pkgconfig_version = run_command(python_exe,
|
42
|
39
|
files('builds/meson/extract_libtool_version.py'),
|
43
|
40
|
files('builds/unix/configure.raw')).stdout().strip()
|
44
|
41
|
|
... |
... |
@@ -173,7 +170,7 @@ ft2_config_headers = files([ |
173
|
170
|
'include/freetype/config/public-macros.h',
|
174
|
171
|
])
|
175
|
172
|
|
176
|
|
-ft2_defines = []
|
|
173
|
+ft2_defines = ['-DFT2_BUILD_LIBRARY=1']
|
177
|
174
|
|
178
|
175
|
|
179
|
176
|
# System support file.
|
... |
... |
@@ -185,13 +182,6 @@ has_unistd_h = cc.has_header('unistd.h') |
185
|
182
|
has_fcntl_h = cc.has_header('fcntl.h')
|
186
|
183
|
has_sys_mman_h = cc.has_header('sys/mman.h')
|
187
|
184
|
|
188
|
|
-if has_unistd_h
|
189
|
|
- ft2_defines += ['-DHAVE_UNISTD_H=1']
|
190
|
|
-endif
|
191
|
|
-if has_fcntl_h
|
192
|
|
- ft2_defines += ['-DHAVE_FCNTL_H']
|
193
|
|
-endif
|
194
|
|
-
|
195
|
185
|
mmap_option = get_option('mmap')
|
196
|
186
|
if mmap_option.auto()
|
197
|
187
|
use_mmap = has_unistd_h and has_fcntl_h and has_sys_mman_h
|
... |
... |
@@ -218,49 +208,42 @@ endif |
218
|
208
|
# into `ftsystem.c` as well.
|
219
|
209
|
#
|
220
|
210
|
if host_machine.system() == 'windows'
|
221
|
|
- ft2_debug_src = 'builds/windows/ftdebug.c'
|
|
211
|
+ winmod = import('windows')
|
|
212
|
+ ft2_sources += [
|
|
213
|
+ 'builds/windows/ftdebug.c',
|
|
214
|
+ winmod.compile_resources('src/base/ftver.rc'),
|
|
215
|
+ ]
|
222
|
216
|
else
|
223
|
|
- ft2_debug_src = 'src/base/ftdebug.c'
|
|
217
|
+ ft2_sources += 'src/base/ftdebug.c'
|
224
|
218
|
endif
|
225
|
|
-ft2_sources += files([ft2_debug_src])
|
226
|
219
|
|
227
|
220
|
ft2_deps = []
|
228
|
221
|
|
229
|
222
|
|
230
|
223
|
# Generate `ftoption.h` based on available dependencies.
|
231
|
224
|
|
232
|
|
-ftoption_command = [python_exe,
|
|
225
|
+process_header_command = [python_exe,
|
233
|
226
|
files('builds/meson/process_ftoption_h.py'),
|
234
|
227
|
'@INPUT@', '--output=@OUTPUT@']
|
|
228
|
+ftoption_command = process_header_command
|
|
229
|
+
|
235
|
230
|
|
236
|
231
|
# GZip support
|
237
|
|
-have_zlib='no'
|
238
|
|
-zlib_option = get_option('zlib')
|
239
|
|
-if zlib_option == 'disabled'
|
240
|
|
- ftoption_command += ['--disable=FT_CONFIG_OPTION_USE_ZLIB']
|
241
|
|
-else
|
242
|
|
- have_zlib='yes'
|
243
|
|
- ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_ZLIB']
|
244
|
|
- if zlib_option == 'builtin'
|
245
|
|
- ftoption_command += ['--disable=FT_CONFIG_OPTION_SYSTEM_ZLIB']
|
246
|
|
- else
|
247
|
|
- # Probe for the system version.
|
248
|
|
- zlib_system = dependency('zlib', required: zlib_option == 'system')
|
249
|
|
- ft2_deps += [zlib_system]
|
250
|
|
- ftoption_command += ['--enable=FT_CONFIG_OPTION_SYSTEM_ZLIB']
|
251
|
|
- endif
|
|
232
|
+zlib_dep = dependency('zlib', required: get_option('zlib'),
|
|
233
|
+ fallback: ['zlib', 'zlib_dep'])
|
|
234
|
+if zlib_dep.found()
|
|
235
|
+ ftoption_command += [
|
|
236
|
+ '--enable=FT_CONFIG_OPTION_USE_ZLIB',
|
|
237
|
+ '--enable=FT_CONFIG_OPTION_SYSTEM_ZLIB',
|
|
238
|
+ ]
|
252
|
239
|
ft2_sources += files(['src/gzip/ftgzip.c',])
|
|
240
|
+ ft2_deps += [zlib_dep]
|
|
241
|
+else
|
|
242
|
+ ftoption_command += ['--disable=FT_CONFIG_OPTION_USE_ZLIB']
|
253
|
243
|
endif
|
254
|
244
|
|
255
|
245
|
# BZip2 support
|
256
|
|
-#
|
257
|
|
-# IMPORTANT NOTE: Without `static: false` here, Meson will find both the
|
258
|
|
-# static library version and the shared library version when they are
|
259
|
|
-# installed on the system, and will try to link them *both* to the final
|
260
|
|
-# library!
|
261
|
|
-bzip2_dep = meson.get_compiler('c').find_library('bz2',
|
262
|
|
- static: false,
|
263
|
|
- required: get_option('bzip2'))
|
|
246
|
+bzip2_dep = cc.find_library('bz2', required: get_option('bzip2'))
|
264
|
247
|
if bzip2_dep.found()
|
265
|
248
|
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_BZIP2']
|
266
|
249
|
ft2_sources += files(['src/bzip2/ftbzip2.c',])
|
... |
... |
@@ -277,7 +260,10 @@ endif |
277
|
260
|
# Harfbuzz support
|
278
|
261
|
harfbuzz_dep = dependency('harfbuzz',
|
279
|
262
|
version: '>= 2.0.0',
|
280
|
|
- required: get_option('harfbuzz'))
|
|
263
|
+ required: get_option('harfbuzz'),
|
|
264
|
+ fallback: ['harfbuzz', 'libharfbuzz_dep'],
|
|
265
|
+ default_options : ['freetype=disabled',
|
|
266
|
+ 'fontconfig=disabled'])
|
281
|
267
|
if harfbuzz_dep.found()
|
282
|
268
|
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_HARFBUZZ']
|
283
|
269
|
ft2_deps += [harfbuzz_dep]
|
... |
... |
@@ -299,39 +285,43 @@ ftoption_h = custom_target('ftoption.h', |
299
|
285
|
install_dir: 'include/freetype2/freetype/config',
|
300
|
286
|
)
|
301
|
287
|
ft2_sources += ftoption_h
|
302
|
|
-
|
303
|
|
-
|
304
|
|
-# QUESTION: What if the compiler doesn't support `-D` but uses `/D` instead
|
305
|
|
-# as on Windows?
|
306
|
|
-#
|
307
|
|
-# Other build systems have something like c_defines to list defines in a
|
308
|
|
-# more portable way. For now assume the compiler supports `-D` (hint: Visual
|
309
|
|
-# Studio does).
|
310
|
|
-ft2_defines += ['-DFT2_BUILD_LIBRARY=1']
|
|
288
|
+ft2_defines += ['-DFT_CONFIG_OPTIONS_H=<ftoption.h>']
|
311
|
289
|
|
312
|
290
|
if host_machine.system() == 'windows'
|
313
|
291
|
ft2_defines += ['-DDLL_EXPORT=1']
|
314
|
292
|
endif
|
315
|
293
|
|
|
294
|
+# Generate `ftconfig.h`
|
316
|
295
|
|
317
|
|
-# Ensure that the `ftoption.h` file generated above will be used to build
|
318
|
|
-# FreeType. Unfortunately, and very surprisingly, configure_file() does not
|
319
|
|
-# support putting the output file in a sub-directory, so we have to override
|
320
|
|
-# the default which is `<freetype/config/ftoption.h>`.
|
321
|
|
-#
|
322
|
|
-# It would be cleaner to generate the file directly into
|
323
|
|
-# `${MESON_BUILD_DIR}/freetype/config/ftoption.h`. See
|
324
|
|
-# 'https://github.com/mesonbuild/meson/issues/2320' for details.
|
325
|
|
-ft2_defines += ['-DFT_CONFIG_OPTIONS_H=<ftoption.h>']
|
|
296
|
+ftconfig_command = process_header_command
|
|
297
|
+if has_unistd_h
|
|
298
|
+ ftconfig_command += '--enable=HAVE_UNISTD_H'
|
|
299
|
+endif
|
|
300
|
+if has_fcntl_h
|
|
301
|
+ ftconfig_command += '--enable=HAVE_FCNTL_H'
|
|
302
|
+endif
|
326
|
303
|
|
327
|
|
-ft2_c_args = ft2_defines
|
328
|
|
-if cc.has_function_attribute('visibility:hidden')
|
329
|
|
- ft2_c_args += ['-fvisibility=hidden']
|
|
304
|
+if host_machine.system() in ['linux', 'darwin', 'cygwin']
|
|
305
|
+ ftconfig_h_in = files('builds/unix/ftconfig.h.in')
|
|
306
|
+else
|
|
307
|
+ ftconfig_h_in = files('include/freetype/config/ftconfig.h')
|
330
|
308
|
endif
|
331
|
309
|
|
|
310
|
+ftconfig_h = custom_target('ftconfig.h',
|
|
311
|
+ input: ftconfig_h_in,
|
|
312
|
+ output: 'ftconfig.h',
|
|
313
|
+ command: ftconfig_command,
|
|
314
|
+ install: true,
|
|
315
|
+ install_dir: 'include/freetype2/freetype/config',
|
|
316
|
+)
|
|
317
|
+ft2_sources += ftconfig_h
|
|
318
|
+ft2_defines += ['-DFT_CONFIG_CONFIG_H=<ftconfig.h>']
|
|
319
|
+
|
|
320
|
+
|
332
|
321
|
ft2_lib = library('freetype',
|
333
|
322
|
sources: ft2_sources + [ftmodule_h],
|
334
|
|
- c_args: ft2_c_args,
|
|
323
|
+ c_args: ft2_defines,
|
|
324
|
+ gnu_symbol_visibility: 'hidden',
|
335
|
325
|
include_directories: ft2_includes,
|
336
|
326
|
dependencies: ft2_deps,
|
337
|
327
|
install: true,
|
... |
... |
@@ -343,7 +333,8 @@ ft2_lib = library('freetype', |
343
|
333
|
freetype2_dep = declare_dependency(
|
344
|
334
|
include_directories: ft2_includes,
|
345
|
335
|
link_with: ft2_lib,
|
346
|
|
- version: ft2_so_version)
|
|
336
|
+ version: ft2_pkgconfig_version)
|
|
337
|
+meson.override_dependency('freetype2', freetype2_dep)
|
347
|
338
|
|
348
|
339
|
|
349
|
340
|
# NOTE: Using both `install_dir` and `subdir` doesn't seem to work below,
|
... |
... |
@@ -357,8 +348,6 @@ install_headers(ft2_config_headers, |
357
|
348
|
install_dir: 'include/freetype2/freetype/config')
|
358
|
349
|
|
359
|
350
|
|
360
|
|
-# TODO(david): Declare_dependency() for using this in a Meson subproject
|
361
|
|
-#
|
362
|
351
|
pkgconfig = import('pkgconfig')
|
363
|
352
|
pkgconfig.generate(ft2_lib,
|
364
|
353
|
filebase: 'freetype2',
|
... |
... |
@@ -366,7 +355,7 @@ pkgconfig.generate(ft2_lib, |
366
|
355
|
description: 'A free, high-quality, and portable font engine.',
|
367
|
356
|
url: 'https://freetype.org',
|
368
|
357
|
subdirs: 'freetype2',
|
369
|
|
- version: ft2_libtool_version,
|
|
358
|
+ version: ft2_pkgconfig_version,
|
370
|
359
|
)
|
371
|
360
|
|
372
|
361
|
|
... |
... |
@@ -378,7 +367,7 @@ gen_docs = custom_target('freetype2 reference documentation', |
378
|
367
|
input: ft2_public_headers + ft2_config_headers,
|
379
|
368
|
command: [python_exe,
|
380
|
369
|
files('builds/meson/generate_reference_docs.py'),
|
381
|
|
- '--version=' + ft2_version,
|
|
370
|
+ '--version=' + meson.project_version(),
|
382
|
371
|
'--input-dir=' + meson.source_root(),
|
383
|
372
|
'--output-dir=@OUTPUT@'
|
384
|
373
|
],
|
... |
... |
@@ -386,7 +375,7 @@ gen_docs = custom_target('freetype2 reference documentation', |
386
|
375
|
|
387
|
376
|
|
388
|
377
|
summary({'OS': host_machine.system(),
|
389
|
|
- 'Zlib': have_zlib,
|
|
378
|
+ 'Zlib': zlib_dep.found() ? 'yes' : 'no',
|
390
|
379
|
'Bzip2': bzip2_dep.found() ? 'yes' : 'no',
|
391
|
380
|
'Png': libpng_dep.found() ? 'yes' : 'no',
|
392
|
381
|
'Harfbuzz': harfbuzz_dep.found() ? 'yes' : 'no',
|