From 5ae4f254b6c4cca3a9f2f340607350757287aa8c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 31 Oct 2024 02:39:38 +0800 Subject: [PATCH] macos_version: add `KERNEL_MAJOR_VERSIONS` map This will be used by `llvm` (and, presumably, in the future, versioned LLVM formulae). The idea is that we will write a config file for each OS version pointing to the correct SDKROOT so that `llvm` does not require rebuilding/reinstalling when a user upgrades to a new major version of macOS. See Homebrew/homebrew-core#196094. --- Library/Homebrew/macos_version.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Library/Homebrew/macos_version.rb b/Library/Homebrew/macos_version.rb index b3a3444a4e63a..fe04f6dab5a20 100644 --- a/Library/Homebrew/macos_version.rb +++ b/Library/Homebrew/macos_version.rb @@ -18,6 +18,8 @@ def initialize(version) # NOTE: When removing symbols here, ensure that they are added # to `DEPRECATED_MACOS_VERSIONS` in `MacOSRequirement`. + # When adding or removing symbols here, ensure that you + # also update the KERNEL_MAJOR_VERSIONS map below. SYMBOLS = { sequoia: "15", sonoma: "14", @@ -31,6 +33,21 @@ def initialize(version) el_capitan: "10.11", }.freeze + # Map of macOS version strings to kernel major versions. + # https://en.wikipedia.org/wiki/MacOS_version_history#Releases + KERNEL_MAJOR_VERSIONS = { + "15" => "24", + "14" => "23", + "13" => "22", + "12" => "21", + "11" => "20", + "10.15" => "19", + "10.14" => "18", + "10.13" => "17", + "10.12" => "16", + "10.11" => "15", + }.freeze + sig { params(version: Symbol).returns(T.attached_class) } def self.from_symbol(version) str = SYMBOLS.fetch(version) { raise MacOSVersion::Error, version }