| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "resource" | 
					
						
							| 
									
										
										
										
											2021-02-26 11:23:33 +00:00
										 |  |  | require "download_strategy" | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "checksum" | 
					
						
							|  |  |  | require "version" | 
					
						
							|  |  |  | require "options" | 
					
						
							|  |  |  | require "build_options" | 
					
						
							|  |  |  | require "dependency_collector" | 
					
						
							| 
									
										
										
										
											2016-04-25 17:57:51 +01:00
										 |  |  | require "utils/bottles" | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "patch" | 
					
						
							|  |  |  | require "compilers" | 
					
						
							| 
									
										
										
										
											2023-05-09 02:15:28 +02:00
										 |  |  | require "macos_version" | 
					
						
							| 
									
										
										
										
											2025-06-09 19:06:16 +01:00
										 |  |  | require "on_system" | 
					
						
							| 
									
										
										
										
											2013-09-14 10:16:52 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  | class SoftwareSpec | 
					
						
							|  |  |  |   include Downloadable | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:38 -05:00
										 |  |  |   extend Forwardable | 
					
						
							| 
									
										
										
										
											2022-06-29 17:48:21 -04:00
										 |  |  |   include OnSystem::MacOSAndLinux | 
					
						
							| 
									
										
										
										
											2013-09-14 10:16:52 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   PREDEFINED_OPTIONS = T.let({ | 
					
						
							| 
									
										
										
										
											2016-12-20 10:22:30 +00:00
										 |  |  |     universal: Option.new("universal", "Build a universal binary"), | 
					
						
							|  |  |  |     cxx11:     Option.new("c++11",     "Build using C++11 mode"), | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   }.freeze, T::Hash[T.any(Symbol, String), Option]) | 
					
						
							| 
									
										
										
										
											2014-08-07 10:45:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(T.nilable(String)) } | 
					
						
							|  |  |  |   attr_reader :name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T.nilable(String)) } | 
					
						
							|  |  |  |   attr_reader :full_name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T.nilable(T.any(Formula, Cask::Cask))) } | 
					
						
							|  |  |  |   attr_reader :owner | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(BuildOptions) } | 
					
						
							|  |  |  |   attr_reader :build | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Hash[String, Resource]) } | 
					
						
							|  |  |  |   attr_reader :resources | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Array[T.any(EmbeddedPatch, ExternalPatch)]) } | 
					
						
							|  |  |  |   attr_reader :patches | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(Options) } | 
					
						
							|  |  |  |   attr_reader :options | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Array[DeprecatedOption]) } | 
					
						
							|  |  |  |   attr_reader :deprecated_flags | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Array[DeprecatedOption]) } | 
					
						
							|  |  |  |   attr_reader :deprecated_options | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(DependencyCollector) } | 
					
						
							|  |  |  |   attr_reader :dependency_collector | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(BottleSpecification) } | 
					
						
							|  |  |  |   attr_reader :bottle_specification | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sig { returns(T::Array[CompilerFailure]) } | 
					
						
							|  |  |  |   attr_reader :compiler_failures | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 15:51:02 +01:00
										 |  |  |   def_delegators :@resource, :stage, :fetch, :verify_download_integrity, :source_modified_time, | 
					
						
							| 
									
										
										
										
											2020-07-07 11:29:33 +01:00
										 |  |  |                  :cached_download, :clear_cache, :checksum, :mirrors, :specs, :using, :version, :mirror, | 
					
						
							| 
									
										
										
										
											2025-08-04 15:51:02 +01:00
										 |  |  |                  :downloader, :download_queue_name, :download_queue_type | 
					
						
							| 
									
										
										
										
											2020-11-24 15:46:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-07 08:33:57 +01:00
										 |  |  |   def_delegators :@resource, :sha256 | 
					
						
							| 
									
										
										
										
											2013-09-14 10:16:52 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(flags: T::Array[String]).void } | 
					
						
							| 
									
										
										
										
											2020-07-26 07:24:14 +02:00
										 |  |  |   def initialize(flags: []) | 
					
						
							| 
									
										
										
										
											2024-07-14 11:42:22 -04:00
										 |  |  |     super() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |     @name = T.let(nil, T.nilable(String)) | 
					
						
							|  |  |  |     @full_name = T.let(nil, T.nilable(String)) | 
					
						
							|  |  |  |     @owner = T.let(nil, T.nilable(T.any(Formula, Cask::Cask))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-24 23:53:35 +01:00
										 |  |  |     # Ensure this is synced with `initialize_dup` and `freeze` (excluding simple objects like integers and booleans) | 
					
						
							| 
									
										
										
										
											2025-04-19 22:22:42 +01:00
										 |  |  |     @resource = T.let(Resource::Formula.new, Resource::Formula) | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |     @resources = T.let({}, T::Hash[String, Resource]) | 
					
						
							|  |  |  |     @dependency_collector = T.let(DependencyCollector.new, DependencyCollector) | 
					
						
							|  |  |  |     @bottle_specification = T.let(BottleSpecification.new, BottleSpecification) | 
					
						
							|  |  |  |     @patches = T.let([], T::Array[T.any(EmbeddedPatch, ExternalPatch)]) | 
					
						
							|  |  |  |     @options = T.let(Options.new, Options) | 
					
						
							|  |  |  |     @flags = T.let(flags, T::Array[String]) | 
					
						
							|  |  |  |     @deprecated_flags = T.let([], T::Array[DeprecatedOption]) | 
					
						
							|  |  |  |     @deprecated_options = T.let([], T::Array[DeprecatedOption]) | 
					
						
							|  |  |  |     @build = T.let(BuildOptions.new(Options.create(@flags), options), BuildOptions) | 
					
						
							|  |  |  |     @compiler_failures = T.let([], T::Array[CompilerFailure]) | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:39 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { override.params(other: T.any(SoftwareSpec, Downloadable)).void } | 
					
						
							| 
									
										
										
										
											2022-08-24 23:53:35 +01:00
										 |  |  |   def initialize_dup(other) | 
					
						
							| 
									
										
										
										
											2022-08-25 11:04:37 +01:00
										 |  |  |     super | 
					
						
							| 
									
										
										
										
											2022-08-24 23:53:35 +01:00
										 |  |  |     @resource = @resource.dup | 
					
						
							|  |  |  |     @resources = @resources.dup | 
					
						
							| 
									
										
										
										
											2022-08-25 11:04:37 +01:00
										 |  |  |     @dependency_collector = @dependency_collector.dup | 
					
						
							| 
									
										
										
										
											2022-08-24 23:53:35 +01:00
										 |  |  |     @bottle_specification = @bottle_specification.dup | 
					
						
							|  |  |  |     @patches = @patches.dup | 
					
						
							|  |  |  |     @options = @options.dup | 
					
						
							|  |  |  |     @flags = @flags.dup | 
					
						
							|  |  |  |     @deprecated_flags = @deprecated_flags.dup | 
					
						
							|  |  |  |     @deprecated_options = @deprecated_options.dup | 
					
						
							|  |  |  |     @build = @build.dup | 
					
						
							|  |  |  |     @compiler_failures = @compiler_failures.dup | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { override.returns(T.self_type) } | 
					
						
							| 
									
										
										
										
											2022-08-24 23:53:35 +01:00
										 |  |  |   def freeze | 
					
						
							|  |  |  |     @resource.freeze | 
					
						
							|  |  |  |     @resources.freeze | 
					
						
							|  |  |  |     @dependency_collector.freeze | 
					
						
							|  |  |  |     @bottle_specification.freeze | 
					
						
							|  |  |  |     @patches.freeze | 
					
						
							|  |  |  |     @options.freeze | 
					
						
							|  |  |  |     @flags.freeze | 
					
						
							|  |  |  |     @deprecated_flags.freeze | 
					
						
							|  |  |  |     @deprecated_options.freeze | 
					
						
							|  |  |  |     @build.freeze | 
					
						
							|  |  |  |     @compiler_failures.freeze | 
					
						
							|  |  |  |     super | 
					
						
							| 
									
										
										
										
											2022-08-25 11:04:37 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(owner: T.any(Formula, Cask::Cask)).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def owner=(owner) | 
					
						
							| 
									
										
										
										
											2013-09-23 21:39:19 -05:00
										 |  |  |     @name = owner.name | 
					
						
							| 
									
										
										
										
											2015-05-27 22:15:35 +08:00
										 |  |  |     @full_name = owner.full_name | 
					
						
							| 
									
										
										
										
											2015-07-03 21:34:22 +08:00
										 |  |  |     @bottle_specification.tap = owner.tap | 
					
						
							| 
									
										
										
										
											2014-02-27 14:50:22 -06:00
										 |  |  |     @owner = owner | 
					
						
							| 
									
										
										
										
											2013-09-23 21:39:19 -05:00
										 |  |  |     @resource.owner = self | 
					
						
							| 
									
										
										
										
											2013-11-26 18:47:41 -06:00
										 |  |  |     resources.each_value do |r| | 
					
						
							| 
									
										
										
										
											2017-08-07 10:12:52 +01:00
										 |  |  |       r.owner = self | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  |       next if r.version | 
					
						
							| 
									
										
										
										
											2024-07-25 02:05:40 +01:00
										 |  |  |       next if version.nil? | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 16:47:09 +01:00
										 |  |  |       r.version(version.head? ? Version.new("HEAD") : version.dup) | 
					
						
							| 
									
										
										
										
											2013-11-26 18:47:41 -06:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-03-13 19:51:23 -05:00
										 |  |  |     patches.each { |p| p.owner = self } | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:39 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-26 11:35:26 -07:00
										 |  |  |   sig { override.params(val: T.nilable(String), specs: T::Hash[Symbol, T.anything]).returns(T.nilable(String)) } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def url(val = nil, specs = {}) | 
					
						
							| 
									
										
										
										
											2025-03-26 11:35:26 -07:00
										 |  |  |     if val | 
					
						
							|  |  |  |       @resource.url(val, **specs) | 
					
						
							|  |  |  |       dependency_collector.add(@resource) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     @resource.url | 
					
						
							| 
									
										
										
										
											2013-09-28 16:37:05 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2015-11-01 20:33:24 +08:00
										 |  |  |   def bottle_defined? | 
					
						
							| 
									
										
										
										
											2021-09-16 18:56:47 +01:00
										 |  |  |     !bottle_specification.collector.tags.empty? | 
					
						
							| 
									
										
										
										
											2015-11-01 20:33:24 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-16 04:04:46 +08:00
										 |  |  |   sig { params(tag: T.nilable(T.any(Utils::Bottles::Tag, Symbol))).returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2021-08-26 14:36:49 -07:00
										 |  |  |   def bottle_tag?(tag = nil) | 
					
						
							|  |  |  |     bottle_specification.tag?(Utils::Bottles.tag(tag)) | 
					
						
							| 
									
										
										
										
											2020-12-09 13:53:10 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-16 04:04:46 +08:00
										 |  |  |   sig { params(tag: T.nilable(T.any(Utils::Bottles::Tag, Symbol))).returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2021-08-26 14:36:49 -07:00
										 |  |  |   def bottled?(tag = nil) | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |     return false unless bottle_tag?(tag) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true if tag.present? | 
					
						
							|  |  |  |     return true if bottle_specification.compatible_locations? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     owner = self.owner | 
					
						
							|  |  |  |     return false unless owner.is_a?(Formula) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     owner.force_bottle | 
					
						
							| 
									
										
										
										
											2014-03-10 14:56:02 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(block: T.proc.bind(BottleSpecification).void).void } | 
					
						
							| 
									
										
										
										
											2022-05-30 14:59:14 +01:00
										 |  |  |   def bottle(&block) | 
					
						
							|  |  |  |     bottle_specification.instance_eval(&block) | 
					
						
							| 
									
										
										
										
											2014-03-10 14:56:02 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(name: String).returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def resource_defined?(name) | 
					
						
							|  |  |  |     resources.key?(name) | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:40 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-03 21:47:49 +02:00
										 |  |  |   sig { | 
					
						
							|  |  |  |     params(name: String, klass: T.class_of(Resource), block: T.nilable(T.proc.bind(Resource).void)) | 
					
						
							|  |  |  |       .returns(T.nilable(Resource)) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-07-14 11:42:22 -04:00
										 |  |  |   def resource(name = T.unsafe(nil), klass = Resource, &block) | 
					
						
							| 
									
										
										
										
											2020-11-16 22:18:56 +01:00
										 |  |  |     if block | 
					
						
							| 
									
										
										
										
											2024-07-14 11:42:22 -04:00
										 |  |  |       raise ArgumentError, "Resource must have a name." if name.nil? | 
					
						
							| 
									
										
										
										
											2016-09-17 15:17:27 +01:00
										 |  |  |       raise DuplicateResourceError, name if resource_defined?(name) | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-02 23:32:42 -07:00
										 |  |  |       res = klass.new(name, &block) | 
					
						
							| 
									
										
										
										
											2020-06-25 22:24:46 +02:00
										 |  |  |       return unless res.url | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 23:42:53 -05:00
										 |  |  |       resources[name] = res | 
					
						
							|  |  |  |       dependency_collector.add(res) | 
					
						
							| 
									
										
										
										
											2024-05-03 21:47:49 +02:00
										 |  |  |       res | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:39 -05:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2024-07-14 11:42:22 -04:00
										 |  |  |       return @resource if name.nil? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-17 21:25:39 -05:00
										 |  |  |       resources.fetch(name) { raise ResourceMissingError.new(owner, name) } | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2013-09-14 10:16:52 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(name: String).returns(T::Boolean) } | 
					
						
							| 
									
										
										
										
											2014-07-31 19:37:39 -05:00
										 |  |  |   def option_defined?(name) | 
					
						
							|  |  |  |     options.include?(name) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(name: T.any(Symbol, String), description: String).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def option(name, description = "") | 
					
						
							| 
									
										
										
										
											2014-08-07 10:45:32 -05:00
										 |  |  |     opt = PREDEFINED_OPTIONS.fetch(name) do | 
					
						
							|  |  |  |       raise ArgumentError, "option name is required" if name.empty? | 
					
						
							| 
									
										
										
										
											2023-04-18 15:06:50 -07:00
										 |  |  |       raise ArgumentError, "option name must be longer than one character: #{name}" if name.length <= 1
 | 
					
						
							| 
									
										
										
										
											2016-04-20 02:17:28 -04:00
										 |  |  |       raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-") | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-07 10:45:32 -05:00
										 |  |  |       Option.new(name, description) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     options << opt | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-07 14:17:14 -07:00
										 |  |  |   sig { params(hash: T::Hash[T.any(String, Symbol, T::Array[String]), T.any(String, Symbol, T::Array[String])]).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def deprecated_option(hash) | 
					
						
							| 
									
										
										
										
											2014-10-16 13:00:20 +01:00
										 |  |  |     raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-16 13:00:20 +01:00
										 |  |  |     hash.each do |old_options, new_options| | 
					
						
							|  |  |  |       Array(old_options).each do |old_option| | 
					
						
							|  |  |  |         Array(new_options).each do |new_option| | 
					
						
							|  |  |  |           deprecated_option = DeprecatedOption.new(old_option, new_option) | 
					
						
							|  |  |  |           deprecated_options << deprecated_option | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           old_flag = deprecated_option.old_flag | 
					
						
							|  |  |  |           new_flag = deprecated_option.current_flag | 
					
						
							| 
									
										
										
										
											2016-09-17 15:17:27 +01:00
										 |  |  |           next unless @flags.include? old_flag | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-17 15:17:27 +01:00
										 |  |  |           @flags -= [old_flag] | 
					
						
							|  |  |  |           @flags |= [new_flag] | 
					
						
							|  |  |  |           @deprecated_flags << deprecated_option | 
					
						
							| 
									
										
										
										
											2014-10-16 13:00:20 +01:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     @build = BuildOptions.new(Options.create(@flags), options) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-07 20:03:18 -07:00
										 |  |  |   sig { params(spec: T.any(String, Symbol, T::Hash[T.any(String, Symbol, T::Class[Requirement]), T.untyped], T::Class[Requirement], Dependable)).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def depends_on(spec) | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |     dep = dependency_collector.add(spec) | 
					
						
							| 
									
										
										
										
											2014-07-31 19:37:39 -05:00
										 |  |  |     add_dep_option(dep) if dep | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 23:45:03 +01:00
										 |  |  |   sig { | 
					
						
							|  |  |  |     params( | 
					
						
							| 
									
										
										
										
											2024-02-13 00:42:54 +01:00
										 |  |  |       dep:    T.any(String, T::Hash[T.any(String, Symbol), T.any(Symbol, T::Array[Symbol])]), | 
					
						
							|  |  |  |       bounds: T::Hash[Symbol, Symbol], | 
					
						
							| 
									
										
										
										
											2024-02-12 23:45:03 +01:00
										 |  |  |     ).void | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-02-13 00:42:54 +01:00
										 |  |  |   def uses_from_macos(dep, bounds = {}) | 
					
						
							|  |  |  |     if dep.is_a?(Hash) | 
					
						
							|  |  |  |       bounds = dep.dup | 
					
						
							| 
									
										
										
										
											2024-02-12 23:45:03 +01:00
										 |  |  |       dep, tags = bounds.shift | 
					
						
							| 
									
										
										
										
											2024-02-13 00:42:54 +01:00
										 |  |  |       dep = T.cast(dep, String) | 
					
						
							| 
									
										
										
										
											2024-02-12 23:45:03 +01:00
										 |  |  |       tags = [*tags] | 
					
						
							| 
									
										
										
										
											2024-02-13 00:42:54 +01:00
										 |  |  |       bounds = T.cast(bounds, T::Hash[Symbol, Symbol]) | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       tags = [] | 
					
						
							| 
									
										
										
										
											2022-07-23 02:47:22 +02:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |     depends_on UsesFromMacOSDependency.new(dep, tags, bounds:) | 
					
						
							| 
									
										
										
										
											2023-06-19 06:03:31 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2021-09-14 04:06:40 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(Dependencies) } | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |   def deps | 
					
						
							| 
									
										
										
										
											2023-06-19 06:03:31 +01:00
										 |  |  |     dependency_collector.deps.dup_without_system_deps | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(Dependencies) } | 
					
						
							| 
									
										
										
										
											2023-06-19 06:03:31 +01:00
										 |  |  |   def declared_deps | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |     dependency_collector.deps | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(T::Array[Dependable]) } | 
					
						
							| 
									
										
										
										
											2017-06-25 03:38:21 -07:00
										 |  |  |   def recursive_dependencies | 
					
						
							| 
									
										
										
										
											2017-07-02 05:39:02 -07:00
										 |  |  |     deps_f = [] | 
					
						
							| 
									
										
										
										
											2024-02-22 23:29:55 +00:00
										 |  |  |     recursive_dependencies = deps.filter_map do |dep| | 
					
						
							| 
									
										
										
										
											2019-10-13 10:03:26 +01:00
										 |  |  |       deps_f << dep.to_formula | 
					
						
							|  |  |  |       dep | 
					
						
							|  |  |  |     rescue TapFormulaUnavailableError | 
					
						
							|  |  |  |       # Don't complain about missing cross-tap dependencies | 
					
						
							|  |  |  |       next | 
					
						
							| 
									
										
										
										
											2024-02-22 23:29:55 +00:00
										 |  |  |     end.uniq | 
					
						
							| 
									
										
										
										
											2017-07-02 05:39:02 -07:00
										 |  |  |     deps_f.compact.each do |f| | 
					
						
							| 
									
										
										
										
											2017-06-25 03:38:21 -07:00
										 |  |  |       f.recursive_dependencies.each do |dep| | 
					
						
							|  |  |  |         recursive_dependencies << dep unless recursive_dependencies.include?(dep) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     recursive_dependencies | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(Requirements) } | 
					
						
							| 
									
										
										
										
											2013-09-21 19:27:24 -05:00
										 |  |  |   def requirements | 
					
						
							|  |  |  |     dependency_collector.requirements | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-03-13 19:51:23 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { returns(Requirements) } | 
					
						
							| 
									
										
										
										
											2017-06-25 03:38:21 -07:00
										 |  |  |   def recursive_requirements | 
					
						
							|  |  |  |     Requirement.expand(self) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { | 
					
						
							|  |  |  |     params(strip: T.any(Symbol, String), src: T.nilable(T.any(String, Symbol)), | 
					
						
							|  |  |  |            block: T.nilable(T.proc.bind(Patch).void)).void | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   def patch(strip = :p1, src = T.unsafe(nil), &block) | 
					
						
							| 
									
										
										
										
											2016-03-22 15:19:33 +08:00
										 |  |  |     p = Patch.create(strip, src, &block) | 
					
						
							| 
									
										
										
										
											2022-07-15 18:25:57 +02:00
										 |  |  |     return if p.is_a?(ExternalPatch) && p.url.blank? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-22 15:19:33 +08:00
										 |  |  |     dependency_collector.add(p.resource) if p.is_a? ExternalPatch | 
					
						
							|  |  |  |     patches << p | 
					
						
							| 
									
										
										
										
											2014-03-13 19:51:23 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-03-13 19:51:23 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(compiler: T.any(T::Hash[Symbol, String], Symbol), block: T.nilable(T.proc.bind(CompilerFailure).void)).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def fails_with(compiler, &block) | 
					
						
							| 
									
										
										
										
											2014-08-19 17:14:02 -05:00
										 |  |  |     compiler_failures << CompilerFailure.create(compiler, &block) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(standards: T::Array[String]).void } | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def needs(*standards) | 
					
						
							| 
									
										
										
										
											2014-08-19 17:14:02 -05:00
										 |  |  |     standards.each do |standard| | 
					
						
							|  |  |  |       compiler_failures.concat CompilerFailure.for_standard(standard) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 19:21:28 +01:00
										 |  |  |   sig { params(dep: Dependable).void } | 
					
						
							| 
									
										
										
										
											2014-07-31 19:37:39 -05:00
										 |  |  |   def add_dep_option(dep) | 
					
						
							| 
									
										
										
										
											2015-12-14 19:47:19 +00:00
										 |  |  |     dep.option_names.each do |name| | 
					
						
							|  |  |  |       if dep.optional? && !option_defined?("with-#{name}") | 
					
						
							|  |  |  |         options << Option.new("with-#{name}", "Build with #{name} support") | 
					
						
							|  |  |  |       elsif dep.recommended? && !option_defined?("without-#{name}") | 
					
						
							|  |  |  |         options << Option.new("without-#{name}", "Build without #{name} support") | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2014-07-31 19:37:39 -05:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-09-14 10:16:52 -05:00
										 |  |  | end |