Merge pull request #13284 from Bo98/sdk-unversioned

os/mac/sdk: use unversioned SDK if matching version isn't found
This commit is contained in:
Bo Anderson 2022-05-17 19:44:01 +01:00 committed by GitHub
commit 5b9730a56d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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