2022-09-13 17:55:17 +00:00
|
|
|
// Copyright 2019 The ChromiumOS Authors
|
2019-04-05 18:56:44 +00:00
|
|
|
// 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;
|
2022-07-27 18:11:32 +00:00
|
|
|
use std::path::PathBuf;
|
2019-04-05 18:56:44 +00:00
|
|
|
|
|
|
|
type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
|
|
|
|
2019-04-06 03:34:50 +00:00
|
|
|
struct LocalProto {
|
|
|
|
// Corresponding to the input file src/$module.proto.
|
|
|
|
module: &'static str,
|
2019-04-05 18:56:44 +00:00
|
|
|
}
|
|
|
|
|
2019-04-06 03:34:50 +00:00
|
|
|
static LOCAL_PROTOS: &[LocalProto] = &[
|
|
|
|
#[cfg(feature = "plugin")]
|
|
|
|
LocalProto { module: "plugin" },
|
2019-07-08 23:14:24 +00:00
|
|
|
#[cfg(feature = "composite-disk")]
|
2022-11-10 21:30:26 +00:00
|
|
|
LocalProto {
|
|
|
|
module: "cdisk_spec",
|
|
|
|
},
|
2023-05-10 19:10:52 +00:00
|
|
|
LocalProto {
|
|
|
|
module: "registered_events",
|
|
|
|
},
|
2019-04-06 03:34:50 +00:00
|
|
|
];
|
|
|
|
|
2019-04-05 18:56:44 +00:00
|
|
|
fn main() -> Result<()> {
|
2022-11-10 21:30:26 +00:00
|
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
2019-04-05 18:56:44 +00:00
|
|
|
|
2019-04-06 03:34:50 +00:00
|
|
|
// Compile protos from the local src directory.
|
2022-11-10 21:30:26 +00:00
|
|
|
let mut proto_paths = Vec::new();
|
2019-04-06 03:34:50 +00:00
|
|
|
for proto in LOCAL_PROTOS {
|
2022-11-10 21:30:26 +00:00
|
|
|
proto_paths.push(
|
|
|
|
["src", &format!("{}.proto", proto.module)]
|
|
|
|
.iter()
|
|
|
|
.collect::<PathBuf>(),
|
|
|
|
);
|
2019-04-05 18:56:44 +00:00
|
|
|
}
|
2022-11-10 21:30:26 +00:00
|
|
|
proto_build_tools::build_protos(&out_dir, proto_paths.as_slice());
|
2019-04-06 03:34:50 +00:00
|
|
|
|
2019-04-05 18:56:44 +00:00
|
|
|
Ok(())
|
|
|
|
}
|