meson: Don't search for python3 twice
[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 = find_program('flex', required : false)
7 if not flex.found()
8   flex = find_program('win_flex', required : false)
9   if not flex.found()
10     error('flex not found')
11   endif
12 endif
13
14 flex_cdata.set('FLEX', flex.path())
15 if cc.get_id() == 'msvc'
16   flex_cdata.set('FLEX_ARGS', '--nounistd')
17 else
18   flex_cdata.set('FLEX_ARGS', '')
19 endif
20
21 gen_lex = configure_file(input : 'gen_lex.py.in',
22   output : 'gen_lex.py',
23   configuration : flex_cdata)
24
25 # Find bison, configure grammar generator
26 bison_cdata = configuration_data()
27
28 bison = find_program('bison', required : false)
29 if not bison.found()
30   bison = find_program('win_bison', required : false)
31   if not bison.found()
32     error('GNU bison not found')
33   endif
34 endif
35
36 bison_cdata.set('BISON', bison.path())
37 bison_cdata.set('BISON_ARGS', '')
38
39 gen_grammar = configure_file(input : 'gen_grammar.py.in',
40   output : 'gen_grammar.py',
41   configuration : bison_cdata)
42
43 # Custom targets
44 parser = custom_target('parselex',
45   input : 'parse.l',
46   output : ['lex.priv_gst_parse_yy.c', 'parse_lex.h'],
47   command : [py3, gen_lex, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', 'DUMMY']
48 )
49
50 grammar = custom_target('parsegrammar',
51   input : 'grammar.y',
52   output : ['grammar.tab.c', 'grammar.tab.h'],
53   command : [py3, gen_grammar, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@'],
54   depends : [parser],
55 )