1# Copyright © 2018, 2019 Iñigo Martínez
2# Copyright © 2019 Christian Persch
3#
4# This library is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License as published
6# by the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library.  If not, see <https://www.gnu.org/licenses/>.
16
17subdir('vte')
18
19src_inc = include_directories('.')
20
21a11y_sources = files(
22  'vteaccess.cc',
23  'vteaccess.h',
24)
25
26debug_sources = files(
27  'debug.cc',
28  'debug.h',
29)
30
31glib_glue_sources = files(
32  'glib-glue.hh',
33)
34
35gtk_glue_sources = files(
36  'gtk-glue.hh',
37)
38
39icu_sources = files(
40  'icu-converter.cc',
41  'icu-converter.hh',
42  'icu-decoder.cc',
43  'icu-decoder.hh',
44  'icu-glue.cc',
45  'icu-glue.hh',
46)
47
48libc_glue_sources = files(
49  'libc-glue.hh',
50)
51
52modes_sources = files(
53  'modes.hh',
54)
55
56modes_sources += custom_target(
57  'modes',
58  command: [
59    files('modes.py'),
60    '--destdir', '@OUTDIR@',
61  ],
62  input: [],
63  install: false,
64  output: [
65    'modes-dec.hh',
66    'modes-ecma.hh',
67  ],
68)
69
70pango_glue_sources = files(
71  'pango-glue.hh',
72)
73
74parser_sources = files(
75  'parser-arg.hh',
76  'parser-charset-tables.hh',
77  'parser-charset.hh',
78  'parser-decsgr.hh',
79  'parser-glue.hh',
80  'parser-osc.hh',
81  'parser-reply.hh',
82  'parser-sgr.hh',
83  'parser-string.hh',
84  'parser.cc',
85  'parser.hh',
86)
87
88parser_sources += custom_target(
89  'parser-seq',
90  command: [
91    files('parser-seq.py'),
92    '--destdir', '@OUTDIR@',
93  ],
94  input: [],
95  install: false,
96  output: [
97    'parser-c01.hh',
98    'parser-cmd.hh',
99    'parser-csi.hh',
100    'parser-dcs.hh',
101    'parser-esc.hh',
102    'parser-sci.hh',
103  ],
104)
105
106pcre2_glue_sources = files(
107  'pcre2-glue.hh',
108)
109
110pty_sources = files(
111  'pty.cc',
112  'pty.hh',
113  'vtepty.cc',
114  'vteptyinternal.hh',
115)
116
117refptr_sources = files(
118  'refptr.hh',
119)
120
121regex_sources = files(
122  'regex.cc',
123  'regex.hh'
124)
125
126std_glue_sources = files(
127  'std-glue.hh',
128)
129
130systemd_sources = files(
131  'systemd.cc',
132  'systemd.hh',
133)
134
135utf8_sources = files(
136  'utf8.cc',
137  'utf8.hh',
138)
139
140libvte_common_sources = config_sources + debug_sources + glib_glue_sources + gtk_glue_sources + libc_glue_sources + modes_sources + pango_glue_sources + parser_sources + pcre2_glue_sources + pty_sources + refptr_sources + regex_sources + std_glue_sources + utf8_sources + files(
141  'attr.hh',
142  'bidi.cc',
143  'bidi.hh',
144  'buffer.h',
145  'cairo-glue.hh',
146  'caps.hh',
147  'cell.hh',
148  'chunk.cc',
149  'chunk.hh',
150  'clipboard-gtk.cc',
151  'clipboard-gtk.hh',
152  'color-triple.hh',
153  'cxx-utils.hh',
154  'drawing-cairo.cc',
155  'drawing-cairo.hh',
156  'fonts-pangocairo.cc',
157  'fonts-pangocairo.hh',
158  'gobject-glue.hh',
159  'keymap.cc',
160  'keymap.h',
161  'minifont.cc',
162  'minifont.hh',
163  'missing.cc',
164  'missing.hh',
165  'reaper.cc',
166  'reaper.hh',
167  'ring.cc',
168  'ring.hh',
169  'ringview.cc',
170  'ringview.hh',
171  'spawn.cc',
172  'spawn.hh',
173  'utf8.cc',
174  'utf8.hh',
175  'vte.cc',
176  'vtedefines.hh',
177  'vtegtk.cc',
178  'vtegtk.hh',
179  'vteinternal.hh',
180  'vteregex.cc',
181  'vteregexinternal.hh',
182  'vterowdata.cc',
183  'vterowdata.hh',
184  'vteseq.cc',
185  'vtespawn.cc',
186  'vtespawn.hh',
187  'vtestream-base.h',
188  'vtestream-file.h',
189  'vtestream.cc',
190  'vtestream.h',
191  'vtetypes.cc',
192  'vtetypes.hh',
193  'vteunistr.cc',
194  'vteunistr.h',
195  'vteutils.cc',
196  'vteutils.h',
197  'widget.cc',
198  'widget.hh',
199)
200
201if get_option('a11y')
202  libvte_common_sources += a11y_sources
203endif
204
205if get_option('icu')
206  libvte_common_sources += icu_sources
207endif
208
209if systemd_dep.found()
210  libvte_common_sources += systemd_sources
211endif
212
213libvte_common_doc_sources = files(
214  # These file contain gtk-doc comments to be extracted for docs and gir
215  'vtegtk.cc',
216  'vtepty.cc',
217  'vteregex.cc',
218)
219
220# FIXMEchpe this should use files('...') (allowed as per docs, afaict), but that crashes meson
221generate_box_drawing = find_program('box_drawing_generate.sh')
222
223libvte_common_sources += custom_target(
224  'box-drawing',
225  input: 'box_drawing.txt',
226  output: 'box_drawing.h',
227  capture: true,
228  command: [generate_box_drawing, '@INPUT@'],
229  install: false,
230)
231
232libvte_common_sources += gnome.compile_resources(
233  'vteresources',
234  'vte.gresource.xml',
235  c_name: '_vte',
236)
237
238libvte_common_sources += gnome.genmarshal(
239  'marshal',
240  sources: 'marshal.list',
241  prefix: '_vte_marshal',
242  internal: true,
243  valist_marshallers: true,
244)
245
246libvte_common_public_deps = [
247  gio_dep,
248  glib_dep,
249  gobject_dep,
250  pango_dep,
251]
252
253libvte_common_deps = libvte_common_public_deps + [
254  fribidi_dep,
255  gnutls_dep,
256  icu_dep,
257  pcre2_dep,
258  libm_dep,
259  pthreads_dep,
260  systemd_dep,
261  zlib_dep,
262]
263
264incs = [
265  top_inc,
266  vte_inc,
267]
268
269libvte_common_cppflags = [
270  '-DG_LOG_DOMAIN="VTE"',
271  '-DLOCALEDIR="@0@"'.format(vte_prefix / vte_localedir),
272  '-DVTE_DISABLE_DEPRECATION_WARNINGS',
273  '-DVTE_COMPILATION',
274  '-UPARSER_INCLUDE_NOP',
275]
276
277if get_option('gtk3')
278  libvte_gtk3_sources = libvte_common_sources + libvte_gtk3_public_headers + libvte_gtk3_enum_sources
279  libvte_gtk3_cppflags = libvte_common_cppflags + gtk3_version_cppflags
280  libvte_gtk3_deps = libvte_common_deps + [gtk3_dep]
281  libvte_gtk3_public_deps = libvte_common_public_deps + [gtk3_dep]
282
283  libvte_gtk3 = shared_library(
284    vte_gtk3_api_name,
285    sources: libvte_gtk3_sources,
286    version: libvte_gtk3_soversion,
287    include_directories: incs,
288    dependencies: libvte_gtk3_deps,
289    cpp_args: libvte_gtk3_cppflags,
290    install: true,
291  )
292
293  libvte_gtk3_dep = declare_dependency(
294    sources: libvte_gtk3_public_headers,
295    include_directories: [src_inc, vte_inc],
296    dependencies: libvte_gtk3_deps,
297    link_with: libvte_gtk3
298  )
299
300  pkg.generate(
301    libvte_gtk3,
302    version: vte_version,
303    name: 'vte',
304    description: 'VTE widget for GTK+ 3.0',
305    filebase: vte_gtk3_api_name,
306    subdirs: vte_gtk3_api_name,
307    requires: libvte_gtk3_public_deps,
308    variables: 'exec_prefix=${prefix}',
309  )
310endif
311
312## Tests
313
314# decoder cat
315
316decoder_cat_sources = config_sources + glib_glue_sources + libc_glue_sources + utf8_sources + debug_sources + files(
317  'decoder-cat.cc',
318)
319
320if get_option('icu')
321  decoder_cat_sources += icu_sources
322endif
323
324decoder_cat = executable(
325  'decoder-cat',
326  decoder_cat_sources,
327  dependencies: [glib_dep, icu_dep,],
328  cpp_args: [],
329  include_directories: top_inc,
330  install: false,
331)
332
333# parser cat
334
335parser_cat_sources = config_sources + glib_glue_sources + libc_glue_sources + parser_sources + std_glue_sources + utf8_sources + debug_sources + files(
336  'parser-cat.cc',
337  'vtedefines.hh',
338)
339
340parser_cat = executable(
341  'parser-cat',
342  parser_cat_sources,
343  dependencies: [glib_dep,],
344  cpp_args: ['-DPARSER_INCLUDE_NOP'],
345  include_directories: top_inc,
346  install: false,
347)
348
349# dumpkeys
350
351dumpkeys_sources = config_sources + files(
352  'dumpkeys.c'
353)
354
355dumpkeys = executable(
356  'dumpkeys',
357  sources: dumpkeys_sources,
358  dependencies: [glib_dep],
359  include_directories: top_inc,
360  install: false,
361)
362
363# mev
364
365mev_sources = config_sources + files(
366  'mev.c'
367)
368
369mev = executable(
370  'mev',
371  sources: mev_sources,
372  dependencies: [glib_dep],
373  include_directories: top_inc,
374  install: false,
375)
376
377# slowcat
378
379slowcat_sources = config_sources + files(
380  'slowcat.c'
381)
382
383slowcat = executable(
384  'slowcat',
385  sources: slowcat_sources,
386  dependencies: [glib_dep],
387  include_directories: top_inc,
388  install: false,
389)
390
391# reflect
392
393reflect_sources = config_sources + files(
394  'reflect.c'
395)
396
397reflect_textview = executable(
398  'reflect-textview',
399  sources: reflect_sources,
400  dependencies: [gtk3_dep],
401  c_args: ['-DUSE_TEXT_VIEW'],
402  include_directories: top_inc,
403  install: false,
404)
405
406reflect_vte = executable(
407  'reflect-vte',
408  sources: reflect_sources,
409  dependencies: [gtk3_dep, libvte_gtk3_dep],
410  c_args: [
411    '-DUSE_VTE',
412    '-DVTE_DISABLE_DEPRECATION_WARNINGS',
413  ],
414  include_directories: top_inc,
415  install: false,
416)
417
418# vte-urlencode-cwd
419
420vte_urlencode_cwd_sources = config_sources + files(
421  'urlencode.cc',
422)
423
424vte_urlencode_cwd = executable(
425  'vte-urlencode-cwd',
426  cpp_args: [
427    '-nostdlib',
428  ],
429  include_directories: [top_inc,],
430  install: true,
431  install_dir: vte_libexecdir,
432  sources: vte_urlencode_cwd_sources,
433)
434
435# xticker
436
437xticker_sources = config_sources + files(
438  'xticker.c'
439)
440
441xticker = executable(
442  'xticker',
443  sources: xticker_sources,
444  dependencies: [glib_dep],
445  c_args: ['-DVTE_DISABLE_DEPRECATION_WARNINGS',],
446  include_directories: top_inc,
447  install: false,
448)
449
450# Unit tests
451
452test_modes_sources = config_sources + modes_sources + files(
453  'modes-test.cc',
454)
455
456test_modes = executable(
457  'test-modes',
458  sources: test_modes_sources,
459  dependencies: [glib_dep],
460  include_directories: top_inc,
461  install: false,
462)
463
464test_parser_sources = config_sources + parser_sources + files(
465  'parser-test.cc',
466)
467
468test_parser = executable(
469  'test-parser',
470  sources: test_parser_sources,
471  dependencies: [glib_dep],
472  cpp_args: ['-DPARSER_INCLUDE_NOP'],
473  include_directories: top_inc,
474  install: false,
475)
476
477test_reaper_sources = config_sources + debug_sources + files(
478  'reaper.cc',
479  'reaper.hh'
480)
481
482test_reaper = executable(
483  'test-reaper',
484  sources: test_reaper_sources,
485  dependencies: [gobject_dep],
486  cpp_args: ['-DMAIN'],
487  include_directories: top_inc,
488  install: false,
489)
490
491test_refptr_sources = config_sources + files(
492  'refptr-test.cc',
493  'refptr.hh'
494)
495
496test_refptr = executable(
497  'test-refptr',
498  sources: test_refptr_sources,
499  dependencies: [glib_dep, gobject_dep],
500  include_directories: top_inc,
501  install: false,
502)
503
504test_stream_sources = config_sources + files(
505  'vtestream-base.h',
506  'vtestream-file.h',
507  'vtestream.cc',
508  'vtestream.h',
509  'vteutils.cc',
510  'vteutils.h',
511)
512
513test_stream = executable(
514  'test-stream',
515  sources: test_stream_sources,
516  dependencies: [gio_dep, gnutls_dep, zlib_dep],
517  cpp_args: ['-DVTESTREAM_MAIN'],
518  include_directories: top_inc,
519  install: false,
520)
521
522test_tabstops_sources = config_sources + files(
523  'tabstops-test.cc',
524  'tabstops.hh'
525)
526
527test_tabstops = executable(
528  'test-tabstops',
529  sources: test_tabstops_sources,
530  dependencies: [glib_dep],
531  include_directories: top_inc,
532  install: false,
533)
534
535test_utf8_sources = config_sources + utf8_sources + files(
536  'utf8-test.cc',
537)
538
539test_utf8 = executable(
540  'test-utf8',
541  sources: test_utf8_sources,
542  dependencies: [glib_dep],
543  include_directories: top_inc,
544  install: false,
545)
546
547test_vtetypes_sources = config_sources + libc_glue_sources + files(
548   'vtetypes.cc',
549   'vtetypes.hh',
550)
551
552test_vtetypes = executable(
553  'test-vtetypes',
554  sources: test_vtetypes_sources,
555  dependencies: [glib_dep, pango_dep, gtk3_dep],
556  cpp_args: ['-DMAIN'],
557  include_directories: top_inc,
558  install: false,
559)
560
561test_env = [
562  'VTE_DEBUG=0'
563]
564
565# apparently there is no way to get a name back from an executable(), so it this ugly way
566test_units = [
567  ['modes', test_modes],
568  ['parser', test_parser],
569  ['reaper', test_reaper],
570  ['refptr', test_refptr],
571  ['stream', test_stream],
572  ['tabstops', test_tabstops],
573  ['utf8', test_utf8],
574  ['vtetypes', test_vtetypes],
575]
576
577foreach test: test_units
578  test(
579    test[0],
580    test[1],
581    env: test_env,
582    timeout: 600, # See issue vte#120
583  )
584endforeach
585
586test_scripts = [
587  ['doc syntax', 'check-doc-syntax.sh'],
588]
589
590foreach test: test_scripts
591  test(
592    test[0],
593    files(test[1]),
594  )
595endforeach
596
597test_scripts_with_arg = [
598  ['vte-urlencode-cwd', 'test-vte-urlencode-cwd.sh', vte_urlencode_cwd],
599]
600
601foreach test: test_scripts_with_arg
602  test(
603    test[0],
604    files(test[1]),
605    args: [test[2]],
606  )
607endforeach
608
609# Shell integration
610
611vte_csh = configure_file(
612  input: 'vte.csh.in',
613  output: '@BASENAME@',
614  configuration: {
615    'libexecdir': vte_prefix / vte_libexecdir,
616  },
617  install: true,
618  install_dir: vte_sysconfdir / 'profile.d',
619)
620
621vte_sh = configure_file(
622  input: 'vte.sh.in',
623  output: '@BASENAME@',
624  configuration: {
625    'libexecdir': vte_prefix / vte_libexecdir,
626  },
627  install: true,
628  install_dir: vte_sysconfdir / 'profile.d',
629)
630
631# Systemd integration
632
633if systemd_dep.found()
634  install_data(
635    sources: 'vte-spawn-.scope.conf',
636    install_dir: vte_systemduserunitdir / 'vte-spawn-.scope.d',
637    rename: 'defaults.conf'
638  )
639endif
640
641# Demo application
642
643subdir('app')
644