Skip to content

Commit

Permalink
split minimal versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Oct 17, 2024
1 parent 046e88c commit 2dc53db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion proto-compiler/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Tenderdash protobuf implementation
// Requirements
pub const DEP_PROTOC_VERSION: &str = "3.2.14";
pub const DEP_PROTOC_VERSION_UBUNTU: &str = "3.12.4";
pub const DEP_PROTOC_VERSION_OTHER: &str = "25.0.0";

/// Tenderdash repository URL.
pub const TENDERDASH_REPO: &str = "https://github.com/dashpay/tenderdash";
Expand Down
20 changes: 17 additions & 3 deletions proto-compiler/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use semver::Version;

use walkdir::WalkDir;

use crate::constants::{GenerationMode, DEFAULT_TENDERDASH_COMMITISH, DEP_PROTOC_VERSION};
use crate::constants::{GenerationMode, DEFAULT_TENDERDASH_COMMITISH, DEP_PROTOC_VERSION_OTHER, DEP_PROTOC_VERSION_UBUNTU};

/// Check out a specific commitish of the tenderdash repository.
///
Expand Down Expand Up @@ -361,9 +361,23 @@ pub(crate) fn check_state(dir: &Path, commitish: &str) -> bool {
}
}

fn get_required_protoc_version() -> &'static str {
#[cfg(target_os = "linux")]
{
// Further refine detection if needed
// For example, detect if it's Ubuntu
DEP_PROTOC_VERSION_UBUNTU
}

#[cfg(not(target_os = "linux"))]
{
DEP_PROTOC_VERSION_OTHER
}
}

/// Check if all dependencies are met
pub(crate) fn check_deps() -> Result<(), String> {
dep_protoc(DEP_PROTOC_VERSION).map(|_| ())
dep_protoc(get_required_protoc_version()).map(|_| ())
}

fn dep_protoc(required_version_str: &str) -> Result<Version, String> {
Expand Down Expand Up @@ -414,7 +428,7 @@ mod tests {
fn test_protoc_dep() {
let expected_versions = vec![
("10.1.0", true),
(DEP_PROTOC_VERSION, true),
(DEP_PROTOC_VERSION_OTHER, true),
("90.5.0", false),
];
for &(required_version, expected_result) in &expected_versions {
Expand Down

0 comments on commit 2dc53db

Please sign in to comment.