Module: Hardware Private
- Defined in:
- extend/os/mac/hardware/cpu/hardware.rb,
hardware.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.
-
.zig_cpu(arch) ⇒ Symbol
private
Returns the closest Zig target CPU for the requested brew-supported architecture symbol.
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.
221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'hardware.rb', line 221 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.
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'hardware.rb', line 236 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.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'hardware.rb', line 263 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 |
.zig_cpu(arch) ⇒ 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.
Returns the closest Zig target CPU for the requested brew-supported
architecture symbol. See zig targets for available CPUs.
283 284 285 286 287 288 289 290 291 292 |
# File 'hardware.rb', line 283 def zig_cpu(arch) case arch when :arm_vortex_tempest then :apple_m1 when :armv6 then :arm1136j_s when :armv8 then :xgene1 when :core then :prescott when :dunno then :baseline else arch.to_s.tr("-", "_").to_sym end end |