feat: Generate constants for runtime version and OS (#2277)

This commit is contained in:
chirag-bgh
2023-04-21 20:54:39 +05:30
committed by GitHub
parent 77d5216192
commit 783d033384
5 changed files with 112 additions and 0 deletions

86
Cargo.lock generated
View File

@@ -492,6 +492,18 @@ dependencies = [
"serde",
]
[[package]]
name = "built"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96f9cdd34d6eb553f9ea20e5bf84abb7b13c729f113fc1d8e49dc00ad9fa8738"
dependencies = [
"cargo-lock",
"chrono",
"git2",
"semver 1.0.17",
]
[[package]]
name = "bumpalo"
version = "3.12.0"
@@ -534,6 +546,18 @@ dependencies = [
"serde",
]
[[package]]
name = "cargo-lock"
version = "8.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031718ddb8f78aa5def78a09e90defe30151d1f6c672f937af4dd916429ed996"
dependencies = [
"semver 1.0.17",
"serde",
"toml 0.5.11",
"url",
]
[[package]]
name = "cargo-platform"
version = "0.1.2"
@@ -574,6 +598,9 @@ name = "cc"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
dependencies = [
"jobserver",
]
[[package]]
name = "cexpr"
@@ -2257,6 +2284,19 @@ version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
[[package]]
name = "git2"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc"
dependencies = [
"bitflags",
"libc",
"libgit2-sys",
"log",
"url",
]
[[package]]
name = "glob"
version = "0.3.1"
@@ -2895,6 +2935,15 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "jobserver"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2"
dependencies = [
"libc",
]
[[package]]
name = "js-sys"
version = "0.3.61"
@@ -3136,6 +3185,18 @@ version = "0.2.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
[[package]]
name = "libgit2-sys"
version = "0.14.2+1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4"
dependencies = [
"cc",
"libc",
"libz-sys",
"pkg-config",
]
[[package]]
name = "libloading"
version = "0.7.4"
@@ -3152,6 +3213,18 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
[[package]]
name = "libz-sys"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "lifetimed-bytes"
version = "0.1.0"
@@ -3926,6 +3999,12 @@ dependencies = [
"spki 0.7.1",
]
[[package]]
name = "pkg-config"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "plain_hasher"
version = "0.2.3"
@@ -4483,6 +4562,7 @@ name = "reth"
version = "0.1.0"
dependencies = [
"backon",
"built",
"clap 4.1.8",
"comfy-table",
"confy",
@@ -7215,6 +7295,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"

View File

@@ -5,6 +5,10 @@ edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/paradigmxyz/reth"
readme = "README.md"
build = "build.rs"
[build-dependencies]
built = { version = "0.6", features = ["git2", "chrono", "semver"] }
[dependencies]
# reth
@@ -34,6 +38,7 @@ reth-net-nat = { path = "../../crates/net/nat" }
reth-payload-builder = { path = "../../crates/payload/builder" }
reth-basic-payload-builder = { path = "../../crates/payload/basic" }
reth-discv4 = { path = "../../crates/net/discv4" }
built = { version = "0.6", features = ["chrono", "semver"] }
# crypto
secp256k1 = { version = "0.26.0", features = [

6
bin/reth/build.rs Normal file
View File

@@ -0,0 +1,6 @@
fn main() {
let mut opts = built::Options::default();
opts.set_dependencies(true);
built::write_built_file().expect("Failed to acquire build-time information");
}

View File

@@ -24,3 +24,5 @@ pub mod stage;
pub mod test_eth_chain;
pub mod test_vectors;
pub mod utils;
pub mod version;
use built as _;

13
bin/reth/src/version.rs Normal file
View File

@@ -0,0 +1,13 @@
//! This module contains the version message for the program.
include!(concat!(env!("OUT_DIR"), "/built.rs"));
const VERSION: &str = PKG_VERSION;
const NAME: &str = PKG_NAME;
const SHA: Option<&str> = GIT_COMMIT_HASH_SHORT;
const OS: &str = std::env::consts::OS;
/// The version message for the current program, like
/// `reth/v0.1.0/macos-6fc95a5/`
pub fn version_message() -> String {
format!("{}/v{}/{}-{}", NAME, VERSION, OS, SHA.unwrap())
}