mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Xcode: allow requesting Xcode/CLT SDKs specifically
This commit is contained in:
parent
4f8a751579
commit
5765dac86c
@ -91,17 +91,7 @@ module OS
|
|||||||
CLTSDKLocator.new
|
CLTSDKLocator.new
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
@locator.sdk_if_applicable(v)
|
||||||
sdk = if v.nil?
|
|
||||||
(Xcode.version.to_i >= 7) ? @locator.latest_sdk : @locator.sdk_for(version)
|
|
||||||
else
|
|
||||||
@locator.sdk_for v
|
|
||||||
end
|
|
||||||
rescue BaseSDKLocator::NoSDKError
|
|
||||||
sdk = @locator.latest_sdk
|
|
||||||
end
|
|
||||||
# Only return an SDK older than the OS version if it was specifically requested
|
|
||||||
sdk if v || (!sdk.nil? && sdk.version >= version)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the path to an SDK or nil, following the rules set by #sdk.
|
# Returns the path to an SDK or nil, following the rules set by #sdk.
|
||||||
|
@ -28,8 +28,26 @@ module OS
|
|||||||
SDK.new v, path
|
SDK.new v, path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sdk_if_applicable(v = nil)
|
||||||
|
begin
|
||||||
|
sdk = if v.nil?
|
||||||
|
(source_version.to_i >= 7) ? latest_sdk : sdk_for(OS::Mac.version)
|
||||||
|
else
|
||||||
|
sdk_for v
|
||||||
|
end
|
||||||
|
rescue BaseSDKLocator::NoSDKError
|
||||||
|
sdk = latest_sdk
|
||||||
|
end
|
||||||
|
# Only return an SDK older than the OS version if it was specifically requested
|
||||||
|
sdk if v || (!sdk.nil? && sdk.version >= OS::Mac.version)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def source_version
|
||||||
|
OS::Mac::Version::NULL
|
||||||
|
end
|
||||||
|
|
||||||
def sdk_prefix
|
def sdk_prefix
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
@ -56,6 +74,10 @@ module OS
|
|||||||
class XcodeSDKLocator < BaseSDKLocator
|
class XcodeSDKLocator < BaseSDKLocator
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def source_version
|
||||||
|
OS::Mac::Xcode.version
|
||||||
|
end
|
||||||
|
|
||||||
def sdk_prefix
|
def sdk_prefix
|
||||||
@sdk_prefix ||= begin
|
@sdk_prefix ||= begin
|
||||||
# Xcode.prefix is pretty smart, so let's look inside to find the sdk
|
# Xcode.prefix is pretty smart, so let's look inside to find the sdk
|
||||||
@ -73,6 +95,10 @@ module OS
|
|||||||
class CLTSDKLocator < BaseSDKLocator
|
class CLTSDKLocator < BaseSDKLocator
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def source_version
|
||||||
|
OS::Mac::CLT.version
|
||||||
|
end
|
||||||
|
|
||||||
# While CLT SDKs existed prior to Xcode 10, those packages also
|
# While CLT SDKs existed prior to Xcode 10, those packages also
|
||||||
# installed a traditional Unix-style header layout and we prefer
|
# installed a traditional Unix-style header layout and we prefer
|
||||||
# using that
|
# using that
|
||||||
|
@ -96,6 +96,16 @@ module OS
|
|||||||
!prefix.nil?
|
!prefix.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sdk(v = nil)
|
||||||
|
@locator ||= XcodeSDKLocator.new
|
||||||
|
|
||||||
|
@locator.sdk_if_applicable(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sdk_path(v = nil)
|
||||||
|
sdk(v)&.path
|
||||||
|
end
|
||||||
|
|
||||||
def update_instructions
|
def update_instructions
|
||||||
if MacOS.version >= "10.9" && !OS::Mac.prerelease?
|
if MacOS.version >= "10.9" && !OS::Mac.prerelease?
|
||||||
<<~EOS
|
<<~EOS
|
||||||
@ -226,6 +236,16 @@ module OS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sdk(v = nil)
|
||||||
|
@locator ||= CLTSDKLocator.new
|
||||||
|
|
||||||
|
@locator.sdk_if_applicable(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sdk_path(v = nil)
|
||||||
|
sdk(v)&.path
|
||||||
|
end
|
||||||
|
|
||||||
def update_instructions
|
def update_instructions
|
||||||
if MacOS.version >= "10.9"
|
if MacOS.version >= "10.9"
|
||||||
<<~EOS
|
<<~EOS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user