diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-05-11 20:52:10 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-05-11 21:09:00 +0200 |
| commit | 0712ae865f6658c5c36b5ccf347309a03742441d (patch) | |
| tree | bf9165f2f9645e3f80ad2a5c8dd8162ed049876d | |
| parent | 0761802e50e3f11ef4cc170f63659f895bc25d42 (diff) | |
| download | rust-0712ae865f6658c5c36b5ccf347309a03742441d.tar.gz rust-0712ae865f6658c5c36b5ccf347309a03742441d.zip | |
Add `extern_` method to `Rustdoc`
| -rw-r--r-- | src/tools/run-make-support/src/rustdoc.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index df91742f4e2..6a65d9616fc 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -45,6 +45,21 @@ impl Rustdoc { Self { cmd, stdin: None } } + /// Specify where an external library is located. + pub fn extern_<P: AsRef<Path>>(&mut self, crate_name: &str, path: P) -> &mut Self { + assert!( + !crate_name.contains(|c: char| c.is_whitespace() || c == '\\' || c == '/'), + "crate name cannot contain whitespace or path separators" + ); + + let path = path.as_ref().to_string_lossy(); + + self.cmd.arg("--extern"); + self.cmd.arg(format!("{crate_name}={path}")); + + self + } + /// Specify path to the input file. pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self { self.cmd.arg(path.as_ref()); |
