Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/meson.build @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 project('harfbuzz', 'c', 'cpp', | |
| 2 meson_version: '>= 0.55.0', | |
| 3 version: '6.0.0', | |
| 4 default_options: [ | |
| 5 'cpp_rtti=false', # Just to support msvc, we are passing -fno-exceptions also anyway | |
| 6 'cpp_std=c++11', | |
| 7 'wrap_mode=nofallback', # Use --wrap-mode=default to revert, https://github.com/harfbuzz/harfbuzz/pull/2548 | |
| 8 ], | |
| 9 ) | |
| 10 | |
| 11 hb_version_arr = meson.project_version().split('.') | |
| 12 hb_version_major = hb_version_arr[0].to_int() | |
| 13 hb_version_minor = hb_version_arr[1].to_int() | |
| 14 hb_version_micro = hb_version_arr[2].to_int() | |
| 15 | |
| 16 # libtool versioning | |
| 17 hb_version_int = hb_version_major*10000 + hb_version_minor*100 + hb_version_micro | |
| 18 hb_libtool_version_info = '@0@:0:@0@'.format(hb_version_int) | |
| 19 | |
| 20 pkgmod = import('pkgconfig') | |
| 21 cpp = meson.get_compiler('cpp') | |
| 22 null_dep = dependency('', required: false) | |
| 23 | |
| 24 if cpp.get_argument_syntax() == 'msvc' | |
| 25 # Ignore several spurious warnings for things HarfBuzz does very commonly. | |
| 26 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it | |
| 27 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once | |
| 28 # NOTE: Only add warnings here if you are sure they're spurious | |
| 29 msvc_args = [ | |
| 30 '/wd4018', # implicit signed/unsigned conversion | |
| 31 '/wd4146', # unary minus on unsigned (beware INT_MIN) | |
| 32 '/wd4244', # lossy type conversion (e.g. double -> int) | |
| 33 '/wd4305', # truncating type conversion (e.g. double -> float) | |
| 34 cpp.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 | |
| 35 ] | |
| 36 add_project_arguments(msvc_args, language: ['c', 'cpp']) | |
| 37 # Disable SAFESEH with MSVC for libs that use external deps that are built with MinGW | |
| 38 # noseh_link_args = ['/SAFESEH:NO'] | |
| 39 # disable exception handling | |
| 40 add_project_arguments(['/EHs-', '/EHc-'], language: 'cpp') | |
| 41 endif | |
| 42 | |
| 43 add_project_link_arguments(cpp.get_supported_link_arguments([ | |
| 44 '-Bsymbolic-functions' | |
| 45 ]), language: 'c') | |
| 46 | |
| 47 add_project_arguments(cpp.get_supported_arguments([ | |
| 48 '-fno-exceptions', | |
| 49 '-fno-rtti', | |
| 50 '-fno-threadsafe-statics', | |
| 51 '-fvisibility-inlines-hidden', | |
| 52 ]), language: 'cpp') | |
| 53 | |
| 54 if host_machine.cpu_family() == 'arm' and cpp.alignment('struct { char c; }') != 1 | |
| 55 if cpp.has_argument('-mstructure-size-boundary=8') | |
| 56 add_project_arguments('-mstructure-size-boundary=8', language: 'cpp') | |
| 57 endif | |
| 58 endif | |
| 59 | |
| 60 if host_machine.system() == 'windows' | |
| 61 add_project_arguments(cpp.get_supported_arguments([ | |
| 62 '-Wa,-mbig-obj' | |
| 63 ]), language : 'cpp') | |
| 64 endif | |
| 65 | |
| 66 check_headers = [ | |
| 67 ['unistd.h'], | |
| 68 ['sys/mman.h'], | |
| 69 ['stdbool.h'], | |
| 70 ['xlocale.h'], | |
| 71 ] | |
| 72 | |
| 73 check_funcs = [ | |
| 74 ['atexit'], | |
| 75 ['mprotect'], | |
| 76 ['sysconf'], | |
| 77 ['getpagesize'], | |
| 78 ['mmap'], | |
| 79 ['isatty'], | |
| 80 ['uselocale'], | |
| 81 ['newlocale'], | |
| 82 ] | |
| 83 | |
| 84 m_dep = cpp.find_library('m', required: false) | |
| 85 | |
| 86 if meson.version().version_compare('>=0.60.0') | |
| 87 # pkg-config: freetype2, cmake: Freetype | |
| 88 freetype_dep = dependency('freetype2', 'Freetype', | |
| 89 required: get_option('freetype'), | |
| 90 default_options: ['harfbuzz=disabled'], | |
| 91 allow_fallback: true) | |
| 92 else | |
| 93 # painful hack to handle multiple dependencies but also respect options | |
| 94 freetype_opt = get_option('freetype') | |
| 95 # we want to handle enabled manually after fallbacks, but also handle disabled normally | |
| 96 if freetype_opt.enabled() | |
| 97 freetype_opt = false | |
| 98 endif | |
| 99 # try pkg-config name | |
| 100 freetype_dep = dependency('freetype2', method: 'pkg-config', required: freetype_opt) | |
| 101 # when disabled, leave it not-found | |
| 102 if not freetype_dep.found() and not get_option('freetype').disabled() | |
| 103 # Try cmake name | |
| 104 freetype_dep = dependency('Freetype', method: 'cmake', required: false) | |
| 105 # Subproject fallback, `allow_fallback: true` means the fallback will be | |
| 106 # tried even if the freetype option is set to `auto`. | |
| 107 if not freetype_dep.found() | |
| 108 freetype_dep = dependency('freetype2', | |
| 109 method: 'pkg-config', | |
| 110 required: get_option('freetype'), | |
| 111 default_options: ['harfbuzz=disabled'], | |
| 112 allow_fallback: true) | |
| 113 endif | |
| 114 endif | |
| 115 endif | |
| 116 | |
| 117 glib_dep = dependency('glib-2.0', required: get_option('glib')) | |
| 118 gobject_dep = dependency('gobject-2.0', required: get_option('gobject')) | |
| 119 graphite2_dep = dependency('graphite2', required: get_option('graphite2')) | |
| 120 graphite_dep = dependency('graphite2', required: get_option('graphite')) | |
| 121 | |
| 122 if meson.version().version_compare('>=0.60.0') | |
| 123 # pkg-config: icu-uc, cmake: ICU but with components | |
| 124 icu_dep = dependency('icu-uc', 'ICU', | |
| 125 components: 'uc', | |
| 126 required: get_option('icu'), | |
| 127 default_options: ['harfbuzz=disabled'], | |
| 128 allow_fallback: true) | |
| 129 else | |
| 130 # painful hack to handle multiple dependencies but also respect options | |
| 131 icu_opt = get_option('icu') | |
| 132 # we want to handle enabled manually after fallbacks, but also handle disabled normally | |
| 133 if icu_opt.enabled() | |
| 134 icu_opt = false | |
| 135 endif | |
| 136 # try pkg-config name | |
| 137 icu_dep = dependency('icu-uc', method: 'pkg-config', required: icu_opt) | |
| 138 # when disabled, leave it not-found | |
| 139 if not icu_dep.found() and not get_option('icu').disabled() | |
| 140 # Try cmake name | |
| 141 icu_dep = dependency('ICU', method: 'cmake', components: 'uc', required: false) | |
| 142 # Try again with subproject fallback. `allow_fallback: true` means the | |
| 143 # fallback will be tried even if the icu option is set to `auto`, but | |
| 144 # we cannot pass this option until Meson 0.59.0, because no wrap file | |
| 145 # is checked into git. | |
| 146 if not icu_dep.found() | |
| 147 icu_dep = dependency('icu-uc', | |
| 148 method: 'pkg-config', | |
| 149 required: get_option('icu')) | |
| 150 endif | |
| 151 endif | |
| 152 endif | |
| 153 | |
| 154 if icu_dep.found() and icu_dep.type_name() == 'pkgconfig' | |
| 155 icu_defs = icu_dep.get_variable(pkgconfig: 'DEFS', default_value: '').split() | |
| 156 if icu_defs.length() > 0 | |
| 157 add_project_arguments(icu_defs, language: ['c', 'cpp']) | |
| 158 endif | |
| 159 endif | |
| 160 | |
| 161 cairo_dep = null_dep | |
| 162 cairo_ft_dep = null_dep | |
| 163 if not get_option('cairo').disabled() | |
| 164 cairo_dep = dependency('cairo', required: false) | |
| 165 cairo_ft_dep = dependency('cairo-ft', required: false) | |
| 166 | |
| 167 if (not cairo_dep.found() and | |
| 168 cpp.get_argument_syntax() == 'msvc' and | |
| 169 cpp.has_header('cairo.h')) | |
| 170 cairo_dep = cpp.find_library('cairo', required: false) | |
| 171 if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face', | |
| 172 prefix: '#include <cairo-ft.h>', | |
| 173 dependencies: cairo_dep) | |
| 174 cairo_ft_dep = cairo_dep | |
| 175 endif | |
| 176 endif | |
| 177 | |
| 178 if not cairo_dep.found() | |
| 179 # Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback | |
| 180 # dependency cycle here because we have configured freetype2 above with | |
| 181 # harfbuzz support disabled, so when cairo will lookup freetype2 dependency | |
| 182 # it will be forced to use that one. | |
| 183 cairo_dep = dependency('cairo', required: get_option('cairo')) | |
| 184 cairo_ft_required = get_option('cairo').enabled() and get_option('freetype').enabled() | |
| 185 cairo_ft_dep = dependency('cairo-ft', required: cairo_ft_required) | |
| 186 endif | |
| 187 endif | |
| 188 | |
| 189 chafa_dep = dependency('chafa', version: '>= 1.6.0', required: get_option('chafa')) | |
| 190 | |
| 191 conf = configuration_data() | |
| 192 incconfig = include_directories('.') | |
| 193 | |
| 194 add_project_arguments('-DHAVE_CONFIG_H', language: ['c', 'cpp']) | |
| 195 | |
| 196 warn_cflags = [ | |
| 197 '-Wno-non-virtual-dtor', | |
| 198 ] | |
| 199 | |
| 200 cpp_args = cpp.get_supported_arguments(warn_cflags) | |
| 201 | |
| 202 if glib_dep.found() | |
| 203 conf.set('HAVE_GLIB', 1) | |
| 204 endif | |
| 205 | |
| 206 if gobject_dep.found() | |
| 207 conf.set('HAVE_GOBJECT', 1) | |
| 208 endif | |
| 209 | |
| 210 if cairo_dep.found() | |
| 211 conf.set('HAVE_CAIRO', 1) | |
| 212 if cairo_dep.type_name() == 'internal' | |
| 213 conf.set('HAVE_CAIRO_USER_FONT_FACE_SET_RENDER_COLOR_GLYPH_FUNC', 1) | |
| 214 else | |
| 215 check_funcs += [['cairo_user_font_face_set_render_color_glyph_func', {'deps': cairo_dep}]] | |
| 216 endif | |
| 217 endif | |
| 218 | |
| 219 if cairo_ft_dep.found() | |
| 220 conf.set('HAVE_CAIRO_FT', 1) | |
| 221 endif | |
| 222 | |
| 223 if chafa_dep.found() | |
| 224 conf.set('HAVE_CHAFA', 1) | |
| 225 endif | |
| 226 | |
| 227 if graphite2_dep.found() or graphite_dep.found() | |
| 228 conf.set('HAVE_GRAPHITE2', 1) | |
| 229 endif | |
| 230 | |
| 231 if icu_dep.found() | |
| 232 conf.set('HAVE_ICU', 1) | |
| 233 endif | |
| 234 | |
| 235 if get_option('icu_builtin') | |
| 236 conf.set('HAVE_ICU_BUILTIN', 1) | |
| 237 endif | |
| 238 | |
| 239 if get_option('experimental_api') | |
| 240 conf.set('HB_EXPERIMENTAL_API', 1) | |
| 241 endif | |
| 242 | |
| 243 if freetype_dep.found() | |
| 244 conf.set('HAVE_FREETYPE', 1) | |
| 245 check_freetype_funcs = [ | |
| 246 ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}], | |
| 247 ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}], | |
| 248 ['FT_Done_MM_Var', {'deps': freetype_dep}], | |
| 249 ['FT_Get_Transform', {'deps': freetype_dep}], | |
| 250 ] | |
| 251 | |
| 252 if freetype_dep.type_name() == 'internal' | |
| 253 foreach func: check_freetype_funcs | |
| 254 name = func[0] | |
| 255 conf.set('HAVE_@0@'.format(name.to_upper()), 1) | |
| 256 endforeach | |
| 257 else | |
| 258 check_funcs += check_freetype_funcs | |
| 259 endif | |
| 260 endif | |
| 261 | |
| 262 gdi_uniscribe_deps = [] | |
| 263 # GDI (Uniscribe) (Windows) | |
| 264 if host_machine.system() == 'windows' and not get_option('gdi').disabled() | |
| 265 if (get_option('directwrite').enabled() and | |
| 266 not (cpp.has_header('usp10.h') and cpp.has_header('windows.h'))) | |
| 267 error('GDI/Uniscribe was enabled explicitly, but required headers are missing.') | |
| 268 endif | |
| 269 | |
| 270 gdi_deps_found = true | |
| 271 foreach usplib : ['usp10', 'gdi32', 'rpcrt4'] | |
| 272 dep = cpp.find_library(usplib, required: get_option('gdi')) | |
| 273 gdi_deps_found = gdi_deps_found and dep.found() | |
| 274 gdi_uniscribe_deps += dep | |
| 275 endforeach | |
| 276 | |
| 277 if gdi_deps_found | |
| 278 conf.set('HAVE_UNISCRIBE', 1) | |
| 279 conf.set('HAVE_GDI', 1) | |
| 280 endif | |
| 281 endif | |
| 282 | |
| 283 # DirectWrite (Windows) | |
| 284 if host_machine.system() == 'windows' and not get_option('directwrite').disabled() | |
| 285 if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h') | |
| 286 error('DirectWrite was enabled explicitly, but required header is missing.') | |
| 287 endif | |
| 288 | |
| 289 conf.set('HAVE_DIRECTWRITE', 1) | |
| 290 endif | |
| 291 | |
| 292 # CoreText (macOS) | |
| 293 coretext_deps = [] | |
| 294 if host_machine.system() == 'darwin' and not get_option('coretext').disabled() | |
| 295 app_services_dep = dependency('appleframeworks', modules: ['ApplicationServices'], required: false) | |
| 296 if cpp.has_type('CTFontRef', prefix: '#include <ApplicationServices/ApplicationServices.h>', dependencies: app_services_dep) | |
| 297 coretext_deps += [app_services_dep] | |
| 298 conf.set('HAVE_CORETEXT', 1) | |
| 299 # On iOS CoreText and CoreGraphics are stand-alone frameworks | |
| 300 # Check for a different symbol to avoid getting cached result | |
| 301 else | |
| 302 coretext_dep = dependency('appleframeworks', modules: ['CoreText'], required: false) | |
| 303 coregraphics_dep = dependency('appleframeworks', modules: ['CoreGraphics'], required: false) | |
| 304 corefoundation_dep = dependency('appleframeworks', modules: ['CoreFoundation'], required: false) | |
| 305 if cpp.has_type('CTRunRef', prefix: '#include <CoreText/CoreText.h>', dependencies: [coretext_dep, coregraphics_dep, corefoundation_dep]) | |
| 306 coretext_deps += [coretext_dep, coregraphics_dep, corefoundation_dep] | |
| 307 conf.set('HAVE_CORETEXT', 1) | |
| 308 elif get_option('coretext').enabled() | |
| 309 error('CoreText was enabled explicitly, but required headers or frameworks are missing.') | |
| 310 endif | |
| 311 endif | |
| 312 endif | |
| 313 | |
| 314 # threads | |
| 315 thread_dep = null_dep | |
| 316 if host_machine.system() != 'windows' | |
| 317 thread_dep = dependency('threads', required: false) | |
| 318 | |
| 319 if thread_dep.found() | |
| 320 conf.set('HAVE_PTHREAD', 1) | |
| 321 endif | |
| 322 endif | |
| 323 | |
| 324 conf.set_quoted('PACKAGE_NAME', 'HarfBuzz') | |
| 325 conf.set_quoted('PACKAGE_VERSION', meson.project_version()) | |
| 326 | |
| 327 foreach check : check_headers | |
| 328 name = check[0] | |
| 329 | |
| 330 if cpp.has_header(name) | |
| 331 conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1) | |
| 332 endif | |
| 333 endforeach | |
| 334 | |
| 335 harfbuzz_extra_deps = [] | |
| 336 foreach check : check_funcs | |
| 337 name = check[0] | |
| 338 opts = check.get(1, {}) | |
| 339 link_withs = opts.get('link_with', []) | |
| 340 check_deps = opts.get('deps', []) | |
| 341 extra_deps = [] | |
| 342 found = true | |
| 343 | |
| 344 # First try without linking | |
| 345 found = cpp.has_function(name, dependencies: check_deps) | |
| 346 | |
| 347 if not found and link_withs.length() > 0 | |
| 348 found = true | |
| 349 | |
| 350 foreach link_with : link_withs | |
| 351 dep = cpp.find_library(link_with, required: false) | |
| 352 if dep.found() | |
| 353 extra_deps += dep | |
| 354 else | |
| 355 found = false | |
| 356 endif | |
| 357 endforeach | |
| 358 | |
| 359 if found | |
| 360 found = cpp.has_function(name, dependencies: check_deps + extra_deps) | |
| 361 endif | |
| 362 endif | |
| 363 | |
| 364 if found | |
| 365 harfbuzz_extra_deps += extra_deps | |
| 366 conf.set('HAVE_@0@'.format(name.to_upper()), 1) | |
| 367 endif | |
| 368 endforeach | |
| 369 | |
| 370 subdir('src') | |
| 371 subdir('util') | |
| 372 | |
| 373 if not get_option('tests').disabled() | |
| 374 subdir('test') | |
| 375 endif | |
| 376 | |
| 377 if not get_option('benchmark').disabled() | |
| 378 subdir('perf') | |
| 379 endif | |
| 380 | |
| 381 if not get_option('docs').disabled() | |
| 382 subdir('docs') | |
| 383 endif | |
| 384 | |
| 385 configure_file(output: 'config.h', configuration: conf) | |
| 386 | |
| 387 build_summary = { | |
| 388 'Directories': | |
| 389 {'prefix': get_option('prefix'), | |
| 390 'bindir': get_option('bindir'), | |
| 391 'libdir': get_option('libdir'), | |
| 392 'includedir': get_option('includedir'), | |
| 393 'datadir': get_option('datadir'), | |
| 394 }, | |
| 395 'Unicode callbacks (you want at least one)': | |
| 396 {'Builtin': true, | |
| 397 'Glib': conf.get('HAVE_GLIB', 0) == 1, | |
| 398 'ICU': conf.get('HAVE_ICU', 0) == 1, | |
| 399 }, | |
| 400 'Font callbacks (the more the merrier)': | |
| 401 {'FreeType': conf.get('HAVE_FREETYPE', 0) == 1, | |
| 402 }, | |
| 403 'Dependencies used for command-line utilities': | |
| 404 {'Cairo': conf.get('HAVE_CAIRO', 0) == 1, | |
| 405 'Chafa': conf.get('HAVE_CHAFA', 0) == 1, | |
| 406 }, | |
| 407 'Additional shapers': | |
| 408 {'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1, | |
| 409 }, | |
| 410 'Platform shapers (not normally needed)': | |
| 411 {'CoreText': conf.get('HAVE_CORETEXT', 0) == 1, | |
| 412 'DirectWrite': conf.get('HAVE_DIRECTWRITE', 0) == 1, | |
| 413 'GDI/Uniscribe': (conf.get('HAVE_GDI', 0) == 1) and (conf.get('HAVE_UNISCRIBE', 0) == 1), | |
| 414 }, | |
| 415 'Other features': | |
| 416 {'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1, | |
| 417 'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1, | |
| 418 'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1, | |
| 419 'Experimental APIs': conf.get('HB_EXPERIMENTAL_API', 0) == 1, | |
| 420 }, | |
| 421 'Testing': | |
| 422 {'Tests': get_option('tests').enabled(), | |
| 423 'Benchmark': get_option('benchmark').enabled(), | |
| 424 }, | |
| 425 } | |
| 426 foreach section_title, section : build_summary | |
| 427 summary(section, bool_yn: true, section: section_title) | |
| 428 endforeach |
