This repository has been archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add version information about zkevm-circuits
- Loading branch information
1 parent
96983cd
commit fd00efd
Showing
4 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::env::var; | ||
use std::fs::File; | ||
use std::io::Read; | ||
use std::io::Write; | ||
use std::process::Command; | ||
|
||
fn get_crate_version(pkg: &str) -> String { | ||
let cmd = Command::new("cargo") | ||
.args([ | ||
"tree", | ||
"--package", | ||
pkg, | ||
"--depth", | ||
"0", | ||
"--prefix", | ||
"none", | ||
"--quiet", | ||
"--charset", | ||
"utf8", | ||
]) | ||
.output() | ||
.expect("cargo tree output"); | ||
|
||
String::from_utf8(cmd.stdout).expect("utf8 output") | ||
} | ||
|
||
fn main() { | ||
let pkg_version = var("CARGO_PKG_VERSION").expect("CARGO_PKG_VERSION"); | ||
let version = format!( | ||
"pub const VERSION: &str = \"{}\n{}\";", | ||
pkg_version, | ||
get_crate_version("zkevm-circuits"), | ||
); | ||
|
||
let path = "src/version.rs"; | ||
let update = match File::open(path) { | ||
Ok(mut file) => { | ||
let mut buffer = String::new(); | ||
file.read_to_string(&mut buffer).expect("read version.rs"); | ||
buffer != version | ||
} | ||
Err(_) => true, | ||
}; | ||
|
||
if update { | ||
let mut file = File::create(path).expect("create version.rs"); | ||
file.write_all(version.as_bytes()) | ||
.expect("write version.rs"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,3 +19,4 @@ pub mod circuits; | |
pub mod server; | ||
pub mod shared_state; | ||
pub mod utils; | ||
pub mod version; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub const VERSION: &str = "0.1.0 | ||
zkevm-circuits v0.1.0 (https://github.com/pinkiebell/zkevm-circuits.git?branch=zkevm-chain#27141e57) | ||
"; |