add D features to InternalDependency

pull/10070/head
Remi Thebault 3 years ago committed by Dylan Baker
parent 2bcc204a11
commit 4fe6f0dd29
  1. 15
      mesonbuild/build.py
  2. 11
      mesonbuild/dependencies/base.py
  3. 11
      mesonbuild/interpreter/interpreter.py
  4. 2
      mesonbuild/modules/gnome.py
  5. 2
      mesonbuild/modules/unstable_external_project.py

@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import annotations
from collections import OrderedDict
from collections import defaultdict, OrderedDict
from dataclasses import dataclass, field
from functools import lru_cache
import copy
@ -710,7 +710,7 @@ class BuildTarget(Target):
self.extra_args: T.Dict[str, T.List['FileOrString']] = {}
self.sources: T.List[File] = []
self.generated: T.List['GeneratedTypes'] = []
self.d_features = {}
self.d_features = defaultdict(list)
self.pic = False
self.pie = False
# Track build_rpath entries so we can remove them at install time
@ -1092,7 +1092,7 @@ class BuildTarget(Target):
dlist = stringlistify(kwargs.get('d_args', []))
self.add_compiler_args('d', dlist)
dfeatures = dict()
dfeatures = defaultdict(list)
dfeature_unittest = kwargs.get('d_unittest', False)
if dfeature_unittest:
dfeatures['unittest'] = dfeature_unittest
@ -1301,6 +1301,13 @@ class BuildTarget(Target):
for dep in deps:
if dep in self.added_deps:
continue
dep_d_features = dep.d_features
for feature in ('versions', 'import_dirs'):
if feature in dep_d_features:
self.d_features[feature].extend(dep_d_features[feature])
if isinstance(dep, dependencies.InternalDependency):
# Those parts that are internal.
self.process_sourcelist(dep.sources)
@ -1315,7 +1322,7 @@ class BuildTarget(Target):
[],
dep.get_compile_args(),
dep.get_link_args(),
[], [], [], [], {})
[], [], [], [], {}, [], [])
self.external_deps.append(extpart)
# Deps of deps.
self.add_deps(dep.ext_deps)

@ -16,6 +16,7 @@
# Custom logic for several other packages are in separate files.
import copy
import os
import collections
import itertools
import typing as T
from enum import Enum
@ -93,6 +94,7 @@ class Dependency(HoldableObject):
self.sources: T.List[T.Union['FileOrString', 'CustomTarget']] = []
self.include_type = self._process_include_type_kw(kwargs)
self.ext_deps: T.List[Dependency] = []
self.d_features: T.DefaultDict[str, T.List[T.Any]] = collections.defaultdict(list)
self.featurechecks: T.List['FeatureCheckBase'] = []
self.feature_since: T.Optional[T.Tuple[str, str]] = None
@ -227,7 +229,8 @@ class InternalDependency(Dependency):
libraries: T.List[T.Union['BuildTarget', 'CustomTarget']],
whole_libraries: T.List[T.Union['BuildTarget', 'CustomTarget']],
sources: T.Sequence[T.Union['FileOrString', 'CustomTarget']],
ext_deps: T.List[Dependency], variables: T.Dict[str, T.Any]):
ext_deps: T.List[Dependency], variables: T.Dict[str, T.Any],
d_module_versions: T.List[str], d_import_dirs: T.List['IncludeDirs']):
super().__init__(DependencyTypeName('internal'), {})
self.version = version
self.is_found = True
@ -239,6 +242,10 @@ class InternalDependency(Dependency):
self.sources = list(sources)
self.ext_deps = ext_deps
self.variables = variables
if d_module_versions:
self.d_features['versions'] = d_module_versions
if d_import_dirs:
self.d_features['import_dirs'] = d_import_dirs
def __deepcopy__(self, memo: T.Dict[int, 'InternalDependency']) -> 'InternalDependency':
result = self.__class__.__new__(self.__class__)
@ -286,7 +293,7 @@ class InternalDependency(Dependency):
return InternalDependency(
self.version, final_includes, final_compile_args,
final_link_args, final_libraries, final_whole_libraries,
final_sources, final_deps, self.variables)
final_sources, final_deps, self.variables, [], [])
def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[str] = None,
configtool: T.Optional[str] = None, internal: T.Optional[str] = None,

@ -639,9 +639,10 @@ class Interpreter(InterpreterBase, HoldableObject):
@FeatureNewKwargs('declare_dependency', '0.46.0', ['link_whole'])
@FeatureNewKwargs('declare_dependency', '0.54.0', ['variables'])
@FeatureNewKwargs('declare_dependency', '0.62.0', ['d_module_versions', 'd_import_dirs'])
@permittedKwargs({'include_directories', 'link_with', 'sources', 'dependencies',
'compile_args', 'link_args', 'link_whole', 'version',
'variables'})
'variables', 'd_module_versions', 'd_import_dirs'})
@noPosargs
def func_declare_dependency(self, node, args, kwargs):
version = kwargs.get('version', self.project_version)
@ -656,6 +657,8 @@ class Interpreter(InterpreterBase, HoldableObject):
compile_args = mesonlib.stringlistify(kwargs.get('compile_args', []))
link_args = mesonlib.stringlistify(kwargs.get('link_args', []))
variables = self.extract_variables(kwargs, list_new=True)
d_module_versions = extract_as_list(kwargs, 'd_module_versions')
d_import_dirs = self.extract_incdirs(kwargs, 'd_import_dirs')
final_deps = []
for d in deps:
if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)):
@ -667,7 +670,7 @@ class Interpreter(InterpreterBase, HoldableObject):
external dependencies (including libraries) must go to "dependencies".''')
dep = dependencies.InternalDependency(version, incs, compile_args,
link_args, libs, libs_whole, sources, final_deps,
variables)
variables, d_module_versions, d_import_dirs)
return dep
@typed_pos_args('assert', bool, optargs=[str])
@ -2407,8 +2410,8 @@ external dependencies (including libraries) must go to "dependencies".''')
install_tag=install_tag, data_type='configure'))
return mesonlib.File.from_built_file(self.subdir, output)
def extract_incdirs(self, kwargs):
prospectives = extract_as_list(kwargs, 'include_directories')
def extract_incdirs(self, kwargs, key: str = 'include_directories'):
prospectives = extract_as_list(kwargs, key)
result = []
for p in prospectives:
if isinstance(p, build.IncludeDirs):

@ -2088,7 +2088,7 @@ class GnomeModule(ExtensionModule):
# - add relevant directories to include dirs
incs = [build.IncludeDirs(state.subdir, ['.'] + vapi_includes, False)]
sources = [vapi_target] + vapi_depends
rv = InternalDependency(None, incs, [], [], link_with, [], sources, [], {})
rv = InternalDependency(None, incs, [], [], link_with, [], sources, [], {}, [], [])
created_values.append(rv)
return ModuleReturnValue(rv, created_values)

@ -264,7 +264,7 @@ class ExternalProject(NewExtensionModule):
link_args = [f'-L{abs_libdir}', f'-l{libname}']
sources = self.target
dep = InternalDependency(version, [], compile_args, link_args, [],
[], [sources], [], {})
[], [sources], [], {}, [], [])
return dep

Loading…
Cancel
Save