2021-01-03 14:07:11 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn js_protos() {
|
|
|
|
let output = Command::new("npm")
|
|
|
|
.arg("run")
|
|
|
|
.arg("build:protobuf")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
if output.status.success() {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
let err = String::from_utf8(output.stderr).unwrap();
|
|
|
|
panic!("JS Protobuf build failure:\n {}", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn webpack() {
|
|
|
|
let output = Command::new("npm")
|
|
|
|
.arg("run")
|
|
|
|
.arg("build:webpack")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
if output.status.success() {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
let err = String::from_utf8(output.stderr).unwrap();
|
|
|
|
panic!("Webpack build failure:\n {}", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-07 20:32:02 +00:00
|
|
|
fn main() {
|
2021-01-03 14:07:11 +00:00
|
|
|
println!("cargo:rerun-if-changed=static/scripts/webpack.config.js");
|
|
|
|
js_protos();
|
|
|
|
webpack();
|
2021-01-02 23:11:09 +00:00
|
|
|
|
2020-12-08 08:47:34 +00:00
|
|
|
let mut config = prost_build::Config::new();
|
2020-12-31 22:21:05 +00:00
|
|
|
config.btree_map(&["."]);
|
2020-12-08 08:47:34 +00:00
|
|
|
config.type_attribute(".", "#[derive(Serialize)]");
|
|
|
|
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
|
2021-01-02 21:26:09 +00:00
|
|
|
|
|
|
|
tonic_build::configure()
|
|
|
|
.build_server(true)
|
|
|
|
.build_client(false)
|
|
|
|
.compile_with_config(
|
|
|
|
config,
|
2020-12-27 21:03:10 +00:00
|
|
|
&["proto/cofd.proto", "proto/cofd_api.proto"],
|
|
|
|
&["src/", "proto/"],
|
|
|
|
)
|
2020-12-08 08:47:34 +00:00
|
|
|
.unwrap();
|
2020-12-07 20:32:02 +00:00
|
|
|
}
|