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 = [
"ar",
"bstr",
"build_helper",
"gimli 0.28.1",
"object 0.34.0",
"regex",

View File

@ -12,7 +12,7 @@ use std::panic;
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<S: AsRef<OsStr>>(command: S) -> DropBomb {
pub fn arm<S: AsRef<OsStr>>(command: S) -> DropBomb {
DropBomb {
command: command.as_ref().into(),
defused: false,
@ -32,7 +32,7 @@ impl 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;
}
}

View File

@ -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;

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
gimli = "0.28.1"
ar = "0.9.0"
build_helper = { path = "../build_helper" }

View File

@ -5,8 +5,8 @@ use std::panic;
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.

View File

@ -2,8 +2,8 @@ use regex::Regex;
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;

View File

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