From 6aefc92c33f7bef17c338aa3e456dc45ca41058a Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 23 Jul 2024 09:40:12 -0700 Subject: 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. --- test cases/frameworks/8 flex/meson.build | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'test cases') 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']) -- cgit v1.2.3