From eea18a5cb10c9fa51086fd26843d3b47e2425f5b Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Tue, 7 Aug 2018 17:56:42 -0700 Subject: [PATCH] MacOS: update sdk_path_if_needed logic --- Library/Homebrew/os/mac.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index abca18c82a..48f6cab424 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -101,7 +101,19 @@ module OS end def sdk_path_if_needed(v = nil) - return if !MacOS::Xcode.installed? && MacOS::CLT.separate_header_package? + # Prefer Xcode SDK when both Xcode and the CLT are installed. + # Expected results: + # 1. On Xcode-only systems, return the Xcode SDK. + # 2. On Xcode-and-CLT systems where headers are provided by the system, return nil. + # 3. On CLT-only systems with no CLT SDK, return nil. + # 4. On CLT-only systems with a CLT SDK, where headers are provided by the system, return nil. + # 5. On CLT-only systems with a CLT SDK, where headers are not provided by the system, return the CLT SDK. + + # If there's no CLT SDK, return early + return if MacOS::CLT.installed? && !MacOS::CLT.provides_sdk? + # If the CLT is installed and provides headers, return early + return if MacOS::CLT.installed? && !MacOS::CLT.separate_header_package? + sdk_path(v) end