From eea00ca354855e546a1f3626c215571a5afa9e6c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 13 May 2024 15:04:10 +0200 Subject: [PATCH 1/3] Add `target` method to `Rustdoc` type --- src/tools/run-make-support/src/rustdoc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index 75ca1fc29747f..fa8521ed9194b 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -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"); From 4057a7b1e3fd1a1371b5dda1fa4323c6d3426b39 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 13 May 2024 15:12:42 +0200 Subject: [PATCH 2/3] Add `library_search_path` to `Rustdoc` --- src/tools/run-make-support/src/rustdoc.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index fa8521ed9194b..c4f4e9f9bd23b 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -143,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>(&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(); From b515de83af4fd73255de0a1ebb48db5849f8e01f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 13 May 2024 15:04:36 +0200 Subject: [PATCH 3/3] Migrate `run-make/rustdoc-target-spec-json-path` to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../rustdoc-target-spec-json-path/Makefile | 9 --------- .../rustdoc-target-spec-json-path/rmake.rs | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) delete mode 100644 tests/run-make/rustdoc-target-spec-json-path/Makefile create mode 100644 tests/run-make/rustdoc-target-spec-json-path/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index d742368292035..5f385280ac5ac 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -251,7 +251,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 diff --git a/tests/run-make/rustdoc-target-spec-json-path/Makefile b/tests/run-make/rustdoc-target-spec-json-path/Makefile deleted file mode 100644 index 6d0bc4186f229..0000000000000 --- a/tests/run-make/rustdoc-target-spec-json-path/Makefile +++ /dev/null @@ -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 diff --git a/tests/run-make/rustdoc-target-spec-json-path/rmake.rs b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs new file mode 100644 index 0000000000000..66530a4f08ee9 --- /dev/null +++ b/tests/run-make/rustdoc-target-spec-json-path/rmake.rs @@ -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(); +}