external-project: Add depends kwarg

The unit test was racy but surprisingly never failed on CI. The reason
is we need to ensure ninja build somelib.so before running `make` into
the external project.
pull/10510/head
Xavier Claessens 3 years ago committed by Eli Schwartz
parent 47426f3663
commit 807cbcb350
  1. 5
      docs/markdown/External-Project-module.md
  2. 16
      mesonbuild/modules/unstable_external_project.py
  3. 1
      test cases/common/230 external project/libfoo/meson.build

@ -87,6 +87,11 @@ Keyword arguments:
and install the project will be printed onto Meson's stdout.
- `env` : environment variables to set, such as `['NAME1=value1', 'NAME2=value2']`,
a dictionary, or an [[@env]] object.
- `depends` : *Since 0.63.0* Specifies that this project depends on the specified
target(s) that must be built before running `make` to build this external
project. This should be used for example when the external project links to a
Meson `library()` that the `configure` script will find using the
`-uninstalled.pc` pkg-config file generated by Meson.
Returns an [`ExternalProject`](#ExternalProject_object) object

@ -24,7 +24,7 @@ from ..compilers.compilers import CFLAGS_MAPPING
from ..envconfig import ENV_VAR_PROG_MAP
from ..dependencies import InternalDependency, PkgConfigDependency
from ..interpreterbase import FeatureNew
from ..interpreter.type_checking import ENV_KW
from ..interpreter.type_checking import ENV_KW, DEPENDS_KW
from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, typed_kwargs, typed_pos_args
from ..mesonlib import (EnvironmentException, MesonException, Popen_safe, MachineChoice,
get_variable_regex, do_replacement, join_args, OptionKey)
@ -35,6 +35,7 @@ if T.TYPE_CHECKING:
from . import ModuleState
from ..interpreter import Interpreter
from ..interpreterbase import TYPE_var
from ..build import BuildTarget, CustomTarget
class Dependency(TypedDict):
@ -46,6 +47,7 @@ if T.TYPE_CHECKING:
cross_configure_options: T.List[str]
verbose: bool
env: build.EnvironmentVariables
depends: T.List[T.Union[BuildTarget, CustomTarget]]
class ExternalProject(NewExtensionModule):
@ -55,7 +57,8 @@ class ExternalProject(NewExtensionModule):
configure_options: T.List[str],
cross_configure_options: T.List[str],
env: build.EnvironmentVariables,
verbose: bool):
verbose: bool,
extra_depends: T.List[T.Union['BuildTarget', 'CustomTarget']]):
super().__init__()
self.methods.update({'dependency': self.dependency_method,
})
@ -97,7 +100,7 @@ class ExternalProject(NewExtensionModule):
self._configure(state)
self.targets = self._create_targets()
self.targets = self._create_targets(extra_depends)
def _configure(self, state: 'ModuleState') -> None:
if self.configure_command == 'waf':
@ -213,7 +216,7 @@ class ExternalProject(NewExtensionModule):
m += '\nSee logs: ' + str(log_filename)
raise MesonException(m)
def _create_targets(self) -> T.List['TYPE_var']:
def _create_targets(self, extra_depends: T.List[T.Union['BuildTarget', 'CustomTarget']]) -> T.List['TYPE_var']:
cmd = self.env.get_build_command()
cmd += ['--internal', 'externalproject',
'--name', self.name,
@ -236,6 +239,7 @@ class ExternalProject(NewExtensionModule):
[f'{self.name}.stamp'],
depfile=f'{self.name}.d',
console=True,
extra_depends=extra_depends,
)
idir = build.InstallDir(self.subdir.as_posix(),
@ -282,6 +286,7 @@ class ExternalProjectModule(ExtensionModule):
KwargInfo('cross_configure_options', ContainerTypeInfo(list, str), default=['--host=@HOST@'], listify=True),
KwargInfo('verbose', bool, default=False),
ENV_KW,
DEPENDS_KW.evolve(since='0.63.0'),
)
def add_project(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'AddProject') -> ModuleReturnValue:
configure_command = args[0]
@ -290,7 +295,8 @@ class ExternalProjectModule(ExtensionModule):
kwargs['configure_options'],
kwargs['cross_configure_options'],
kwargs['env'],
kwargs['verbose'])
kwargs['verbose'],
kwargs['depends'])
return ModuleReturnValue(project, project.targets)

@ -16,6 +16,7 @@ p = mod.add_project('configure',
'--includedir=@PREFIX@/@INCLUDEDIR@',
'--libext=' + libext,
],
depends: somelib,
)
libfoo_dep = declare_dependency(link_with : somelib,

Loading…
Cancel
Save