aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-06-21 12:02:06 -0700
committerDylan Baker <dylan@pnwbakers.com>2023-06-27 11:53:18 -0700
commit43f24060f3e0065b44b1909d88bcc8e2882e9e5e (patch)
tree0350478696a6bd7270279d184518ce1daf27943c /mesonbuild
parent78b8d447eea08445c9708bc0e3ba3c886717f6cd (diff)
downloadmeson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.zip
meson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.tar.gz
meson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.tar.bz2
modules/rust: Add a `link_with` kwarg to the test method
This was requested by Mesa, where a bunch of `declare_dependency` objects are being created as a workaround for the lack of this keyword
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/modules/rust.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py
index bf1fd1d..4153630 100644
--- a/mesonbuild/modules/rust.py
+++ b/mesonbuild/modules/rust.py
@@ -1,4 +1,4 @@
-# Copyright © 2020-2022 Intel Corporation
+# Copyright © 2020-2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,15 +18,16 @@ import typing as T
from . import ExtensionModule, ModuleReturnValue, ModuleInfo
from .. import mlog
-from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, StructuredSources
+from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, InvalidArguments, Jar, StructuredSources
from ..compilers.compilers import are_asserts_disabled
from ..dependencies import Dependency, ExternalLibrary
-from ..interpreter.type_checking import DEPENDENCIES_KW, TEST_KWS, OUTPUT_KW, INCLUDE_DIRECTORIES
+from ..interpreter.type_checking import DEPENDENCIES_KW, LINK_WITH_KW, TEST_KWS, OUTPUT_KW, INCLUDE_DIRECTORIES
from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs
from ..mesonlib import File
if T.TYPE_CHECKING:
from . import ModuleState
+ from ..build import LibTypes
from ..interpreter import Interpreter
from ..interpreter import kwargs as _kwargs
from ..interpreter.interpreter import SourceInputs, SourceOutputs
@@ -38,6 +39,7 @@ if T.TYPE_CHECKING:
dependencies: T.List[T.Union[Dependency, ExternalLibrary]]
is_parallel: bool
+ link_with: T.List[LibTypes]
class FuncBindgen(TypedDict):
@@ -68,6 +70,7 @@ class RustModule(ExtensionModule):
'rust.test',
*TEST_KWS,
DEPENDENCIES_KW,
+ LINK_WITH_KW.evolve(since='1.2.0'),
KwargInfo('is_parallel', bool, default=False),
)
def test(self, state: ModuleState, args: T.Tuple[str, BuildTarget], kwargs: FuncTest) -> ModuleReturnValue:
@@ -112,6 +115,9 @@ class RustModule(ExtensionModule):
rust.test('rust_lib_test', rust_lib)
```
"""
+ if any(isinstance(t, Jar) for t in kwargs.get('link_with', [])):
+ raise InvalidArguments('Rust tests cannot link with Jar targets')
+
name = args[0]
base_target: BuildTarget = args[1]
if not base_target.uses_rust():
@@ -145,6 +151,7 @@ class RustModule(ExtensionModule):
new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test']
new_target_kwargs['install'] = False
new_target_kwargs['dependencies'] = new_target_kwargs.get('dependencies', []) + kwargs['dependencies']
+ new_target_kwargs['link_with'] = new_target_kwargs.get('link_with', []) + kwargs['link_with']
sources = T.cast('T.List[SourceOutputs]', base_target.sources.copy())
sources.extend(base_target.generated)