1cc = meson.get_compiler('c')
2
3# Find flex, configure lex generator
4flex_cdata = configuration_data()
5
6flex_min_version='2.5.31'
7flex = find_program('flex', 'win_flex')
8
9get_flex_version = find_program('get_flex_version.py')
10flexversion_res = run_command([get_flex_version, flex], check: true)
11flexversion = flexversion_res.stdout().strip()
12if flexversion.version_compare('<' + flex_min_version)
13  error('flex version @0@ >= @1@: NO'.format(flexversion, flex_min_version))
14else
15  message('flex version @0@ >= @1@: YES'.format(flexversion, flex_min_version))
16endif
17
18flex_cdata.set('FLEX', flex.path())
19if cc.get_id() == 'msvc'
20  flex_cdata.set('FLEX_ARGS', '--nounistd')
21else
22  flex_cdata.set('FLEX_ARGS', '')
23endif
24
25gen_lex = configure_file(input : 'gen_lex.py.in',
26  output : 'gen_lex.py',
27  configuration : flex_cdata)
28
29# Find bison, configure grammar generator
30bison_cdata = configuration_data()
31
32bison_min_version='2.4'
33bison = find_program('bison', 'win_bison')
34
35bversion_res = run_command([bison, '--version'])
36if bversion_res.returncode() != 0
37  error('Could not get bison version (@0@)'.format(bversion_res.stderr()))
38endif
39
40bversion = bversion_res.stdout().split('\n')[0].split(' ')[-1].strip()
41if bversion.version_compare('<' + bison_min_version)
42  error('bison version @0@ >= @1@: NO'.format(bversion, bison_min_version))
43else
44  message('bison version @0@ >= @1@: YES'.format(bversion, bison_min_version))
45endif
46
47
48
49bison_cdata.set('BISON', bison.path())
50bison_cdata.set('BISON_ARGS', '')
51
52gen_grammar = configure_file(input : 'gen_grammar.py.in',
53  output : 'gen_grammar.py',
54  configuration : bison_cdata)
55
56# Custom targets
57parser = custom_target('parselex',
58  input : 'parse.l',
59  output : ['lex.priv_gst_parse_yy.c', 'parse_lex.h'],
60  command : [python3, gen_lex, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', 'DUMMY']
61)
62
63grammar = custom_target('parsegrammar',
64  input : 'grammar.y',
65  output : ['grammar.tab.c', 'grammar.tab.h'],
66  command : [python3, gen_grammar, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@'],
67  depends : [parser],
68)
69
70gst_parse_sources += [parser, grammar]
71