From 97990a475928cb7428ed945342cec70a4e19c3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 4 Jul 2024 15:47:30 +0200 Subject: [PATCH] Move `DropBomb` from `run-make-support` to `build_helper` So that it can be also used in bootstrap. --- Cargo.lock | 1 + .../src/drop_bomb/mod.rs | 8 ++++---- .../src/drop_bomb/tests.rs | 0 src/tools/build_helper/src/lib.rs | 1 + src/tools/run-make-support/Cargo.toml | 2 ++ src/tools/run-make-support/src/command.rs | 2 +- src/tools/run-make-support/src/diff/mod.rs | 2 +- src/tools/run-make-support/src/lib.rs | 1 - 8 files changed, 10 insertions(+), 7 deletions(-) rename src/tools/{run-make-support => build_helper}/src/drop_bomb/mod.rs (88%) rename src/tools/{run-make-support => build_helper}/src/drop_bomb/tests.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index eba4eed3686..cafc623c185 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3420,6 +3420,7 @@ version = "0.2.0" dependencies = [ "ar", "bstr", + "build_helper", "gimli 0.28.1", "object 0.34.0", "regex", diff --git a/src/tools/run-make-support/src/drop_bomb/mod.rs b/src/tools/build_helper/src/drop_bomb/mod.rs similarity index 88% rename from src/tools/run-make-support/src/drop_bomb/mod.rs rename to src/tools/build_helper/src/drop_bomb/mod.rs index 2fc84892c1b..ffb86d1c9ee 100644 --- a/src/tools/run-make-support/src/drop_bomb/mod.rs +++ b/src/tools/build_helper/src/drop_bomb/mod.rs @@ -12,7 +12,7 @@ mod tests; #[derive(Debug)] -pub(crate) struct DropBomb { +pub struct DropBomb { command: OsString, defused: bool, armed_line: u32, @@ -21,9 +21,9 @@ pub(crate) struct DropBomb { impl DropBomb { /// Arm a [`DropBomb`]. If the value is dropped without being [`defused`][Self::defused], then /// it will panic. It is expected that the command wrapper uses `#[track_caller]` to help - /// propagate the caller info from rmake.rs. + /// propagate the caller location. #[track_caller] - pub(crate) fn arm>(command: S) -> DropBomb { + pub fn arm>(command: S) -> DropBomb { DropBomb { command: command.as_ref().into(), defused: false, @@ -32,7 +32,7 @@ pub(crate) fn arm>(command: S) -> DropBomb { } /// Defuse the [`DropBomb`]. This will prevent the drop bomb from panicking when dropped. - pub(crate) fn defuse(&mut self) { + pub fn defuse(&mut self) { self.defused = true; } } diff --git a/src/tools/run-make-support/src/drop_bomb/tests.rs b/src/tools/build_helper/src/drop_bomb/tests.rs similarity index 100% rename from src/tools/run-make-support/src/drop_bomb/tests.rs rename to src/tools/build_helper/src/drop_bomb/tests.rs diff --git a/src/tools/build_helper/src/lib.rs b/src/tools/build_helper/src/lib.rs index 15807d1c0d8..4a4f0ca2a9d 100644 --- a/src/tools/build_helper/src/lib.rs +++ b/src/tools/build_helper/src/lib.rs @@ -1,6 +1,7 @@ //! Types and functions shared across tools in this workspace. pub mod ci; +pub mod drop_bomb; pub mod git; pub mod metrics; pub mod stage0_parser; diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index ec3b8a96ef3..969552dec84 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -11,3 +11,5 @@ wasmparser = "0.118.2" regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace gimli = "0.28.1" ar = "0.9.0" + +build_helper = { path = "../build_helper" } diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index c506c3d6b61..5017a4b88da 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -5,8 +5,8 @@ use std::path::Path; use std::process::{Command as StdCommand, ExitStatus, Output, Stdio}; -use crate::drop_bomb::DropBomb; use crate::{assert_contains, assert_equals, assert_not_contains, handle_failed_output}; +use build_helper::drop_bomb::DropBomb; /// This is a custom command wrapper that simplifies working with commands and makes it easier to /// ensure that we check the exit status of executed processes. diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs index 24fa88af82e..ad989b74e4d 100644 --- a/src/tools/run-make-support/src/diff/mod.rs +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -2,8 +2,8 @@ use similar::TextDiff; use std::path::{Path, PathBuf}; -use crate::drop_bomb::DropBomb; use crate::fs_wrapper; +use build_helper::drop_bomb::DropBomb; #[cfg(test)] mod tests; diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 5655318267a..cb61aa7516d 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -7,7 +7,6 @@ pub mod clang; mod command; pub mod diff; -mod drop_bomb; pub mod fs_wrapper; pub mod llvm; pub mod run;