aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-07-21 15:57:33 +0200
committerDylan Baker <dylan@pnwbakers.com>2025-07-21 09:20:44 -0700
commit2b7661a43f8e85d666dd66ecddb85aedb154a58c (patch)
treef105e8af409fe0dbbb0e7097a63c5899065a97da
parent9530af6d657d1a393ef511c5ee13d12c10f81ae1 (diff)
downloadmeson-2b7661a43f8e85d666dd66ecddb85aedb154a58c.zip
meson-2b7661a43f8e85d666dd66ecddb85aedb154a58c.tar.gz
meson-2b7661a43f8e85d666dd66ecddb85aedb154a58c.tar.bz2
rust: pass rpath arguments to rustdoc --test
rustdoc does not support --print, and therefore the rpath argument corresponding to the rust installation is not passed to doctests. Forward anything that requires --print to the RustCompiler, thus fixing doctests with a shared library dependency. Fixes: #14813 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/compilers/rust.py22
-rw-r--r--test cases/rust/9 unit tests/meson.build6
2 files changed, 27 insertions, 1 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index b72f6b0..aef88eb 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -341,7 +341,7 @@ class RustCompiler(Compiler):
return RustdocTestCompiler(exelist, self.version, self.for_machine,
self.is_cross, self.info, full_version=self.full_version,
- linker=self.linker)
+ linker=self.linker, rustc=self)
class ClippyRustCompiler(RustCompiler):
@@ -361,6 +361,26 @@ class RustdocTestCompiler(RustCompiler):
id = 'rustdoc --test'
+ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
+ is_cross: bool, info: 'MachineInfo',
+ full_version: T.Optional[str],
+ linker: T.Optional['DynamicLinker'], rustc: RustCompiler):
+ super().__init__(exelist, version, for_machine,
+ is_cross, info, full_version, linker)
+ self.rustc = rustc
+
+ @functools.lru_cache(maxsize=None)
+ def get_sysroot(self) -> str:
+ return self.rustc.get_sysroot()
+
+ @functools.lru_cache(maxsize=None)
+ def get_target_libdir(self) -> str:
+ return self.rustc.get_target_libdir()
+
+ @functools.lru_cache(maxsize=None)
+ def get_cfgs(self) -> T.List[str]:
+ return self.rustc.get_cfgs()
+
def get_debug_args(self, is_debug: bool) -> T.List[str]:
return []
diff --git a/test cases/rust/9 unit tests/meson.build b/test cases/rust/9 unit tests/meson.build
index 0fa2fa8..81045f2 100644
--- a/test cases/rust/9 unit tests/meson.build
+++ b/test cases/rust/9 unit tests/meson.build
@@ -40,6 +40,12 @@ if rustdoc.found()
protocol : 'rust',
suite : ['doctests'],
)
+
+ doclib = shared_library('rust_doc_lib', ['doctest1.rs'], build_by_default : false)
+ rust.doctest('rust shared doctests', doclib,
+ protocol : 'rust',
+ suite : ['doctests'],
+ )
endif
exe = executable('rust_exe', ['test2.rs', 'test.rs'], build_by_default : false)