mintro: fix some interpreter crashes

pull/5271/head
Daniel Mensinger 6 years ago committed by Nirbheek Chauhan
parent ee97dbf73f
commit f6757408f7
  1. 24
      mesonbuild/ast/interpreter.py
  2. 4
      mesonbuild/ast/introspection.py
  3. 7
      test cases/unit/55 introspection/meson.build
  4. 1
      test cases/unit/55 introspection/meson_options.txt

@ -153,8 +153,20 @@ class AstInterpreter(interpreterbase.InterpreterBase):
return True return True
def evaluate_arithmeticstatement(self, cur): def evaluate_arithmeticstatement(self, cur):
self.evaluate_statement(cur.left)
self.evaluate_statement(cur.right)
return 0 return 0
def evaluate_uminusstatement(self, cur):
self.evaluate_statement(cur.value)
return 0
def evaluate_ternary(self, node):
assert(isinstance(node, mparser.TernaryNode))
self.evaluate_statement(node.condition)
self.evaluate_statement(node.trueblock)
self.evaluate_statement(node.falseblock)
def evaluate_plusassign(self, node): def evaluate_plusassign(self, node):
assert(isinstance(node, mparser.PlusAssignmentNode)) assert(isinstance(node, mparser.PlusAssignmentNode))
if node.var_name not in self.assignments: if node.var_name not in self.assignments:
@ -177,6 +189,18 @@ class AstInterpreter(interpreterbase.InterpreterBase):
return args.arguments, args.kwargs return args.arguments, args.kwargs
def evaluate_comparison(self, node): def evaluate_comparison(self, node):
self.evaluate_statement(node.left)
self.evaluate_statement(node.right)
return False
def evaluate_andstatement(self, cur):
self.evaluate_statement(cur.left)
self.evaluate_statement(cur.right)
return False
def evaluate_orstatement(self, cur):
self.evaluate_statement(cur.left)
self.evaluate_statement(cur.right)
return False return False
def evaluate_foreach(self, node): def evaluate_foreach(self, node):

@ -20,7 +20,7 @@ from .. import compilers, environment, mesonlib, optinterpreter
from .. import coredata as cdata from .. import coredata as cdata
from ..interpreterbase import InvalidArguments from ..interpreterbase import InvalidArguments
from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary
from ..mparser import ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode
import os import os
build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'] build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries']
@ -191,6 +191,8 @@ class IntrospectionInterpreter(AstInterpreter):
# Make sure nothing can crash when creating the build class # Make sure nothing can crash when creating the build class
kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']} kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']}
kwargs_reduced = {k: v.value if isinstance(v, ElementaryNode) else v for k, v in kwargs_reduced.items()}
kwargs_reduced = {k: v for k, v in kwargs_reduced.items() if not isinstance(v, BaseNode)}
is_cross = False is_cross = False
objects = [] objects = []
empty_sources = [] # Passing the unresolved sources list causes errors empty_sources = [] # Passing the unresolved sources list causes errors

@ -4,6 +4,11 @@ dep1 = dependency('threads')
dep2 = dependency('zlib', required: false) dep2 = dependency('zlib', required: false)
dep3 = dependency('bugDep1', required: get_option('test_opt1')) dep3 = dependency('bugDep1', required: get_option('test_opt1'))
b1 = get_option('test_opt1')
b2 = get_option('test_opt2')
test_bool = b1 or b2
test_bool = b1 and b2
if false if false
dependency('somethingthatdoesnotexist', required: true) dependency('somethingthatdoesnotexist', required: true)
dependency('look_i_have_a_fallback', fallback: ['oh_no', 'the_subproject_does_not_exist']) dependency('look_i_have_a_fallback', fallback: ['oh_no', 'the_subproject_does_not_exist'])
@ -12,7 +17,7 @@ endif
subdir('sharedlib') subdir('sharedlib')
subdir('staticlib') subdir('staticlib')
t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true) t1 = executable('test1', 't1.cpp', link_with: [sharedlib], install: true, build_by_default: get_option('test_opt2'))
t2 = executable('test2', 't2.cpp', link_with: [staticlib]) t2 = executable('test2', 't2.cpp', link_with: [staticlib])
t3 = executable('test3', 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1]) t3 = executable('test3', 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1])

@ -1 +1,2 @@
option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag') option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag')
option('test_opt2', type: 'boolean', value: true, description: 'simple boolean flag')

Loading…
Cancel
Save