diff options
| author | Mike McQuaid | 2014-10-16 13:00:20 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2014-10-19 13:58:52 +0100 | 
| commit | 2536c4c347d0785f359beab0a17b7e70993b3076 (patch) | |
| tree | e64cadea7e0610fa6452a21e82d7843777880fac /Library/Homebrew/software_spec.rb | |
| parent | 2db08f52e4c71d01e5596e56ac4d19414a7cde3d (diff) | |
| download | homebrew-2536c4c347d0785f359beab0a17b7e70993b3076.tar.bz2 | |
Add deprecated_option to software_spec.
Allows remapping one option name to another and updates build options
and flags accordingly.
Diffstat (limited to 'Library/Homebrew/software_spec.rb')
| -rw-r--r-- | Library/Homebrew/software_spec.rb | 26 | 
1 files changed, 25 insertions, 1 deletions
| diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 4ea2f56c4..fab50be73 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -20,6 +20,7 @@ class SoftwareSpec    attr_reader :name, :owner    attr_reader :build, :resources, :patches, :options +  attr_reader :deprecated_flags, :deprecated_options    attr_reader :dependency_collector    attr_reader :bottle_specification    attr_reader :compiler_failures @@ -36,7 +37,10 @@ class SoftwareSpec      @bottle_specification = BottleSpecification.new      @patches = []      @options = Options.new -    @build = BuildOptions.new(Options.create(ARGV.flags_only), options) +    @flags = ARGV.flags_only +    @deprecated_flags = [] +    @deprecated_options = [] +    @build = BuildOptions.new(Options.create(@flags), options)      @compiler_failures = []    end @@ -99,6 +103,26 @@ class SoftwareSpec      options << opt    end +  def deprecated_option hash +    raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty? +    hash.each do |old_options, new_options| +      Array(old_options).each do |old_option| +        Array(new_options).each do |new_option| +          deprecated_option = DeprecatedOption.new(old_option, new_option) +          deprecated_options << deprecated_option + +          old_flag = deprecated_option.old_flag +          new_flag = deprecated_option.current_flag +          next unless @flags.include? old_flag +          @flags -= [old_flag] +          @flags |= [new_flag] +          @deprecated_flags << deprecated_option +        end +      end +    end +    @build = BuildOptions.new(Options.create(@flags), options) +  end +    def depends_on spec      dep = dependency_collector.add(spec)      add_dep_option(dep) if dep | 
