]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Meson: Handle bindparser lexer and parser files conditionally
authorFred Morcos <fred.morcos@open-xchange.com>
Wed, 30 Aug 2023 12:21:20 +0000 (14:21 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Wed, 20 Mar 2024 12:28:49 +0000 (13:28 +0100)
meson.build
meson/bison/meson.build [deleted file]
meson/flex/meson.build [deleted file]
pdns/meson.build

index 7ba99c220a0f8e44060091d2b8ef0579cadb9319..4e937cae1abd15bc4f136e4894c33c189d93eae1 100644 (file)
@@ -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 (file)
index 8ff17f1..0000000
+++ /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 (file)
index 1ef5905..0000000
+++ /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@'],
-)
index 37c110f8080f27eb0a9aed8e942024726d3831ce..4bae74704729e3aacf7e5cd7cc32f2396e46f8b9 100644 (file)
@@ -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,
+    ],
   )
 )