diff options
| author | Misty De Meo | 2016-11-03 16:48:51 -0700 | 
|---|---|---|
| committer | Misty De Meo | 2016-11-10 15:09:36 -0800 | 
| commit | 20bbeb5e9c4cdd5fb5b7cc92b46325d86b543cf8 (patch) | |
| tree | f79848082c10b418a5a16b170a3313410c376cba | |
| parent | 16529a4de5c24f62574ba0b7dbc033f5323e7afb (diff) | |
| download | brew-20bbeb5e9c4cdd5fb5b7cc92b46325d86b543cf8.tar.bz2 | |
Return compiler versions and builds as Versions
| -rw-r--r-- | Library/Homebrew/compilers.rb | 11 | ||||
| -rw-r--r-- | Library/Homebrew/development_tools.rb | 22 | 
2 files changed, 26 insertions, 7 deletions
| diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 7503f1d77..b6c87aeca 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -14,7 +14,14 @@ end  class CompilerFailure    attr_reader :name -  attr_rw :version + +  def version(val = nil) +    if val +      @version = Version.parse(val.to_s) +    else +      @version +    end +  end    # Allows Apple compiler `fails_with` statements to keep using `build`    # even though `build` and `version` are the same internally @@ -45,7 +52,7 @@ class CompilerFailure    def initialize(name, version, &block)      @name = name -    @version = version +    @version = Version.parse(version.to_s)      instance_eval(&block) if block_given?    end diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index 3e1f16d2a..febe04b21 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -44,7 +44,9 @@ class DevelopmentTools      def gcc_40_build_version        @gcc_40_build_version ||=          if (path = locate("gcc-4.0")) -          `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i +          Version.new `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i +        else +          Version::NULL          end      end      alias gcc_4_0_build_version gcc_40_build_version @@ -54,7 +56,9 @@ class DevelopmentTools          begin            gcc = locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2")            if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm") -            `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i +            Version.new `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1] +          else +            Version::NULL            end          end      end @@ -63,14 +67,18 @@ class DevelopmentTools      def clang_version        @clang_version ||=          if (path = locate("clang")) -          `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1] +          Version.new `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1] +        else +          Version::NULL          end      end      def clang_build_version        @clang_build_version ||=          if (path = locate("clang")) -          `#{path} --version`[/clang-(\d{2,})/, 1].to_i +          Version.new `#{path} --version`[/clang-(\d{2,})/, 1] +        else +          Version::NULL          end      end @@ -78,7 +86,11 @@ class DevelopmentTools        (@non_apple_gcc_version ||= {}).fetch(cc) do          path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)          path = locate(cc) unless path.exist? -        version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path +        version = if path +          Version.new(`#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1]) +        else +          Version::NULL +        end          @non_apple_gcc_version[cc] = version        end      end | 
