diff --git a/proto-build/src/commands/export.rs b/proto-build/src/commands/export.rs index b724b33..756167c 100644 --- a/proto-build/src/commands/export.rs +++ b/proto-build/src/commands/export.rs @@ -1,6 +1,6 @@ use std::fs; use std::path::Path; -use crate::{ARCHWAY_DIR, COSMOS_SDK_DIR, IBC_DIR, WASMD_DIR}; +use crate::consts::{ARCHWAY_DIR, COSMOS_SDK_DIR, IBC_DIR, WASMD_DIR}; use crate::utils::run::run_buf_export; pub fn export(submodules_dir: &Path, proto_dir: &Path) { diff --git a/proto-build/src/commands/output_version.rs b/proto-build/src/commands/output_version.rs index 666efc7..193b851 100644 --- a/proto-build/src/commands/output_version.rs +++ b/proto-build/src/commands/output_version.rs @@ -1,6 +1,6 @@ use std::fs; use std::path::Path; -use crate::{ARCHWAY_REV, COSMOS_SDK_REV, IBC_REV, WASMD_REV}; +use crate::consts::{ARCHWAY_REV, COSMOS_SDK_REV, IBC_REV, WASMD_REV}; pub fn output_versions(out_dir: &Path) { println!("Writing versions..."); diff --git a/proto-build/src/commands/update_submodules.rs b/proto-build/src/commands/update_submodules.rs index 1f04ea1..a03ac5d 100644 --- a/proto-build/src/commands/update_submodules.rs +++ b/proto-build/src/commands/update_submodules.rs @@ -1,5 +1,5 @@ use std::path::Path; -use crate::{ARCHWAY_DIR, ARCHWAY_REV, COSMOS_SDK_DIR, COSMOS_SDK_REV, IBC_DIR, IBC_REV, WASMD_DIR, WASMD_REV}; +use crate::consts::{ARCHWAY_DIR, ARCHWAY_REV, COSMOS_SDK_DIR, COSMOS_SDK_REV, IBC_DIR, IBC_REV, WASMD_DIR, WASMD_REV}; use crate::utils::run::run_git; pub fn update_submodules(submodules_dir: &Path) { @@ -7,18 +7,18 @@ pub fn update_submodules(submodules_dir: &Path) { run_git(["submodule", "foreach", "git", "fetch"]).unwrap(); println!("Updating archway-network/archway submodule..."); - let archway_dir = format!("{}/{}", submodules_dir.display(), ARCHWAY_DIR); - run_git(["-C", archway_dir.as_str(), "reset", "--hard", ARCHWAY_REV]).unwrap(); + let archway_dir = submodules_dir.join(ARCHWAY_DIR); + run_git(["-C", archway_dir.to_str().unwrap(), "reset", "--hard", ARCHWAY_REV]).unwrap(); println!("Updating cosmos/cosmos-sdk submodule..."); - let sdk_dir = format!("{}/{}", submodules_dir.display(), COSMOS_SDK_DIR); - run_git(["-C", sdk_dir.as_str(), "reset", "--hard", COSMOS_SDK_REV]).unwrap(); + let sdk_dir = submodules_dir.join(COSMOS_SDK_DIR); + run_git(["-C", sdk_dir.to_str().unwrap(), "reset", "--hard", COSMOS_SDK_REV]).unwrap(); println!("Updating cosmos/ibc-go submodule..."); - let ibc_dir = format!("{}/{}", submodules_dir.display(), IBC_DIR); - run_git(["-C", ibc_dir.as_str(), "reset", "--hard", IBC_REV]).unwrap(); + let ibc_dir = submodules_dir.join(IBC_DIR); + run_git(["-C", ibc_dir.to_str().unwrap(), "reset", "--hard", IBC_REV]).unwrap(); println!("Updating wasmd submodule..."); - let wasmd_dir = format!("{}/{}", submodules_dir.display(), WASMD_DIR); - run_git(["-C", wasmd_dir.as_str(), "reset", "--hard", WASMD_REV]).unwrap(); + let wasmd_dir = submodules_dir.join(WASMD_DIR); + run_git(["-C", wasmd_dir.to_str().unwrap(), "reset", "--hard", WASMD_REV]).unwrap(); } diff --git a/proto-build/src/consts.rs b/proto-build/src/consts.rs new file mode 100644 index 0000000..ddd00c4 --- /dev/null +++ b/proto-build/src/consts.rs @@ -0,0 +1,18 @@ +/// The Archway commit or tag to be cloned and used to build the proto files +pub const ARCHWAY_REV: &str = "v7.0.1"; +pub const ARCHWAY_DIR: &str = "archway"; + +/// The Cosmos SDK commit or tag to be cloned and used to build the proto files +pub const COSMOS_SDK_REV: &str = "v0.47.11"; +pub const COSMOS_SDK_DIR: &str = "cosmos-sdk"; + +/// The Cosmos ibc-go commit or tag to be cloned and used to build the proto files +pub const IBC_REV: &str = "v7.4.0"; +pub const IBC_DIR: &str = "ibc-go"; + +/// The wasmd commit or tag to be cloned and used to build the proto files +pub const WASMD_REV: &str = "v0.45.0"; +pub const WASMD_DIR: &str = "wasmd"; + +pub const PROTO_DIR: &str = "proto"; +pub const OUT_DIR: &str = "packages/proto/src/gen"; diff --git a/proto-build/src/main.rs b/proto-build/src/main.rs index 8010cbb..3af8070 100644 --- a/proto-build/src/main.rs +++ b/proto-build/src/main.rs @@ -1,6 +1,7 @@ mod parser; mod utils; mod commands; +mod consts; use std::{io, path::Path, process}; use std::path::PathBuf; @@ -14,27 +15,9 @@ use crate::commands::generate::generate; use crate::commands::output_version::output_versions; use crate::commands::rustfmt::rustfmt; use crate::commands::update_submodules::update_submodules; +use crate::consts::{OUT_DIR, PROTO_DIR}; use crate::utils::run::run_cargo; -/// The Archway commit or tag to be cloned and used to build the proto files -const ARCHWAY_REV: &str = "v7.0.1"; -const ARCHWAY_DIR: &str = "archway"; - -/// The Cosmos SDK commit or tag to be cloned and used to build the proto files -const COSMOS_SDK_REV: &str = "v0.47.11"; -const COSMOS_SDK_DIR: &str = "cosmos-sdk"; - -/// The Cosmos ibc-go commit or tag to be cloned and used to build the proto files -const IBC_REV: &str = "v7.4.0"; -const IBC_DIR: &str = "ibc-go"; - -/// The wasmd commit or tag to be cloned and used to build the proto files -const WASMD_REV: &str = "v0.45.0"; -const WASMD_DIR: &str = "wasmd"; - -const PROTO_DIR: &str = "proto"; -const OUT_DIR: &str = "packages/proto/src/gen"; - error_chain! { foreign_links { IoError(io::Error);