Class: UsesFromMacOSDependency Private

Inherits:
Dependency show all
Defined in:
dependency/uses_from_macos_dependency.rb

Overview

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

A dependency that's marked as "installed" on macOS

Constant Summary

Constants included from Dependable

Dependable::KEEP_BUT_PRUNE_RECURSIVE_DEPS, Dependable::PRUNE, Dependable::RESERVED_TAGS, Dependable::SKIP

Instance Attribute Summary collapse

Attributes inherited from Dependency

#name, #tags, #tap

Instance Method Summary collapse

Methods inherited from Dependency

action, cache, clear_cache, delete_timestamped_cache_entry, expand, merge_repeats, #missing_options, #option_names, #satisfied?, #to_formula, #to_installed_formula

Methods included from Dependable

#build?, #implicit?, #no_linkage?, #option_names, #option_tags, #optional?, #options, #prune_from_option?, #prune_if_build_and_not_dependent?, #recommended?, #required?, #tags, #test?

Constructor Details

#initialize(name, tags = [], 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.

Parameters:



10
11
12
13
14
# File 'dependency/uses_from_macos_dependency.rb', line 10

def initialize(name, tags = [], bounds:)
  super(name, tags)

  @bounds = bounds
end

Instance Attribute Details

#boundsHash{Symbol => Symbol} (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:



7
8
9
# File 'dependency/uses_from_macos_dependency.rb', line 7

def bounds
  @bounds
end

Instance Method Details

#dup_with_formula_name(formula) ⇒ T.self_type

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.self_type)


85
86
87
# File 'dependency/uses_from_macos_dependency.rb', line 85

def dup_with_formula_name(formula)
  self.class.new(formula.full_name.to_s, tags, bounds:)
end

#installed?(minimum_version: nil, minimum_revision: nil, minimum_compatibility_version: nil, bottle_os_version: nil) ⇒ 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:

  • minimum_version (Version, nil) (defaults to: nil)
  • minimum_revision (Integer, nil) (defaults to: nil)
  • minimum_compatibility_version (Integer, nil) (defaults to: nil)
  • bottle_os_version (String, nil) (defaults to: nil)

Returns:

  • (Boolean)


38
39
40
41
# File 'dependency/uses_from_macos_dependency.rb', line 38

def installed?(minimum_version: nil, minimum_revision: nil, minimum_compatibility_version: nil,
               bottle_os_version: nil)
  use_macos_install?(bottle_os_version:) || super
end

#use_macos_install?(bottle_os_version: nil) ⇒ 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:

  • bottle_os_version (String, nil) (defaults to: nil)

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'dependency/uses_from_macos_dependency.rb', line 44

def use_macos_install?(bottle_os_version: nil)
  # Check whether macOS is new enough for dependency to not be required.
  if Homebrew::SimulateSystem.simulating_or_running_on_macos?
    # If there's no since bound, the dependency is always available from macOS
    since_os_bounds = bounds[:since]
    return true if since_os_bounds.blank?

    # When installing a bottle built on an older macOS version, use that version
    # to determine if the dependency should come from macOS or Homebrew
    effective_os = if bottle_os_version.present? &&
                      bottle_os_version.start_with?("macOS ")
      # bottle_os_version is a string like "14" for Sonoma, "15" for Sequoia
      # Convert it to a MacOS version symbol for comparison
      MacOSVersion.new(bottle_os_version.delete_prefix("macOS "))
    elsif Homebrew::SimulateSystem.current_os == :macos
      # Assume the oldest macOS version when simulating a generic macOS version
      # Version::NULL is always treated as less than any other version.
      Version::NULL
    else
      MacOSVersion.from_symbol(Homebrew::SimulateSystem.current_os)
    end

    since_os = begin
      MacOSVersion.from_symbol(since_os_bounds)
    rescue MacOSVersion::Error
      # If we can't parse the bound, it means it's an unsupported macOS version
      # so let's default to the oldest possible macOS version
      Version::NULL
    end
    return true if effective_os >= since_os
  end

  false
end

#uses_from_macos?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)


80
81
82
# File 'dependency/uses_from_macos_dependency.rb', line 80

def uses_from_macos?
  true
end