Rollup merge of #125071 - GuillaumeGomez:migrate-rustdoc-target-spec-json-path, r=jieyouxu

Migrate rustdoc target spec json path

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
This commit is contained in:
Matthias Krüger 2024-05-13 20:29:19 +02:00 committed by GitHub
commit ed2c2c06e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 10 deletions

View File

@ -123,6 +123,12 @@ impl Rustdoc {
self
}
/// Specify the target triple, or a path to a custom target json spec file.
pub fn target(&mut self, target: &str) -> &mut Self {
self.cmd.arg(format!("--target={target}"));
self
}
/// Specify the crate type.
pub fn crate_type(&mut self, crate_type: &str) -> &mut Self {
self.cmd.arg("--crate-type");
@ -137,6 +143,14 @@ impl Rustdoc {
self
}
/// Add a directory to the library search path. It corresponds to the `-L`
/// rustdoc option.
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-L");
self.cmd.arg(path.as_ref());
self
}
#[track_caller]
pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output {
let caller_location = std::panic::Location::caller();

View File

@ -248,7 +248,6 @@ run-make/rustdoc-scrape-examples-multiple/Makefile
run-make/rustdoc-scrape-examples-remap/Makefile
run-make/rustdoc-scrape-examples-test/Makefile
run-make/rustdoc-scrape-examples-whitespace/Makefile
run-make/rustdoc-target-spec-json-path/Makefile
run-make/rustdoc-themes/Makefile
run-make/rustdoc-verify-output-files/Makefile
run-make/rustdoc-with-out-dir-option/Makefile

View File

@ -1,9 +0,0 @@
include ../tools.mk
# Test that rustdoc will properly canonicalize the target spec json path just like rustc
OUTPUT_DIR := "$(TMPDIR)/rustdoc-target-spec-json-path"
all:
$(RUSTC) --crate-type lib dummy_core.rs --target target.json
$(RUSTDOC) -o $(OUTPUT_DIR) -L $(TMPDIR) my_crate.rs --target target.json

View File

@ -0,0 +1,14 @@
// Test that rustdoc will properly canonicalize the target spec json path just like rustc.
use run_make_support::{rustc, rustdoc, tmp_dir};
fn main() {
let out_dir = tmp_dir().join("rustdoc-target-spec-json-path");
rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run();
rustdoc()
.input("my_crate.rs")
.output(out_dir)
.library_search_path(tmp_dir())
.target("target.json")
.run();
}