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.
This commit is contained in:
Carlo Cabrera 2024-10-31 02:39:38 +08:00
parent d9f1784c90
commit 5ae4f254b6
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -18,6 +18,8 @@ class MacOSVersion < 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 @@ class MacOSVersion < 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 }