Skip to content

Commit 2dec5ce

Browse files
committed
rust: intercept is part of bear
1 parent ea46fca commit 2dec5ce

File tree

19 files changed

+30
-70
lines changed

19 files changed

+30
-70
lines changed

rust/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
[workspace]
44
members = [
5-
"bear",
6-
"intercept"
5+
"bear"
76
]
87
resolver = "2"
98

rust/bear/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ path = "src/lib.rs"
1717

1818
[[bin]]
1919
name = "bear"
20-
path = "src/bin/main.rs"
20+
path = "src/bin/bear.rs"
21+
22+
[[bin]]
23+
name = "wrapper"
24+
path = "src/bin/wrapper.rs"
2125

2226
[dependencies]
23-
intercept = { path = "../intercept" }
2427
thiserror.workspace = true
2528
anyhow.workspace = true
2629
lazy_static.workspace = true
@@ -36,3 +39,6 @@ path-absolutize.workspace = true
3639
shell-words.workspace = true
3740
nom.workspace = true
3841
regex.workspace = true
42+
crossbeam.workspace = true
43+
crossbeam-channel.workspace = true
44+
rand.workspace = true
File renamed without changes.

rust/intercept/src/bin/wrapper.rs renamed to rust/bear/src/bin/wrapper.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
extern crate core;
1919

2020
use anyhow::{Context, Result};
21-
use intercept::reporter::{Reporter, TcpReporter};
22-
use intercept::KEY_DESTINATION;
21+
use bear::intercept::reporter::{Reporter, TcpReporter};
22+
use bear::intercept::{Event, Execution, ProcessId, KEY_DESTINATION};
2323
use std::path::{Path, PathBuf};
2424

2525
/// Implementation of the wrapper process.
@@ -98,9 +98,9 @@ fn next_in_path(target: &Path) -> Result<PathBuf> {
9898
.ok_or_else(|| anyhow::anyhow!("Cannot find the real executable"))
9999
}
100100

101-
fn report(execution: intercept::Execution) -> Result<()> {
102-
let event = intercept::Event {
103-
pid: intercept::ProcessId(std::process::id() as u32),
101+
fn report(execution: Execution) -> Result<()> {
102+
let event = Event {
103+
pid: ProcessId(std::process::id() as u32),
104104
execution,
105105
};
106106

@@ -115,10 +115,10 @@ fn report(execution: intercept::Execution) -> Result<()> {
115115
.with_context(|| "Sending execution failed")
116116
}
117117

118-
fn into_execution(path_buf: &Path) -> Result<intercept::Execution> {
118+
fn into_execution(path_buf: &Path) -> Result<Execution> {
119119
std::env::current_dir()
120120
.with_context(|| "Cannot get current directory")
121-
.map(|working_dir| intercept::Execution {
121+
.map(|working_dir| Execution {
122122
executable: path_buf.to_path_buf(),
123123
// FIXME: substitute the executable name on the first position
124124
arguments: std::env::args().collect(),

rust/bear/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::io::BufReader;
88
use std::path::PathBuf;
99

1010
use super::args;
11-
use intercept::Execution;
11+
use super::intercept::Execution;
1212

1313
/// Responsible for reading the build events from the intercept mode.
1414
///
File renamed without changes.
File renamed without changes.
File renamed without changes.

rust/bear/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod args;
44
pub mod config;
55
mod fixtures;
66
pub mod input;
7+
pub mod intercept;
78
pub mod output;
89
pub mod recognition;
910
pub mod semantic;

rust/bear/src/recognition.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
//! The recognition logic is implemented in the `interpreters` module.
66
//! Here we only handle the errors and logging them to the console.
77
8-
use super::{config, semantic};
9-
use intercept::Execution;
8+
use super::{config, intercept, semantic};
109
use std::convert::TryFrom;
1110

1211
pub struct Recognition {
@@ -51,7 +50,7 @@ impl TryFrom<&config::Main> for Recognition {
5150
impl Recognition {
5251
/// Simple call the semantic module to recognize the execution.
5352
/// Forward only the compiler calls, and log each recognition result.
54-
pub fn apply(&self, execution: Execution) -> Option<semantic::CompilerCall> {
53+
pub fn apply(&self, execution: intercept::Execution) -> Option<semantic::CompilerCall> {
5554
match self.interpreter.recognize(&execution) {
5655
semantic::Recognition::Success(semantic) => {
5756
log::debug!(

0 commit comments

Comments
 (0)