Class: OS::Mac::BaseSDKLocator

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/os/mac/sdk.rb

Direct Known Subclasses

CLTSDKLocator, XcodeSDKLocator

Defined Under Namespace

Classes: NoSDKError

Instance Method Summary collapse

Instance Method Details

#latest_sdkObject



26
27
28
29
30
31
# File 'brew/Library/Homebrew/os/mac/sdk.rb', line 26

def latest_sdk
  return if sdk_paths.empty?

  v, path = sdk_paths.max { |a, b| OS::Mac::Version.new(a[0]) <=> OS::Mac::Version.new(b[0]) }
  SDK.new v, path
end

#sdk_for(v) ⇒ Object

Raises:



19
20
21
22
23
24
# File 'brew/Library/Homebrew/os/mac/sdk.rb', line 19

def sdk_for(v)
  path = sdk_paths[v]
  raise NoSDKError if path.nil?

  SDK.new v, path
end

#sdk_if_applicable(v = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'brew/Library/Homebrew/os/mac/sdk.rb', line 33

def sdk_if_applicable(v = nil)
  sdk = begin
    if v.nil?
      (source_version.to_i >= 7) ? latest_sdk : sdk_for(OS::Mac.version)
    else
      sdk_for v
    end
  rescue BaseSDKLocator::NoSDKError
    latest_sdk
  end
  # Only return an SDK older than the OS version if it was specifically requested
  return unless v || (!sdk.nil? && sdk.version >= OS::Mac.version)

  sdk
end