2016-08-12 14:55:17 +00:00
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
# Find flex, configure lex generator
|
|
|
|
flex_cdata = configuration_data()
|
|
|
|
|
2017-04-11 13:17:40 +00:00
|
|
|
flex_min_version='2.5.31'
|
2016-08-12 14:55:17 +00:00
|
|
|
flex = find_program('flex', required : false)
|
|
|
|
if not flex.found()
|
|
|
|
flex = find_program('win_flex', required : false)
|
|
|
|
if not flex.found()
|
|
|
|
error('flex not found')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-04-11 13:17:40 +00:00
|
|
|
flexversion_res = run_command([flex, '--version'])
|
|
|
|
if flexversion_res.returncode() != 0
|
|
|
|
error('Could not get flex version (@0@)'.format(flexversion_res.stderr()))
|
|
|
|
endif
|
|
|
|
|
2017-04-11 15:52:20 +00:00
|
|
|
flexversion = flexversion_res.stdout().split('\n')[0].split(' ')[1].strip()
|
2017-04-11 13:17:40 +00:00
|
|
|
if flexversion.version_compare('<' + flex_min_version)
|
|
|
|
error('flex version @0@ >= @1@: NO'.format(flexversion, flex_min_version))
|
|
|
|
else
|
|
|
|
message('flex version @0@ >= @1@: YES'.format(flexversion, flex_min_version))
|
|
|
|
endif
|
|
|
|
|
2016-08-12 14:55:17 +00:00
|
|
|
flex_cdata.set('FLEX', flex.path())
|
|
|
|
if cc.get_id() == 'msvc'
|
|
|
|
flex_cdata.set('FLEX_ARGS', '--nounistd')
|
|
|
|
else
|
|
|
|
flex_cdata.set('FLEX_ARGS', '')
|
|
|
|
endif
|
|
|
|
|
|
|
|
gen_lex = configure_file(input : 'gen_lex.py.in',
|
|
|
|
output : 'gen_lex.py',
|
|
|
|
configuration : flex_cdata)
|
|
|
|
|
|
|
|
# Find bison, configure grammar generator
|
|
|
|
bison_cdata = configuration_data()
|
|
|
|
|
2017-04-11 13:17:40 +00:00
|
|
|
bison_min_version='2.4'
|
2016-08-12 14:55:17 +00:00
|
|
|
bison = find_program('bison', required : false)
|
|
|
|
if not bison.found()
|
|
|
|
bison = find_program('win_bison', required : false)
|
|
|
|
if not bison.found()
|
|
|
|
error('GNU bison not found')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-04-11 13:17:40 +00:00
|
|
|
bversion_res = run_command([bison, '--version'])
|
|
|
|
if bversion_res.returncode() != 0
|
|
|
|
error('Could not get bison version (@0@)'.format(bversion_res.stderr()))
|
|
|
|
endif
|
|
|
|
|
|
|
|
bversion = bversion_res.stdout().split('\n')[0].split(' ')[-1].strip()
|
|
|
|
if bversion.version_compare('<' + bison_min_version)
|
|
|
|
error('bison version @0@ >= @1@: NO'.format(bversion, bison_min_version))
|
|
|
|
else
|
|
|
|
message('bison version @0@ >= @1@: YES'.format(bversion, bison_min_version))
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-12 14:55:17 +00:00
|
|
|
bison_cdata.set('BISON', bison.path())
|
|
|
|
bison_cdata.set('BISON_ARGS', '')
|
|
|
|
|
|
|
|
gen_grammar = configure_file(input : 'gen_grammar.py.in',
|
|
|
|
output : 'gen_grammar.py',
|
|
|
|
configuration : bison_cdata)
|
|
|
|
|
|
|
|
# Custom targets
|
|
|
|
parser = custom_target('parselex',
|
|
|
|
input : 'parse.l',
|
|
|
|
output : ['lex.priv_gst_parse_yy.c', 'parse_lex.h'],
|
2017-07-07 11:06:44 +00:00
|
|
|
command : [python3, gen_lex, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', 'DUMMY']
|
2016-08-12 14:55:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
grammar = custom_target('parsegrammar',
|
|
|
|
input : 'grammar.y',
|
|
|
|
output : ['grammar.tab.c', 'grammar.tab.h'],
|
2017-07-07 11:06:44 +00:00
|
|
|
command : [python3, gen_grammar, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@'],
|
2016-08-12 14:55:17 +00:00
|
|
|
depends : [parser],
|
|
|
|
)
|