35ed6f2f40ca622e7d6ffe50ce52ee9d777ed9a9
[platform/upstream/gstreamer.git] / gst / parse / meson.build
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.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'])
37 if bversion_res.returncode() != 0
38   error('Could not get bison version (@0@)'.format(bversion_res.stderr()))
39 endif
40
41 bversion = bversion_res.stdout().split('\n')[0].split(' ')[-1].strip()
42 if bversion.version_compare('<' + bison_min_version)
43   error('bison version @0@ >= @1@: NO'.format(bversion, bison_min_version))
44 else
45   message('bison version @0@ >= @1@: YES'.format(bversion, bison_min_version))
46 endif
47
48 if bversion.version_compare('>' + '2.5')
49   bison_parser_cdata.set('BISON_PURE_PARSER', '%define api.pure full')
50 else
51   bison_parser_cdata.set('BISON_PURE_PARSER', '%pure-parser')
52 endif
53
54 gen_grammar_file = configure_file(input : 'grammar.y.in',
55   output : 'grammar.y',
56   configuration : bison_parser_cdata)
57
58 bison_cdata.set('BISON', bison.path())
59 bison_cdata.set('BISON_ARGS', '')
60
61 gen_grammar = configure_file(input : 'gen_grammar.py.in',
62   output : 'gen_grammar.py',
63   configuration : bison_cdata)
64
65 # Custom targets
66 parser = custom_target('parselex',
67   input : 'parse.l',
68   output : ['lex.priv_gst_parse_yy.c', 'parse_lex.h'],
69   command : [python3, gen_lex, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', 'DUMMY']
70 )
71
72 grammar = custom_target('parsegrammar',
73   input : gen_grammar_file,
74   output : ['grammar.tab.c', 'grammar.tab.h'],
75   command : [python3, gen_grammar, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@'],
76   depends : [parser],
77 )
78
79 gst_parse_sources += [parser, grammar]