All checks were successful
Build and Push Image / build-and-push (push) Successful in 5m24s
42 lines
981 B
Rust
42 lines
981 B
Rust
use dotenv::dotenv;
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
tonic_build::configure()
|
|
.build_server(false)
|
|
.build_client(true)
|
|
.compile_protos(
|
|
&[
|
|
"../AobaServer/Proto/Aoba.proto",
|
|
"../AobaServer/Proto/Auth.proto",
|
|
"../AobaServer/Proto/Metrics.proto",
|
|
"../AobaServer/Proto/Types.proto",
|
|
],
|
|
&["../AobaServer/"],
|
|
)?;
|
|
forward_env();
|
|
Ok(())
|
|
}
|
|
|
|
fn forward_env() {
|
|
let dest_path = "./src/env.rs";
|
|
let mut f = File::create(&dest_path).unwrap();
|
|
f.write_all(b"// This file is automatically generated by build.rs\n\n")
|
|
.unwrap();
|
|
|
|
dotenv().ok();
|
|
for (key, value) in env::vars() {
|
|
if key.starts_with("APP_") {
|
|
f.write_all("#[allow(dead_code)]\n".as_bytes()).unwrap();
|
|
let line = format!(
|
|
"pub const {}: &'static str = \"{}\";\n",
|
|
key,
|
|
value.replace("\"", "\\\"")
|
|
);
|
|
f.write_all(line.as_bytes()).unwrap();
|
|
}
|
|
}
|
|
}
|