Module: Hardware Private
- Defined in:
- hardware.rb,
extend/os/mac/hardware/cpu.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper module for querying hardware information.
Defined Under Namespace
Classes: CPU
Class Method Summary collapse
- .cores_as_words ⇒ String private
- .oldest_cpu(_version = nil) ⇒ Symbol private
-
.rustflags_target_cpu(arch) ⇒ String?
private
Returns a Rust flag to set the target CPU if necessary.
Class Method Details
.cores_as_words ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'hardware.rb', line 213 def cores_as_words case Hardware::CPU.cores when 1 then "single" when 2 then "dual" when 4 then "quad" when 6 then "hexa" when 8 then "octa" when 10 then "deca" when 12 then "dodeca" else Hardware::CPU.cores.to_s end end |
.oldest_cpu(_version = nil) ⇒ Symbol
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'hardware.rb', line 228 def oldest_cpu(_version = nil) if Hardware::CPU.intel? if Hardware::CPU.is_64_bit? Hardware::CPU::INTEL_64BIT_OLDEST_CPU else :core end elsif Hardware::CPU.arm? if Hardware::CPU.is_64_bit? :armv8 else :armv6 end elsif Hardware::CPU.ppc? && Hardware::CPU.is_64_bit? if Hardware::CPU.little_endian? :ppc64le else :ppc64 end else Hardware::CPU.family end end |
.rustflags_target_cpu(arch) ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Rust flag to set the target CPU if necessary. Defaults to nil.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'hardware.rb', line 255 def rustflags_target_cpu(arch) # Rust already defaults to the oldest supported cpu for each target-triplet # so it's safe to ignore generic archs such as :armv6 here. # Rust defaults to apple-m1 since Rust 1.71 for aarch64-apple-darwin. @target_cpu ||= T.let(case arch when :core :prescott when :native, :ivybridge, :sandybridge, :westmere, :nehalem, :core2 arch end, T.nilable(Symbol)) return if @target_cpu.blank? "--codegen target-cpu=#{@target_cpu}" end |