1 cc = meson.get_compiler('c')
3 # Find flex, configure lex generator
4 flex_cdata = configuration_data()
6 flex_min_version='2.5.31'
7 flex = find_program('flex', required : false)
9 flex = find_program('win_flex', required : false)
11 error('flex not found')
15 flexversion_res = run_command([flex, '--version'])
16 if flexversion_res.returncode() != 0
17 error('Could not get flex version (@0@)'.format(flexversion_res.stderr()))
20 flexversion = flexversion_res.stdout().split('\n')[0].split(' ')[-1].strip()
21 if flexversion.version_compare('<' + flex_min_version)
22 error('flex version @0@ >= @1@: NO'.format(flexversion, flex_min_version))
24 message('flex version @0@ >= @1@: YES'.format(flexversion, flex_min_version))
27 flex_cdata.set('FLEX', flex.path())
28 if cc.get_id() == 'msvc'
29 flex_cdata.set('FLEX_ARGS', '--nounistd')
31 flex_cdata.set('FLEX_ARGS', '')
34 gen_lex = configure_file(input : 'gen_lex.py.in',
35 output : 'gen_lex.py',
36 configuration : flex_cdata)
38 # Find bison, configure grammar generator
39 bison_cdata = configuration_data()
41 bison_min_version='2.4'
42 bison = find_program('bison', required : false)
44 bison = find_program('win_bison', required : false)
46 error('GNU bison not found')
50 bversion_res = run_command([bison, '--version'])
51 if bversion_res.returncode() != 0
52 error('Could not get bison version (@0@)'.format(bversion_res.stderr()))
55 bversion = bversion_res.stdout().split('\n')[0].split(' ')[-1].strip()
56 if bversion.version_compare('<' + bison_min_version)
57 error('bison version @0@ >= @1@: NO'.format(bversion, bison_min_version))
59 message('bison version @0@ >= @1@: YES'.format(bversion, bison_min_version))
64 bison_cdata.set('BISON', bison.path())
65 bison_cdata.set('BISON_ARGS', '')
67 gen_grammar = configure_file(input : 'gen_grammar.py.in',
68 output : 'gen_grammar.py',
69 configuration : bison_cdata)
72 parser = custom_target('parselex',
74 output : ['lex.priv_gst_parse_yy.c', 'parse_lex.h'],
75 command : [py3, gen_lex, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', 'DUMMY']
78 grammar = custom_target('parsegrammar',
80 output : ['grammar.tab.c', 'grammar.tab.h'],
81 command : [py3, gen_grammar, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@'],