-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.rs
39 lines (33 loc) · 1.06 KB
/
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
31
32
33
34
35
36
37
38
39
use cargo_lock::Lockfile;
fn main() -> anyhow::Result<()> {
// Proto
let mut config = prost_build::Config::new();
config.boxed(".blockdaemon.solana.accountsdb_plugin_kafka.types.MessageWrapper");
config.protoc_arg("--experimental_allow_proto3_optional");
config.compile_protos(&["proto/event.proto"], &["proto/"])?;
// Version metrics
let mut envs = vergen::EmitBuilder::builder();
envs.all_build().all_rustc();
envs.emit()?;
// vergen git version does not looks cool
println!(
"cargo:rustc-env=GIT_VERSION={}",
git_version::git_version!()
);
// Extract Solana version
let lockfile = Lockfile::load("./Cargo.lock")?;
println!(
"cargo:rustc-env=SOLANA_SDK_VERSION={}",
get_pkg_version(&lockfile, "solana-sdk")
);
Ok(())
}
fn get_pkg_version(lockfile: &Lockfile, pkg_name: &str) -> String {
lockfile
.packages
.iter()
.filter(|pkg| pkg.name.as_str() == pkg_name)
.map(|pkg| pkg.version.to_string())
.collect::<Vec<_>>()
.join(",")
}