Module: FormulaVersions::LegacyMacOS Private

Defined in:
formula_versions.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Advisory history walks answer MacOS from the simulated target, even when it matches the host, and hold host-only queries. Other callers keep the host MacOS API.

Constant Summary collapse

LINUX_ANSWERS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let({
  full_version:       LegacyMacOSVersion::NULL,
  sdk_root_needed?:   false,
  sdk_path_if_needed: nil,
  sdk_path:           nil,
}.freeze, T::Hash[Symbol, T.nilable(T.any(LegacyMacOSVersion, T::Boolean))])

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.simulated_target ⇒ Boolean

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:

  • (Boolean)


180
181
182
# File 'formula_versions.rb', line 180

def simulated_target
  @simulated_target
end

Class Method Details

.const_missing(name) ⇒ T.anything

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:

Returns:

  • (T.anything)

Raises:



217
218
219
220
221
222
223
224
225
226
227
# File 'formula_versions.rb', line 217

def const_missing(name)
  # Host callers keep constants such as `MacOS::CLT::PKG_PATH`.
  # rubocop:disable Sorbet/ConstantsFromStrings
  return ::MacOS.const_get(name, false) unless simulated_target
  # rubocop:enable Sorbet/ConstantsFromStrings
  if Homebrew::SimulateSystem.current_os == :linux && [:Xcode, :CLT].include?(name)
    return LegacyLinuxDeveloperTools
  end

  raise FormulaSpecificationError, "historical MacOS::#{name} has no simulated target answer"
end

.method_missing(name, *args, **kwargs, &block) ⇒ T.anything

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 (Symbol)
  • args (T.anything)
  • kwargs (T.anything)
  • block (Proc, nil)

Returns:

  • (T.anything)

Raises:



200
201
202
203
204
205
206
207
# File 'formula_versions.rb', line 200

def method_missing(name, *args, **kwargs, &block)
  return ::MacOS.public_send(name, *args, **kwargs, &block) unless simulated_target
  if Homebrew::SimulateSystem.current_os == :linux && LINUX_ANSWERS.key?(name)
    return LINUX_ANSWERS.fetch(name)
  end

  raise FormulaSpecificationError, "historical MacOS.#{name} has no simulated target answer"
end

.respond_to_missing?(name, include_private = false) ⇒ Boolean

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 (Symbol)
  • include_private (Boolean) (defaults to: false)

Returns:

  • (Boolean)


210
211
212
213
214
# File 'formula_versions.rb', line 210

def respond_to_missing?(name, include_private = false)
  return ::MacOS.respond_to?(name, include_private) unless simulated_target

  Homebrew::SimulateSystem.current_os == :linux && LINUX_ANSWERS.key?(name)
end

.target_version ⇒ LegacyMacOSVersion

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:



188
189
190
191
192
193
194
195
# File 'formula_versions.rb', line 188

def target_version
  target = Homebrew::SimulateSystem.current_os
  return LegacyMacOSVersion::NULL if target == :linux

  LegacyMacOSVersion.new(LegacyMacOSVersion::RELEASES.fetch(target) do
    raise FormulaSpecificationError, "historical MacOS.version requires a concrete macOS target"
  end)
end

.version ⇒ LegacyMacOSVersion, MacOSVersion

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.



183
184
185
# File 'formula_versions.rb', line 183

def version
  simulated_target ? target_version : ::MacOS.version
end