| 
									
										
										
										
											2021-09-11 01:00:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-05-24 21:36:48 -03:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 00:13:50 +00:00
										 |  |  | # The Library/Homebrew/extend/os/software_spec.rb conditional logic will need to be more nuanced | 
					
						
							|  |  |  | # if this file ever includes more than `uses_from_macos`. | 
					
						
							| 
									
										
										
										
											2019-05-24 21:36:48 -03:00
										 |  |  | class SoftwareSpec | 
					
						
							| 
									
										
										
										
											2019-05-26 00:17:40 -03:00
										 |  |  |   undef uses_from_macos | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-28 14:17:54 +01:00
										 |  |  |   def uses_from_macos(deps, bounds = {}) | 
					
						
							|  |  |  |     if deps.is_a?(Hash) | 
					
						
							|  |  |  |       bounds = deps.dup | 
					
						
							| 
									
										
										
										
											2021-09-14 04:06:40 +01:00
										 |  |  |       deps = [bounds.shift].to_h | 
					
						
							| 
									
										
										
										
											2020-04-28 14:17:54 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 04:06:40 +01:00
										 |  |  |     @uses_from_macos_elements << deps | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-04 17:16:39 +01:00
										 |  |  |     bounds = bounds.transform_values { |v| MacOS::Version.from_symbol(v) } | 
					
						
							| 
									
										
										
										
											2021-09-14 04:06:40 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Linux simulating macOS. Assume oldest macOS version. | 
					
						
							|  |  |  |     return if Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # macOS new enough for dependency to not be required. | 
					
						
							|  |  |  |     return if MacOS.version >= bounds[:since] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     depends_on deps | 
					
						
							| 
									
										
										
										
											2019-05-24 21:36:48 -03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |