Add OS.mac? and OS.linux?
This commit is contained in:
parent
45e7f0ccb0
commit
c511d7d2f4
@ -224,7 +224,7 @@ module Stdenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def macosxsdk version=MacOS.version
|
def macosxsdk version=MacOS.version
|
||||||
return unless MACOS
|
return unless OS.mac?
|
||||||
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
|
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
|
||||||
remove_macosxsdk
|
remove_macosxsdk
|
||||||
version = version.to_s
|
version = version.to_s
|
||||||
|
@ -384,7 +384,7 @@ class FormulaInstaller
|
|||||||
link
|
link
|
||||||
end
|
end
|
||||||
|
|
||||||
fix_install_names
|
fix_install_names if OS.mac?
|
||||||
|
|
||||||
record_cxx_stdlib
|
record_cxx_stdlib
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ require 'extend/ARGV'
|
|||||||
require 'extend/string'
|
require 'extend/string'
|
||||||
require 'extend/symbol'
|
require 'extend/symbol'
|
||||||
require 'extend/enumerable'
|
require 'extend/enumerable'
|
||||||
|
require 'os'
|
||||||
require 'utils'
|
require 'utils'
|
||||||
require 'exceptions'
|
require 'exceptions'
|
||||||
require 'set'
|
require 'set'
|
||||||
@ -72,11 +73,9 @@ if RUBY_PLATFORM =~ /darwin/
|
|||||||
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
||||||
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].to_f
|
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].to_f
|
||||||
OS_VERSION = "Mac OS X #{MACOS_FULL_VERSION}"
|
OS_VERSION = "Mac OS X #{MACOS_FULL_VERSION}"
|
||||||
MACOS = true
|
|
||||||
else
|
else
|
||||||
MACOS_FULL_VERSION = MACOS_VERSION = 0
|
MACOS_FULL_VERSION = MACOS_VERSION = 0
|
||||||
OS_VERSION = RUBY_PLATFORM
|
OS_VERSION = RUBY_PLATFORM
|
||||||
MACOS = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'os'
|
||||||
|
|
||||||
class Hardware
|
class Hardware
|
||||||
module CPU extend self
|
module CPU extend self
|
||||||
INTEL_32BIT_ARCHS = [:i386].freeze
|
INTEL_32BIT_ARCHS = [:i386].freeze
|
||||||
@ -30,11 +32,10 @@ class Hardware
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
case RUBY_PLATFORM.downcase
|
if OS.mac?
|
||||||
when /darwin/
|
|
||||||
require 'os/mac/hardware'
|
require 'os/mac/hardware'
|
||||||
CPU.extend MacCPUs
|
CPU.extend MacCPUs
|
||||||
when /linux/
|
elsif OS.linux?
|
||||||
require 'os/linux/hardware'
|
require 'os/linux/hardware'
|
||||||
CPU.extend LinuxCPUs
|
CPU.extend LinuxCPUs
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
class Keg
|
class Keg
|
||||||
def fix_install_names options={}
|
def fix_install_names options={}
|
||||||
return unless MACOS
|
|
||||||
mach_o_files.each do |file|
|
mach_o_files.each do |file|
|
||||||
install_names_for(file, options) do |id, bad_names|
|
install_names_for(file, options) do |id, bad_names|
|
||||||
file.ensure_writable do
|
file.ensure_writable do
|
||||||
|
@ -253,7 +253,7 @@ module MacOS extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mdfind id
|
def mdfind id
|
||||||
return [] unless MACOS
|
return [] unless OS.mac?
|
||||||
(@mdfind ||= {}).fetch(id.to_s) do |key|
|
(@mdfind ||= {}).fetch(id.to_s) do |key|
|
||||||
@mdfind[key] = `/usr/bin/mdfind "kMDItemCFBundleIdentifier == '#{key}'"`.split("\n")
|
@mdfind[key] = `/usr/bin/mdfind "kMDItemCFBundleIdentifier == '#{key}'"`.split("\n")
|
||||||
end
|
end
|
||||||
|
9
Library/Homebrew/os.rb
Normal file
9
Library/Homebrew/os.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module OS
|
||||||
|
def self.mac?
|
||||||
|
/darwin/i === RUBY_PLATFORM
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.linux?
|
||||||
|
/linux/i === RUBY_PLATFORM
|
||||||
|
end
|
||||||
|
end
|
@ -84,7 +84,7 @@ module MacOS::Xcode extend self
|
|||||||
# This is a separate function as you can't cache the value out of a block
|
# This is a separate function as you can't cache the value out of a block
|
||||||
# if return is used in the middle, which we do many times in here.
|
# if return is used in the middle, which we do many times in here.
|
||||||
|
|
||||||
return "0" unless MACOS
|
return "0" unless OS.mac?
|
||||||
|
|
||||||
# this shortcut makes version work for people who don't realise you
|
# this shortcut makes version work for people who don't realise you
|
||||||
# need to install the CLI tools
|
# need to install the CLI tools
|
||||||
|
@ -29,7 +29,6 @@ HOMEBREW_VERSION = '0.9-test'
|
|||||||
RUBY_BIN = Pathname.new(RbConfig::CONFIG['bindir'])
|
RUBY_BIN = Pathname.new(RbConfig::CONFIG['bindir'])
|
||||||
RUBY_PATH = RUBY_BIN + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']
|
RUBY_PATH = RUBY_BIN + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']
|
||||||
|
|
||||||
MACOS = true
|
|
||||||
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
||||||
MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }.to_f
|
MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }.to_f
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ case HOMEBREW_PREFIX.to_s when '/', '/usr'
|
|||||||
# it may work, but I only see pain this route and don't want to support it
|
# it may work, but I only see pain this route and don't want to support it
|
||||||
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
|
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
|
||||||
end
|
end
|
||||||
if MACOS and MACOS_VERSION < 10.5
|
if OS.mac? and MacOS.version < 10.5
|
||||||
abort <<-EOABORT.undent
|
abort <<-EOABORT.undent
|
||||||
Homebrew requires Leopard or higher. For Tiger support, see:
|
Homebrew requires Leopard or higher. For Tiger support, see:
|
||||||
https://github.com/mistydemeo/tigerbrew
|
https://github.com/mistydemeo/tigerbrew
|
||||||
|
Loading…
x
Reference in New Issue
Block a user