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)


176
177
178
# File 'formula_versions.rb', line 176

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:



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

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:



196
197
198
199
200
201
202
203
# File 'formula_versions.rb', line 196

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)


206
207
208
209
210
# File 'formula_versions.rb', line 206

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:



184
185
186
187
188
189
190
191
# File 'formula_versions.rb', line 184

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.



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

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