From 2dc53db6099d42a2bb42fcb5d453b8b3a4959f75 Mon Sep 17 00:00:00 2001 From: Odysseas Gabrielides Date: Thu, 17 Oct 2024 17:19:57 +0300 Subject: [PATCH] split minimal versions --- proto-compiler/src/constants.rs | 3 ++- proto-compiler/src/functions.rs | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/proto-compiler/src/constants.rs b/proto-compiler/src/constants.rs index 97b04cc..8a94de5 100644 --- a/proto-compiler/src/constants.rs +++ b/proto-compiler/src/constants.rs @@ -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"; diff --git a/proto-compiler/src/functions.rs b/proto-compiler/src/functions.rs index 3644ef8..7277873 100644 --- a/proto-compiler/src/functions.rs +++ b/proto-compiler/src/functions.rs @@ -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. /// @@ -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 { @@ -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 {