crosvm/protos/build.rs
maciek swiech fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00

44 lines
1.1 KiB
Rust

// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::env;
use std::error::Error;
use std::path::PathBuf;
type Result<T> = std::result::Result<T, Box<dyn Error>>;
struct LocalProto {
// Corresponding to the input file src/$module.proto.
module: &'static str,
}
static LOCAL_PROTOS: &[LocalProto] = &[
#[cfg(feature = "plugin")]
LocalProto { module: "plugin" },
#[cfg(feature = "composite-disk")]
LocalProto {
module: "cdisk_spec",
},
LocalProto {
module: "registered_events",
},
];
fn main() -> Result<()> {
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
// Compile protos from the local src directory.
let mut proto_paths = Vec::new();
for proto in LOCAL_PROTOS {
proto_paths.push(
["src", &format!("{}.proto", proto.module)]
.iter()
.collect::<PathBuf>(),
);
}
proto_build_tools::build_protos(&out_dir, proto_paths.as_slice());
Ok(())
}