Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
If there is already a bes backend on the command line we should skip …
Browse files Browse the repository at this point in the history
…operating
  • Loading branch information
ianoc authored and ianoc-stripe committed Oct 13, 2020
1 parent ac7345d commit 0ba8d83
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ctrlc = "3.1.6"
async-trait = "0.1.41"
env_logger = "0.7.1"
dashmap = "3.11.10"
exec = "0.3.1"

[dev-dependencies]
tempfile = "3.1.0"
Expand Down
36 changes: 36 additions & 0 deletions src/bazel_runner/bazel_runner_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::atomic::Ordering;
use tonic::transport::Server;

use bazelfe::protos::*;
use std::ffi::OsString;

use bazelfe::bazel_runner;
use bazelfe::build_events::build_event_server::bazel_event;
Expand Down Expand Up @@ -88,6 +89,41 @@ where
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let opt = Opt::parse();

// If someone is using a bes backend we need to nope out so we don't conflict.
// This also means our other tools can call in using our same utilities
// with this already set to make this app passthrough
if opt
.passthrough_args
.contains(&String::from("--bes_backend"))
{
let application: OsString = opt
.passthrough_args
.first()
.map(|a| {
let a: String = a.clone().into();
a
})
.expect("Should have had at least one arg the bazel process itself.")
.into();

let remaining_args: Vec<OsString> = opt
.passthrough_args
.iter()
.skip(1)
.map(|str_ref| {
let a: String = str_ref.clone().into();
let a: OsString = a.into();
a
})
.collect();

let resp = ::exec::Command::new(application)
.args(&remaining_args)
.exec();
panic!("Should be unreachable: {:#?}", resp);
}

let mut rng = rand::thread_rng();
let mut builder = pretty_env_logger::formatted_timed_builder();
builder.format_timestamp_nanos();
Expand Down

0 comments on commit 0ba8d83

Please sign in to comment.