diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2024-12-19 23:38:31 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-04-02 08:44:37 -0700 |
| commit | 0c8f6400e3f731a5c5091653c0940f6318bdce23 (patch) | |
| tree | 65f32846112e452d5fbadfa1c9f4608884ca7b75 /mesonbuild/modules/rust.py | |
| parent | bf8d4927238a40dc0dca584e91988f456a970bbb (diff) | |
| download | meson-0c8f6400e3f731a5c5091653c0940f6318bdce23.tar.gz | |
rust: add link_whole to rust.test and rust.doctest
QEMU needs it in its integration tests (in order to run global constructors),
and therefore in rust.doctest too. With this change I could do:
# Rust executables do not support objects, so add an intermediate step.
rust_qemu_api_objs = static_library(
'rust_qemu_api_objs',
objects: [libqom.extract_all_objects(recursive: false),
libhwcore.extract_all_objects(recursive: false)])
rust.doctest('rust-qemu-api-doc', _qemu_api_rs,
dependencies: [qemu_api, qemu_api_macros],
link_with: libqemuutil,
link_whole: [rust_qemu_api_objs],
suite: ['doc', 'rust'])
followed by "meson test --suite doc".
For completeness, add it to rust.test as well.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/modules/rust.py')
| -rw-r--r-- | mesonbuild/modules/rust.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index fdb18261e..f43a0ede9 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -15,8 +15,8 @@ from ..build import (BothLibraries, BuildTarget, CustomTargetIndex, Executable, CustomTarget, InvalidArguments, Jar, StructuredSources, SharedLibrary, StaticLibrary) from ..compilers.compilers import are_asserts_disabled_for_subproject, lang_suffixes from ..interpreter.type_checking import ( - DEPENDENCIES_KW, LINK_WITH_KW, SHARED_LIB_KWS, TEST_KWS, TEST_KWS_NO_ARGS, OUTPUT_KW, - INCLUDE_DIRECTORIES, SOURCES_VARARGS, NoneType, in_set_validator + DEPENDENCIES_KW, LINK_WITH_KW, LINK_WHOLE_KW, SHARED_LIB_KWS, TEST_KWS, TEST_KWS_NO_ARGS, + OUTPUT_KW, INCLUDE_DIRECTORIES, SOURCES_VARARGS, NoneType, in_set_validator ) from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs, permittedKwargs from ..interpreter.interpreterobjects import Doctest @@ -44,6 +44,7 @@ if T.TYPE_CHECKING: dependencies: T.List[T.Union[Dependency, ExternalLibrary]] is_parallel: bool link_with: T.List[LibTypes] + link_whole: T.List[LibTypes] rust_args: T.List[str] FuncTest = FuncRustTest[_kwargs.TestArgs] @@ -147,6 +148,8 @@ class RustModule(ExtensionModule): """ if any(isinstance(t, Jar) for t in kwargs.get('link_with', [])): raise InvalidArguments('Rust tests cannot link with Jar targets') + if any(isinstance(t, Jar) for t in kwargs.get('link_whole', [])): + raise InvalidArguments('Rust tests cannot link with Jar targets') name = args[0] base_target: BuildTarget = args[1] @@ -181,6 +184,7 @@ class RustModule(ExtensionModule): 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'] + new_target_kwargs['link_whole'] = new_target_kwargs.get('link_whole', []) + kwargs['link_whole'] del new_target_kwargs['rust_crate_type'] for kw in ['pic', 'prelink', 'rust_abi', 'version', 'soversion', 'darwin_versions']: if kw in new_target_kwargs: @@ -207,6 +211,7 @@ class RustModule(ExtensionModule): *TEST_KWS, DEPENDENCIES_KW, LINK_WITH_KW.evolve(since='1.2.0'), + LINK_WHOLE_KW.evolve(since='1.8.0'), *RUST_TEST_KWS, ) def test(self, state: ModuleState, args: T.Tuple[str, BuildTarget], kwargs: FuncTest) -> ModuleReturnValue: @@ -224,6 +229,7 @@ class RustModule(ExtensionModule): *TEST_KWS_NO_ARGS, DEPENDENCIES_KW, LINK_WITH_KW, + LINK_WHOLE_KW, *RUST_TEST_KWS, KwargInfo( 'args', |
