Persist modules so they are imported only once for the lifetime of a build directory.

pull/54/merge
Jussi Pakkanen 10 years ago
parent 96839e5893
commit 1ac00031f9
  1. 1
      build.py
  2. 1
      coredata.py
  3. 16
      interpreter.py
  4. 2
      test cases/frameworks/4 qt5/meson.build

@ -74,7 +74,6 @@ class Build:
self.pkgconfig_gens = []
self.install_script = None
self.install_dirs = []
self.modules = {}
def has_language(self, language):
for i in self.compilers:

@ -54,6 +54,7 @@ class CoreData():
self.deps = {}
self.ext_progs = {}
self.ext_libs = {}
self.modules = {}
def get_builtin_option(self, optname):
if optname == 'type':

@ -600,15 +600,15 @@ class ModuleState:
pass
class ModuleHolder(InterpreterObject):
def __init__(self, modname, interpreter):
def __init__(self, modname, module, interpreter):
InterpreterObject.__init__(self)
self.modname = modname
self.m = importlib.import_module('modules.' + modname).initialize()
self.held_object = module
self.interpreter = interpreter
def method_call(self, method_name, args, kwargs):
try:
fn = getattr(self.m, method_name)
fn = getattr(self.held_object, method_name)
except AttributeError:
raise InvalidArguments('Module %s does not have method %s.' % (self.modname, method_name))
state = ModuleState()
@ -735,7 +735,6 @@ class Interpreter():
self.global_args_frozen = False
self.subprojects = {}
self.subproject_stack = []
self.modules = {}
def build_func_dict(self):
self.funcs = {'project' : self.func_project,
@ -865,11 +864,10 @@ class Interpreter():
modname = args[0]
if not isinstance(modname, str):
raise InvalidCode('Argument to import was not a string')
if not modname in self.modules:
mh = mh = ModuleHolder(modname, self)
self.modules[modname] = mh
self.build.modules[modname] = mh.m
return self.modules[modname]
if not modname in self.environment.coredata.modules:
module = importlib.import_module('modules.' + modname).initialize()
self.environment.coredata.modules[modname] = module
return ModuleHolder(modname, self.environment.coredata.modules[modname], self)
def set_variable(self, varname, variable):
if variable is None:

@ -10,7 +10,7 @@ endif
q5exe = executable('qt5app',
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing.
qt5.preprocess(moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use.
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol.
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol.
qresources : 'stuff.qrc', # Resource file for rcc compiler.
)],
dependencies : qt5dep)

Loading…
Cancel
Save