module FFI::Clang::Utils
Public Class Methods
clang_major_version()
click to toggle source
# File lib/ffi/clang/utils.rb, line 66 def self.clang_major_version clang_version[0] end
clang_minor_version()
click to toggle source
# File lib/ffi/clang/utils.rb, line 70 def self.clang_minor_version clang_version[1] end
clang_version()
click to toggle source
# File lib/ffi/clang/utils.rb, line 34 def self.clang_version unless @@clang_version # Version string vary wildy: # Ubuntu: "Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)" # Mac OS X: "Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)" # Linux: "clang version 3.3" if parts = clang_version_string.match(/(?:clang version|based on LLVM) (\d+)\.(\d+)(svn)?/) major = parts[1].to_i minor = parts[2].to_i rc = parts[3] # Mac OS X currently reports support for 3.3svn, but this support is broken in some ways, so we revert it back to 3.2 which it supports completely. if rc == 'svn' minor -= 1 end @@clang_version = [major, minor] puts "Clang version detected: #{@@clang_version.inspect}" else abort "Invalid/unsupported clang version string." end end return @@clang_version end
clang_version_string()
click to toggle source
# File lib/ffi/clang/utils.rb, line 30 def self.clang_version_string Lib.extract_string Lib.get_clang_version end
clang_version_symbol()
click to toggle source
# File lib/ffi/clang/utils.rb, line 62 def self.clang_version_symbol "clang_#{clang_version.join('_')}".to_sym end
satisfy_version?(min_version, max_version = nil)
click to toggle source
Returns true if the current clang version is >= min version and optionally <= max_version
# File lib/ffi/clang/utils.rb, line 75 def self.satisfy_version?(min_version, max_version = nil) min_version = Gem::Version.create(min_version) max_version = Gem::Version.create(max_version) if max_version current_version = Gem::Version.create(self.clang_version.join('.')) return (current_version >= min_version) && (!max_version || current_version <= max_version) end