meson.build (33746B)
1 fs = import('fs') 2 3 hb_version_h = configure_file( 4 command: [find_program('gen-hb-version.py'), meson.project_version(), '@OUTPUT@', '@INPUT@'], 5 input: 'hb-version.h.in', 6 output: 'hb-version.h', 7 install: true, 8 install_dir: get_option('includedir') / meson.project_name()) 9 10 # Base and default-included sources and headers 11 hb_base_sources = files( 12 'hb-aat-layout-ankr-table.hh', 13 'hb-aat-layout-bsln-table.hh', 14 'hb-aat-layout-common.hh', 15 'hb-aat-layout-feat-table.hh', 16 'hb-aat-layout-just-table.hh', 17 'hb-aat-layout-kerx-table.hh', 18 'hb-aat-layout-morx-table.hh', 19 'hb-aat-layout-opbd-table.hh', 20 'hb-aat-layout-trak-table.hh', 21 'hb-aat-layout.cc', 22 'hb-aat-layout.hh', 23 'hb-aat-ltag-table.hh', 24 'hb-aat-map.cc', 25 'hb-aat-map.hh', 26 'hb-algs.hh', 27 'hb-alloc-pool.hh', 28 'hb-array.hh', 29 'hb-atomic.hh', 30 'hb-bimap.hh', 31 'hb-bit-page.hh', 32 'hb-bit-set.hh', 33 'hb-bit-set-invertible.hh', 34 'hb-bit-vector.hh', 35 'hb-blob.cc', 36 'hb-blob.hh', 37 'hb-buffer-serialize.cc', 38 'hb-buffer-verify.cc', 39 'hb-buffer.cc', 40 'hb-buffer.hh', 41 'hb-cache.hh', 42 'hb-cff-interp-common.hh', 43 'hb-cff-interp-cs-common.hh', 44 'hb-cff-interp-dict-common.hh', 45 'hb-cff1-interp-cs.hh', 46 'hb-cff2-interp-cs.hh', 47 'hb-common.cc', 48 'hb-config.hh', 49 'hb-debug.hh', 50 'hb-decycler.hh', 51 'hb-dispatch.hh', 52 'hb-draw.cc', 53 'hb-draw.hh', 54 'hb-geometry.hh', 55 'hb-paint.cc', 56 'hb-paint.hh', 57 'hb-paint-bounded.cc', 58 'hb-paint-bounded.hh', 59 'hb-paint-extents.cc', 60 'hb-paint-extents.hh', 61 'hb-face.cc', 62 'hb-face.hh', 63 'hb-face-builder.cc', 64 'hb-fallback-shape.cc', 65 'hb-font.cc', 66 'hb-font.hh', 67 'hb-free-pool.hh', 68 'hb-iter.hh', 69 'hb-kern.hh', 70 'hb-limits.hh', 71 'hb-machinery.hh', 72 'hb-map.cc', 73 'hb-map.hh', 74 'hb-meta.hh', 75 'hb-ms-feature-ranges.hh', 76 'hb-multimap.hh', 77 'hb-mutex.hh', 78 'hb-null.hh', 79 'hb-number.cc', 80 'hb-number.hh', 81 'hb-object.hh', 82 'hb-open-file.hh', 83 'hb-open-type.hh', 84 'hb-ot-cff-common.hh', 85 'hb-ot-cff1-std-str.hh', 86 'hb-ot-cff1-table.cc', 87 'hb-ot-cff1-table.hh', 88 'hb-ot-cff2-table.cc', 89 'hb-ot-cff2-table.hh', 90 'hb-ot-cmap-table.hh', 91 'hb-ot-color.cc', 92 'hb-ot-face-table-list.hh', 93 'hb-ot-face.cc', 94 'hb-ot-face.hh', 95 'hb-ot-font.cc', 96 'hb-ot-gasp-table.hh', 97 'hb-ot-glyf-table.hh', 98 'hb-ot-hdmx-table.hh', 99 'hb-ot-head-table.hh', 100 'hb-ot-hhea-table.hh', 101 'hb-ot-hmtx-table.hh', 102 'hb-ot-kern-table.hh', 103 'hb-ot-layout-base-table.hh', 104 'hb-ot-layout-common.hh', 105 'hb-ot-layout-gdef-table.hh', 106 'hb-ot-layout-gpos-table.hh', 107 'hb-ot-layout-gsub-table.hh', 108 'hb-outline.hh', 109 'hb-outline.cc', 110 'OT/Color/CBDT/CBDT.hh', 111 'OT/Color/COLR/COLR.hh', 112 'OT/Color/CPAL/CPAL.hh', 113 'OT/Color/sbix/sbix.hh', 114 'OT/Color/svg/svg.hh', 115 'OT/glyf/glyf.hh', 116 'OT/glyf/glyf-helpers.hh', 117 'OT/glyf/loca.hh', 118 'OT/glyf/path-builder.hh', 119 'OT/glyf/Glyph.hh', 120 'OT/glyf/GlyphHeader.hh', 121 'OT/glyf/SimpleGlyph.hh', 122 'OT/glyf/CompositeGlyph.hh', 123 'OT/glyf/SubsetGlyph.hh', 124 'OT/Layout/types.hh', 125 'OT/Layout/Common/Coverage.hh', 126 'OT/Layout/Common/CoverageFormat1.hh', 127 'OT/Layout/Common/CoverageFormat2.hh', 128 'OT/Layout/Common/RangeRecord.hh', 129 'OT/Layout/GDEF/GDEF.hh', 130 'OT/Layout/GPOS/AnchorFormat1.hh', 131 'OT/Layout/GPOS/AnchorFormat2.hh', 132 'OT/Layout/GPOS/AnchorFormat3.hh', 133 'OT/Layout/GPOS/Anchor.hh', 134 'OT/Layout/GPOS/AnchorMatrix.hh', 135 'OT/Layout/GPOS/ChainContextPos.hh', 136 'OT/Layout/GPOS/Common.hh', 137 'OT/Layout/GPOS/ContextPos.hh', 138 'OT/Layout/GPOS/CursivePosFormat1.hh', 139 'OT/Layout/GPOS/CursivePos.hh', 140 'OT/Layout/GPOS/ExtensionPos.hh', 141 'OT/Layout/GPOS/GPOS.hh', 142 'OT/Layout/GPOS/LigatureArray.hh', 143 'OT/Layout/GPOS/MarkArray.hh', 144 'OT/Layout/GPOS/MarkBasePosFormat1.hh', 145 'OT/Layout/GPOS/MarkBasePos.hh', 146 'OT/Layout/GPOS/MarkLigPosFormat1.hh', 147 'OT/Layout/GPOS/MarkLigPos.hh', 148 'OT/Layout/GPOS/MarkMarkPosFormat1.hh', 149 'OT/Layout/GPOS/MarkMarkPos.hh', 150 'OT/Layout/GPOS/MarkRecord.hh', 151 'OT/Layout/GPOS/PairPosFormat1.hh', 152 'OT/Layout/GPOS/PairPosFormat2.hh', 153 'OT/Layout/GPOS/PairPos.hh', 154 'OT/Layout/GPOS/PairSet.hh', 155 'OT/Layout/GPOS/PairValueRecord.hh', 156 'OT/Layout/GPOS/PosLookup.hh', 157 'OT/Layout/GPOS/PosLookupSubTable.hh', 158 'OT/Layout/GPOS/SinglePosFormat1.hh', 159 'OT/Layout/GPOS/SinglePosFormat2.hh', 160 'OT/Layout/GPOS/SinglePos.hh', 161 'OT/Layout/GPOS/ValueFormat.hh', 162 'OT/Layout/GSUB/AlternateSet.hh', 163 'OT/Layout/GSUB/AlternateSubstFormat1.hh', 164 'OT/Layout/GSUB/AlternateSubst.hh', 165 'OT/Layout/GSUB/ChainContextSubst.hh', 166 'OT/Layout/GSUB/Common.hh', 167 'OT/Layout/GSUB/ContextSubst.hh', 168 'OT/Layout/GSUB/ExtensionSubst.hh', 169 'OT/Layout/GSUB/GSUB.hh', 170 'OT/Layout/GSUB/Ligature.hh', 171 'OT/Layout/GSUB/LigatureSet.hh', 172 'OT/Layout/GSUB/LigatureSubstFormat1.hh', 173 'OT/Layout/GSUB/LigatureSubst.hh', 174 'OT/Layout/GSUB/MultipleSubstFormat1.hh', 175 'OT/Layout/GSUB/MultipleSubst.hh', 176 'OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh', 177 'OT/Layout/GSUB/ReverseChainSingleSubst.hh', 178 'OT/Layout/GSUB/Sequence.hh', 179 'OT/Layout/GSUB/SingleSubstFormat1.hh', 180 'OT/Layout/GSUB/SingleSubstFormat2.hh', 181 'OT/Layout/GSUB/SingleSubst.hh', 182 'OT/Layout/GSUB/SubstLookup.hh', 183 'OT/Layout/GSUB/SubstLookupSubTable.hh', 184 'OT/name/name.hh', 185 'OT/Var/VARC/coord-setter.hh', 186 'OT/Var/VARC/VARC.cc', 187 'OT/Var/VARC/VARC.hh', 188 'hb-ot-layout-gsubgpos.hh', 189 'hb-ot-layout-jstf-table.hh', 190 'hb-ot-layout.cc', 191 'hb-ot-layout.hh', 192 'hb-ot-map.cc', 193 'hb-ot-map.hh', 194 'hb-ot-math-table.hh', 195 'hb-ot-math.cc', 196 'hb-ot-maxp-table.hh', 197 'hb-ot-meta-table.hh', 198 'hb-ot-meta.cc', 199 'hb-ot-metrics.cc', 200 'hb-ot-metrics.hh', 201 'hb-ot-name-language-static.hh', 202 'hb-ot-name-language.hh', 203 'hb-ot-name-table.hh', 204 'hb-ot-name.cc', 205 'hb-ot-os2-table.hh', 206 'hb-ot-os2-unicode-ranges.hh', 207 'hb-ot-post-macroman.hh', 208 'hb-ot-post-table.hh', 209 'hb-ot-post-table-v2subset.hh', 210 'hb-ot-shaper-arabic-fallback.hh', 211 'hb-ot-shaper-arabic-joining-list.hh', 212 'hb-ot-shaper-arabic-pua.hh', 213 'hb-ot-shaper-arabic-table.hh', 214 'hb-ot-shaper-arabic-win1256.hh', 215 'hb-ot-shaper-arabic.cc', 216 'hb-ot-shaper-arabic.hh', 217 'hb-ot-shaper-default.cc', 218 'hb-ot-shaper-hangul.cc', 219 'hb-ot-shaper-hebrew.cc', 220 'hb-ot-shaper-indic-table.cc', 221 'hb-ot-shaper-indic.cc', 222 'hb-ot-shaper-indic.hh', 223 'hb-ot-shaper-khmer.cc', 224 'hb-ot-shaper-myanmar.cc', 225 'hb-ot-shaper-syllabic.cc', 226 'hb-ot-shaper-syllabic.hh', 227 'hb-ot-shaper-thai.cc', 228 'hb-ot-shaper-use-table.hh', 229 'hb-ot-shaper-use.cc', 230 'hb-ot-shaper-vowel-constraints.cc', 231 'hb-ot-shaper-vowel-constraints.hh', 232 'hb-ot-shaper.hh', 233 'hb-ot-shape-fallback.cc', 234 'hb-ot-shape-fallback.hh', 235 'hb-ot-shape-normalize.cc', 236 'hb-ot-shape-normalize.hh', 237 'hb-ot-shape.cc', 238 'hb-ot-shape.hh', 239 'hb-ot-stat-table.hh', 240 'hb-ot-tag-table.hh', 241 'hb-ot-tag.cc', 242 'hb-ot-var-avar-table.hh', 243 'hb-ot-var-common.hh', 244 'hb-ot-var-cvar-table.hh', 245 'hb-ot-var-fvar-table.hh', 246 'hb-ot-var-gvar-table.hh', 247 'hb-ot-var-hvar-table.hh', 248 'hb-ot-var-mvar-table.hh', 249 'hb-ot-var-varc-table.hh', 250 'hb-ot-var.cc', 251 'hb-ot-vorg-table.hh', 252 'hb-priority-queue.hh', 253 'hb-repacker.hh', 254 'hb-sanitize.hh', 255 'hb-serialize.hh', 256 'hb-set-digest.hh', 257 'hb-set.cc', 258 'hb-set.hh', 259 'hb-shape-plan.cc', 260 'hb-shape-plan.hh', 261 'hb-shape.cc', 262 'hb-shaper-impl.hh', 263 'hb-shaper-list.hh', 264 'hb-shaper.cc', 265 'hb-shaper.hh', 266 'hb-static.cc', 267 'hb-string-array.hh', 268 'hb-style.cc', 269 'hb-ucd-table.hh', 270 'hb-ucd.cc', 271 'hb-unicode-emoji-table.hh', 272 'hb-unicode.cc', 273 'hb-unicode.hh', 274 'hb-utf.hh', 275 'hb-vector.hh', 276 'hb.hh', 277 ) 278 279 hb_base_ragel_generated_sources = files( 280 'hb-buffer-deserialize-json.hh', 281 'hb-buffer-deserialize-text-glyphs.hh', 282 'hb-buffer-deserialize-text-unicode.hh', 283 'hb-number-parser.hh', 284 'hb-ot-shaper-indic-machine.hh', 285 'hb-ot-shaper-khmer-machine.hh', 286 'hb-ot-shaper-myanmar-machine.hh', 287 'hb-ot-shaper-use-machine.hh', 288 ) 289 hb_base_ragel_sources = [ 290 'hb-buffer-deserialize-json.rl', 291 'hb-buffer-deserialize-text-glyphs.rl', 292 'hb-buffer-deserialize-text-unicode.rl', 293 'hb-number-parser.rl', 294 'hb-ot-shaper-indic-machine.rl', 295 'hb-ot-shaper-khmer-machine.rl', 296 'hb-ot-shaper-myanmar-machine.rl', 297 'hb-ot-shaper-use-machine.rl', 298 ] 299 300 hb_base_headers = files( 301 'hb-aat-layout.h', 302 'hb-aat.h', 303 'hb-blob.h', 304 'hb-buffer.h', 305 'hb-common.h', 306 'hb-cplusplus.hh', 307 'hb-deprecated.h', 308 'hb-draw.h', 309 'hb-paint.h', 310 'hb-face.h', 311 'hb-font.h', 312 'hb-map.h', 313 'hb-ot-color.h', 314 'hb-ot-deprecated.h', 315 'hb-ot-font.h', 316 'hb-ot-layout.h', 317 'hb-ot-math.h', 318 'hb-ot-meta.h', 319 'hb-ot-metrics.h', 320 'hb-ot-name.h', 321 'hb-ot-shape.h', 322 'hb-ot-var.h', 323 'hb-ot.h', 324 'hb-script-list.h', 325 'hb-set.h', 326 'hb-shape-plan.h', 327 'hb-shape.h', 328 'hb-style.h', 329 'hb-unicode.h', 330 'hb.h', 331 ) 332 hb_base_headers += hb_version_h 333 334 # Optional Sources and Headers with external deps 335 336 hb_ft_sources = files('hb-ft.cc', 'hb-ft-colr.hh') 337 hb_ft_headers = files('hb-ft.h') 338 339 hb_fontations_sources = files() 340 hb_fontations_headers = files('hb-fontations.h') 341 342 hb_harfrust_sources = files('hb-harfrust.cc') 343 hb_harfrust_headers = files() 344 345 hb_kbts_sources = files('hb-kbts.cc') 346 hb_kbts_headers = files() 347 348 hb_glib_sources = files('hb-glib.cc') 349 hb_glib_headers = files('hb-glib.h') 350 351 hb_graphite2_sources = files('hb-graphite2.cc') 352 hb_graphite2_headers = files('hb-graphite2.h') 353 354 hb_wasm_sources = files( 355 'hb-wasm-api.cc', 356 'hb-wasm-api.hh', 357 'hb-wasm-api-blob.hh', 358 'hb-wasm-api-buffer.hh', 359 'hb-wasm-api-common.hh', 360 'hb-wasm-api-face.hh', 361 'hb-wasm-api-font.hh', 362 'hb-wasm-api-list.hh', 363 'hb-wasm-api-shape.hh', 364 'hb-wasm-shape.cc', 365 ) 366 hb_wasm_headers = files() 367 368 # System-dependent sources and headers 369 370 hb_coretext_sources = files('hb-coretext.cc', 'hb-coretext.hh', 'hb-coretext-font.cc', 'hb-coretext-shape.cc') 371 hb_coretext_headers = files('hb-coretext.h') 372 373 hb_directwrite_sources = files('hb-directwrite.cc', 'hb-directwrite.hh', 'hb-directwrite-font.cc', 'hb-directwrite-shape.cc') 374 hb_directwrite_headers = files('hb-directwrite.h') 375 376 hb_gdi_sources = files('hb-gdi.cc') 377 hb_gdi_headers = files('hb-gdi.h') 378 379 hb_uniscribe_sources = files('hb-uniscribe.cc') 380 hb_uniscribe_headers = files('hb-uniscribe.h') 381 382 # Sources for libharfbuzz-gobject and libharfbuzz-icu 383 hb_icu_sources = files('hb-icu.cc') 384 hb_icu_headers = files('hb-icu.h') 385 386 # Sources for libharfbuzz-subset 387 hb_subset_sources = files( 388 'hb-number.cc', 389 'hb-number.hh', 390 'hb-ot-cff1-table.cc', 391 'hb-ot-cff2-table.cc', 392 'hb-static.cc', 393 'hb-subset-accelerator.hh', 394 'hb-subset-cff-common.cc', 395 'hb-subset-cff-common.hh', 396 'hb-subset-cff1.cc', 397 'hb-subset-cff2.cc', 398 'hb-subset-input.cc', 399 'hb-subset-input.hh', 400 'hb-subset-instancer-iup.hh', 401 'hb-subset-instancer-iup.cc', 402 'hb-subset-instancer-solver.hh', 403 'hb-subset-instancer-solver.cc', 404 'hb-subset-plan.cc', 405 'hb-subset-plan-layout.cc', 406 'hb-subset-plan-var.cc', 407 'hb-subset-plan.hh', 408 'hb-subset-plan-member-list.hh', 409 'hb-subset-serialize.cc', 410 'hb-subset-table.hh', 411 'hb-subset-table-layout.cc', 412 'hb-subset-table-var.cc', 413 'hb-subset-table-cff.cc', 414 'hb-subset-table-color.cc', 415 'hb-subset-table-other.cc', 416 'graph/gsubgpos-context.cc', 417 'graph/gsubgpos-context.hh', 418 'graph/gsubgpos-graph.hh', 419 'graph/pairpos-graph.hh', 420 'graph/markbasepos-graph.hh', 421 'graph/coverage-graph.hh', 422 'graph/classdef-graph.hh', 423 'graph/split-helpers.hh', 424 'hb-subset.cc', 425 'hb-subset.hh', 426 ) 427 428 hb_subset_headers = files( 429 'hb-subset.h', 430 'hb-subset-serialize.h' 431 ) 432 433 hb_gobject_sources = files( 434 'hb-gobject-structs.cc' 435 ) 436 437 hb_gobject_headers = files( 438 'hb-gobject.h', 439 'hb-gobject-structs.h', 440 ) 441 442 hb_failing_alloc_sources = files('failing-alloc.c') 443 444 ragel = find_program('ragel', version: '6.10', required: false) 445 has_ragel = ragel.found() 446 if not has_ragel and get_option('ragel_subproject') 447 ragel = subproject('ragel').get_variable('ragel') 448 has_ragel = true 449 endif 450 if not has_ragel 451 if not meson.is_subproject() 452 warning('You have to install ragel if you are going to develop HarfBuzz itself') 453 endif 454 else 455 ragel_helper = find_program('gen-ragel-artifacts.py') 456 foreach rl : hb_base_ragel_sources 457 hh = rl.split('.')[0] + '.hh' 458 custom_target('@0@'.format(hh), 459 build_by_default: true, 460 input: rl, 461 output: hh, 462 command: [ragel_helper, ragel, '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], 463 ) 464 endforeach 465 endif 466 467 custom_target('harfbuzz.cc', 468 build_by_default: true, 469 output: 'harfbuzz.cc', 470 input: hb_base_sources + hb_glib_sources + hb_ft_sources + 471 hb_graphite2_sources + hb_uniscribe_sources + hb_gdi_sources + 472 hb_directwrite_sources + hb_coretext_sources + hb_wasm_sources, 473 command: [find_program('gen-harfbuzzcc.py'), 474 '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], 475 ) 476 477 incsrc = include_directories('.') 478 479 hb_sources = hb_base_sources + hb_base_ragel_generated_sources 480 hb_headers = hb_base_headers 481 482 harfbuzz_deps = [thread_dep, m_dep] + harfbuzz_extra_deps 483 484 if get_option('with_libstdcxx') 485 chosen_linker = 'cpp' 486 else 487 # Use a C linker, not C++; Don't link to libstdc++ 488 chosen_linker = 'c' 489 endif 490 libharfbuzz_link_language = chosen_linker 491 492 if conf.get('HAVE_FREETYPE', 0) == 1 493 hb_sources += hb_ft_sources 494 hb_headers += hb_ft_headers 495 harfbuzz_deps += [freetype_dep] 496 endif 497 498 if conf.get('HAVE_GLIB', 0) == 1 499 hb_sources += hb_glib_sources 500 hb_headers += hb_glib_headers 501 harfbuzz_deps += [glib_dep] 502 endif 503 504 # We set those here to not include the sources below that are of no use to 505 # GObject Introspection 506 gir_sources = hb_sources + hb_gobject_sources 507 gir_headers = hb_headers + hb_gobject_headers 508 509 if conf.get('HAVE_GDI', 0) == 1 510 hb_sources += hb_gdi_sources 511 hb_headers += hb_gdi_headers 512 harfbuzz_deps += gdi_uniscribe_deps 513 endif 514 515 if conf.get('HAVE_GRAPHITE2', 0) == 1 516 hb_sources += hb_graphite2_sources 517 hb_headers += hb_graphite2_headers 518 harfbuzz_deps += [graphite2_dep, graphite_dep] 519 endif 520 521 if conf.get('HAVE_WASM', 0) == 1 522 hb_sources += hb_wasm_sources 523 hb_headers += hb_wasm_headers 524 harfbuzz_deps += wasm_dep 525 #harfbuzz_deps += llvm_dep 526 endif 527 528 if conf.get('HAVE_UNISCRIBE', 0) == 1 529 hb_sources += hb_uniscribe_sources 530 hb_headers += hb_uniscribe_headers 531 endif 532 533 if conf.get('HAVE_DIRECTWRITE', 0) == 1 534 hb_sources += hb_directwrite_sources 535 hb_headers += hb_directwrite_headers 536 harfbuzz_deps += directwrite_dep 537 # hb-directwrite needs a C++ linker 538 libharfbuzz_link_language = 'cpp' 539 endif 540 541 if conf.get('HAVE_CORETEXT', 0) == 1 542 hb_sources += hb_coretext_sources 543 hb_headers += hb_coretext_headers 544 harfbuzz_deps += coretext_deps 545 endif 546 547 if conf.get('HAVE_FONTATIONS', 0) == 1 or conf.get('HAVE_HARFRUST', 0) == 1 548 subdir('rust') 549 harfbuzz_deps += [harfbuzz_rust_dep] 550 endif 551 552 if conf.get('HAVE_FONTATIONS', 0) == 1 553 hb_sources += hb_fontations_sources 554 hb_headers += hb_fontations_headers 555 endif 556 557 if conf.get('HAVE_HARFRUST', 0) == 1 558 hb_sources += hb_harfrust_sources 559 hb_headers += hb_harfrust_headers 560 endif 561 562 if conf.get('HAVE_KBTS', 0) == 1 563 hb_sources += hb_kbts_sources 564 hb_headers += hb_kbts_headers 565 harfbuzz_deps += [kbts_dep] 566 endif 567 568 have_icu = conf.get('HAVE_ICU', 0) == 1 569 have_icu_builtin = conf.get('HAVE_ICU_BUILTIN', 0) == 1 570 if have_icu and have_icu_builtin 571 hb_sources += hb_icu_sources 572 hb_headers += hb_icu_headers 573 harfbuzz_deps += [icu_dep] 574 endif 575 576 features = [ 577 'CAIRO', 578 'CORETEXT', 579 'DIRECTWRITE', 580 'FREETYPE', 581 'GDI', 582 'GLIB', 583 'GOBJECT', 584 'GRAPHITE', 585 'ICU', 586 'UNISCRIBE', 587 'WASM', 588 ] 589 590 hb_enabled_features = configuration_data() 591 hb_supported_features = configuration_data() 592 foreach feature : features 593 key = 'HB_HAS_@0@'.format(feature) 594 hb_enabled_features.set(key, conf.get('HAVE_@0@'.format(feature), false)) 595 hb_supported_features.set(key, 1) 596 endforeach 597 598 # The enabled features. This file is installed. 599 hb_features_h = configure_file(input: 'hb-features.h.in', 600 output: 'hb-features.h', 601 configuration: hb_enabled_features, 602 install: true, 603 install_dir: get_option('includedir') / meson.project_name()) 604 605 # This file is generated to convince gtk-doc to generate documentation for all 606 # HB_HAS_* macros, whether they are enabled for the current build or not. 607 # This file should not be installed. 608 hb_supported_features_h = configure_file(input: 'hb-features.h.in', 609 output: 'hb-supported-features.h', 610 configuration: hb_supported_features, 611 install: false) 612 613 614 # Base and default-included sources and headers 615 gen_def = find_program('gen-def.py') 616 gen_def_cmd = [gen_def, '@OUTPUT@', '@INPUT@'] 617 if get_option('experimental_api') 618 gen_def_cmd += '--experimental-api' 619 endif 620 621 # harfbuzz 622 harfbuzz_def = custom_target('harfbuzz.def', 623 command: gen_def_cmd, 624 input: hb_headers, 625 output: 'harfbuzz.def') 626 defs_list = [harfbuzz_def] 627 628 version = '0.@0@.0'.format(hb_version_int) 629 630 extra_hb_cpp_args = [] 631 if cpp_is_microsoft_compiler 632 if get_option('default_library') != 'static' 633 extra_hb_cpp_args += '-DHB_DLL_EXPORT' 634 endif 635 hb_so_version = '' 636 else 637 hb_so_version = '0' 638 endif 639 640 if get_option('fuzzer_ldflags') != '' 641 extra_hb_cpp_args += ['-DHB_CUSTOM_MALLOC'] 642 hb_sources += hb_failing_alloc_sources 643 hb_subset_sources += hb_failing_alloc_sources 644 hb_icu_sources += hb_failing_alloc_sources 645 hb_gobject_sources += hb_failing_alloc_sources 646 endif 647 648 darwin_versions = [hb_version_int, '@0@.0.0'.format(hb_version_int)] 649 650 libharfbuzz = library('harfbuzz', hb_sources, 651 include_directories: incconfig, 652 dependencies: harfbuzz_deps, 653 cpp_args: cpp_args + extra_hb_cpp_args, 654 soversion: hb_so_version, 655 version: version, 656 install: true, 657 darwin_versions: darwin_versions, 658 link_language: libharfbuzz_link_language, 659 ) 660 661 libharfbuzz_dep = declare_dependency( 662 link_with: libharfbuzz, 663 include_directories: incsrc, 664 dependencies: harfbuzz_deps) 665 meson.override_dependency('harfbuzz', libharfbuzz_dep) 666 667 # harfbuzz-subset 668 harfbuzz_subset_def = custom_target('harfbuzz-subset.def', 669 command: gen_def_cmd, 670 input: hb_subset_headers, 671 output: 'harfbuzz-subset.def') 672 defs_list += [harfbuzz_subset_def] 673 674 libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, 675 include_directories: incconfig, 676 dependencies: [m_dep], 677 link_with: [libharfbuzz], 678 cpp_args: cpp_args + extra_hb_cpp_args, 679 soversion: hb_so_version, 680 version: version, 681 install: true, 682 darwin_versions: darwin_versions, 683 link_language: chosen_linker, 684 ) 685 686 custom_target('harfbuzz-subset.cc', 687 build_by_default: true, 688 output: 'harfbuzz-subset.cc', 689 input: hb_base_sources + hb_subset_sources, 690 command: [find_program('gen-harfbuzzcc.py'), 691 '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], 692 ) 693 694 libharfbuzz_subset_dep = declare_dependency( 695 link_with: libharfbuzz_subset, 696 include_directories: incsrc, 697 dependencies: [m_dep]) 698 meson.override_dependency('harfbuzz-subset', libharfbuzz_subset_dep) 699 700 libharfbuzz_cairo_dep = null_dep 701 if conf.get('HAVE_CAIRO', 0) == 1 702 hb_cairo_sources = [ 703 'hb-cairo.cc', 704 'hb-cairo-utils.cc', 705 'hb-cairo-utils.hh', 706 'hb-static.cc' 707 ] 708 709 hb_cairo_headers = [ 710 'hb-cairo.h', 711 ] 712 713 cairo_dep = dependency('cairo') 714 715 libharfbuzz_cairo = library('harfbuzz-cairo', hb_cairo_sources, 716 include_directories: incconfig, 717 dependencies: [m_dep, cairo_dep], 718 link_with: [libharfbuzz], 719 cpp_args: cpp_args + extra_hb_cpp_args, 720 soversion: hb_so_version, 721 version: version, 722 install: true, 723 darwin_versions: darwin_versions, 724 link_language: chosen_linker, 725 ) 726 727 install_headers(hb_cairo_headers, subdir: meson.project_name()) 728 729 libharfbuzz_cairo_dep = declare_dependency( 730 link_with: libharfbuzz_cairo, 731 include_directories: incsrc, 732 dependencies: [m_dep, cairo_dep]) 733 meson.override_dependency('harfbuzz-cairo', libharfbuzz_cairo_dep) 734 735 harfbuzz_cairo_def = custom_target('harfbuzz-cairo.def', 736 command: gen_def_cmd, 737 input: hb_cairo_headers, 738 output: 'harfbuzz-cairo.def') 739 defs_list += [harfbuzz_cairo_def] 740 741 pkgmod.generate(libharfbuzz_cairo, 742 description: 'HarfBuzz cairo support', 743 requires: ['harfbuzz = @0@'.format(meson.project_version())], 744 subdirs: [meson.project_name()], 745 version: meson.project_version(), 746 ) 747 endif 748 749 if get_option('tests').enabled() 750 # TODO: Microsoft LINK gives the following because extern, non dllexport 751 # symbols can only be used when linking against a static library 752 # error LNK2019: unresolved external symbol "unsigned __int64 const * const _hb_NullPool" 753 if not cpp_is_microsoft_compiler 754 noinst_programs = { 755 'main': 'main.cc', 756 'test-basics': 'test.cc', 757 'test-buffer-serialize': 'test-buffer-serialize.cc', 758 'test-ot-meta': 'test-ot-meta.cc', 759 'test-ot-name': 'test-ot-name.cc', 760 'test-ot-glyphname': 'test-ot-glyphname.cc', 761 'test-ot-gpos-size-params': 'test-gpos-size-params.cc', 762 'test-ot-gsub-get-alternates': 'test-gsub-get-alternates.cc', 763 'test-ot-gsub-would-substitute': 'test-gsub-would-substitute.cc', 764 'test-use-table': 'test-use-table.cc', 765 } 766 foreach name, source : noinst_programs 767 executable(name, source, 768 include_directories: incconfig, 769 dependencies: libharfbuzz_dep, 770 install: false, 771 ) 772 endforeach 773 endif 774 775 compiled_tests = { 776 'test-algs': ['test-algs.cc', 'hb-static.cc'], 777 'test-array': ['test-array.cc'], 778 'test-bimap': ['test-bimap.cc', 'hb-static.cc'], 779 'test-cff': ['test-cff.cc', 'hb-static.cc'], 780 'test-classdef-graph': ['graph/test-classdef-graph.cc', 'hb-static.cc', 'graph/gsubgpos-context.cc'], 781 'test-decycler': ['test-decycler.cc', 'hb-static.cc'], 782 'test-iter': ['test-iter.cc', 'hb-static.cc'], 783 'test-machinery': ['test-machinery.cc', 'hb-static.cc'], 784 'test-map': ['test-map.cc', 'hb-static.cc'], 785 'test-multimap': ['test-multimap.cc', 'hb-static.cc'], 786 'test-number': ['test-number.cc', 'hb-number.cc'], 787 'test-ot-tag': ['hb-ot-tag.cc'], 788 'test-set': ['test-set.cc', 'hb-static.cc'], 789 'test-serialize': ['test-serialize.cc', 'hb-static.cc'], 790 'test-vector': ['test-vector.cc', 'hb-static.cc'], 791 'test-repacker': ['test-repacker.cc', 'hb-static.cc', 'graph/gsubgpos-context.cc'], 792 'test-instancer-solver': ['test-subset-instancer-solver.cc', 'hb-subset-instancer-solver.cc', 'hb-static.cc'], 793 'test-priority-queue': ['test-priority-queue.cc', 'hb-static.cc'], 794 'test-tuple-varstore': ['test-tuple-varstore.cc', 'hb-subset-instancer-solver.cc', 'hb-subset-instancer-iup.cc', 'hb-static.cc'], 795 'test-item-varstore': ['test-item-varstore.cc', 'hb-subset-instancer-solver.cc', 'hb-subset-instancer-iup.cc', 'hb-static.cc'], 796 'test-unicode-ranges': ['test-unicode-ranges.cc'], 797 } 798 foreach name, source : compiled_tests 799 if cpp_is_microsoft_compiler and source.contains('hb-static.cc') 800 # TODO: Microsoft compilers cannot link tests using hb-static.cc, fix them 801 continue 802 endif 803 test(name, executable(name, source, 804 include_directories: incconfig, 805 cpp_args: cpp_args + ['-DMAIN', '-UNDEBUG'], 806 dependencies: libharfbuzz_dep, 807 install: false, 808 ), suite: ['src']) 809 endforeach 810 endif 811 812 pkgmod.generate(libharfbuzz, 813 description: 'HarfBuzz text shaping library', 814 subdirs: [meson.project_name()], 815 version: meson.project_version(), 816 ) 817 818 pkgmod.generate(libharfbuzz_subset, 819 description: 'HarfBuzz font subsetter', 820 requires: ['harfbuzz = @0@'.format(meson.project_version())], 821 subdirs: [meson.project_name()], 822 version: meson.project_version(), 823 ) 824 825 libharfbuzz_icu_dep = null_dep 826 if have_icu and not have_icu_builtin 827 harfbuzz_icu_def = custom_target('harfbuzz-icu.def', 828 command: gen_def_cmd, 829 input: [hb_icu_headers], 830 output: 'harfbuzz-icu.def') 831 defs_list += [harfbuzz_icu_def] 832 833 libharfbuzz_icu = library('harfbuzz-icu', [hb_icu_sources, hb_icu_headers], 834 include_directories: incconfig, 835 dependencies: icu_dep, 836 link_with: [libharfbuzz], 837 cpp_args: cpp_args + extra_hb_cpp_args, 838 soversion: hb_so_version, 839 version: version, 840 install: true, 841 darwin_versions: darwin_versions, 842 # ICU links to stdc++ anyway so the default linker is good 843 # link_language: chosen_linker, 844 ) 845 846 libharfbuzz_icu_dep = declare_dependency( 847 link_with: libharfbuzz_icu, 848 include_directories: incsrc, 849 dependencies: icu_dep) 850 meson.override_dependency('harfbuzz-icu', libharfbuzz_icu_dep) 851 852 pkgmod.generate(libharfbuzz_icu, 853 description: 'HarfBuzz text shaping library ICU integration', 854 requires: ['harfbuzz = @0@'.format(meson.project_version())], 855 subdirs: [meson.project_name()], 856 version: meson.project_version(), 857 ) 858 859 install_headers(hb_icu_headers, subdir: meson.project_name()) 860 endif 861 862 have_gobject = conf.get('HAVE_GOBJECT', 0) == 1 863 864 # This code (especially PACKAGE_INIT) kept similar to what CMake's own 865 # configure_package_config_file() generates, see 866 # https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:configure_package_config_file 867 868 cmake_config = configuration_data() 869 cmake_config_dir = cmake_package_install_dir / 'harfbuzz' 870 871 if meson.version().version_compare('>=1.3.0') 872 cmake_package_prefix_dir = fs.relative_to(get_option('prefix'), get_option('prefix') / cmake_config_dir) 873 else 874 relative_to = find_program('relative_to.py') 875 cmake_package_prefix_dir = run_command(relative_to, get_option('prefix'), get_option('prefix') / cmake_config_dir, check: true).stdout().strip() 876 endif 877 878 cmake_package_prefix_dir = '${CMAKE_CURRENT_LIST_DIR}/@0@'.format(cmake_package_prefix_dir) 879 880 # Make all the relevant paths relative to our prefix, so we can later append 881 # them onto ${PACKAGE_PREFIX_DIR} to get the correct paths. 882 883 cmake_install_includedir = get_option('includedir') 884 885 if fs.is_absolute(cmake_install_includedir) 886 if meson.version().version_compare('>=1.3.0') 887 cmake_install_includedir = fs.relative_to(cmake_install_includedir, get_option('prefix')) 888 else 889 cmake_install_includedir = run_command(relative_to, cmake_install_includedir, get_option('prefix'), check: true).stdout().strip() 890 endif 891 endif 892 893 cmake_install_libdir = get_option('libdir') 894 895 if fs.is_absolute(cmake_install_libdir) 896 if meson.version().version_compare('>=1.3.0') 897 cmake_install_libdir = fs.relative_to(cmake_install_libdir, get_option('prefix')) 898 else 899 cmake_install_libdir = run_command(relative_to, cmake_install_libdir, get_option('prefix'), check: true).stdout().strip() 900 endif 901 endif 902 903 cmake_config.set('PACKAGE_INIT', ''' 904 get_filename_component(PACKAGE_PREFIX_DIR "@0@" ABSOLUTE) 905 906 macro(set_and_check _var _file) 907 set(${_var} "${_file}") 908 if(NOT EXISTS "${_file}") 909 message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") 910 endif() 911 endmacro() 912 913 macro(check_required_components _NAME) 914 foreach(comp ${${_NAME}_FIND_COMPONENTS}) 915 if(NOT ${_NAME}_${comp}_FOUND) 916 if(${_NAME}_FIND_REQUIRED_${comp}) 917 set(${_NAME}_FOUND FALSE) 918 endif() 919 endif() 920 endforeach() 921 endmacro() 922 '''.format(cmake_package_prefix_dir)) 923 924 cmake_config.set('PACKAGE_CMAKE_INSTALL_INCLUDEDIR', '${PACKAGE_PREFIX_DIR}/@0@'.format(cmake_install_includedir)) 925 cmake_config.set('PACKAGE_CMAKE_INSTALL_LIBDIR', '${PACKAGE_PREFIX_DIR}/@0@'.format(cmake_install_libdir)) 926 cmake_config.set('PACKAGE_INCLUDE_INSTALL_DIR', '${PACKAGE_PREFIX_DIR}/@0@/@1@'.format(cmake_install_includedir, meson.project_name())) 927 cmake_config.set('HARFBUZZ_VERSION', meson.project_version()) 928 cmake_config.set('HB_HAVE_GOBJECT', have_gobject ? 'YES' : 'NO') 929 cmake_config.set('HB_LIBRARY_TYPE', get_option('default_library') == 'static' ? 'STATIC' : 'SHARED') 930 931 if get_option('default_library') == 'static' 932 cmake_config.set('HB_LIB_PREFIX', '${CMAKE_STATIC_LIBRARY_PREFIX}') 933 cmake_config.set('HB_LIB_SUFFIX', '${CMAKE_STATIC_LIBRARY_SUFFIX}') 934 elif host_machine.system() == 'darwin' 935 cmake_config.set('HB_LIB_PREFIX', '${CMAKE_SHARED_LIBRARY_PREFIX}') 936 cmake_config.set('HB_LIB_SUFFIX', '.@0@${CMAKE_SHARED_LIBRARY_SUFFIX}'.format(hb_so_version)) 937 elif host_machine.system() == 'windows' 938 cmake_config.set('HB_LIB_PREFIX', '${CMAKE_IMPORT_LIBRARY_PREFIX}') 939 cmake_config.set('HB_LIB_SUFFIX', '${CMAKE_IMPORT_LIBRARY_SUFFIX}') 940 else 941 cmake_config.set('HB_LIB_PREFIX', '${CMAKE_SHARED_LIBRARY_PREFIX}') 942 cmake_config.set('HB_LIB_SUFFIX', '${CMAKE_SHARED_LIBRARY_SUFFIX}.@0@'.format(version)) 943 endif 944 945 configure_file(input: 'harfbuzz-config.cmake.in', 946 output: 'harfbuzz-config.cmake', 947 configuration: cmake_config, 948 install_dir: cmake_config_dir, 949 ) 950 951 gobject_enums_c = [] 952 gobject_enums_h = [] 953 libharfbuzz_gobject_dep = null_dep 954 if have_gobject 955 gnome = import('gnome') 956 957 h_templ = configure_file( 958 input: 'hb-gobject-enums.h.tmpl', 959 output: 'hb-gobject-enums-tmp.h.tmpl', 960 copy: true) 961 962 cc_templ = configure_file( 963 input: 'hb-gobject-enums.cc.tmpl', 964 output: 'hb-gobject-enums-tmp.cc.tmpl', 965 copy: true) 966 967 enums = gnome.mkenums('hb-gobject', 968 sources: hb_headers, 969 h_template: h_templ, 970 c_template: cc_templ, 971 identifier_prefix: 'hb_', 972 symbol_prefix: 'hb_gobject', 973 ) 974 975 gobject_enums_c = custom_target('hb-gobject-enums.cc', 976 input: enums[0], 977 output: 'hb-gobject-enums.cc', 978 command: [find_program('fix_get_types.py'), '@INPUT@', '@OUTPUT@'] 979 ) 980 981 gobject_enums_h = custom_target('hb-gobject-enums.h', 982 input: enums[1], 983 output: 'hb-gobject-enums.h', 984 command: [find_program('fix_get_types.py'), '@INPUT@', '@OUTPUT@'], 985 install: true, 986 install_dir: get_option('prefix') / get_option('includedir') / meson.project_name(), 987 ) 988 989 hb_gobject_sources += [gobject_enums_c] 990 991 harfbuzz_gobject_def = custom_target('harfbuzz-gobject.def', 992 command: gen_def_cmd, 993 input: [hb_gobject_headers, gobject_enums_h], 994 output: 'harfbuzz-gobject.def') 995 defs_list += [harfbuzz_gobject_def] 996 997 libharfbuzz_gobject = library('harfbuzz-gobject', [hb_gobject_sources, gobject_enums_c, gobject_enums_h], 998 include_directories: incconfig, 999 dependencies: [glib_dep, gobject_dep], 1000 link_with: [libharfbuzz], 1001 cpp_args: cpp_args + extra_hb_cpp_args, 1002 soversion: hb_so_version, 1003 version: version, 1004 install: true, 1005 darwin_versions: darwin_versions, 1006 link_language: chosen_linker, 1007 ) 1008 1009 gir = find_program('g-ir-scanner', required: get_option('introspection')) 1010 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled()) 1011 1012 build_gir = build_gir and get_option('default_library') != 'static' 1013 if not build_gir and get_option('introspection').enabled() 1014 error('Introspection support is requested but the default library option should be shared or both') 1015 endif 1016 1017 if build_gir 1018 conf.set('HAVE_INTROSPECTION', 1) 1019 hb_gen_files_gir = gnome.generate_gir([libharfbuzz_gobject, libharfbuzz], 1020 sources: [gir_headers, gir_sources, gobject_enums_h], 1021 dependencies: libharfbuzz_dep, 1022 namespace: 'HarfBuzz', 1023 nsversion: '0.0', 1024 identifier_prefix: 'hb_', 1025 symbol_prefix: ['hb', 'hb_gobject'], 1026 includes: ['GObject-2.0', 'freetype2-2.0'], 1027 export_packages: ['harfbuzz-gobject', 'harfbuzz'], 1028 header: 'hb-gobject.h', 1029 install: true, 1030 extra_args: ['--cflags-begin', 1031 '-DHB_NO_SINGLE_HEADER_ERROR', 1032 '-DHAVE_GOBJECT', 1033 '-DHB_EXTERN=', 1034 '--cflags-end']) 1035 endif 1036 1037 libharfbuzz_gobject_dep = declare_dependency( 1038 link_with: libharfbuzz_gobject, 1039 include_directories: incsrc, 1040 sources: build_gir ? hb_gen_files_gir : hb_gobject_sources, 1041 dependencies: [glib_dep, gobject_dep]) 1042 meson.override_dependency('harfbuzz-gobject', libharfbuzz_gobject_dep) 1043 1044 pkgmod.generate(libharfbuzz_gobject, 1045 description: 'HarfBuzz text shaping library GObject integration', 1046 requires: ['harfbuzz = @0@'.format(meson.project_version()), 'glib-2.0', 'gobject-2.0'], 1047 subdirs: [meson.project_name()], 1048 version: meson.project_version(), 1049 ) 1050 1051 install_headers(hb_gobject_headers, subdir: meson.project_name()) 1052 else 1053 if get_option('introspection').enabled() 1054 error('introspection requires gobject to be enabled') 1055 endif 1056 endif 1057 1058 if get_option('tests').enabled() 1059 dist_check_script = [ 1060 'check-c-linkage-decls', 1061 'check-externs', 1062 'check-header-guards', 1063 'check-includes', 1064 ] 1065 1066 env = environment() 1067 HBSOURCES = [] 1068 foreach f : hb_sources 1069 if meson.version().version_compare('>=1.4.0') 1070 f = f.full_path() 1071 endif 1072 HBSOURCES += '@0@'.format(f) 1073 endforeach 1074 env.set('HBSOURCES', ' '.join(HBSOURCES)) 1075 HBHEADERS = [] 1076 foreach f : hb_headers 1077 if meson.version().version_compare('>=1.4.0') 1078 f = f.full_path() 1079 endif 1080 HBHEADERS += '@0@'.format(f) 1081 endforeach 1082 env.set('HBHEADERS', ' '.join(HBHEADERS)) 1083 1084 if cpp.get_argument_syntax() != 'msvc' and not meson.is_cross_build() # ensure the local tools are usable 1085 dist_check_script += ['check-static-inits', 'check-symbols'] 1086 if get_option('wasm').disabled() and not get_option('with_libstdcxx') 1087 dist_check_script += ['check-libstdc++'] 1088 endif 1089 endif 1090 1091 foreach name : dist_check_script 1092 test(name, find_program(name + '.py'), 1093 env: env, 1094 args: [ 1095 meson.current_source_dir(), 1096 meson.project_source_root(), 1097 meson.current_build_dir(), 1098 ], 1099 depends: name == 'check-symbols' ? defs_list : [], 1100 suite: ['src'], 1101 ) 1102 endforeach 1103 1104 test('check-release-notes', 1105 find_program('check-release-notes.py'), 1106 args: [ 1107 meson.current_source_dir() / '..' / 'NEWS', 1108 meson.project_version() 1109 ], 1110 ) 1111 endif 1112 1113 install_headers(hb_headers + hb_subset_headers, subdir: meson.project_name())