-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to resolve build issue in cli (#106)
* Attempt to resolve build issue in cli * moved solana validator check to localnet command Co-authored-by: mwrites <[email protected]>
- Loading branch information
1 parent
363e25f
commit 210dd3d
Showing
3 changed files
with
35 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,33 @@ | ||
use cargo_toml::{Dependency, Manifest}; | ||
use regex::Regex; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let validator_version = get_validator_version(); | ||
let geyser_interface_version = get_geyser_interface_version(); | ||
|
||
println!("cargo:rustc-env=VALIDATOR_VERSION={}", validator_version); | ||
println!( | ||
"cargo:rustc-env=GEYSER_INTERFACE_VERSION={}", | ||
geyser_interface_version | ||
); | ||
} | ||
|
||
fn get_validator_version() -> String { | ||
let output = Command::new("solana-test-validator") | ||
.arg("--version") | ||
.output() | ||
.unwrap(); | ||
let version = String::from_utf8_lossy(&output.stdout); | ||
let re = Regex::new(r"(\d{1}\.\d{2}\.\d{1})").unwrap(); | ||
let caps = re.captures(&version).unwrap(); | ||
caps.get(1) | ||
.map_or("unknown (error parsing solana-validator version)", |m| { | ||
m.as_str() | ||
}) | ||
.into() | ||
} | ||
|
||
fn get_geyser_interface_version() -> String { | ||
let plugin_manifest = Manifest::from_path("../plugin/Cargo.toml").unwrap(); | ||
let plugin_interface = plugin_manifest | ||
.dependencies | ||
.get("solana-geyser-plugin-interface") | ||
.unwrap(); | ||
|
||
match plugin_interface { | ||
let semver = match plugin_interface { | ||
Dependency::Simple(version) => version.into(), | ||
Dependency::Detailed(detail) => detail.version.as_ref().unwrap().into(), | ||
_ => "unknown (error parsing Cargo.toml)".to_string(), | ||
} | ||
_ => "unknown (error parsing Plugin's Cargo.toml)".to_string(), | ||
}; | ||
|
||
let re = Regex::new(r"(\d\.\d{2}\.\d)").unwrap(); | ||
re.captures(&semver) | ||
.unwrap() | ||
.get(1) | ||
.map_or("unknown (error parsing solana-geyser-plugin-interface version)", |m| { | ||
m.as_str() | ||
}) | ||
.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters