Move DropBomb from run-make-support to build_helper

So that it can be also used in bootstrap.
This commit is contained in:
Jakub Beránek 2024-07-04 15:47:30 +02:00 committed by Jakub Beránek
parent 5d76a13bbe
commit 97990a4759
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
8 changed files with 10 additions and 7 deletions

View file

@ -3420,6 +3420,7 @@ version = "0.2.0"
dependencies = [ dependencies = [
"ar", "ar",
"bstr", "bstr",
"build_helper",
"gimli 0.28.1", "gimli 0.28.1",
"object 0.34.0", "object 0.34.0",
"regex", "regex",

View file

@ -12,7 +12,7 @@ use std::panic;
mod tests; mod tests;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct DropBomb { pub struct DropBomb {
command: OsString, command: OsString,
defused: bool, defused: bool,
armed_line: u32, armed_line: u32,
@ -21,9 +21,9 @@ pub(crate) struct DropBomb {
impl DropBomb { impl DropBomb {
/// Arm a [`DropBomb`]. If the value is dropped without being [`defused`][Self::defused], then /// 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 /// 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] #[track_caller]
pub(crate) fn arm<S: AsRef<OsStr>>(command: S) -> DropBomb { pub fn arm<S: AsRef<OsStr>>(command: S) -> DropBomb {
DropBomb { DropBomb {
command: command.as_ref().into(), command: command.as_ref().into(),
defused: false, defused: false,
@ -32,7 +32,7 @@ impl DropBomb {
} }
/// Defuse the [`DropBomb`]. This will prevent the drop bomb from panicking when dropped. /// 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; self.defused = true;
} }
} }

View file

@ -1,6 +1,7 @@
//! Types and functions shared across tools in this workspace. //! Types and functions shared across tools in this workspace.
pub mod ci; pub mod ci;
pub mod drop_bomb;
pub mod git; pub mod git;
pub mod metrics; pub mod metrics;
pub mod stage0_parser; pub mod stage0_parser;

View file

@ -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 regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
gimli = "0.28.1" gimli = "0.28.1"
ar = "0.9.0" ar = "0.9.0"
build_helper = { path = "../build_helper" }

View file

@ -5,8 +5,8 @@ use std::panic;
use std::path::Path; use std::path::Path;
use std::process::{Command as StdCommand, ExitStatus, Output, Stdio}; 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 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 /// 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. /// ensure that we check the exit status of executed processes.

View file

@ -2,8 +2,8 @@ use regex::Regex;
use similar::TextDiff; use similar::TextDiff;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::drop_bomb::DropBomb;
use crate::fs_wrapper; use crate::fs_wrapper;
use build_helper::drop_bomb::DropBomb;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View file

@ -7,7 +7,6 @@ pub mod cc;
pub mod clang; pub mod clang;
mod command; mod command;
pub mod diff; pub mod diff;
mod drop_bomb;
pub mod fs_wrapper; pub mod fs_wrapper;
pub mod llvm; pub mod llvm;
pub mod run; pub mod run;