diff options
| author | Mike McQuaid | 2014-10-16 13:00:20 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-10-19 13:58:52 +0100 |
| commit | 02e10beb7c79f29d5c8a17d89649af344034d541 (patch) | |
| tree | 478793f3d98c59d0296dee316113605d91d7d588 /Library/Homebrew/software_spec.rb | |
| parent | da0a65356d662575c0005b70371050b8015227b2 (diff) | |
| download | brew-02e10beb7c79f29d5c8a17d89649af344034d541.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 |
