From 057c30b2c8ceafa4130ba62adcb8428cdf9f9cfa Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Wed, 30 Aug 2023 14:21:20 +0200 Subject: [PATCH] Meson: Handle bindparser lexer and parser files conditionally --- meson.build | 3 +-- meson/bison/meson.build | 11 --------- meson/flex/meson.build | 11 --------- pdns/meson.build | 53 ++++++++++++++++++++++++++++++++++++++--- 4 files changed, 51 insertions(+), 27 deletions(-) delete mode 100644 meson/bison/meson.build delete mode 100644 meson/flex/meson.build diff --git a/meson.build b/meson.build index 7ba99c220a..4e937cae1a 100644 --- a/meson.build +++ b/meson.build @@ -29,6 +29,7 @@ conf = configuration_data() # Toplevel includes dep_pdns = declare_dependency(include_directories: include_directories('.', 'pdns')) +# Feature detection and system configuration subdir('meson' / 'config') # Config subdir('meson' / 'version') # Generate version define subdir('meson' / 'compiler-setup') # Common compiler setup @@ -38,8 +39,6 @@ subdir('meson' / 'libdir') # Libdir subdir('meson' / 'platform') # Platform detection subdir('meson' / 'timet-size') # Check the size of time_t subdir('meson' / 'timet-sign') # Check the sign of time_t -subdir('meson' / 'flex') # Find flex and create generator -subdir('meson' / 'bison') # Find bison and create generator subdir('meson' / 'ragel') # Find ragel and create generator subdir('meson' / 'atomics') # Check atomics support subdir('meson' / 'pthread-headers') # Check pthread headers diff --git a/meson/bison/meson.build b/meson/bison/meson.build deleted file mode 100644 index 8ff17f1b50..0000000000 --- a/meson/bison/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -bison = find_program('bison', required: true) - -summary('Bison', bison.found(), bool_yn: true, section: 'Programs') -summary('Bison Path', bison.full_path(), section: 'Programs') -summary('Bison Version', bison.version(), section: 'Programs') - -bison_generator = generator( - bison, - output: '@BASENAME@.cc', - arguments: ['-d', '--verbose', '--debug', '--output=@OUTPUT@', '@INPUT@'], -) diff --git a/meson/flex/meson.build b/meson/flex/meson.build deleted file mode 100644 index 1ef5905e3e..0000000000 --- a/meson/flex/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -flex = find_program('flex', required: true) - -summary('Flex', flex.found(), bool_yn: true, section: 'Programs') -summary('Flex Path', flex.full_path(), section: 'Programs') -summary('Flex Version', flex.version(), section: 'Programs') - -flex_generator = generator( - flex, - output: '@BASENAME@.c', - arguments: ['--case-insensitive', '--outfile=@OUTPUT@', '@INPUT@'], -) diff --git a/pdns/meson.build b/pdns/meson.build index 37c110f808..4bae747047 100644 --- a/pdns/meson.build +++ b/pdns/meson.build @@ -1,14 +1,61 @@ +fs = import('fs') + +libpdns_bindlexer_cc = 'bindlexer.c' +if not fs.is_file(libpdns_bindlexer_cc) + flex = find_program('flex', required: true) + + summary('Flex', flex.found(), bool_yn: true, section: 'BIND Parser') + summary('Flex Path', flex.full_path(), section: 'BIND Parser') + summary('Flex Version', flex.version(), section: 'BIND Parser') + + flex_generator = generator( + flex, + output: '@BASENAME@.c', + arguments: ['--case-insensitive', '--outfile=@OUTPUT@', '@INPUT@'], + ) + + libpdns_bindlexer_cc = flex_generator.process('bindlexer.l') +endif +libpdns_bindlexer_cc = declare_dependency( + sources: [libpdns_bindlexer_cc], +) + +libpdns_bindparser_cc = 'bindparser.cc' +if not fs.is_file(libpdns_bindparser_cc) and not fs.is_file('bindparser.hh') + bison = find_program('bison', required: false) + if not bison.found() + bison = find_program('yacc', required: true) + endif + + summary('Bison/YACC', bison.found(), bool_yn: true, section: 'BIND Parser') + summary('Bison/YACC Path', bison.full_path(), section: 'BIND Parser') + summary('Bison/YACC Version', bison.version(), section: 'BIND Parser') + + bison_generator = generator( + bison, + output: ['@BASENAME@.cc', '@BASENAME@.hh', '@BASENAME@.output'], + arguments: ['-d', '--verbose', '--debug', '--output=@OUTPUT0@', '@INPUT@'], + ) + + libpdns_bindparser_cc = bison_generator.process('bindparser.yy') +endif +libpdns_bindparser_cc = declare_dependency( + sources: [libpdns_bindparser_cc], +) + libpdns_bind_parser = declare_dependency( link_with: static_library( 'pdns-bind-parser', 'zoneparser-tng.cc', - flex_generator.process('bindlexer.l'), - bison_generator.process('bindparser.yy'), extra_files: [ 'zoneparser-tng.hh', ], cpp_args: '-Wno-redundant-decls', - dependencies: deps, + dependencies: [ + deps, + libpdns_bindlexer_cc, + libpdns_bindparser_cc, + ], ) ) -- 2.47.2