diff options
-rw-r--r-- | mesonbuild/ast/interpreter.py | 10 | ||||
-rw-r--r-- | mesonbuild/ast/introspection.py | 2 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 3 | ||||
-rw-r--r-- | test cases/unit/55 introspection/meson.build | 7 |
4 files changed, 18 insertions, 4 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index eb9cb9f..5354710 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -260,6 +260,12 @@ class AstInterpreter(interpreterbase.InterpreterBase): id_loop_detect = [] flattend_args = [] + if isinstance(args, BaseNode): + assert(hasattr(args, 'ast_id')) + if args.ast_id in id_loop_detect: + return [] # Loop detected + id_loop_detect += [args.ast_id] + if isinstance(args, ArrayNode): args = [x for x in args.args.arguments] @@ -301,8 +307,8 @@ class AstInterpreter(interpreterbase.InterpreterBase): # Resolve the contents of args for i in args: - if isinstance(i, IdNode) and i.value not in id_loop_detect: - flattend_args += self.flatten_args(quick_resolve(i), include_unknown_args, id_loop_detect + [i.value]) + if isinstance(i, IdNode): + flattend_args += self.flatten_args(quick_resolve(i), include_unknown_args, id_loop_detect) elif isinstance(i, (ArrayNode, ArgumentNode, ArithmeticNode, MethodNode)): flattend_args += self.flatten_args(i, include_unknown_args, id_loop_detect) elif isinstance(i, mparser.ElementaryNode): diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index b6ec450..5ac6133 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -118,7 +118,7 @@ class IntrospectionInterpreter(AstInterpreter): subproject_dir_abs = os.path.join(self.environment.get_source_dir(), self.subproject_dir) subpr = os.path.join(subproject_dir_abs, dirname) try: - subi = IntrospectionInterpreter(subpr, '', self.backend, cross_file=self.cross_file, subproject=dirname, subproject_dir=self.subproject_dir, env=self.environment) + subi = IntrospectionInterpreter(subpr, '', self.backend, cross_file=self.cross_file, subproject=dirname, subproject_dir=self.subproject_dir, env=self.environment, visitors=self.visitors) subi.analyze() subi.project_data['name'] = dirname self.project_data['subprojects'] += [subi.project_data] diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index cd9d35a..3b50d55 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -14,6 +14,7 @@ import os from . import coredata, environment, mesonlib, build, mintro, mlog +from .ast import AstIDGenerator def add_arguments(parser): coredata.register_builtin_arguments(parser) @@ -52,7 +53,7 @@ class Conf: # Make sure that log entries in other parts of meson don't interfere with the JSON output mlog.disable() self.source_dir = os.path.abspath(os.path.realpath(self.build_dir)) - intr = mintro.IntrospectionInterpreter(self.source_dir, '', 'ninja') + intr = mintro.IntrospectionInterpreter(self.source_dir, '', 'ninja', visitors = [AstIDGenerator()]) intr.analyze() # Reenable logging just in case mlog.enable() diff --git a/test cases/unit/55 introspection/meson.build b/test cases/unit/55 introspection/meson.build index f11d64d..3f013aa 100644 --- a/test cases/unit/55 introspection/meson.build +++ b/test cases/unit/55 introspection/meson.build @@ -34,6 +34,13 @@ systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machin message(systype) ### END: Test inspired by taisei +# Minimal code version to produce bug #5376 +# Code inspired by https://github.com/mesa3d/mesa/blob/974c4d679c23373dbed386c696e3e3bc1bfa23ae/meson.build#L1341-L1347 +osmesa_lib_name = 'OSMesa' +osmesa_bits = '8' +osmesa_lib_name = osmesa_lib_name + osmesa_bits +message(osmesa_lib_name) # Infinite recursion gets triggered here when the parameter osmesa_lib_name is resolved + test('test case 1', t1) test('test case 2', t2) benchmark('benchmark 1', t3) |