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