diff options
| author | Mike McQuaid | 2016-04-25 17:57:51 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-05-08 16:51:22 +0100 |
| commit | 931e292bf12b8e05f6586ac7721255b35f04a389 (patch) | |
| tree | 0ba3a1b81851de032c2e30a1f3fd3b2f6e3dc573 /Library/Homebrew/extend | |
| parent | ddb576b582ddc801ac702566bacbc2f231fc86af (diff) | |
| download | brew-931e292bf12b8e05f6586ac7721255b35f04a389.tar.bz2 | |
Make bottle code cross-platform.
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/os/bottles.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/extend/os/mac/utils/bottles.rb | 59 |
2 files changed, 64 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/os/bottles.rb b/Library/Homebrew/extend/os/bottles.rb new file mode 100644 index 000000000..aff9300de --- /dev/null +++ b/Library/Homebrew/extend/os/bottles.rb @@ -0,0 +1,5 @@ +require "utils/bottles" + +if OS.mac? + require "extend/os/mac/utils/bottles" +end diff --git a/Library/Homebrew/extend/os/mac/utils/bottles.rb b/Library/Homebrew/extend/os/mac/utils/bottles.rb new file mode 100644 index 000000000..6b83ad6c4 --- /dev/null +++ b/Library/Homebrew/extend/os/mac/utils/bottles.rb @@ -0,0 +1,59 @@ +module Utils + class Bottles + class << self + def tag + if MacOS.version >= :lion + MacOS.cat + elsif MacOS.version == :snow_leopard + Hardware::CPU.is_64_bit? ? :snow_leopard : :snow_leopard_32 + else + # Return, e.g., :tiger_g3, :leopard_g5_64, :leopard_64 (which is Intel) + if Hardware::CPU.type == :ppc + tag = "#{MacOS.cat}_#{Hardware::CPU.family}".to_sym + else + tag = MacOS.cat + end + MacOS.prefer_64_bit? ? "#{tag}_64".to_sym : tag + end + end + end + + class Collector + private + + alias_method :original_find_matching_tag, :find_matching_tag + def find_matching_tag(tag) + original_find_matching_tag(tag) || find_altivec_tag(tag) || find_or_later_tag(tag) + end + + # This allows generic Altivec PPC bottles to be supported in some + # formulae, while also allowing specific bottles in others; e.g., + # sometimes a formula has just :tiger_altivec, other times it has + # :tiger_g4, :tiger_g5, etc. + def find_altivec_tag(tag) + if tag.to_s =~ /(\w+)_(g4|g4e|g5)$/ + altivec_tag = "#{$1}_altivec".to_sym + altivec_tag if key?(altivec_tag) + end + end + + # Allows a bottle tag to specify a specific OS or later, + # so the same bottle can target multiple OSs. + # Not used in core, used in taps. + def find_or_later_tag(tag) + begin + tag_version = MacOS::Version.from_symbol(tag) + rescue ArgumentError + return + end + + keys.find do |key| + if key.to_s.end_with?("_or_later") + later_tag = key.to_s[/(\w+)_or_later$/, 1].to_sym + MacOS::Version.from_symbol(later_tag) <= tag_version + end + end + end + end + end +end |
