Skip to content

Commit

Permalink
feat(proto-build): move consts to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
SpekalsG3 committed Aug 20, 2024
1 parent 763476f commit 802211b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion proto-build/src/commands/export.rs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion proto-build/src/commands/output_version.rs
Original file line number Diff line number Diff line change
@@ -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...");
Expand Down
18 changes: 9 additions & 9 deletions proto-build/src/commands/update_submodules.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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) {
run_git(["submodule", "update", "--init"]).unwrap();
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();
}
18 changes: 18 additions & 0 deletions proto-build/src/consts.rs
Original file line number Diff line number Diff line change
@@ -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";
21 changes: 2 additions & 19 deletions proto-build/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod parser;
mod utils;
mod commands;
mod consts;

use std::{io, path::Path, process};

Check warning on line 6 in proto-build/src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable)

unused import: `process`

Check warning on line 6 in proto-build/src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (1.70.0)

unused import: `process`

Check warning on line 6 in proto-build/src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable)

unused import: `process`

Check warning on line 6 in proto-build/src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (1.70.0)

unused import: `process`
use std::path::PathBuf;
Expand All @@ -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);
Expand Down

0 comments on commit 802211b

Please sign in to comment.