aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2013-05-09 23:53:26 -0500
committerJack Nagel2013-05-10 23:27:28 -0500
commit366ac016bdc7d43e1d4a11d8647a4ecf85925cec (patch)
tree1ee2858133feda98c6399cd30962ce5f14f46b30
parent9b7c228bdf9fd59b7b6021b52a2f67a90c5b5571 (diff)
downloadhomebrew-366ac016bdc7d43e1d4a11d8647a4ecf85925cec.tar.bz2
Reorganize compat
-rw-r--r--Library/Homebrew/compat.rb7
-rw-r--r--Library/Homebrew/compat/compatibility.rb167
-rw-r--r--Library/Homebrew/compat/env.rb13
-rw-r--r--Library/Homebrew/compat/fails_with_llvm.rb17
-rw-r--r--Library/Homebrew/compat/formula.rb29
-rw-r--r--Library/Homebrew/compat/hardware.rb (renamed from Library/Homebrew/compat/hardware_compat.rb)0
-rw-r--r--Library/Homebrew/compat/macos.rb56
-rw-r--r--Library/Homebrew/compat/md5.rb23
-rw-r--r--Library/Homebrew/compat/version.rb6
-rw-r--r--Library/Homebrew/global.rb5
-rw-r--r--Library/Homebrew/hardware.rb2
-rw-r--r--Library/Homebrew/test/testing_env.rb5
12 files changed, 153 insertions, 177 deletions
diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb
new file mode 100644
index 000000000..697355f15
--- /dev/null
+++ b/Library/Homebrew/compat.rb
@@ -0,0 +1,7 @@
+require 'compat/env'
+require 'compat/fails_with_llvm'
+require 'compat/formula'
+require 'compat/hardware'
+require 'compat/macos'
+require 'compat/md5'
+require 'compat/version'
diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb
deleted file mode 100644
index e4de3c16c..000000000
--- a/Library/Homebrew/compat/compatibility.rb
+++ /dev/null
@@ -1,167 +0,0 @@
-def x11_installed?
- MacOS::X11.installed?
-end
-
-def snow_leopard_64?
- MacOS.prefer_64_bit?
-end
-
-class Formula
- # in compatability because the naming is somewhat confusing
- def self.resolve_alias name
- opoo 'Formula.resolve_alias is deprecated and will eventually be removed'
- opoo 'Use Formula.canonical_name instead.'
-
- # Don't resolve paths or URLs
- return name if name.include?("/")
-
- aka = HOMEBREW_REPOSITORY+"Library/Aliases"+name
- if aka.file?
- aka.realpath.basename('.rb').to_s
- else
- name
- end
- end
-
- # This used to be called in "def install", but should now be used
- # up in the DSL section.
- def fails_with_llvm msg=nil, data=nil
- opoo "Calling fails_with_llvm in the install method is deprecated"
- puts "Use the fails_with DSL instead"
- end
-
- def fails_with_llvm?
- fails_with? :llvm
- end
-
- def self.fails_with_llvm msg=nil, data={}
- case msg when Hash then data = msg end
- failure = CompilerFailure.new(:llvm) { build(data.delete(:build).to_i) }
- @cc_failures ||= Set.new
- @cc_failures << failure
- end
-
- def std_cmake_parameters
- "-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev"
- end
-
- class << self
- def bottle_sha1 val=nil
- val.nil? ? @bottle_sha1 : @bottle_sha1 = val
- end
- end
-
- def self.all
- opoo "Formula.all is deprecated, use Formula.map instead"
- map
- end
-end
-
-class UnidentifiedFormula < Formula
-end
-
-module HomebrewEnvExtension extend self
- def use_clang?
- compiler == :clang
- end
-
- def use_gcc?
- compiler == :gcc
- end
-
- def use_llvm?
- compiler == :llvm
- end
-end
-
-# TODO eventually some of these should print deprecation warnings
-module MacOS extend self
- def xcode_folder
- Xcode.folder
- end
-
- def xcode_prefix
- Xcode.prefix
- end
-
- def xcode_installed?
- Xcode.installed?
- end
-
- def xcode_version
- Xcode.version
- end
-
- def clt_installed?
- CLT.installed?
- end
-
- def clt_version?
- CLT.version
- end
-
- def x11_installed?
- X11.installed?
- end
-
- def x11_prefix
- X11.prefix
- end
-
- def leopard?
- 10.5 == MACOS_VERSION
- end
-
- def snow_leopard?
- 10.6 <= MACOS_VERSION # Actually Snow Leopard or newer
- end
- alias_method :snow_leopard_or_newer?, :snow_leopard?
-
- def lion?
- 10.7 <= MACOS_VERSION # Actually Lion or newer
- end
- alias_method :lion_or_newer?, :lion?
-
- def mountain_lion?
- 10.8 <= MACOS_VERSION # Actually Mountain Lion or newer
- end
- alias_method :mountain_lion_or_newer?, :mountain_lion?
-
- def macports_or_fink_installed?
- not MacOS.macports_or_fink.empty?
- end
-end
-
-
-class Version
- def slice *args
- opoo "Calling slice on versions is deprecated, use: to_s.slice"
- to_s.slice(*args)
- end
-end
-
-
-# MD5 support
-class Formula
- def self.md5(val)
- @stable ||= SoftwareSpec.new
- @stable.md5(val)
- end
-end
-
-class SoftwareSpec
- def md5(val)
- @checksum = Checksum.new(:md5, val)
- end
-end
-
-class Pathname
- def md5
- require 'digest/md5'
- opoo <<-EOS.undent
- MD5 support is deprecated and will be removed in a future version.
- Please switch this formula to #{Checksum::TYPES.map { |t| t.to_s.upcase } * ' or '}.
- EOS
- incremental_hash(Digest::MD5)
- end
-end
diff --git a/Library/Homebrew/compat/env.rb b/Library/Homebrew/compat/env.rb
new file mode 100644
index 000000000..73f9b0009
--- /dev/null
+++ b/Library/Homebrew/compat/env.rb
@@ -0,0 +1,13 @@
+module HomebrewEnvExtension
+ def use_clang?
+ compiler == :clang
+ end
+
+ def use_gcc?
+ compiler == :gcc
+ end
+
+ def use_llvm?
+ compiler == :llvm
+ end
+end
diff --git a/Library/Homebrew/compat/fails_with_llvm.rb b/Library/Homebrew/compat/fails_with_llvm.rb
new file mode 100644
index 000000000..19338ceb5
--- /dev/null
+++ b/Library/Homebrew/compat/fails_with_llvm.rb
@@ -0,0 +1,17 @@
+class Formula
+ def fails_with_llvm msg=nil, data=nil
+ opoo "Calling fails_with_llvm in the install method is deprecated"
+ puts "Use the fails_with DSL instead"
+ end
+
+ def fails_with_llvm?
+ fails_with? :llvm
+ end
+
+ def self.fails_with_llvm msg=nil, data={}
+ case msg when Hash then data = msg end
+ failure = CompilerFailure.new(:llvm) { build(data.delete(:build).to_i) }
+ @cc_failures ||= Set.new
+ @cc_failures << failure
+ end
+end
diff --git a/Library/Homebrew/compat/formula.rb b/Library/Homebrew/compat/formula.rb
new file mode 100644
index 000000000..509ff5d18
--- /dev/null
+++ b/Library/Homebrew/compat/formula.rb
@@ -0,0 +1,29 @@
+module FormulaCompat
+ def x11_installed?
+ MacOS::X11.installed?
+ end
+
+ def snow_leopard_64?
+ MacOS.prefer_64_bit?
+ end
+end
+
+class Formula
+ include FormulaCompat
+ extend FormulaCompat
+
+ def std_cmake_parameters
+ "-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev"
+ end
+
+ def self.bottle_sha1(*)
+ end
+
+ def self.all
+ opoo "Formula.all is deprecated, use Formula.map instead"
+ map
+ end
+end
+
+class UnidentifiedFormula < Formula
+end
diff --git a/Library/Homebrew/compat/hardware_compat.rb b/Library/Homebrew/compat/hardware.rb
index 550c10118..550c10118 100644
--- a/Library/Homebrew/compat/hardware_compat.rb
+++ b/Library/Homebrew/compat/hardware.rb
diff --git a/Library/Homebrew/compat/macos.rb b/Library/Homebrew/compat/macos.rb
new file mode 100644
index 000000000..2b3cb9d81
--- /dev/null
+++ b/Library/Homebrew/compat/macos.rb
@@ -0,0 +1,56 @@
+module MacOS
+ def xcode_folder
+ Xcode.folder
+ end
+
+ def xcode_prefix
+ Xcode.prefix
+ end
+
+ def xcode_installed?
+ Xcode.installed?
+ end
+
+ def xcode_version
+ Xcode.version
+ end
+
+ def clt_installed?
+ CLT.installed?
+ end
+
+ def clt_version?
+ CLT.version
+ end
+
+ def x11_installed?
+ X11.installed?
+ end
+
+ def x11_prefix
+ X11.prefix
+ end
+
+ def leopard?
+ version == 10.5
+ end
+
+ def snow_leopard?
+ version >= 10.6
+ end
+ alias_method :snow_leopard_or_newer?, :snow_leopard?
+
+ def lion?
+ version >= 10.7
+ end
+ alias_method :lion_or_newer?, :lion?
+
+ def mountain_lion?
+ version >= 10.8
+ end
+ alias_method :mountain_lion_or_newer?, :mountain_lion?
+
+ def macports_or_fink_installed?
+ not MacOS.macports_or_fink.empty?
+ end
+end
diff --git a/Library/Homebrew/compat/md5.rb b/Library/Homebrew/compat/md5.rb
new file mode 100644
index 000000000..d600bab6d
--- /dev/null
+++ b/Library/Homebrew/compat/md5.rb
@@ -0,0 +1,23 @@
+class Formula
+ def self.md5(val)
+ @stable ||= SoftwareSpec.new
+ @stable.md5(val)
+ end
+end
+
+class SoftwareSpec
+ def md5(val)
+ @checksum = Checksum.new(:md5, val)
+ end
+end
+
+class Pathname
+ def md5
+ require 'digest/md5'
+ opoo <<-EOS.undent
+ MD5 support is deprecated and will be removed in a future version.
+ Please switch this formula to #{Checksum::TYPES.map { |t| t.to_s.upcase } * ' or '}.
+ EOS
+ incremental_hash(Digest::MD5)
+ end
+end
diff --git a/Library/Homebrew/compat/version.rb b/Library/Homebrew/compat/version.rb
new file mode 100644
index 000000000..027df9fc3
--- /dev/null
+++ b/Library/Homebrew/compat/version.rb
@@ -0,0 +1,6 @@
+class Version
+ def slice *args
+ opoo "Calling slice on versions is deprecated, use: to_s.slice"
+ to_s.slice(*args)
+ end
+end
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index da834467b..8d43afcf2 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -93,9 +93,6 @@ FORMULA_META_FILES = Metafiles.new
ISSUES_URL = "https://github.com/mxcl/homebrew/wiki/troubleshooting"
HOMEBREW_PULL_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)?\/(pull\/(\d+)|commit\/\w{4,40})'
-unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
- $:.unshift(File.expand_path("#{__FILE__}/../compat"))
- require 'compatibility'
-end
+require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb
index b139215ae..69f87eade 100644
--- a/Library/Homebrew/hardware.rb
+++ b/Library/Homebrew/hardware.rb
@@ -1,5 +1,3 @@
-require 'hardware_compat'
-
class Hardware
module CPU extend self
def type
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index 731ef5b86..8e3c92a32 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -67,10 +67,7 @@ def shutup
end
end
-unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
- $:.unshift(File.expand_path("#{ABS__FILE__}/../../compat"))
- require 'compatibility'
-end
+require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
require 'test/unit' # must be after at_exit
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser