summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-20 13:42:14 +0100
committerEli Schwartz <eschwartz93@gmail.com>2025-02-03 20:01:37 -0500
commita19df7da15848b7b01dfe3cf8f88211529b9143b (patch)
tree149cc00436c972a2bb4ffd96d93c152ec63d3cf6 /mesonbuild/compilers
parent39d5ffc27fe0dae50b0be10ed23cf54e05a6c38b (diff)
downloadmeson-a19df7da15848b7b01dfe3cf8f88211529b9143b.tar.gz
ninjabackend: start adjusting for differences between rustc and rustdoc
Add functions to RustCompiler() to account for differences between rustc and "rustdoc --test": rustdoc always generates a binary, does not support -g, and does not need --emit. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/rust.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index 09a1d24de..ee3155c88 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -170,7 +170,10 @@ class RustCompiler(Compiler):
self.native_static_libs = [i for i in match.group(1).split() if i not in exclude]
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
- return ['--dep-info', outfile]
+ return ['--emit', f'dep-info={outfile}']
+
+ def get_output_args(self, outputname: str) -> T.List[str]:
+ return ['--emit', f'link={outputname}']
@functools.lru_cache(maxsize=None)
def get_sysroot(self) -> str:
@@ -222,9 +225,6 @@ class RustCompiler(Compiler):
return parameter_list
- def get_output_args(self, outputname: str) -> T.List[str]:
- return ['-o', outputname]
-
@classmethod
def use_linker_args(cls, linker: str, version: str) -> T.List[str]:
return ['-C', f'linker={linker}']
@@ -324,3 +324,21 @@ class ClippyRustCompiler(RustCompiler):
"""
id = 'clippy-driver rustc'
+
+
+class RustdocTestCompiler(RustCompiler):
+
+ """We invoke Rustdoc to run doctests. Some of the flags
+ are different from rustc and some (e.g. --emit link) are
+ ignored."""
+
+ id = 'rustdoc --test'
+
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
+ return []
+
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
+ return []
+
+ def get_output_args(self, outputname: str) -> T.List[str]:
+ return []