 9ac306e464
			
		
	
	
		9ac306e464
		
			
		
	
	
	
	
		
			
			This is the pattern we've been adopting for a while and it's a bit cleaner. Let's remove all of the existing usage of the existing pattern to avoid confusion when adopting the new one.
		
			
				
	
	
		
			34 lines
		
	
	
		
			898 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			898 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # typed: strict
 | |
| # frozen_string_literal: true
 | |
| 
 | |
| module OS
 | |
|   module Mac
 | |
|     module Hardware
 | |
|       module ClassMethods
 | |
|         sig { params(version: T.nilable(MacOSVersion)).returns(Symbol) }
 | |
|         def oldest_cpu(version = nil)
 | |
|           version = if version
 | |
|             MacOSVersion.new(version.to_s)
 | |
|           else
 | |
|             MacOS.version
 | |
|           end
 | |
|           if ::Hardware::CPU.arch == :arm64
 | |
|             :arm_vortex_tempest
 | |
|           # This cannot use a newer CPU e.g. haswell because Rosetta 2 does not
 | |
|           # support AVX instructions in bottles:
 | |
|           #   https://github.com/Homebrew/homebrew-core/issues/67713
 | |
|           elsif version >= :ventura
 | |
|             :westmere
 | |
|           elsif version >= :mojave
 | |
|             :nehalem
 | |
|           else
 | |
|             super
 | |
|           end
 | |
|         end
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 | |
| 
 | |
| Hardware.singleton_class.prepend(OS::Mac::Hardware::ClassMethods)
 |