Class: SoftwareSpec
- Inherits:
-
Object
- Object
- SoftwareSpec
- Extended by:
- Forwardable
- Defined in:
- Library/Homebrew/extend/os/mac/software_spec.rb,
Library/Homebrew/software_spec.rb
Overview
typed: false frozen_string_literal: true
Direct Known Subclasses
Constant Summary collapse
- PREDEFINED_OPTIONS =
{ universal: Option.new("universal", "Build a universal binary"), cxx11: Option.new("c++11", "Build using C++11 mode"), }.freeze
Instance Attribute Summary collapse
-
#bottle_disable_reason ⇒ Object
readonly
Returns the value of attribute bottle_disable_reason.
-
#bottle_specification ⇒ Object
readonly
Returns the value of attribute bottle_specification.
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#compiler_failures ⇒ Object
readonly
Returns the value of attribute compiler_failures.
-
#dependency_collector ⇒ Object
readonly
Returns the value of attribute dependency_collector.
-
#deprecated_flags ⇒ Object
readonly
Returns the value of attribute deprecated_flags.
-
#deprecated_options ⇒ Object
readonly
Returns the value of attribute deprecated_options.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#patches ⇒ Object
readonly
Returns the value of attribute patches.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#uses_from_macos_elements ⇒ Object
readonly
Returns the value of attribute uses_from_macos_elements.
Instance Method Summary collapse
- #add_dep_option(dep) ⇒ Object
-
#add_legacy_patches(list) ⇒ Object
TODO: ?.
- #bottle(disable_type = nil, disable_reason = nil, &block) ⇒ Object
- #bottle_defined? ⇒ Boolean
- #bottle_disabled? ⇒ Boolean
- #bottle_unneeded? ⇒ Boolean
- #bottled? ⇒ Boolean
- #depends_on(spec) ⇒ Object
- #deprecated_option(hash) ⇒ Object
- #deps ⇒ Object
- #fails_with(compiler, &block) ⇒ Object
- #go_resource(name, &block) ⇒ Object
-
#initialize(flags: []) ⇒ SoftwareSpec
constructor
A new instance of SoftwareSpec.
- #needs(*standards) ⇒ Object
- #option(name, description = "") ⇒ Object
- #option_defined?(name) ⇒ Boolean
- #patch(strip = :p1, src = nil, &block) ⇒ Object
- #recursive_dependencies ⇒ Object
- #recursive_requirements ⇒ Object
- #requirements ⇒ Object
- #resource(name, klass = Resource, &block) ⇒ Object
- #resource_defined?(name) ⇒ Boolean
- #url(val = nil, specs = {}) ⇒ Object
- #uses_from_macos(deps, bounds = {}) ⇒ Object
Constructor Details
#initialize(flags: []) ⇒ SoftwareSpec
Returns a new instance of SoftwareSpec.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'Library/Homebrew/software_spec.rb', line 32 def initialize(flags: []) @resource = Resource.new @resources = {} @dependency_collector = DependencyCollector.new @bottle_specification = BottleSpecification.new @patches = [] @options = Options.new @flags = flags @deprecated_flags = [] @deprecated_options = [] @build = BuildOptions.new(Options.create(@flags), ) @compiler_failures = [] @bottle_disable_reason = nil end |
Instance Attribute Details
#bottle_disable_reason ⇒ Object (readonly)
Returns the value of attribute bottle_disable_reason
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def bottle_disable_reason @bottle_disable_reason end |
#bottle_specification ⇒ Object (readonly)
Returns the value of attribute bottle_specification
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def bottle_specification @bottle_specification end |
#build ⇒ Object (readonly)
Returns the value of attribute build
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def build @build end |
#compiler_failures ⇒ Object (readonly)
Returns the value of attribute compiler_failures
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def compiler_failures @compiler_failures end |
#dependency_collector ⇒ Object (readonly)
Returns the value of attribute dependency_collector
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def dependency_collector @dependency_collector end |
#deprecated_flags ⇒ Object (readonly)
Returns the value of attribute deprecated_flags
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def deprecated_flags @deprecated_flags end |
#deprecated_options ⇒ Object (readonly)
Returns the value of attribute deprecated_options
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def @deprecated_options end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def full_name @full_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def @options end |
#owner ⇒ Object
Returns the value of attribute owner
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def owner @owner end |
#patches ⇒ Object (readonly)
Returns the value of attribute patches
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def patches @patches end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def resources @resources end |
#uses_from_macos_elements ⇒ Object (readonly)
Returns the value of attribute uses_from_macos_elements
24 25 26 |
# File 'Library/Homebrew/software_spec.rb', line 24 def uses_from_macos_elements @uses_from_macos_elements end |
Instance Method Details
#add_dep_option(dep) ⇒ Object
226 227 228 229 230 231 232 233 234 |
# File 'Library/Homebrew/software_spec.rb', line 226 def add_dep_option(dep) dep.option_names.each do |name| if dep.optional? && !option_defined?("with-#{name}") << Option.new("with-#{name}", "Build with #{name} support") elsif dep.recommended? && !option_defined?("without-#{name}") << Option.new("without-#{name}", "Build without #{name} support") end end end |
#add_legacy_patches(list) ⇒ Object
TODO: ?
220 221 222 223 224 |
# File 'Library/Homebrew/software_spec.rb', line 220 def add_legacy_patches(list) list = Patch.normalize_legacy_patches(list) list.each { |p| p.owner = self } patches.concat(list) end |
#bottle(disable_type = nil, disable_reason = nil, &block) ⇒ Object
94 95 96 97 98 99 100 |
# File 'Library/Homebrew/software_spec.rb', line 94 def bottle(disable_type = nil, disable_reason = nil, &block) if disable_type @bottle_disable_reason = BottleDisableReason.new(disable_type, disable_reason) else bottle_specification.instance_eval(&block) end end |
#bottle_defined? ⇒ Boolean
85 86 87 |
# File 'Library/Homebrew/software_spec.rb', line 85 def bottle_defined? !bottle_specification.collector.keys.empty? end |
#bottle_disabled? ⇒ Boolean
81 82 83 |
# File 'Library/Homebrew/software_spec.rb', line 81 def bottle_disabled? @bottle_disable_reason ? true : false end |
#bottle_unneeded? ⇒ Boolean
75 76 77 78 79 |
# File 'Library/Homebrew/software_spec.rb', line 75 def bottle_unneeded? return false unless @bottle_disable_reason @bottle_disable_reason.unneeded? end |
#bottled? ⇒ Boolean
89 90 91 92 |
# File 'Library/Homebrew/software_spec.rb', line 89 def bottled? bottle_specification.tag?(Utils::Bottles.tag) && \ (bottle_specification.compatible_cellar? || owner.force_bottle) end |
#depends_on(spec) ⇒ Object
164 165 166 167 |
# File 'Library/Homebrew/software_spec.rb', line 164 def depends_on(spec) dep = dependency_collector.add(spec) add_dep_option(dep) if dep end |
#deprecated_option(hash) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'Library/Homebrew/software_spec.rb', line 142 def deprecated_option(hash) raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty? hash.each do |, | Array().each do |old_option| Array().each do |new_option| deprecated_option = DeprecatedOption.new(old_option, new_option) << deprecated_option old_flag = deprecated_option.old_flag new_flag = deprecated_option.current_flag next unless @flags.include? old_flag @flags -= [old_flag] @flags |= [new_flag] @deprecated_flags << deprecated_option end end end @build = BuildOptions.new(Options.create(@flags), ) end |
#deps ⇒ Object
174 175 176 |
# File 'Library/Homebrew/software_spec.rb', line 174 def deps dependency_collector.deps end |
#fails_with(compiler, &block) ⇒ Object
209 210 211 |
# File 'Library/Homebrew/software_spec.rb', line 209 def fails_with(compiler, &block) compiler_failures << CompilerFailure.create(compiler, &block) end |
#go_resource(name, &block) ⇒ Object
120 121 122 |
# File 'Library/Homebrew/software_spec.rb', line 120 def go_resource(name, &block) resource name, Resource::Go, &block end |
#needs(*standards) ⇒ Object
213 214 215 216 217 |
# File 'Library/Homebrew/software_spec.rb', line 213 def needs(*standards) standards.each do |standard| compiler_failures.concat CompilerFailure.for_standard(standard) end end |
#option(name, description = "") ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'Library/Homebrew/software_spec.rb', line 128 def option(name, description = "") opt = PREDEFINED_OPTIONS.fetch(name) do unless name.is_a?(String) raise ArgumentError, "option name must be string or symbol; got a #{name.class}: #{name}" end raise ArgumentError, "option name is required" if name.empty? raise ArgumentError, "option name must be longer than one character: #{name}" unless name.length > 1 raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-") Option.new(name, description) end << opt end |
#option_defined?(name) ⇒ Boolean
124 125 126 |
# File 'Library/Homebrew/software_spec.rb', line 124 def option_defined?(name) .include?(name) end |
#patch(strip = :p1, src = nil, &block) ⇒ Object
203 204 205 206 207 |
# File 'Library/Homebrew/software_spec.rb', line 203 def patch(strip = :p1, src = nil, &block) p = Patch.create(strip, src, &block) dependency_collector.add(p.resource) if p.is_a? ExternalPatch patches << p end |
#recursive_dependencies ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'Library/Homebrew/software_spec.rb', line 178 def recursive_dependencies deps_f = [] recursive_dependencies = deps.map do |dep| deps_f << dep.to_formula dep rescue TapFormulaUnavailableError # Don't complain about missing cross-tap dependencies next end.compact.uniq deps_f.compact.each do |f| f.recursive_dependencies.each do |dep| recursive_dependencies << dep unless recursive_dependencies.include?(dep) end end recursive_dependencies end |
#recursive_requirements ⇒ Object
199 200 201 |
# File 'Library/Homebrew/software_spec.rb', line 199 def recursive_requirements Requirement.(self) end |
#requirements ⇒ Object
195 196 197 |
# File 'Library/Homebrew/software_spec.rb', line 195 def requirements dependency_collector.requirements end |
#resource(name, klass = Resource, &block) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'Library/Homebrew/software_spec.rb', line 106 def resource(name, klass = Resource, &block) if block_given? raise DuplicateResourceError, name if resource_defined?(name) res = klass.new(name, &block) return unless res.url resources[name] = res dependency_collector.add(res) else resources.fetch(name) { raise ResourceMissingError.new(owner, name) } end end |
#resource_defined?(name) ⇒ Boolean
102 103 104 |
# File 'Library/Homebrew/software_spec.rb', line 102 def resource_defined?(name) resources.key?(name) end |
#url(val = nil, specs = {}) ⇒ Object
68 69 70 71 72 73 |
# File 'Library/Homebrew/software_spec.rb', line 68 def url(val = nil, specs = {}) return @resource.url if val.nil? @resource.url(val, specs) dependency_collector.add(@resource) end |
#uses_from_macos(deps, bounds = {}) ⇒ Object
169 170 171 172 |
# File 'Library/Homebrew/software_spec.rb', line 169 def uses_from_macos(spec, _bounds = {}) spec = Hash[*spec.first] if spec.is_a?(Hash) depends_on(spec) end |