]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3730] Added generate parser
authorFrancis Dupont <fdupont@isc.org>
Thu, 20 Feb 2025 00:02:16 +0000 (01:02 +0100)
committerAndrei Pavel <andrei@isc.org>
Fri, 21 Feb 2025 16:43:12 +0000 (18:43 +0200)
14 files changed:
cd-and-run.sh [new file with mode: 0755]
doc/devel/make-devel.sh.in
doc/devel/meson.build
meson.build
src/bin/agent/meson.build
src/bin/d2/meson.build
src/bin/dhcp4/meson.build
src/bin/dhcp6/meson.build
src/bin/netconf/meson.build
src/bin/shell/meson.build
src/bin/shell/tests/meson.build
src/lib/eval/meson.build
src/lib/util/python/meson.build
tools/meson.build

diff --git a/cd-and-run.sh b/cd-and-run.sh
new file mode 100755 (executable)
index 0000000..9fe8958
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+cd "$1" || exit 1
+shift
+exec "$@"
index d3bc95d5fffa0fc1d01044c2f230e27a878c2912..9fc1c2da5fd5f6991d0d807af7140efdd1b1730d 100755 (executable)
@@ -2,8 +2,7 @@
 
 set -v
 
-cd @srcdir@ || exit 1
 mkdir -p @builddir@/html
 
-(cat @srcdir@/Doxyfile; echo PROJECT_NUMBER=@PACKAGE_VERSION@) | doxygen - > @builddir@/html/doxygen.log 2> @builddir@/html/doxygen-error.log
+(cat Doxyfile; echo PROJECT_NUMBER=@PACKAGE_VERSION@) | doxygen - > @builddir@/html/doxygen.log 2> @builddir@/html/doxygen-error.log
 echo "$(grep -c ': warning:' @builddir@/html/doxygen-error.log)" warnings/errors detected.
index 96feeb518f41f2d02246eb6f4b3b8e0b4d625b79..1e344fd92d3a07238174744bf8825cc61c051ccd 100644 (file)
@@ -2,13 +2,15 @@ if not doxygen_exe.found()
     subdir_done()
 endif
 
+current_build_dir = meson.current_build_dir()
+current_source_dir = meson.current_source_dir()
 make_devel_conf_data = configuration_data()
-make_devel_conf_data.set('builddir', meson.current_build_dir())
-make_devel_conf_data.set('srcdir', meson.current_source_dir())
+make_devel_conf_data.set('builddir', current_build_dir)
 make_devel_conf_data.set('PACKAGE_VERSION', project_version)
-make_devel = configure_file(
+configure_file(
     input: 'make-devel.sh.in',
     output: 'make-devel.sh',
     configuration: make_devel_conf_data,
 )
-run_target('make-devel', command: [make_devel])
+make_devel = f'@current_build_dir@/make-devel.sh'
+run_target('make-devel', command: [CD_AND_RUN, current_source_dir, make_devel])
index fd4ec04a9ed052ebdd9174ae64b9afcb463bb1a2..2f4dacf83cdf5f213c713a805d026a07d7fab820 100644 (file)
@@ -156,8 +156,8 @@ message(f'Detected system "@SYSTEM@".')
 #### Programs
 
 python_exe = find_program('python3', 'python', required: false)
-flex_exe = find_program('flex', required: false)
-bison_exe = find_program('bison', required: false)
+flex_exe = find_program('flex', version: '>=2.6.4', required: false)
+bison_exe = find_program('bison', version: '>=3.3.0', required: false)
 awk_exe = find_program('gawk', 'awk', required: false)
 doxygen_exe = find_program('doxygen', required: false)
 sphinx_exe = find_program('sphinx-build', 'sphinx-build-3', required: false)
@@ -169,6 +169,20 @@ pip_compile_exe = find_program('pip-compile', required: false)
 install_exe = find_program('install', required: true)
 valgrind_exe = find_program('valgrind', required: false)
 
+if python_exe.found()
+    PYTHON = python_exe.full_path()
+endif
+if flex_exe.found()
+    FLEX = flex_exe.full_path()
+endif
+if bison_exe.found()
+    BISON = bison_exe.full_path()
+endif
+if awk_exe.found()
+    AWK = awk_exe.full_path()
+endif
+CD_AND_RUN = f'@TOP_SOURCE_DIR@/cd-and-run.sh'
+
 #### Dependencies
 
 boost = dependency('boost', version: '>=1.66')
@@ -495,7 +509,7 @@ report_conf_data.set('LD_ID', cpp.get_linker_id())
 report_conf_data.set('LD_ARGS', ' '.join(link_args))
 if python_exe.found()
     report_conf_data.set('HAVE_PYTHON', 'yes')
-    report_conf_data.set('PYTHON_PATH', python_exe.full_path())
+    report_conf_data.set('PYTHON_PATH', PYTHON)
     result = run_command(
         python_exe,
         '-c',
@@ -580,12 +594,12 @@ else
     report_conf_data.set('LOG4CPLUS_VERSION', log4cplus.version())
 endif
 if flex_exe.found()
-    report_conf_data.set('FLEX', flex_exe.full_path())
+    report_conf_data.set('FLEX', FLEX)
 else
     report_conf_data.set('FLEX', 'unknown')
 endif
 if bison_exe.found()
-    report_conf_data.set('BISON', bison_exe.full_path())
+    report_conf_data.set('BISON', BISON)
 else
     report_conf_data.set('BISON', 'unknown')
 endif
@@ -670,6 +684,7 @@ config_report = custom_target(
 
 LIBS_BUILT_SO_FAR = []
 TARGETS_GEN_MESSAGES = []
+TARGETS_GEN_PARSER = []
 subdir('tools')
 subdir('src')
 subdir('fuzz')
@@ -679,6 +694,7 @@ if have_premium
 endif
 
 alias_target('all-targets-gen-messages', TARGETS_GEN_MESSAGES)
+alias_target('all-targets-gen-parser', TARGETS_GEN_PARSER)
 
 top_docs = [
     'AUTHORS',
index dc7731209fe133fa90e4623c07debbad8f107b0a..89e24e39d7e66bb2d0a75e67508fbf35f879eae7 100644 (file)
@@ -25,11 +25,43 @@ executable(
 )
 subdir('tests')
 
+current_source_dir = meson.current_source_dir()
 if HAS_KEA_MSG_COMPILER
-    current_source_dir = meson.current_source_dir()
     target_gen_messages = run_target(
         'src-bin-agent-ca_messages',
         command: [kea_msg_compiler, f'@current_source_dir@/ca_messages.mes'],
     )
     TARGETS_GEN_MESSAGES += [target_gen_messages]
 endif
+
+if flex_exe.found() and bison_exe.found()
+    target_parser = run_target(
+        'src-bin-agent-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=agent_parser.h',
+            '--report=all',
+            '--report-file=agent_parser.report',
+            '-o',
+            'agent_parser.cc',
+            'agent_parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-bin-agent-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'agent_',
+            '-o',
+            'agent_lexer.cc',
+            'agent_lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index b5abd2f79a5209b09dbab475d3334ddc4e4687bf..a641a597a7084aa8288604fa82d3b887d02c03e0 100644 (file)
@@ -28,3 +28,36 @@ executable(
     link_with: [d2_lib] + LIBS_BUILT_SO_FAR,
 )
 subdir('tests')
+
+if flex_exe.found() and bison_exe.found()
+    current_source_dir = meson.current_source_dir()
+    target_parser = run_target(
+        'src-bin-d2-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=d2_parser.h',
+            '--report=all',
+            '--report-file=d2_parser.report',
+            '-o',
+            'd2_parser.cc',
+            'd2_parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-bin-d2-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'd2_parser_',
+            '-o',
+            'd2_lexer.cc',
+            'd2_lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index d8084ca743f5f61b0a6788ede814341d529e6ad1..4303513cd14aa8afe40f2f685499b0b6169f7d5a 100644 (file)
@@ -24,11 +24,43 @@ executable(
 )
 subdir('tests')
 
+current_source_dir = meson.current_source_dir()
 if HAS_KEA_MSG_COMPILER
-    current_source_dir = meson.current_source_dir()
     target_gen_messages = run_target(
         'src-bin-dhcp4-dhcp4_messages',
         command: [kea_msg_compiler, f'@current_source_dir@/dhcp4_messages.mes'],
     )
     TARGETS_GEN_MESSAGES += [target_gen_messages]
 endif
+
+if flex_exe.found() and bison_exe.found()
+    target_parser = run_target(
+        'src-bin-dhcp4-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=dhcp4_parser.h',
+            '--report=all',
+            '--report-file=dhcp4_parser.report',
+            '-o',
+            'dhcp4_parser.cc',
+            'dhcp4_parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-bin-dhcp4-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'parser4_',
+            '-o',
+            'dhcp4_lexer.cc',
+            'dhcp4_lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index 9ea8ed620906f39880fe54642408564126a21bfb..e1a8ac89ff6f73c9fedd033da5fa374f5a09ade2 100644 (file)
@@ -25,11 +25,43 @@ executable(
 )
 subdir('tests')
 
+current_source_dir = meson.current_source_dir()
 if HAS_KEA_MSG_COMPILER
-    current_source_dir = meson.current_source_dir()
     target_gen_messages = run_target(
         'src-bin-dhcp6-dhcp6_messages',
         command: [kea_msg_compiler, f'@current_source_dir@/dhcp6_messages.mes'],
     )
     TARGETS_GEN_MESSAGES += [target_gen_messages]
 endif
+
+if flex_exe.found() and bison_exe.found()
+    target_parser = run_target(
+        'src-bin-dhcp6-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=dhcp6_parser.h',
+            '--report=all',
+            '--report-file=dhcp6_parser.report',
+            '-o',
+            'dhcp6_parser.cc',
+            'dhcp6_parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-bin-dhcp6-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'parser6_',
+            '-o',
+            'dhcp6_lexer.cc',
+            'dhcp6_lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index 813c1a6e11a4cb5d61c51e39d2f324970e7d0c7e..24c93a12e1ad79c739ee1e693cb1e2be0cab5d61 100644 (file)
@@ -38,8 +38,8 @@ executable(
 
 subdir('tests')
 
+current_source_dir = meson.current_source_dir()
 if HAS_KEA_MSG_COMPILER
-    current_source_dir = meson.current_source_dir()
     target_gen_messages = run_target(
         'src-bin-netconf-netconf_messages',
         command: [
@@ -49,3 +49,35 @@ if HAS_KEA_MSG_COMPILER
     )
     TARGETS_GEN_MESSAGES += [target_gen_messages]
 endif
+
+if flex_exe.found() and bison_exe.found()
+    target_parser = run_target(
+        'src-bin-netconf-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=netconf_parser.h',
+            '--report=all',
+            '--report-file=netconf_parser.report',
+            '-o',
+            'netconf_parser.cc',
+            'netconf_parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-bin-netconf-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'netconf_',
+            '-o',
+            'netconf_lexer.cc',
+            'netconf_lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index a193aebd96ca05f7fc7d0f92c060f31e99ca37e8..f86e4e92116d6ce10d4d4b16051f7b6f4c629257 100644 (file)
@@ -3,7 +3,7 @@ if not python_exe.found()
 endif
 
 kea_shell_conf_data = configuration_data()
-kea_shell_conf_data.set('PYTHON', python_exe.full_path())
+kea_shell_conf_data.set('PYTHON', PYTHON)
 kea_shell_conf_data.set('PACKAGE_VERSION', project_version)
 kea_shell_conf_data.set('EXTENDED_VERSION', project_version + ' (tarball)')
 
index 8fe1d36935d51fa6b05a930252c9dd895b56771f..334b9cb372a7bec8ac26689430ad095fc1dadb09 100644 (file)
@@ -3,7 +3,7 @@ if not gtest.found()
 endif
 
 shell_tests_conf_data = configuration_data()
-shell_tests_conf_data.set('PYTHON', python_exe.full_path())
+shell_tests_conf_data.set('PYTHON', PYTHON)
 shell_tests_conf_data.set('abs_top_builddir', TOP_BUILD_DIR)
 shell_tests_conf_data.set('abs_top_srcdir', TOP_SOURCE_DIR)
 shell_unittest = configure_file(
index 5df98aba27ace11da61cce2874180eb9042fa540..def72b171cd82e628a8cd509bf59a7d1f54c2ef1 100644 (file)
@@ -27,11 +27,41 @@ kea_eval_headers = [
 ]
 install_headers(kea_eval_headers, preserve_path: true, subdir: 'kea/eval')
 
+current_source_dir = meson.current_source_dir()
 if HAS_KEA_MSG_COMPILER
-    current_source_dir = meson.current_source_dir()
     target_gen_messages = run_target(
         'src-lib-eval-eval_messages',
         command: [kea_msg_compiler, f'@current_source_dir@/eval_messages.mes'],
     )
     TARGETS_GEN_MESSAGES += [target_gen_messages]
 endif
+
+if flex_exe.found() and bison_exe.found()
+    target_parser = run_target(
+        'src-lib-eval-parser',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            BISON,
+            '-Wno-yacc',
+            '--defines=parser.h',
+            '-o',
+            'parser.cc',
+            'parser.yy',
+        ],
+    )
+    target_lexer = run_target(
+        'src-lib-eval-lexer',
+        command: [
+            CD_AND_RUN,
+            current_source_dir,
+            FLEX,
+            '--prefix',
+            'eval',
+            '-o',
+            'lexer.cc',
+            'lexer.ll',
+        ],
+    )
+    TARGETS_GEN_PARSER += [target_parser, target_lexer]
+endif
index 37634f8c7453bf00ddc159fc6905fa584331d936..3f5996b86577a6ef84486ba03ffabdf62c59fb46 100644 (file)
@@ -4,7 +4,7 @@ endif
 
 configure_file(input: 'const2hdr.py', output: 'const2hdr.py', copy: true)
 util_python_conf_data = configuration_data()
-util_python_conf_data.set('PYTHON', python_exe.full_path())
+util_python_conf_data.set('PYTHON', PYTHON)
 configure_file(
     input: 'gen_wiredata.py.in',
     output: 'gen_wiredata.py',
index 23f6efa9dc9360d721ba165ad48e0d3a94eb2bad..ca59455090f4e487e32858adc098d47030a9f410 100644 (file)
@@ -6,12 +6,12 @@ tools_conf_data.set('exec_prefix', '${prefix}')
 tools_conf_data.set('libdir', '${exec_prefix}/' + get_option('libdir'))
 tools_conf_data.set('SEP', '+')
 if bison_exe.found()
-    tools_conf_data.set('YACC', bison_exe.full_path())
+    tools_conf_data.set('YACC', BISON)
 else
     tools_conf_data.set('YACC', 'bison')
 endif
 if awk_exe.found()
-    tools_conf_data.set('AWK', awk_exe.full_path())
+    tools_conf_data.set('AWK', AWK)
 else
     tools_conf_data.set('AWK', 'awk')
 endif