From f7f2fa540f59384481d0cf1e2de799883219087f Mon Sep 17 00:00:00 2001 From: Jonathan Pallant Date: Mon, 6 Jan 2025 11:02:30 +0000 Subject: [PATCH] Ensure generate-copyright is executed from the project root. --- src/bootstrap/src/core/build_steps/run.rs | 3 +++ src/tools/generate-copyright/src/main.rs | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 0a6aea26359f..1c2a8dbaf90e 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -218,6 +218,9 @@ fn run(self, builder: &Builder<'_>) -> Self::Output { cmd.env("DEST_LIBSTD", &dest_libstd); cmd.env("OUT_DIR", &builder.out); cmd.env("CARGO", &builder.initial_cargo); + // it is important that generate-copyright runs from the root of the + // source tree, because it uses relative paths + cmd.current_dir(&builder.src); cmd.run(builder); vec![dest, dest_libstd] diff --git a/src/tools/generate-copyright/src/main.rs b/src/tools/generate-copyright/src/main.rs index f83d16d0cabf..0a446ecff5b8 100644 --- a/src/tools/generate-copyright/src/main.rs +++ b/src/tools/generate-copyright/src/main.rs @@ -8,7 +8,10 @@ /// The entry point to the binary. /// -/// You should probably let `bootstrap` execute this program instead of running it directly. +/// You should probably let `bootstrap` execute this program instead of running +/// it directly. It assumes that the current working directory is the root of a +/// Rust git repository checkout, and constructs a bunch of relative paths based +/// on that assumption. /// /// Run `x.py run generate-copyright` fn main() -> Result<(), Error> {