6006d98541e0249c8e375af5ada68ec4fbb43da3
[platform/upstream/fribidi.git] / gen.tab / meson.build
1 # gen.tab
2
3 native_cc = meson.get_compiler('c')
4
5 # Don't pick up top-level config.h, as that has defines for the cross-compiler
6 # (if we're cross-compiling), but here we need values for the host compiler/env
7 # in that case. We shall pass those on the command line since it's just a few.
8 native_args = ['-UHAVE_CONFIG_H']
9
10 # This is available pretty much everywhere
11 native_args += ['-DHAVE_STRINGIZE']
12
13 native_args += ['-DDONT_HAVE_FRIBIDI_CONFIG_H']
14
15 if native_cc.has_header('stdlib.h')
16   native_args += ['-DHAVE_STDLIB_H']
17 endif
18
19 if native_cc.has_header('string.h')
20   native_args += ['-DHAVE_STRING_H']
21 endif
22
23 if native_cc.has_header('strings.h')
24   native_args += ['-DHAVE_STRINGS_H']
25
26   # Not entirely correct, but sufficient for us. Should move away from this
27   # ancient define and just include individual headers based on individual defs.
28   # stdlib.h and string.h are standard nowadays, but strings.h not (msvc)
29   native_args += ['-DSTDC_HEADERS=1']
30 endif
31
32 gen_unicode_version = executable('gen-unicode-version',
33   'gen-unicode-version.c',
34   include_directories: incs,
35   c_args: native_args,
36   install: false)
37
38 fribidi_unicode_version_h = custom_target('fribidi-unicode-version.h',
39   input: files('unidata/ReadMe.txt', 'unidata/BidiMirroring.txt'),
40   output: 'fribidi-unicode-version.h',
41   command: [gen_unicode_version, '@INPUT0@', '@INPUT1@', 'gen-unicode-version'],
42   capture: true,
43   install_dir: join_paths(get_option('includedir'), 'fribidi'),
44   install: true)
45
46 COMPRESSION='2'
47
48 tabs = [
49   ['bidi-type', files('unidata/UnicodeData.txt')],
50   ['joining-type', files('unidata/UnicodeData.txt', 'unidata/ArabicShaping.txt')],
51   ['arabic-shaping', files('unidata/UnicodeData.txt')],
52   ['mirroring', files('unidata/BidiMirroring.txt')],
53   ['brackets', files('unidata/BidiBrackets.txt', 'unidata/UnicodeData.txt')],
54   ['brackets-type', files('unidata/BidiBrackets.txt')],
55 ]
56
57 generated_tab_include_files = []
58
59 foreach tab : tabs
60   gen_prog_name = 'gen-@0@-tab'.format(tab[0])
61   gen_prog_src = 'gen-@0@-tab.c'.format(tab[0])
62   gen_prog_out = '@0@.tab.i'.format(tab[0])
63   gen_prog_inputs = tab[1]
64
65   gen_exe = executable(gen_prog_name,
66     fribidi_unicode_version_h,
67     gen_prog_src, 'packtab.c',
68     include_directories: incs,
69     c_args: native_args,
70     install: false)
71
72   tab_inc_file = custom_target(gen_prog_name,
73     input: gen_prog_inputs,
74     output: gen_prog_out,
75     command: [gen_exe, COMPRESSION, '@INPUT@', gen_prog_name],
76     capture: true)
77
78   generated_tab_include_files += [tab_inc_file]
79 endforeach