os/mac/sdk: use unversioned SDK if matching version isn't found

This commit is contained in:
Bo Anderson 2022-05-16 16:18:48 +01:00
parent c20b3ab913
commit fb358071ce
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65

View File

@ -59,6 +59,8 @@ module OS
# Bail out if there is no SDK prefix at all # Bail out if there is no SDK prefix at all
return @all_sdks unless File.directory? sdk_prefix return @all_sdks unless File.directory? sdk_prefix
found_versions = Set.new
Dir["#{sdk_prefix}/MacOSX*.sdk"].each do |sdk_path| Dir["#{sdk_prefix}/MacOSX*.sdk"].each do |sdk_path|
next unless sdk_path.match?(SDK::VERSIONED_SDK_REGEX) next unless sdk_path.match?(SDK::VERSIONED_SDK_REGEX)
@ -66,14 +68,13 @@ module OS
next if version.nil? next if version.nil?
@all_sdks << SDK.new(version, sdk_path, source) @all_sdks << SDK.new(version, sdk_path, source)
found_versions << version
end end
# Fall back onto unversioned SDK if we've not found a suitable SDK # Use unversioned SDK only if we don't have one matching that version.
if @all_sdks.empty? sdk_path = Pathname.new("#{sdk_prefix}/MacOSX.sdk")
sdk_path = Pathname.new("#{sdk_prefix}/MacOSX.sdk") if (version = read_sdk_version(sdk_path)) && found_versions.exclude?(version)
if (version = read_sdk_version(sdk_path)) @all_sdks << SDK.new(version, sdk_path, source)
@all_sdks << SDK.new(version, sdk_path, source)
end
end end
@all_sdks @all_sdks