Use dependency cache

pull/5276/head
Dylan Baker 6 years ago
parent 5df6823bd8
commit 146e97e974
  1. 9
      mesonbuild/coredata.py
  2. 4
      mesonbuild/dependencies/base.py
  3. 17
      mesonbuild/interpreter.py
  4. 3
      mesonbuild/mconf.py
  5. 2
      mesonbuild/mintro.py
  6. 2
      mesonbuild/modules/rpm.py
  7. 22
      mesonbuild/munstable_coredata.py

@ -359,7 +359,14 @@ class CoreData:
self.cross_files = self.__load_config_files(options.cross_file, 'cross')
self.compilers = OrderedDict()
self.cross_compilers = OrderedDict()
self.deps = OrderedDict()
build_cache = DependencyCache(self.builtins, False)
if self.cross_files:
host_cache = DependencyCache(self.builtins, True)
else:
host_cache = build_cache
self.deps = PerMachine(build_cache, host_cache) # type: PerMachine[DependencyCache]
self.compiler_check_cache = OrderedDict()
# Only to print a warning if it changes between Meson invocations.
self.config_files = self.__load_config_files(options.native_file, 'native')

@ -2358,8 +2358,8 @@ class ExtraFrameworkDependency(ExternalDependency):
return 'framework'
def get_dep_identifier(name, kwargs, want_cross: bool) -> Tuple:
identifier = (name, want_cross)
def get_dep_identifier(name, kwargs) -> Tuple:
identifier = (name, )
for key, value in kwargs.items():
# 'version' is irrelevant for caching; the caller must check version matches
# 'native' is handled above with `want_cross`

@ -2860,14 +2860,13 @@ external dependencies (including libraries) must go to "dependencies".''')
# FIXME: Not all dependencies support such a distinction right now,
# and we repeat this check inside dependencies that do. We need to
# consolidate this somehow.
is_cross = self.environment.is_cross_build()
if 'native' in kwargs and is_cross:
want_cross = not kwargs['native']
if self.environment.is_cross_build() and kwargs.get('native', False):
for_machine = MachineChoice.BUILD
else:
want_cross = is_cross
for_machine = MachineChoice.HOST
identifier = dependencies.get_dep_identifier(name, kwargs, want_cross)
cached_dep = self.coredata.deps.get(identifier)
identifier = dependencies.get_dep_identifier(name, kwargs)
cached_dep = self.coredata.deps[for_machine].get(identifier)
if cached_dep:
if not cached_dep.found():
mlog.log('Dependency', mlog.bold(name),
@ -3019,7 +3018,11 @@ external dependencies (including libraries) must go to "dependencies".''')
# cannot cache them. They must always be evaluated else
# we won't actually read all the build files.
if dep.found():
self.coredata.deps[identifier] = dep
if self.environment.is_cross_build() and kwargs.get('native', False):
for_machine = MachineChoice.BUILD
else:
for_machine = MachineChoice.HOST
self.coredata.deps[for_machine].put(identifier, dep)
return DependencyHolder(dep, self.subproject)
if has_fallback:

@ -63,7 +63,8 @@ class Conf:
raise ConfException('Directory {} is neither a Meson build directory nor a project source directory.'.format(build_dir))
def clear_cache(self):
self.coredata.deps.clear()
self.coredata.deps.host.clear()
self.coredata.deps.build.clear()
def set_options(self, options):
self.coredata.set_options(options)

@ -282,7 +282,7 @@ def list_deps_from_source(intr: IntrospectionInterpreter):
def list_deps(coredata: cdata.CoreData):
result = []
for d in coredata.deps.values():
for d in coredata.deps.host.values():
if d.found():
result += [{'name': d.name,
'compile_args': d.get_compile_args(),

@ -83,7 +83,7 @@ class RPMModule(ExtensionModule):
fn.write('BuildRequires: meson\n')
for compiler in required_compilers:
fn.write('BuildRequires: %s\n' % compiler)
for dep in coredata.environment.coredata.deps:
for dep in coredata.environment.coredata.deps.host:
fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0])
# ext_libs and ext_progs have been removed from coredata so the following code
# no longer works. It is kept as a reminder of the idea should anyone wish

@ -97,13 +97,11 @@ def run(options):
print('Cached cross compilers:')
dump_compilers(v)
elif k == 'deps':
native = []
cross = []
for dep_key, dep in sorted(v.items()):
if dep_key[1]:
cross.append((dep_key, dep))
else:
native.append((dep_key, dep))
native = list(sorted(v.build.items()))
if v.host is not v.build:
cross = list(sorted(v.host.items()))
else:
cross = []
def print_dep(dep_key, dep):
print(' ' + dep_key[0] + ": ")
@ -115,12 +113,14 @@ def run(options):
if native:
print('Cached native dependencies:')
for dep_key, dep in native:
print_dep(dep_key, dep)
for dep_key, deps in native:
for dep in deps:
print_dep(dep_key, dep)
if cross:
print('Cached dependencies:')
for dep_key, dep in cross:
print_dep(dep_key, dep)
for dep_key, deps in cross:
for dep in deps:
print_dep(dep_key, dep)
else:
print(k + ':')
print(textwrap.indent(pprint.pformat(v), ' '))

Loading…
Cancel
Save