From fb358071ce92f885df382cef4da651c22b5516f1 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 16 May 2022 16:18:48 +0100 Subject: [PATCH] os/mac/sdk: use unversioned SDK if matching version isn't found --- Library/Homebrew/os/mac/sdk.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/os/mac/sdk.rb b/Library/Homebrew/os/mac/sdk.rb index 0b717e8ef2..28f838cfdc 100644 --- a/Library/Homebrew/os/mac/sdk.rb +++ b/Library/Homebrew/os/mac/sdk.rb @@ -59,6 +59,8 @@ module OS # Bail out if there is no SDK prefix at all return @all_sdks unless File.directory? sdk_prefix + found_versions = Set.new + Dir["#{sdk_prefix}/MacOSX*.sdk"].each do |sdk_path| next unless sdk_path.match?(SDK::VERSIONED_SDK_REGEX) @@ -66,14 +68,13 @@ module OS next if version.nil? @all_sdks << SDK.new(version, sdk_path, source) + found_versions << version end - # Fall back onto unversioned SDK if we've not found a suitable SDK - if @all_sdks.empty? - sdk_path = Pathname.new("#{sdk_prefix}/MacOSX.sdk") - if (version = read_sdk_version(sdk_path)) - @all_sdks << SDK.new(version, sdk_path, source) - end + # Use unversioned SDK only if we don't have one matching that version. + sdk_path = Pathname.new("#{sdk_prefix}/MacOSX.sdk") + if (version = read_sdk_version(sdk_path)) && found_versions.exclude?(version) + @all_sdks << SDK.new(version, sdk_path, source) end @all_sdks