• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1hb_version_h = configure_file(
2               command: [find_program('gen-hb-version.py'), meson.project_version(), '@OUTPUT@', '@INPUT@'],
3               input: 'hb-version.h.in',
4               output: 'hb-version.h',
5               install: true,
6               install_dir: get_option('includedir') / meson.project_name())
7
8# Base and default-included sources and headers
9hb_base_sources = files(
10  'hb-aat-layout-ankr-table.hh',
11  'hb-aat-layout-bsln-table.hh',
12  'hb-aat-layout-common.hh',
13  'hb-aat-layout-feat-table.hh',
14  'hb-aat-layout-just-table.hh',
15  'hb-aat-layout-kerx-table.hh',
16  'hb-aat-layout-morx-table.hh',
17  'hb-aat-layout-opbd-table.hh',
18  'hb-aat-layout-trak-table.hh',
19  'hb-aat-layout.cc',
20  'hb-aat-layout.hh',
21  'hb-aat-ltag-table.hh',
22  'hb-aat-map.cc',
23  'hb-aat-map.hh',
24  'hb-algs.hh',
25  'hb-array.hh',
26  'hb-atomic.hh',
27  'hb-bimap.hh',
28  'hb-bit-page.hh',
29  'hb-blob.cc',
30  'hb-blob.hh',
31  'hb-buffer-serialize.cc',
32  'hb-buffer.cc',
33  'hb-buffer.hh',
34  'hb-cache.hh',
35  'hb-cff-interp-common.hh',
36  'hb-cff-interp-cs-common.hh',
37  'hb-cff-interp-dict-common.hh',
38  'hb-cff1-interp-cs.hh',
39  'hb-cff2-interp-cs.hh',
40  'hb-common.cc',
41  'hb-config.hh',
42  'hb-debug.hh',
43  'hb-dispatch.hh',
44  'hb-draw.cc',
45  'hb-draw.hh',
46  'hb-face.cc',
47  'hb-face.hh',
48  'hb-fallback-shape.cc',
49  'hb-font.cc',
50  'hb-font.hh',
51  'hb-iter.hh',
52  'hb-kern.hh',
53  'hb-machinery.hh',
54  'hb-map.cc',
55  'hb-map.hh',
56  'hb-meta.hh',
57  'hb-ms-feature-ranges.cc',
58  'hb-ms-feature-ranges.hh',
59  'hb-mutex.hh',
60  'hb-null.hh',
61  'hb-number.cc',
62  'hb-number.hh',
63  'hb-object.hh',
64  'hb-open-file.hh',
65  'hb-open-type.hh',
66  'hb-ot-cff-common.hh',
67  'hb-ot-cff1-std-str.hh',
68  'hb-ot-cff1-table.cc',
69  'hb-ot-cff1-table.hh',
70  'hb-ot-cff2-table.cc',
71  'hb-ot-cff2-table.hh',
72  'hb-ot-cmap-table.hh',
73  'hb-ot-color-cbdt-table.hh',
74  'hb-ot-color-colr-table.hh',
75  'hb-ot-color-cpal-table.hh',
76  'hb-ot-color-sbix-table.hh',
77  'hb-ot-color-svg-table.hh',
78  'hb-ot-color.cc',
79  'hb-ot-face-table-list.hh',
80  'hb-ot-face.cc',
81  'hb-ot-face.hh',
82  'hb-ot-font.cc',
83  'hb-ot-gasp-table.hh',
84  'hb-ot-glyf-table.hh',
85  'hb-ot-hdmx-table.hh',
86  'hb-ot-head-table.hh',
87  'hb-ot-hhea-table.hh',
88  'hb-ot-hmtx-table.hh',
89  'hb-ot-kern-table.hh',
90  'hb-ot-layout-base-table.hh',
91  'hb-ot-layout-common.hh',
92  'hb-ot-layout-gdef-table.hh',
93  'hb-ot-layout-gpos-table.hh',
94  'hb-ot-layout-gsub-table.hh',
95  'hb-ot-layout-gsubgpos.hh',
96  'hb-ot-layout-jstf-table.hh',
97  'hb-ot-layout.cc',
98  'hb-ot-layout.hh',
99  'hb-ot-map.cc',
100  'hb-ot-map.hh',
101  'hb-ot-math-table.hh',
102  'hb-ot-math.cc',
103  'hb-ot-maxp-table.hh',
104  'hb-ot-meta-table.hh',
105  'hb-ot-meta.cc',
106  'hb-ot-metrics.cc',
107  'hb-ot-metrics.hh',
108  'hb-ot-name-language-static.hh',
109  'hb-ot-name-language.hh',
110  'hb-ot-name-table.hh',
111  'hb-ot-name.cc',
112  'hb-ot-os2-table.hh',
113  'hb-ot-os2-unicode-ranges.hh',
114  'hb-ot-post-macroman.hh',
115  'hb-ot-post-table.hh',
116  'hb-ot-shape-complex-arabic-fallback.hh',
117  'hb-ot-shape-complex-arabic-joining-list.hh',
118  'hb-ot-shape-complex-arabic-table.hh',
119  'hb-ot-shape-complex-arabic-win1256.hh',
120  'hb-ot-shape-complex-arabic.cc',
121  'hb-ot-shape-complex-arabic.hh',
122  'hb-ot-shape-complex-default.cc',
123  'hb-ot-shape-complex-hangul.cc',
124  'hb-ot-shape-complex-hebrew.cc',
125  'hb-ot-shape-complex-indic-table.cc',
126  'hb-ot-shape-complex-indic.cc',
127  'hb-ot-shape-complex-indic.hh',
128  'hb-ot-shape-complex-khmer.cc',
129  'hb-ot-shape-complex-khmer.hh',
130  'hb-ot-shape-complex-myanmar.cc',
131  'hb-ot-shape-complex-myanmar.hh',
132  'hb-ot-shape-complex-syllabic.cc',
133  'hb-ot-shape-complex-syllabic.hh',
134  'hb-ot-shape-complex-thai.cc',
135  'hb-ot-shape-complex-use-table.hh',
136  'hb-ot-shape-complex-use.cc',
137  'hb-ot-shape-complex-vowel-constraints.cc',
138  'hb-ot-shape-complex-vowel-constraints.hh',
139  'hb-ot-shape-complex.hh',
140  'hb-ot-shape-fallback.cc',
141  'hb-ot-shape-fallback.hh',
142  'hb-ot-shape-normalize.cc',
143  'hb-ot-shape-normalize.hh',
144  'hb-ot-shape.cc',
145  'hb-ot-shape.hh',
146  'hb-ot-stat-table.hh',
147  'hb-ot-tag-table.hh',
148  'hb-ot-tag.cc',
149  'hb-ot-var-avar-table.hh',
150  'hb-ot-var-common.hh',
151  'hb-ot-var-fvar-table.hh',
152  'hb-ot-var-gvar-table.hh',
153  'hb-ot-var-hvar-table.hh',
154  'hb-ot-var-mvar-table.hh',
155  'hb-ot-var.cc',
156  'hb-ot-vorg-table.hh',
157  'hb-pool.hh',
158  'hb-sanitize.hh',
159  'hb-serialize.hh',
160  'hb-set-digest.hh',
161  'hb-set.cc',
162  'hb-set.hh',
163  'hb-shape-plan.cc',
164  'hb-shape-plan.hh',
165  'hb-shape.cc',
166  'hb-shaper-impl.hh',
167  'hb-shaper-list.hh',
168  'hb-shaper.cc',
169  'hb-shaper.hh',
170  'hb-static.cc',
171  'hb-string-array.hh',
172  'hb-style.cc',
173  'hb-ucd-table.hh',
174  'hb-ucd.cc',
175  'hb-unicode-emoji-table.hh',
176  'hb-unicode.cc',
177  'hb-unicode.hh',
178  'hb-utf.hh',
179  'hb-vector.hh',
180  'hb.hh',
181)
182
183hb_base_ragel_generated_sources = files(
184  'hb-buffer-deserialize-json.hh',
185  'hb-buffer-deserialize-text.hh',
186  'hb-number-parser.hh',
187  'hb-ot-shape-complex-indic-machine.hh',
188  'hb-ot-shape-complex-khmer-machine.hh',
189  'hb-ot-shape-complex-myanmar-machine.hh',
190  'hb-ot-shape-complex-use-machine.hh',
191)
192hb_base_ragel_sources = [
193  'hb-buffer-deserialize-json.rl',
194  'hb-buffer-deserialize-text.rl',
195  'hb-number-parser.rl',
196  'hb-ot-shape-complex-indic-machine.rl',
197  'hb-ot-shape-complex-khmer-machine.rl',
198  'hb-ot-shape-complex-myanmar-machine.rl',
199  'hb-ot-shape-complex-use-machine.rl',
200]
201
202hb_base_headers = files(
203  'hb-aat-layout.h',
204  'hb-aat.h',
205  'hb-blob.h',
206  'hb-buffer.h',
207  'hb-common.h',
208  'hb-deprecated.h',
209  'hb-draw.h',
210  'hb-face.h',
211  'hb-font.h',
212  'hb-map.h',
213  'hb-ot-color.h',
214  'hb-ot-deprecated.h',
215  'hb-ot-font.h',
216  'hb-ot-layout.h',
217  'hb-ot-math.h',
218  'hb-ot-meta.h',
219  'hb-ot-metrics.h',
220  'hb-ot-name.h',
221  'hb-ot-shape.h',
222  'hb-ot-var.h',
223  'hb-ot.h',
224  'hb-set.h',
225  'hb-shape-plan.h',
226  'hb-shape.h',
227  'hb-style.h',
228  'hb-unicode.h',
229  'hb.h',
230)
231hb_base_headers += hb_version_h
232
233# Optional Sources and Headers with external deps
234
235hb_ft_sources = files('hb-ft.cc')
236hb_ft_headers = files('hb-ft.h')
237
238hb_glib_sources = files('hb-glib.cc')
239hb_glib_headers = files('hb-glib.h')
240
241hb_graphite2_sources = files('hb-graphite2.cc')
242hb_graphite2_headers = files('hb-graphite2.h')
243
244# System-dependent sources and headers
245
246hb_coretext_sources = files('hb-coretext.cc')
247hb_coretext_headers = files('hb-coretext.h')
248
249hb_directwrite_sources = files('hb-directwrite.cc')
250hb_directwrite_headers = files('hb-directwrite.h')
251
252hb_gdi_sources = files('hb-gdi.cc')
253hb_gdi_headers = files('hb-gdi.h')
254
255hb_uniscribe_sources = files('hb-uniscribe.cc')
256hb_uniscribe_headers = files('hb-uniscribe.h')
257
258# Sources for libharfbuzz-gobject and libharfbuzz-icu
259hb_icu_sources = files('hb-icu.cc')
260hb_icu_headers = files('hb-icu.h')
261
262# Sources for libharfbuzz-subset
263hb_subset_sources = files(
264  'hb-number.cc',
265  'hb-number.hh',
266  'hb-ot-cff1-table.cc',
267  'hb-ot-cff2-table.cc',
268  'hb-static.cc',
269  'hb-subset-cff-common.cc',
270  'hb-subset-cff-common.hh',
271  'hb-subset-cff1.cc',
272  'hb-subset-cff1.hh',
273  'hb-subset-cff2.cc',
274  'hb-subset-cff2.hh',
275  'hb-subset-input.cc',
276  'hb-subset-input.hh',
277  'hb-subset-plan.cc',
278  'hb-subset-plan.hh',
279  'hb-subset.cc',
280  'hb-subset.hh',
281)
282
283hb_subset_headers = files('hb-subset.h')
284
285hb_gobject_sources = files(
286  'hb-gobject-structs.cc'
287)
288
289hb_gobject_headers = files(
290  'hb-gobject.h',
291  'hb-gobject-structs.h',
292)
293
294ragel = find_program('ragel', version: '6.10', required: false)
295has_ragel = ragel.found()
296if not has_ragel and get_option('ragel_subproject')
297    ragel = subproject('ragel').get_variable('ragel')
298    has_ragel = true
299endif
300if not has_ragel
301  warning('You have to install ragel if you are going to develop HarfBuzz itself')
302else
303  ragel_helper = find_program('gen-ragel-artifacts.py')
304  foreach rl : hb_base_ragel_sources
305    hh = rl.split('.')[0] + '.hh'
306    custom_target('@0@'.format(hh),
307      build_by_default: true,
308      input: rl,
309      output: hh,
310      command: [ragel_helper, ragel, '@OUTPUT@', meson.current_source_dir(), '@INPUT@'],
311    )
312  endforeach
313endif
314
315custom_target('harfbuzz.cc',
316  build_by_default: true,
317  output: 'harfbuzz.cc',
318  input: hb_base_sources + hb_glib_sources + hb_ft_sources +
319         hb_graphite2_sources + hb_uniscribe_sources + hb_gdi_sources +
320         hb_directwrite_sources + hb_coretext_sources,
321  command: [find_program('gen-harfbuzzcc.py'),
322            '@OUTPUT@', meson.current_source_dir(), '@INPUT@'],
323)
324
325incsrc = include_directories('.')
326
327hb_sources = hb_base_sources + hb_base_ragel_generated_sources
328hb_headers = hb_base_headers
329
330harfbuzz_deps = [thread_dep, m_dep] + harfbuzz_extra_deps
331
332libharfbuzz_link_language = 'c'
333
334if conf.get('HAVE_FREETYPE', 0) == 1
335  hb_sources += hb_ft_sources
336  hb_headers += hb_ft_headers
337  harfbuzz_deps += [freetype_dep]
338endif
339
340if conf.get('HAVE_GDI', 0) == 1
341  hb_sources += hb_gdi_sources
342  hb_headers += hb_gdi_headers
343  harfbuzz_deps += gdi_uniscribe_deps
344endif
345
346if conf.get('HAVE_GRAPHITE2', 0) == 1
347  hb_sources += hb_graphite2_sources
348  hb_headers += hb_graphite2_headers
349  harfbuzz_deps += [graphite2_dep, graphite_dep]
350endif
351
352if conf.get('HAVE_GLIB', 0) == 1
353  hb_sources += hb_glib_sources
354  hb_headers += hb_glib_headers
355  harfbuzz_deps += [glib_dep]
356endif
357
358if conf.get('HAVE_UNISCRIBE', 0) == 1
359  hb_sources += hb_uniscribe_sources
360  hb_headers += hb_uniscribe_headers
361endif
362
363if conf.get('HAVE_DIRECTWRITE', 0) == 1
364  hb_sources += hb_directwrite_sources
365  hb_headers += hb_directwrite_headers
366  # hb-directwrite needs a C++ linker
367  libharfbuzz_link_language = 'cpp'
368endif
369
370if conf.get('HAVE_CORETEXT', 0) == 1
371  hb_sources += hb_coretext_sources
372  hb_headers += hb_coretext_headers
373  harfbuzz_deps += coretext_deps
374endif
375
376have_icu = conf.get('HAVE_ICU', 0) == 1
377have_icu_builtin = conf.get('HAVE_ICU_BUILTIN', 0) == 1
378
379if have_icu and have_icu_builtin
380  hb_sources += hb_icu_sources
381  hb_headers += hb_icu_headers
382  harfbuzz_deps += [icu_dep]
383endif
384
385# harfbuzz
386gen_def = find_program('gen-def.py')
387
388harfbuzz_def_command_args = [gen_def, '@OUTPUT@', '@INPUT@']
389if get_option('experimental_api')
390  harfbuzz_def_command_args += '--experimental-api'
391endif
392
393harfbuzz_def = custom_target('harfbuzz.def',
394    command: harfbuzz_def_command_args,
395    input: hb_headers,
396    output: 'harfbuzz.def')
397defs_list = [harfbuzz_def]
398
399version = '0.@0@.0'.format(hb_version_int)
400
401extra_hb_cpp_args = []
402if cpp.get_id() == 'msvc'
403  if get_option('default_library') != 'static'
404    extra_hb_cpp_args += '-DHB_DLL_EXPORT'
405  endif
406  hb_so_version = ''
407else
408  hb_so_version = '0'
409endif
410
411if get_option('fuzzer_ldflags') != ''
412  extra_hb_cpp_args += ['-DHB_CUSTOM_MALLOC']
413  hb_sources += 'failing-alloc.c'
414  hb_subset_sources += 'failing-alloc.c'
415  hb_icu_sources += 'failing-alloc.c'
416  hb_gobject_sources += 'failing-alloc.c'
417endif
418
419darwin_versions = [hb_version_int, '@0@.0.0'.format(hb_version_int)]
420
421libharfbuzz = library('harfbuzz', hb_sources,
422  include_directories: incconfig,
423  dependencies: harfbuzz_deps,
424  cpp_args: cpp_args + extra_hb_cpp_args,
425  soversion: hb_so_version,
426  version: version,
427  install: true,
428  darwin_versions: darwin_versions,
429  link_language: libharfbuzz_link_language,
430)
431
432libharfbuzz_dep = declare_dependency(
433  link_with: libharfbuzz,
434  include_directories: incsrc,
435  dependencies: harfbuzz_deps)
436
437# harfbuzz-subset
438harfbuzz_subset_def = custom_target('harfbuzz-subset.def',
439    command: [gen_def, '@OUTPUT@', '@INPUT@'],
440    input: hb_subset_headers,
441    output: 'harfbuzz-subset.def')
442defs_list += [harfbuzz_subset_def]
443
444libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources,
445  include_directories: incconfig,
446  dependencies: [m_dep],
447  link_with: [libharfbuzz],
448  cpp_args: cpp_args + extra_hb_cpp_args,
449  soversion: hb_so_version,
450  version: version,
451  install: true,
452  darwin_versions: darwin_versions,
453  link_language: 'c',
454)
455
456libharfbuzz_subset_dep = declare_dependency(
457  link_with: libharfbuzz_subset,
458  include_directories: incsrc,
459  dependencies: [m_dep])
460
461if get_option('tests').enabled()
462  # TODO: MSVC gives the following,
463  # error LNK2019: unresolved external symbol "unsigned __int64 const * const _hb_NullPool"
464  if cpp.get_id() != 'msvc'
465    noinst_programs = {
466      'main': 'main.cc',
467      'test-basics': 'test.cc',
468      'test-buffer-serialize': 'test-buffer-serialize.cc',
469      'test-ot-meta': 'test-ot-meta.cc',
470      'test-ot-name': 'test-ot-name.cc',
471      'test-ot-glyphname': 'test-ot-glyphname.cc',
472      'test-ot-gpos-size-params': 'test-gpos-size-params.cc',
473      'test-ot-gsub-would-substitute': 'test-gsub-would-substitute.cc',
474    }
475    foreach name, source : noinst_programs
476      executable(name, source,
477        include_directories: incconfig,
478        cpp_args: cpp_args,
479        dependencies: libharfbuzz_dep,
480        install: false,
481      )
482    endforeach
483  endif
484
485  compiled_tests = {
486    'test-algs': ['test-algs.cc', 'hb-static.cc'],
487    'test-array': ['test-array.cc'],
488    'test-repacker': ['test-repacker.cc', 'hb-static.cc'],
489    'test-priority-queue': ['test-priority-queue.cc', 'hb-static.cc'],
490    'test-iter': ['test-iter.cc', 'hb-static.cc'],
491    'test-map': ['test-map.cc', 'hb-static.cc'],
492    'test-number': ['test-number.cc', 'hb-number.cc'],
493    'test-ot-tag': ['hb-ot-tag.cc'],
494    'test-set': ['test-set.cc', 'hb-static.cc'],
495    'test-unicode-ranges': ['test-unicode-ranges.cc'],
496    'test-vector': ['test-vector.cc', 'hb-static.cc'],
497    'test-bimap': ['test-bimap.cc', 'hb-static.cc'],
498  }
499  foreach name, source : compiled_tests
500    if cpp.get_id() == 'msvc' and source.contains('hb-static.cc')
501      # TODO: MSVC doesn't like tests having hb-static.cc, fix them
502      continue
503    endif
504    test(name, executable(name, source,
505      include_directories: incconfig,
506      cpp_args: cpp_args + ['-DMAIN', '-UNDEBUG'],
507      dependencies: libharfbuzz_dep,
508      install: false,
509    ), suite: ['src'])
510  endforeach
511endif
512
513pkgmod.generate(libharfbuzz,
514  description: 'HarfBuzz text shaping library',
515  subdirs: [meson.project_name()],
516  version: meson.project_version(),
517)
518
519pkgmod.generate(libharfbuzz_subset,
520  description: 'HarfBuzz font subsetter',
521  requires: ['harfbuzz = @0@'.format(meson.project_version())],
522  subdirs: [meson.project_name()],
523  version: meson.project_version(),
524)
525
526libharfbuzz_icu_dep = null_dep
527if have_icu and not have_icu_builtin
528  harfbuzz_icu_def = custom_target('harfbuzz-icu.def',
529    command: [gen_def, '@OUTPUT@', '@INPUT@'],
530    input: [hb_icu_headers],
531    output: 'harfbuzz-icu.def')
532  defs_list += [harfbuzz_icu_def]
533
534  libharfbuzz_icu = library('harfbuzz-icu', [hb_icu_sources, hb_icu_headers],
535    include_directories: incconfig,
536    dependencies: icu_dep,
537    link_with: [libharfbuzz],
538    cpp_args: cpp_args + extra_hb_cpp_args,
539    soversion: hb_so_version,
540    version: version,
541    install: true,
542    darwin_versions: darwin_versions,
543    # ICU links to stdc++ anyway so the default linker is good
544    # link_language: 'c',
545  )
546
547  libharfbuzz_icu_dep = declare_dependency(
548    link_with: libharfbuzz_icu,
549    include_directories: incsrc,
550    dependencies: icu_dep)
551
552  pkgmod.generate(libharfbuzz_icu,
553    description: 'HarfBuzz text shaping library ICU integration',
554    requires: ['harfbuzz = @0@'.format(meson.project_version())],
555    subdirs: [meson.project_name()],
556    version: meson.project_version(),
557  )
558
559  install_headers(hb_icu_headers, subdir: meson.project_name())
560endif
561
562have_gobject = conf.get('HAVE_GOBJECT', 0) == 1
563
564cmake_config = configuration_data()
565cmake_config.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
566cmake_config.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
567cmake_config.set('HB_LIBTOOL_VERSION_INFO', hb_libtool_version_info)
568cmake_config.set('have_gobject', '@0@'.format(have_gobject))
569configure_file(input: 'harfbuzz-config.cmake.in',
570  output: 'harfbuzz-config.cmake',
571  configuration: cmake_config,
572  install_dir: get_option('libdir') / 'cmake' / 'harfbuzz',
573)
574
575libharfbuzz_gobject_dep = null_dep
576if have_gobject
577  gnome = import('gnome')
578
579  h_templ = configure_file(
580    input: 'hb-gobject-enums.h.tmpl',
581    output: 'hb-gobject-enums-tmp.h.tmpl',
582    copy: true)
583
584  cc_templ = configure_file(
585    input: 'hb-gobject-enums.cc.tmpl',
586    output: 'hb-gobject-enums-tmp.cc.tmpl',
587    copy: true)
588
589  enums = gnome.mkenums('hb-gobject',
590    sources: hb_headers,
591    h_template: h_templ,
592    c_template: cc_templ,
593    identifier_prefix: 'hb_',
594    symbol_prefix: 'hb_gobject',
595  )
596
597  enum_c = custom_target('hb-gobject-enums.cc',
598    input: enums[0],
599    output: 'hb-gobject-enums.cc',
600    command: [find_program('fix_get_types.py'), '@INPUT@', '@OUTPUT@']
601  )
602
603  enum_h = custom_target('hb-gobject-enums.h',
604    input: enums[1],
605    output: 'hb-gobject-enums.h',
606    command: [find_program('fix_get_types.py'), '@INPUT@', '@OUTPUT@'],
607    install: true,
608    install_dir: get_option('prefix') / get_option('includedir') / meson.project_name(),
609  )
610
611  hb_gobject_sources += [enum_c]
612
613  harfbuzz_gobject_def = custom_target('harfbuzz-gobject.def',
614    command: [gen_def, '@OUTPUT@', '@INPUT@'],
615    input: [hb_gobject_headers, enum_h],
616    output: 'harfbuzz-gobject.def')
617  defs_list += [harfbuzz_gobject_def]
618
619  libharfbuzz_gobject = library('harfbuzz-gobject', [hb_gobject_sources, enum_c, enum_h],
620    include_directories: incconfig,
621    dependencies: [glib_dep, gobject_dep],
622    link_with: [libharfbuzz],
623    cpp_args: cpp_args + extra_hb_cpp_args,
624    soversion: hb_so_version,
625    version: version,
626    install: true,
627    darwin_versions: darwin_versions,
628    link_language: 'c',
629  )
630
631  gir = find_program('g-ir-scanner', required: get_option('introspection'))
632  build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
633
634  build_gir = build_gir and get_option('default_library') != 'static'
635  if not build_gir and get_option('introspection').enabled()
636    error('Introspection support is requested but the default library option should be shared or both')
637  endif
638
639  if build_gir
640    conf.set('HAVE_INTROSPECTION', 1)
641    hb_gen_files_gir = gnome.generate_gir(libharfbuzz_gobject,
642      sources: [hb_headers, hb_sources, hb_gobject_headers, hb_gobject_sources, enum_h],
643      dependencies: libharfbuzz_dep,
644      namespace: 'HarfBuzz',
645      nsversion: '0.0',
646      identifier_prefix: 'hb_',
647      symbol_prefix: ['hb', 'hb_gobject'],
648      includes: ['GObject-2.0'],
649      export_packages: ['harfbuzz-gobject'],
650      header: 'hb-gobject.h',
651      install: true,
652      extra_args:  ['--cflags-begin',
653                    '-DHB_NO_SINGLE_HEADER_ERROR',
654                    '-DHAVE_GOBJECT',
655                    '-DHB_EXTERN=',
656                    '--cflags-end'])
657  endif
658
659  libharfbuzz_gobject_dep = declare_dependency(
660    link_with: libharfbuzz_gobject,
661    include_directories: incsrc,
662    sources: build_gir ? hb_gen_files_gir : hb_gobject_sources,
663    dependencies: [glib_dep, gobject_dep])
664
665  pkgmod.generate(libharfbuzz_gobject,
666    description: 'HarfBuzz text shaping library GObject integration',
667    requires: ['harfbuzz = @0@'.format(meson.project_version()), 'glib-2.0', 'gobject-2.0'],
668    subdirs: [meson.project_name()],
669    version: meson.project_version(),
670  )
671
672  install_headers(hb_gobject_headers, subdir: meson.project_name())
673else
674  if get_option('introspection').enabled()
675    error('introspection requires gobject to be enabled')
676  endif
677endif
678
679if get_option('tests').enabled()
680  dist_check_script = [
681    'check-c-linkage-decls',
682    'check-externs',
683    'check-header-guards',
684    'check-includes',
685  ]
686
687  env = environment()
688  env.set('srcdir', meson.current_source_dir())
689  env.set('builddir', meson.current_build_dir())
690  env.set('libs', meson.current_build_dir()) # TODO: Merge this with builddir after autotools removal
691  HBSOURCES = []
692  foreach f : hb_sources
693    HBSOURCES += '@0@'.format(f)
694  endforeach
695  env.set('HBSOURCES', ' '.join(HBSOURCES))
696  HBHEADERS = []
697  foreach f : hb_headers
698    HBHEADERS += '@0@'.format(f)
699  endforeach
700  env.set('HBHEADERS', ' '.join(HBHEADERS))
701
702  if cpp.get_id() != 'msvc' and not meson.is_cross_build() # ensure the local tools are usable
703    dist_check_script += ['check-libstdc++', 'check-static-inits', 'check-symbols']
704  endif
705
706  foreach name : dist_check_script
707    test(name, find_program(name + '.py'),
708      env: env,
709      depends: name == 'check-symbols' ? defs_list : [],
710      suite: ['src'],
711    )
712  endforeach
713endif
714
715install_headers(hb_headers + hb_subset_headers, subdir: meson.project_name())
716