summaryrefslogtreecommitdiff
path: root/gen.tab/meson.build
blob: 6006d98541e0249c8e375af5ada68ec4fbb43da3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# gen.tab

native_cc = meson.get_compiler('c')

# Don't pick up top-level config.h, as that has defines for the cross-compiler
# (if we're cross-compiling), but here we need values for the host compiler/env
# in that case. We shall pass those on the command line since it's just a few.
native_args = ['-UHAVE_CONFIG_H']

# This is available pretty much everywhere
native_args += ['-DHAVE_STRINGIZE']

native_args += ['-DDONT_HAVE_FRIBIDI_CONFIG_H']

if native_cc.has_header('stdlib.h')
  native_args += ['-DHAVE_STDLIB_H']
endif

if native_cc.has_header('string.h')
  native_args += ['-DHAVE_STRING_H']
endif

if native_cc.has_header('strings.h')
  native_args += ['-DHAVE_STRINGS_H']

  # Not entirely correct, but sufficient for us. Should move away from this
  # ancient define and just include individual headers based on individual defs.
  # stdlib.h and string.h are standard nowadays, but strings.h not (msvc)
  native_args += ['-DSTDC_HEADERS=1']
endif

gen_unicode_version = executable('gen-unicode-version',
  'gen-unicode-version.c',
  include_directories: incs,
  c_args: native_args,
  install: false)

fribidi_unicode_version_h = custom_target('fribidi-unicode-version.h',
  input: files('unidata/ReadMe.txt', 'unidata/BidiMirroring.txt'),
  output: 'fribidi-unicode-version.h',
  command: [gen_unicode_version, '@INPUT0@', '@INPUT1@', 'gen-unicode-version'],
  capture: true,
  install_dir: join_paths(get_option('includedir'), 'fribidi'),
  install: true)

COMPRESSION='2'

tabs = [
  ['bidi-type', files('unidata/UnicodeData.txt')],
  ['joining-type', files('unidata/UnicodeData.txt', 'unidata/ArabicShaping.txt')],
  ['arabic-shaping', files('unidata/UnicodeData.txt')],
  ['mirroring', files('unidata/BidiMirroring.txt')],
  ['brackets', files('unidata/BidiBrackets.txt', 'unidata/UnicodeData.txt')],
  ['brackets-type', files('unidata/BidiBrackets.txt')],
]

generated_tab_include_files = []

foreach tab : tabs
  gen_prog_name = 'gen-@0@-tab'.format(tab[0])
  gen_prog_src = 'gen-@0@-tab.c'.format(tab[0])
  gen_prog_out = '@0@.tab.i'.format(tab[0])
  gen_prog_inputs = tab[1]

  gen_exe = executable(gen_prog_name,
    fribidi_unicode_version_h,
    gen_prog_src, 'packtab.c',
    include_directories: incs,
    c_args: native_args,
    install: false)

  tab_inc_file = custom_target(gen_prog_name,
    input: gen_prog_inputs,
    output: gen_prog_out,
    command: [gen_exe, COMPRESSION, '@INPUT@', gen_prog_name],
    capture: true)

  generated_tab_include_files += [tab_inc_file]
endforeach