Debian Codegraph @

gst/parse/meson.build

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