forked from tmrlvi/kaspa-miner
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.rs
27 lines (25 loc) · 1.14 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
use std::env;
use time::{format_description, OffsetDateTime};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let format = format_description::parse("[year repr:last_two][month][day][hour][minute]")?;
let dt = OffsetDateTime::now_utc().format(&format)?;
println!("cargo:rustc-env=PACKAGE_COMPILE_TIME={}", dt);
println!("cargo:rerun-if-changed=proto");
println!("cargo:rerun-if-changed=src/keccakf1600_x86-64.s");
tonic_build::configure()
.build_server(false)
// .type_attribute(".", "#[derive(Debug)]")
.compile(
&["proto/rpc.proto", "proto/p2p.proto", "proto/messages.proto"],
&["proto"],
)?;
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_arch == "x86_64" && target_os != "windows" && target_os != "macos" {
cc::Build::new().flag("-c").file("src/keccakf1600_x86-64.s").compile("libkeccak.a");
}
if target_arch == "x86_64" && target_os == "macos" {
cc::Build::new().flag("-c").file("src/keccakf1600_x86-64-osx.s").compile("libkeccak.a");
}
Ok(())
}