mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 09:33:01 +00:00
c29271e168
This reverts commit 55a5c8d8f9
.
In order to accommodate the removal of the
UnixSeqPacket+CloseNotifier change, I updated the controller.rs
to reference platform-specific internal implementations.
On Windows, CloseNotifier is used to detect closed Tubes.
On Linux, we rely on PollContext returning because the socket fd
is hung up.
Some minor adjustmets to the code were made just to allow as
litte duplication as possible.
In the end, very little logic has changed from the original CL,
it's just moved around.
TL;DR:
This fixes the downstream regression by removing its dependency
on the breaking changes to base.
BUG=b:232316549
FIXED=b:232316549
TEST=Crosvm tests
Change-Id: I946d5096f7a312538c3c694950697fab1be7f0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661257
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
52 lines
1.6 KiB
Rust
52 lines
1.6 KiB
Rust
// Copyright 2022 The ChromiumOS Authors.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
use protoc_rust::{Codegen, Customize};
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
use std::path::PathBuf;
|
|
use std::{env, fs};
|
|
|
|
fn main() {
|
|
build_protos();
|
|
}
|
|
|
|
// TODO(mikehoyle): Unify all proto-building logic across crates into a common build dependency.
|
|
fn build_protos() {
|
|
let proto_files = vec!["protos/event_details.proto"];
|
|
let out_dir = format!(
|
|
"{}/metrics_protos",
|
|
env::var("OUT_DIR").expect("OUT_DIR env does not exist.")
|
|
);
|
|
fs::create_dir_all(&out_dir).unwrap();
|
|
|
|
Codegen::new()
|
|
.out_dir(&out_dir)
|
|
.inputs(&proto_files)
|
|
.customize(Customize {
|
|
serde_derive: Some(true),
|
|
..Default::default()
|
|
})
|
|
.run()
|
|
.unwrap();
|
|
create_gen_file(proto_files, &out_dir);
|
|
}
|
|
|
|
fn create_gen_file(proto_files: Vec<&str>, out_dir: &str) {
|
|
let generated = PathBuf::from(&out_dir).join("generated.rs");
|
|
let out = File::create(generated).expect("Failed to create generated file.");
|
|
|
|
for proto in proto_files {
|
|
let file_stem = PathBuf::from(proto)
|
|
.file_stem()
|
|
.unwrap()
|
|
.to_str()
|
|
.unwrap()
|
|
.to_owned();
|
|
let out_dir = out_dir.replace("\\", "/");
|
|
writeln!(&out, "#[path = \"{}/{}.rs\"]", out_dir, file_stem)
|
|
.expect("failed to write to generated.");
|
|
writeln!(&out, "pub mod {}_proto;", file_stem).expect("failed to write to generated.");
|
|
}
|
|
}
|