-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
30 lines (27 loc) · 932 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fs;
use std::path::Path;
fn main() {
download_geosite();
let mut config = prost_build::Config::new();
config.bytes(["."]);
//config.type_attribute(".", "#[derive(PartialOrd)]");
config
.out_dir("src/")
.compile_protos(&["src/proto/geosite.proto"], &["src/"])
.unwrap();
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/proto/geosite.proto");
println!("cargo:rerun-if-changed=deps/*");
}
fn download_geosite() {
let url = "https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat";
let path = Path::new(".").join("deps");
fs::create_dir_all(path.clone()).unwrap();
let path = path.join("geosite.dat");
if path.exists() {
return;
}
let mut resp = reqwest::blocking::get(url).unwrap();
let mut file = fs::File::create(path).unwrap();
resp.copy_to(&mut file).unwrap();
}