summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-07-23 09:40:12 -0700
committerDylan Baker <dylan@pnwbakers.com>2025-10-24 22:20:49 -0700
commit6aefc92c33f7bef17c338aa3e456dc45ca41058a (patch)
treefce85244140e726204387e380fd5b9f29c2c24fa /test cases
parentf4650db5b06371eeb37005245366325723eadf9e (diff)
downloadmeson-6aefc92c33f7bef17c338aa3e456dc45ca41058a.tar.gz
modules/codegen: Add wrapper for lex/flex/reflex
This module is a bit of a dumping ground for code generators, particularly ones that are important and non-trivial to wrap, either due to multiple implementations, major command line changes, or complex outputs (such as those that may output a directory structure). The initially provided method is for lex. It provides a simple wrapper that handles win_flex, reflex, flex, and generic lex.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/frameworks/8 flex/meson.build24
1 files changed, 14 insertions, 10 deletions
diff --git a/test cases/frameworks/8 flex/meson.build b/test cases/frameworks/8 flex/meson.build
index 55b96dda7..070036072 100644
--- a/test cases/frameworks/8 flex/meson.build
+++ b/test cases/frameworks/8 flex/meson.build
@@ -1,10 +1,15 @@
+# SPDX-License-Identifier: Apache-2.0
+# Copyright © 2024-2025 Intel Corporation
+
project('flex and bison', 'c')
# The point of this test is that one generator
# may output headers that are necessary to build
# the sources of a different generator.
-flex = find_program('flex', required: false)
+# TODO: handle win_flex/win_bison
+
+flex = find_program('reflex', 'flex', 'lex', required: false)
bison = find_program('bison', required: false)
if not flex.found()
@@ -15,11 +20,9 @@ if not bison.found()
error('MESON_SKIP_TEST bison not found.')
endif
-lgen = generator(flex,
-output : '@PLAINNAME@.yy.c',
-arguments : ['-o', '@OUTPUT@', '@INPUT@'])
-
-lfiles = lgen.process('lexer.l')
+codegen = import('unstable-codegen')
+lex = codegen.lex(implementations : ['flex', 'reflex', 'lex'])
+lfiles = lex.generate('lexer.l')
pgen = generator(bison,
output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
@@ -27,10 +30,11 @@ arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
pfiles = pgen.process('parser.y')
-e = executable('pgen', 'prog.c',
- lfiles,
- pfiles,
- override_options: 'unity=off')
+e = executable(
+ 'pgen',
+ 'prog.c', lfiles, pfiles,
+ override_options : ['unity=off'],
+)
test('parsertest', e,
args: [meson.current_source_dir() / 'testfile'])