Skip to content

Commit 0b54f24

Browse files
authored
fix: cross build ci required for releases + remove const_format (#1643)
1 parent eef1184 commit 0b54f24

File tree

4 files changed

+43
-54
lines changed

4 files changed

+43
-54
lines changed

Cargo.lock

Lines changed: 0 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ethportal-api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ base64 = "0.13.0"
2020
bimap = "0.6.3"
2121
bytes.workspace = true
2222
c-kzg = "1.0.0"
23-
const_format = {version = "0.2.0", features = ["rust_1_64"]}
2423
discv5.workspace = true
2524
eth_trie.workspace = true
2625
ethereum_hashing.workspace = true

crates/ethportal-api/build.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::error::Error;
1+
use std::{env, error::Error};
22

33
use vergen::EmitBuilder;
44

@@ -10,6 +10,40 @@ fn main() -> Result<(), Box<dyn Error>> {
1010
.rustc_semver()
1111
.cargo_features()
1212
.cargo_target_triple()
13-
.emit()?;
13+
.emit_and_set()?;
14+
15+
// Set short SHA
16+
let sha = env::var("VERGEN_GIT_SHA")?;
17+
let short_sha = &sha[0..7];
18+
println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={short_sha}");
19+
20+
// Trin's version is the same as the git tag.
21+
let git_describe = env::var("VERGEN_GIT_DESCRIBE")?;
22+
let trin_version = git_describe.split('-').collect::<Vec<&str>>()[0];
23+
println!("cargo:rustc-env=TRIN_VERSION={}", trin_version);
24+
25+
let cargo_target_triple = env::var("VERGEN_CARGO_TARGET_TRIPLE")?;
26+
let target_triple = cargo_target_triple.split('-').collect::<Vec<&str>>();
27+
let build_architecture = target_triple[0];
28+
let build_operating_system = target_triple[2];
29+
30+
// The operating system of the build, linux, macos, windows etc.
31+
println!("cargo:rustc-env=TRIN_BUILD_OPERATING_SYSTEM={build_operating_system}");
32+
33+
// The architecture of the build, x86_64, aarch64, etc.
34+
println!("cargo:rustc-env=TRIN_BUILD_ARCHITECTURE={build_architecture}");
35+
36+
println!(
37+
"cargo:rustc-env=TRIN_FULL_VERSION={}",
38+
format_args!(
39+
"{version}-{hash} {build_os}-{build_arch} rustc{rust_version}",
40+
version = trin_version,
41+
hash = short_sha,
42+
build_os = build_operating_system,
43+
build_arch = build_architecture,
44+
rust_version = env::var("VERGEN_RUSTC_SEMVER")?
45+
)
46+
);
47+
1448
Ok(())
1549
}

crates/ethportal-api/src/version.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1+
use std::env;
2+
13
/// The latest git commit hash of the build.
24
pub const TRIN_FULL_COMMIT: &str = env!("VERGEN_GIT_SHA");
3-
pub const TRIN_SHORT_COMMIT: &str = const_format::str_index!(TRIN_FULL_COMMIT, ..8);
5+
pub const TRIN_SHORT_COMMIT: &str = env!("VERGEN_GIT_SHA_SHORT");
46

57
/// Trin's version is the same as the git tag.
6-
pub const TRIN_VERSION: &str = const_format::str_split!(env!("VERGEN_GIT_DESCRIBE"), '-')[0];
8+
pub const TRIN_VERSION: &str = env!("TRIN_VERSION");
79

810
/// The operating system of the build, linux, macos, windows etc.
9-
pub const BUILD_OPERATING_SYSTEM: &str =
10-
const_format::str_split!(env!("VERGEN_CARGO_TARGET_TRIPLE"), "-")[2];
11+
pub const BUILD_OPERATING_SYSTEM: &str = env!("TRIN_BUILD_OPERATING_SYSTEM");
1112

1213
/// The architecture of the build, x86_64, aarch64, etc.
13-
pub const BUILD_ARCHITECTURE: &str =
14-
const_format::str_split!(env!("VERGEN_CARGO_TARGET_TRIPLE"), "-")[0];
14+
pub const BUILD_ARCHITECTURE: &str = env!("TRIN_BUILD_ARCHITECTURE");
1515

1616
// /// The version of the programming language used to build the binary.
1717
pub const PROGRAMMING_LANGUAGE_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");
1818

19-
pub const FULL_VERSION: &str = const_format::formatcp!(
20-
"{version}-{hash} {build_os}-{build_arch} rustc{rust_version}",
21-
version = TRIN_VERSION,
22-
hash = TRIN_SHORT_COMMIT,
23-
build_os = BUILD_OPERATING_SYSTEM,
24-
build_arch = BUILD_ARCHITECTURE,
25-
rust_version = PROGRAMMING_LANGUAGE_VERSION
26-
);
19+
pub const FULL_VERSION: &str = env!("TRIN_FULL_VERSION");
2720

2821
/// Returns the trin version and git revision.
2922
pub const fn get_trin_version() -> &'static str {

0 commit comments

Comments
 (0)