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)


185
186
187
# File 'formula_versions.rb', line 185

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:



222
223
224
225
226
227
228
229
230
231
232
# File 'formula_versions.rb', line 222

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:



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

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)


215
216
217
218
219
# File 'formula_versions.rb', line 215

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:



193
194
195
196
197
198
199
200
# File 'formula_versions.rb', line 193

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.



188
189
190
# File 'formula_versions.rb', line 188

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