diff options
| author | BrewTestBot | 2015-08-03 13:09:07 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-08-03 13:22:35 +0100 |
| commit | 13d544e11e92ba8ea3788723432046f8dfe4adf9 (patch) | |
| tree | e6da18436d9ce956e6fbe80e3185c67cf3b58808 /Library/Homebrew/os | |
| parent | 3b68215be793774fafd9ce124a2065f5968f50e5 (diff) | |
| download | brew-13d544e11e92ba8ea3788723432046f8dfe4adf9.tar.bz2 | |
Core files style updates.
Closes Homebrew/homebrew#42354.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/os')
| -rw-r--r-- | Library/Homebrew/os/linux/hardware.rb | 28 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac.rb | 60 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/hardware.rb | 38 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/version.rb | 20 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xquartz.rb | 18 |
6 files changed, 90 insertions, 78 deletions
diff --git a/Library/Homebrew/os/linux/hardware.rb b/Library/Homebrew/os/linux/hardware.rb index 507639e3a..c8d7f4954 100644 --- a/Library/Homebrew/os/linux/hardware.rb +++ b/Library/Homebrew/os/linux/hardware.rb @@ -1,15 +1,25 @@ module LinuxCPUs OPTIMIZATION_FLAGS = { - :penryn => '-march=core2 -msse4.1', - :core2 => '-march=core2', - :core => '-march=prescott', + :penryn => "-march=core2 -msse4.1", + :core2 => "-march=core2", + :core => "-march=prescott" }.freeze - def optimization_flags; OPTIMIZATION_FLAGS; end + def optimization_flags + OPTIMIZATION_FLAGS + end # Linux supports x86 only, and universal archs do not apply - def arch_32_bit; :i386; end - def arch_64_bit; :x86_64; end - def universal_archs; [].extend ArchitectureListExtension; end + def arch_32_bit + :i386 + end + + def arch_64_bit + :x86_64 + end + + def universal_archs + [].extend ArchitectureListExtension + end def cpuinfo @cpuinfo ||= File.read("/proc/cpuinfo") @@ -42,9 +52,9 @@ module LinuxCPUs @features ||= flags[1..-1].map(&:intern) end - %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each { |flag| + %w[aes altivec avx avx2 lm sse3 ssse3 sse4 sse4_2].each do |flag| define_method(flag + "?") { flags.include? flag } - } + end alias_method :is_64_bit?, :lm? def bits diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index 8aae29c9d..ffab00b00 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -1,7 +1,7 @@ -require 'hardware' -require 'os/mac/version' -require 'os/mac/xcode' -require 'os/mac/xquartz' +require "hardware" +require "os/mac/version" +require "os/mac/xcode" +require "os/mac/xquartz" module OS module Mac @@ -19,7 +19,7 @@ module OS version.to_sym end - def locate tool + def locate(tool) # Don't call tools (cc, make, strip, etc.) directly! # Give the name of the binary you look for as a string to this method # in order to get the full path back as a Pathname. @@ -54,32 +54,32 @@ module OS end def default_cc - cc = locate 'cc' + cc = locate "cc" cc.realpath.basename.to_s rescue nil end def default_compiler case default_cc - when /^gcc-4.0/ then :gcc_4_0 - when /^gcc/ then :gcc - when /^llvm/ then :llvm - when "clang" then :clang + when /^gcc-4.0/ then :gcc_4_0 + when /^gcc/ then :gcc + when /^llvm/ then :llvm + when "clang" then :clang + else + # guess :( + if Xcode.version >= "4.3" + :clang + elsif Xcode.version >= "4.2" + :llvm else - # guess :( - if Xcode.version >= "4.3" - :clang - elsif Xcode.version >= "4.2" - :llvm - else - :gcc - end + :gcc + end end end def gcc_40_build_version @gcc_40_build_version ||= if (path = locate("gcc-4.0")) - %x{#{path} --version}[/build (\d{4,})/, 1].to_i + `#{path} --version`[/build (\d{4,})/, 1].to_i end end alias_method :gcc_4_0_build_version, :gcc_40_build_version @@ -89,7 +89,7 @@ module OS begin gcc = MacOS.locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2") if gcc.exist? && gcc.realpath.basename.to_s !~ /^llvm/ - %x{#{gcc} --version}[/build (\d{4,})/, 1].to_i + `#{gcc} --version`[/build (\d{4,})/, 1].to_i end end end @@ -98,21 +98,21 @@ module OS def llvm_build_version @llvm_build_version ||= if (path = locate("llvm-gcc")) && path.realpath.basename.to_s !~ /^clang/ - %x{#{path} --version}[/LLVM build (\d{4,})/, 1].to_i + `#{path} --version`[/LLVM build (\d{4,})/, 1].to_i end end def clang_version @clang_version ||= if (path = locate("clang")) - %x{#{path} --version}[/(?:clang|LLVM) version (\d\.\d)/, 1] + `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1] end end def clang_build_version @clang_build_version ||= if (path = locate("clang")) - %x{#{path} --version}[%r[clang-(\d{2,})], 1].to_i + `#{path} --version`[/clang-(\d{2,})/, 1].to_i end end @@ -120,7 +120,7 @@ module OS (@non_apple_gcc_version ||= {}).fetch(cc) do path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc) path = locate(cc) unless path.exist? - version = %x{#{path} --version}[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path + version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path @non_apple_gcc_version[cc] = version end end @@ -140,7 +140,7 @@ module OS # First look in the path because MacPorts is relocatable and Fink # may become relocatable in the future. - %w{port fink}.each do |ponk| + %w[port fink].each do |ponk| path = which(ponk) paths << path unless path.nil? end @@ -148,7 +148,7 @@ module OS # Look in the standard locations, because even if port or fink are # not in the path they can still break builds if the build scripts # have these paths baked in. - %w{/sw/bin/fink /opt/local/bin/port}.each do |ponk| + %w[/sw/bin/fink /opt/local/bin/port].each do |ponk| path = Pathname.new(ponk) paths << path if path.exist? end @@ -157,7 +157,7 @@ module OS # read-only in order to try out Homebrew, but this doens't work as # some build scripts error out when trying to read from these now # unreadable paths. - %w{/sw /opt/local}.map { |p| Pathname.new(p) }.each do |path| + %w[/sw /opt/local].map { |p| Pathname.new(p) }.each do |path| paths << path if path.exist? && !path.readable? end @@ -165,7 +165,7 @@ module OS end def prefer_64_bit? - Hardware::CPU.is_64_bit? and version > :leopard + Hardware::CPU.is_64_bit? && version > :leopard end def preferred_arch @@ -211,7 +211,7 @@ module OS "6.3.1" => { :clang => "6.1", :clang_build => 602 }, "6.3.2" => { :clang => "6.1", :clang_build => 602 }, "6.4" => { :clang => "6.1", :clang_build => 602 }, - "7.0" => { :clang => "7.0", :clang_build => 700 }, + "7.0" => { :clang => "7.0", :clang_build => 700 } } def compilers_standard? @@ -233,7 +233,7 @@ module OS def app_with_bundle_id(*ids) path = mdfind(*ids).first - Pathname.new(path) unless path.nil? or path.empty? + Pathname.new(path) unless path.nil? || path.empty? end def mdfind(*ids) diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb index 60de1eba8..11cf0142a 100644 --- a/Library/Homebrew/os/mac/hardware.rb +++ b/Library/Homebrew/os/mac/hardware.rb @@ -1,16 +1,18 @@ -require 'mach' +require "mach" module MacCPUs OPTIMIZATION_FLAGS = { - :penryn => '-march=core2 -msse4.1', - :core2 => '-march=core2', - :core => '-march=prescott', - :g3 => '-mcpu=750', - :g4 => '-mcpu=7400', - :g4e => '-mcpu=7450', - :g5 => '-mcpu=970' + :penryn => "-march=core2 -msse4.1", + :core2 => "-march=core2", + :core => "-march=prescott", + :g3 => "-mcpu=750", + :g4 => "-mcpu=7400", + :g4e => "-mcpu=7450", + :g5 => "-mcpu=970" }.freeze - def optimization_flags; OPTIMIZATION_FLAGS; end + def optimization_flags + OPTIMIZATION_FLAGS + end # These methods use info spewed out by sysctl. # Look in <mach/machine.h> for decoding info. @@ -92,7 +94,7 @@ module MacCPUs def universal_archs # Building 64-bit is a no-go on Tiger, and pretty hit or miss on Leopard. # Don't even try unless Tigerbrew's experimental 64-bit Leopard support is enabled. - if MacOS.version <= :leopard and !MacOS.prefer_64_bit? + if MacOS.version <= :leopard && !MacOS.prefer_64_bit? [arch_32_bit].extend ArchitectureListExtension else [arch_32_bit, arch_64_bit].extend ArchitectureListExtension @@ -108,35 +110,35 @@ module MacCPUs end def aes? - sysctl_bool('hw.optional.aes') + sysctl_bool("hw.optional.aes") end def altivec? - sysctl_bool('hw.optional.altivec') + sysctl_bool("hw.optional.altivec") end def avx? - sysctl_bool('hw.optional.avx1_0') + sysctl_bool("hw.optional.avx1_0") end def avx2? - sysctl_bool('hw.optional.avx2_0') + sysctl_bool("hw.optional.avx2_0") end def sse3? - sysctl_bool('hw.optional.sse3') + sysctl_bool("hw.optional.sse3") end def ssse3? - sysctl_bool('hw.optional.supplementalsse3') + sysctl_bool("hw.optional.supplementalsse3") end def sse4? - sysctl_bool('hw.optional.sse4_1') + sysctl_bool("hw.optional.sse4_1") end def sse4_2? - sysctl_bool('hw.optional.sse4_2') + sysctl_bool("hw.optional.sse4_2") end private diff --git a/Library/Homebrew/os/mac/version.rb b/Library/Homebrew/os/mac/version.rb index febbfd4f7..9a529df80 100644 --- a/Library/Homebrew/os/mac/version.rb +++ b/Library/Homebrew/os/mac/version.rb @@ -1,17 +1,17 @@ -require 'version' +require "version" module OS module Mac class Version < ::Version SYMBOLS = { - :el_capitan => '10.11', - :yosemite => '10.10', - :mavericks => '10.9', - :mountain_lion => '10.8', - :lion => '10.7', - :snow_leopard => '10.6', - :leopard => '10.5', - :tiger => '10.4', + :el_capitan => "10.11", + :yosemite => "10.10", + :mavericks => "10.9", + :mountain_lion => "10.8", + :lion => "10.7", + :snow_leopard => "10.6", + :leopard => "10.5", + :tiger => "10.4" } def self.from_symbol(sym) @@ -38,7 +38,7 @@ module OS end def pretty_name - to_sym.to_s.split('_').map(&:capitalize).join(' ') + to_sym.to_s.split("_").map(&:capitalize).join(" ") end end end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 766443419..83ba84ff8 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -60,7 +60,7 @@ module OS end def installed? - not prefix.nil? + !prefix.nil? end def version @@ -178,7 +178,7 @@ module OS else version = `/usr/bin/clang --version` end - version = version[%r{clang-(\d+\.\d+\.\d+(\.\d+)?)}, 1] || "0" + version = version[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1] || "0" version < latest_version end diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index 9c717367e..b253ad8e0 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -22,7 +22,7 @@ module OS "2.7.53" => "2.7.5_rc4", "2.7.54" => "2.7.5", "2.7.61" => "2.7.6", - "2.7.73" => "2.7.7", + "2.7.73" => "2.7.7" }.freeze # This returns the version number of XQuartz, not of the upstream X.org. @@ -69,10 +69,10 @@ module OS # educated guess as to what version is installed. def guess_system_version case MacOS.version - when '10.5' then '2.1.6' - when '10.6' then '2.3.6' - when '10.7' then '2.6.3' - else 'dunno' + when "10.5" then "2.1.6" + when "10.6" then "2.3.6" + when "10.7" then "2.6.3" + else "dunno" end end @@ -93,10 +93,10 @@ module OS # remain public. New code should use MacOS::X11.bin, MacOS::X11.lib and # MacOS::X11.include instead, as that accounts for Xcode-only systems. def prefix - @prefix ||= if Pathname.new('/opt/X11/lib/libpng.dylib').exist? - Pathname.new('/opt/X11') - elsif Pathname.new('/usr/X11/lib/libpng.dylib').exist? - Pathname.new('/usr/X11') + @prefix ||= if Pathname.new("/opt/X11/lib/libpng.dylib").exist? + Pathname.new("/opt/X11") + elsif Pathname.new("/usr/X11/lib/libpng.dylib").exist? + Pathname.new("/usr/X11") end end |
