diff options
Diffstat (limited to 'dependency_checker.rb')
-rw-r--r-- | dependency_checker.rb | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/dependency_checker.rb b/dependency_checker.rb index cfc10b45f0..223a0321f9 100644 --- a/dependency_checker.rb +++ b/dependency_checker.rb @@ -1,5 +1,7 @@ require 'pp' +NOT_INSTALLED_VERSION="-1" + XAMARIN_MAC_MIN_VERSION="2.3" XAMARIN_MAC_VERSION=lambda { product_version ("/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp") } XAMARIN_MAC_URL="http://www.xamarin.com" @@ -20,25 +22,39 @@ def compare_version(first, second) end def mono_version(binary) - actual_version = `#{binary} --version` - # Extract the version number from a string like this: - # `Mono JIT compiler version 4.2.0 (explicit/08b7103 Mon Aug 17 16:58:52 EDT 2015)` - actual_version = actual_version.split('version ')[1] - return actual_version.split(' ')[0] + if File.exist?("#{binary}") + actual_version = `#{binary} --version` + # Extract the version number from a string like this: + # `Mono JIT compiler version 4.2.0 (explicit/08b7103 Mon Aug 17 16:58:52 EDT 2015)` + actual_version = actual_version.split('version ')[1] + return actual_version.split(' ')[0] + else + return NOT_INSTALLED_VERSION + end end def product_version(binary) - version = `#{binary} --version` - return version.split(' ')[1] + if File.exist?("#{binary}") + version = `#{binary} --version` + return version.split(' ')[1] + else + return NOT_INSTALLED_VERSION + end end def check_product(product_min_version, product_version, product_url, product_name) actual_version = product_version.call - retval = compare_version(actual_version, product_min_version) - if (retval < 0) - puts "" + if (actual_version == NOT_INSTALLED_VERSION) + puts "You do not have #{product_name} installed.".red + retval = -1 + else puts "Your installed #{product_name} (#{actual_version}) is too old, please use #{product_min_version} or newer".red + retval = compare_version(actual_version, product_min_version) + end + + if (retval < 0) puts "You can download it from #{product_url}".red + puts end return retval end @@ -49,7 +65,7 @@ def check_monodevelop_dependencies() check_product(XAMARIN_MAC_MIN_VERSION, XAMARIN_MAC_VERSION, XAMARIN_MAC_URL, "Xamarin.Mac") ] if (result.min < 0) - raise RuntimeError + exit 1 end end |