Store bunch of data to coredata.

pull/15/head
Jussi Pakkanen 12 years ago
parent e7a2121bdc
commit 9948b616df
  1. 7
      coredata.py
  2. 46
      environment.py
  3. 29
      interpreter.py

@ -34,6 +34,13 @@ class CoreData():
self.strip = options.strip
self.coverage = options.coverage
if isinstance(options, CoreData):
self.compilers = options.compilers.copy()
self.deps = options.deps.copy()
else:
self.compilers = {}
self.deps = {}
def load(filename):
obj = pickle.load(open(filename, 'rb'))
if not isinstance(obj, CoreData):

@ -264,6 +264,12 @@ class Environment():
def get_script_dir(self):
return os.path.dirname(self.meson_script_file)
def get_old_coredata(self):
return self.old_coredata
def get_new_coredata(self):
return self.new_coredata
def get_build_command(self):
return self.meson_script_file
@ -397,6 +403,9 @@ class Dependency():
def get_link_flags(self):
return []
def found(self):
return False
# This should be an InterpreterObject. Fix it.
class PkgConfigDependency(Dependency):
@ -404,6 +413,7 @@ class PkgConfigDependency(Dependency):
def __init__(self, name):
Dependency.__init__(self)
self.is_found = False
if not PkgConfigDependency.pkgconfig_found:
self.check_pkgconfig()
@ -411,22 +421,27 @@ class PkgConfigDependency(Dependency):
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Dependency %s not known to pkg-config.' % name)
self.modversion = out.decode().strip()
p = subprocess.Popen(['pkg-config', '--cflags', name], stdout=subprocess.PIPE,
print('Dependency %s not known to pkg-config.' % name)
self.modversion = 'none'
self.cflags = []
self.libs = []
else:
self.is_found = True
self.modversion = out.decode().strip()
p = subprocess.Popen(['pkg-config', '--cflags', name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate cflags for %s.' % name)
self.cflags = out.decode().split()
p = subprocess.Popen(['pkg-config', '--libs', name], stdout=subprocess.PIPE,
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate cflags for %s.' % name)
self.cflags = out.decode().split()
p = subprocess.Popen(['pkg-config', '--libs', name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate libs for %s.' % name)
self.libs = out.decode().split()
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate libs for %s.' % name)
self.libs = out.decode().split()
def get_modversion(self):
return self.modversion
@ -445,6 +460,9 @@ class PkgConfigDependency(Dependency):
print('Found pkg-config version %s.' % out.decode().strip())
PkgConfigDependency.pkgconfig_found = True
def found(self):
return self.is_found
# Fixme, move to environment.
def find_external_dependency(name, kwargs):
# Add detectors for non-pkg-config deps (e.g. Boost) etc here.

@ -446,6 +446,8 @@ class Interpreter():
self.build_def_files = [environment.build_filename]
self.subdir = ''
self.generators = []
self.old_coredata = self.environment.get_old_coredata()
self.new_coredata = self.environment.get_new_coredata()
def build_func_dict(self):
self.funcs = {'project' : self.func_project,
@ -464,7 +466,7 @@ class Interpreter():
'include_directories' : self.func_include_directories,
'add_global_arguments' : self.func_add_global_arguments,
}
def get_build_def_files(self):
return self.build_def_files
@ -563,19 +565,30 @@ class Interpreter():
def add_languages(self, node, args):
for lang in args:
if lang.lower() == 'c':
comp = self.environment.detect_c_compiler()
elif lang.lower() == 'cxx':
comp = self.environment.detect_cxx_compiler()
if lang in self.new_coredata.compilers:
comp = self.new_coredata.compilers[lang]
else:
raise InvalidCode('Tried to use unknown language "%s".' % lang)
comp.sanity_check(self.environment.get_scratch_dir())
if lang.lower() == 'c':
comp = self.environment.detect_c_compiler()
elif lang.lower() == 'cxx':
comp = self.environment.detect_cxx_compiler()
else:
raise InvalidCode('Tried to use unknown language "%s".' % lang)
comp.sanity_check(self.environment.get_scratch_dir())
self.new_coredata.compilers[lang] = comp
self.build.compilers.append(comp)
def func_find_dep(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])
name = args[0]
dep = environment.find_external_dependency(name, kwargs)
if name in self.old_coredata.deps:
dep = self.old_coredata.deps[name]
if not dep.found():
raise RuntimeError('Non-found dependency stored in coredata.')
else:
dep = environment.find_external_dependency(name, kwargs)
if dep.found():
self.new_coredata.deps[name] = dep
return dep
def func_executable(self, node, args, kwargs):

Loading…
Cancel
Save