Class: SoftwareSpec

Inherits:
Object show all
Extended by:
Forwardable
Includes:
Downloadable, OnSystem::MacOSAndLinux
Defined in:
software_spec.rb,
sorbet/rbi/dsl/software_spec.rbi

Direct Known Subclasses

HeadSoftwareSpec

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

Instance Method Summary collapse

Methods included from OnSystem::MacOSAndLinux

included, #on_arch_conditional, #on_macos, #on_system_conditional

Methods included from Downloadable

#download_strategy, #downloaded?

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(flags: []) ⇒ SoftwareSpec

Returns a new instance of SoftwareSpec.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'software_spec.rb', line 37

def initialize(flags: [])
  super()

  # Ensure this is synced with `initialize_dup` and `freeze` (excluding simple objects like integers and booleans)
  @resource = Resource::Formula.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), options)
  @compiler_failures = []
end

Instance Attribute Details

#bottle_specificationObject (readonly)

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 value of attribute bottle_specification.



28
29
30
# File 'software_spec.rb', line 28

def bottle_specification
  @bottle_specification
end

#buildObject (readonly)

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 value of attribute build.



28
29
30
# File 'software_spec.rb', line 28

def build
  @build
end

#compiler_failuresObject (readonly)

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 value of attribute compiler_failures.



28
29
30
# File 'software_spec.rb', line 28

def compiler_failures
  @compiler_failures
end

#dependency_collectorObject (readonly)

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 value of attribute dependency_collector.



28
29
30
# File 'software_spec.rb', line 28

def dependency_collector
  @dependency_collector
end

#deprecated_flagsObject (readonly)

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 value of attribute deprecated_flags.



28
29
30
# File 'software_spec.rb', line 28

def deprecated_flags
  @deprecated_flags
end

#deprecated_optionsObject (readonly)

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 value of attribute deprecated_options.



28
29
30
# File 'software_spec.rb', line 28

def deprecated_options
  @deprecated_options
end

#full_nameObject (readonly)

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 value of attribute full_name.



28
29
30
# File 'software_spec.rb', line 28

def full_name
  @full_name
end

#nameObject (readonly)

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 value of attribute name.



28
29
30
# File 'software_spec.rb', line 28

def name
  @name
end

#optionsObject (readonly)

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 value of attribute options.



28
29
30
# File 'software_spec.rb', line 28

def options
  @options
end

#ownerObject

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 value of attribute owner.



28
29
30
# File 'software_spec.rb', line 28

def owner
  @owner
end

#patchesObject (readonly)

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 value of attribute patches.



28
29
30
# File 'software_spec.rb', line 28

def patches
  @patches
end

#resourcesObject (readonly)

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 value of attribute resources.



28
29
30
# File 'software_spec.rb', line 28

def resources
  @resources
end

Instance Method Details

#add_dep_option(dep) ⇒ Object



276
277
278
279
280
281
282
283
284
# File 'software_spec.rb', line 276

def add_dep_option(dep)
  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
  end
end

#bottle(&block) ⇒ Object



125
126
127
# File 'software_spec.rb', line 125

def bottle(&block)
  bottle_specification.instance_eval(&block)
end

#bottle_defined?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'software_spec.rb', line 112

def bottle_defined?
  !bottle_specification.collector.tags.empty?
end

#bottle_tag?(tag = nil) ⇒ Boolean

Returns:

  • (Boolean)


116
117
118
# File 'software_spec.rb', line 116

def bottle_tag?(tag = nil)
  bottle_specification.tag?(Utils::Bottles.tag(tag))
end

#bottled?(tag = nil) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
123
# File 'software_spec.rb', line 120

def bottled?(tag = nil)
  bottle_tag?(tag) &&
    (tag.present? || bottle_specification.compatible_locations? || owner.force_bottle)
end

#cached_download(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


10
# File 'sorbet/rbi/dsl/software_spec.rbi', line 10

def cached_download(*args, &block); end

#checksum(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


13
# File 'sorbet/rbi/dsl/software_spec.rbi', line 13

def checksum(*args, &block); end

#clear_cache(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


16
# File 'sorbet/rbi/dsl/software_spec.rbi', line 16

def clear_cache(*args, &block); end

#declared_depsObject



229
230
231
# File 'software_spec.rb', line 229

def declared_deps
  dependency_collector.deps
end

#depends_on(spec) ⇒ Object



200
201
202
203
# File 'software_spec.rb', line 200

def depends_on(spec)
  dep = dependency_collector.add(spec)
  add_dep_option(dep) if dep
end

#deprecated_option(hash) ⇒ Object

Raises:

  • (ArgumentError)


178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'software_spec.rb', line 178

def deprecated_option(hash)
  raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty?

  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
        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), options)
end

#depsObject



225
226
227
# File 'software_spec.rb', line 225

def deps
  dependency_collector.deps.dup_without_system_deps
end

#download_name(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


19
# File 'sorbet/rbi/dsl/software_spec.rbi', line 19

def download_name(*args, &block); end

#download_typeString

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:



85
86
87
# File 'software_spec.rb', line 85

def download_type
  "formula"
end

#downloader(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


22
# File 'sorbet/rbi/dsl/software_spec.rbi', line 22

def downloader(*args, &block); end

#fails_with(compiler, &block) ⇒ Object



266
267
268
# File 'software_spec.rb', line 266

def fails_with(compiler, &block)
  compiler_failures << CompilerFailure.create(compiler, &block)
end

#fetch(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


25
# File 'sorbet/rbi/dsl/software_spec.rbi', line 25

def fetch(*args, &block); end

#freezeObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'software_spec.rb', line 69

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
end

#go_resource(name, &block) ⇒ Object



155
156
157
158
# File 'software_spec.rb', line 155

def go_resource(name, &block)
  odisabled "`SoftwareSpec#go_resource`", "Go modules"
  resource name, Resource::Go, &block
end

#initialize_dup(other) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'software_spec.rb', line 54

def initialize_dup(other)
  super
  @resource = @resource.dup
  @resources = @resources.dup
  @dependency_collector = @dependency_collector.dup
  @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

#mirror(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


28
# File 'sorbet/rbi/dsl/software_spec.rbi', line 28

def mirror(*args, &block); end

#mirrors(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


31
# File 'sorbet/rbi/dsl/software_spec.rbi', line 31

def mirrors(*args, &block); end

#needs(*standards) ⇒ Object



270
271
272
273
274
# File 'software_spec.rb', line 270

def needs(*standards)
  standards.each do |standard|
    compiler_failures.concat CompilerFailure.for_standard(standard)
  end
end

#option(name, description = "") ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'software_spec.rb', line 164

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}" if name.length <= 1
    raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-")

    Option.new(name, description)
  end
  options << opt
end

#option_defined?(name) ⇒ Boolean

Returns:

  • (Boolean)


160
161
162
# File 'software_spec.rb', line 160

def option_defined?(name)
  options.include?(name)
end

#patch(strip = :p1, src = nil, &block) ⇒ Object



258
259
260
261
262
263
264
# File 'software_spec.rb', line 258

def patch(strip = :p1, src = nil, &block)
  p = Patch.create(strip, src, &block)
  return if p.is_a?(ExternalPatch) && p.url.blank?

  dependency_collector.add(p.resource) if p.is_a? ExternalPatch
  patches << p
end

#recursive_dependenciesObject



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'software_spec.rb', line 233

def recursive_dependencies
  deps_f = []
  recursive_dependencies = deps.filter_map do |dep|
    deps_f << dep.to_formula
    dep
  rescue TapFormulaUnavailableError
    # Don't complain about missing cross-tap dependencies
    next
  end.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_requirementsObject



254
255
256
# File 'software_spec.rb', line 254

def recursive_requirements
  Requirement.expand(self)
end

#requirementsObject



250
251
252
# File 'software_spec.rb', line 250

def requirements
  dependency_collector.requirements
end

#resource(name = T.unsafe(nil), klass = Resource, &block) ⇒ Resource?

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.

Parameters:

  • name (String) (defaults to: T.unsafe(nil))
  • klass (T.class_of(Resource)) (defaults to: Resource)
  • block (T.proc.bind(Resource).void, nil)

Returns:



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'software_spec.rb', line 137

def resource(name = T.unsafe(nil), klass = Resource, &block)
  if block
    raise ArgumentError, "Resource must have a name." if name.nil?
    raise DuplicateResourceError, name if resource_defined?(name)

    res = klass.new(name, &block)
    return unless res.url

    resources[name] = res
    dependency_collector.add(res)
    res
  else
    return @resource if name.nil?

    resources.fetch(name) { raise ResourceMissingError.new(owner, name) }
  end
end

#resource_defined?(name) ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'software_spec.rb', line 129

def resource_defined?(name)
  resources.key?(name)
end

#sha256(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


34
# File 'sorbet/rbi/dsl/software_spec.rbi', line 34

def sha256(*args, &block); end

#source_modified_time(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


37
# File 'sorbet/rbi/dsl/software_spec.rbi', line 37

def source_modified_time(*args, &block); end

#specs(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


40
# File 'sorbet/rbi/dsl/software_spec.rbi', line 40

def specs(*args, &block); end

#stage(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


43
# File 'sorbet/rbi/dsl/software_spec.rbi', line 43

def stage(*args, &block); end

#url(val = nil, specs = {}) ⇒ Object



105
106
107
108
109
110
# File 'software_spec.rb', line 105

def url(val = nil, specs = {})
  return @resource.url if val.nil?

  @resource.url(val, **specs)
  dependency_collector.add(@resource)
end

#uses_from_macos(dep, bounds = {}) ⇒ void

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.

This method returns an undefined value.

Parameters:



211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'software_spec.rb', line 211

def uses_from_macos(dep, bounds = {})
  if dep.is_a?(Hash)
    bounds = dep.dup
    dep, tags = bounds.shift
    dep = T.cast(dep, String)
    tags = [*tags]
    bounds = T.cast(bounds, T::Hash[Symbol, Symbol])
  else
    tags = []
  end

  depends_on UsesFromMacOSDependency.new(dep, tags, bounds:)
end

#using(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


46
# File 'sorbet/rbi/dsl/software_spec.rbi', line 46

def using(*args, &block); end

#verify_download_integrity(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


49
# File 'sorbet/rbi/dsl/software_spec.rbi', line 49

def verify_download_integrity(*args, &block); end

#version(*args, &block) ⇒ T.untyped

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.

Parameters:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


52
# File 'sorbet/rbi/dsl/software_spec.rbi', line 52

def version(*args, &block); end