|
|
@ -28,6 +28,7 @@ from .interpreterbase import InterpreterBase |
|
|
|
from .interpreterbase import check_stringlist, noPosargs, noKwargs, stringArgs |
|
|
|
from .interpreterbase import check_stringlist, noPosargs, noKwargs, stringArgs |
|
|
|
from .interpreterbase import InterpreterException, InvalidArguments, InvalidCode |
|
|
|
from .interpreterbase import InterpreterException, InvalidArguments, InvalidCode |
|
|
|
from .interpreterbase import InterpreterObject, MutableInterpreterObject |
|
|
|
from .interpreterbase import InterpreterObject, MutableInterpreterObject |
|
|
|
|
|
|
|
from .modules import ModuleReturnValue |
|
|
|
|
|
|
|
|
|
|
|
import os, sys, shutil, uuid |
|
|
|
import os, sys, shutil, uuid |
|
|
|
import re |
|
|
|
import re |
|
|
@ -973,6 +974,7 @@ class ModuleHolder(InterpreterObject): |
|
|
|
raise InvalidArguments('Module %s does not have method %s.' % (self.modname, method_name)) |
|
|
|
raise InvalidArguments('Module %s does not have method %s.' % (self.modname, method_name)) |
|
|
|
if method_name.startswith('_'): |
|
|
|
if method_name.startswith('_'): |
|
|
|
raise InvalidArguments('Function {!r} in module {!r} is private.'.format(method_name, self.modname)) |
|
|
|
raise InvalidArguments('Function {!r} in module {!r} is private.'.format(method_name, self.modname)) |
|
|
|
|
|
|
|
build_hash = hash(self.interpreter.build) |
|
|
|
state = ModuleState() |
|
|
|
state = ModuleState() |
|
|
|
state.build_to_src = os.path.relpath(self.interpreter.environment.get_source_dir(), |
|
|
|
state.build_to_src = os.path.relpath(self.interpreter.environment.get_source_dir(), |
|
|
|
self.interpreter.environment.get_build_dir()) |
|
|
|
self.interpreter.environment.get_build_dir()) |
|
|
@ -988,6 +990,8 @@ class ModuleHolder(InterpreterObject): |
|
|
|
state.global_args = self.interpreter.build.global_args |
|
|
|
state.global_args = self.interpreter.build.global_args |
|
|
|
state.project_args = self.interpreter.build.projects_args.get(self.interpreter.subproject, {}) |
|
|
|
state.project_args = self.interpreter.build.projects_args.get(self.interpreter.subproject, {}) |
|
|
|
value = fn(state, args, kwargs) |
|
|
|
value = fn(state, args, kwargs) |
|
|
|
|
|
|
|
if hash(self.interpreter.build) != build_hash: |
|
|
|
|
|
|
|
raise InterpreterException('Extension module altered internal state illegally.') |
|
|
|
return self.interpreter.module_method_callback(value) |
|
|
|
return self.interpreter.module_method_callback(value) |
|
|
|
|
|
|
|
|
|
|
|
class MesonMain(InterpreterObject): |
|
|
|
class MesonMain(InterpreterObject): |
|
|
@ -1227,7 +1231,10 @@ class Interpreter(InterpreterBase): |
|
|
|
'join_paths': self.func_join_paths, |
|
|
|
'join_paths': self.func_join_paths, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
def module_method_callback(self, invalues): |
|
|
|
def module_method_callback(self, return_object): |
|
|
|
|
|
|
|
if not isinstance(return_object, ModuleReturnValue): |
|
|
|
|
|
|
|
raise InterpreterException('Bug in module, it returned an invalid object') |
|
|
|
|
|
|
|
invalues = return_object.new_objects |
|
|
|
unwrap_single = False |
|
|
|
unwrap_single = False |
|
|
|
if invalues is None: |
|
|
|
if invalues is None: |
|
|
|
return |
|
|
|
return |
|
|
@ -1264,7 +1271,7 @@ class Interpreter(InterpreterBase): |
|
|
|
raise InterpreterException('Module returned a value of unknown type.') |
|
|
|
raise InterpreterException('Module returned a value of unknown type.') |
|
|
|
if len(outvalues) == 1 and unwrap_single: |
|
|
|
if len(outvalues) == 1 and unwrap_single: |
|
|
|
return outvalues[0] |
|
|
|
return outvalues[0] |
|
|
|
return outvalues |
|
|
|
return return_object.return_value |
|
|
|
|
|
|
|
|
|
|
|
def get_build_def_files(self): |
|
|
|
def get_build_def_files(self): |
|
|
|
return self.build_def_files |
|
|
|
return self.build_def_files |
|
|
|