Module: OS::Mac::CLT Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- os/mac/xcode.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper module for querying macOS Command Line Tools information.
Constant Summary collapse
- EXECUTABLE_PKG_ID =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"com.apple.pkg.CLTools_Executables"- PKG_PATH =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"/Library/Developer/CommandLineTools"
Class Method Summary collapse
- .below_minimum_version? ⇒ Boolean private
- .detect_clang_version ⇒ String? private
- .detect_version ⇒ String? private
- .detect_version_from_clang_version ⇒ String? private
- .installation_instructions ⇒ String private
- .installation_then_reinstall_instructions ⇒ String private
-
.installed? ⇒ Boolean
private
Returns true even if outdated tools are installed.
-
.latest_clang_version ⇒ String
private
Bump these when the new version is distributed through Software Update and our CI systems have been updated.
-
.minimum_version ⇒ String
private
Bump these if things are badly broken (e.g. no SDK for this macOS) without this.
- .outdated? ⇒ Boolean private
- .reinstall_instructions(reason: "resolve your issues") ⇒ String private
- .sdk(version = nil) ⇒ SDK? private
- .sdk_locator ⇒ CLTSDKLocator private
- .sdk_path(version = nil) ⇒ ::Pathname? private
- .separate_header_package? ⇒ Boolean private
- .update_instructions ⇒ String private
-
.version ⇒ ::Version
internal
Version string (a pretty long one) of the CLT package.
Methods included from Utils::Output::Mixin
odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_duration, pretty_installed, pretty_outdated, pretty_uninstalled
Class Method Details
.below_minimum_version? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
364 365 366 367 368 |
# File 'os/mac/xcode.rb', line 364 def self.below_minimum_version? return false unless installed? version < minimum_version end |
.detect_clang_version ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
379 380 381 382 |
# File 'os/mac/xcode.rb', line 379 def self.detect_clang_version version_output = Utils.popen_read("#{PKG_PATH}/usr/bin/clang", "--version") version_output[/clang-(\d+(\.\d+)+)/, 1] end |
.detect_version ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
407 408 409 410 411 412 413 414 415 |
# File 'os/mac/xcode.rb', line 407 def self.detect_version version = T.let(nil, T.nilable(String)) if File.exist?("#{PKG_PATH}/usr/bin/clang") version = MacOS.pkgutil_info(EXECUTABLE_PKG_ID)[/version: (.+)$/, 1] return version if version end detect_version_from_clang_version end |
.detect_version_from_clang_version ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
385 386 387 388 389 390 |
# File 'os/mac/xcode.rb', line 385 def self.detect_version_from_clang_version clang_version = detect_clang_version return if clang_version.nil? MacOS::Xcode.detect_version_from_clang_version(Version.new(clang_version)) end |
.installation_instructions ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'os/mac/xcode.rb', line 278 def self.installation_instructions if OS::Mac.version.prerelease? <<~EOS Install the Command Line Tools for Xcode #{minimum_version.split(".").first} from: #{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)} EOS else <<~EOS Install the Command Line Tools: xcode-select --install EOS end end |
.installation_then_reinstall_instructions ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
323 324 325 326 327 328 |
# File 'os/mac/xcode.rb', line 323 def self.installation_then_reinstall_instructions <<~EOS #{installation_instructions} #{reinstall_instructions} EOS end |
.installed? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns true even if outdated tools are installed.
252 253 254 |
# File 'os/mac/xcode.rb', line 252 def self.installed? !version.null? end |
.latest_clang_version ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Bump these when the new version is distributed through Software Update and our CI systems have been updated.
333 334 335 336 337 338 339 340 341 342 343 |
# File 'os/mac/xcode.rb', line 333 def self.latest_clang_version case MacOS.version when "26" then "1700.3.19.1" when "15" then "1700.0.13.5" when "14" then "1600.0.26.6" when "13" then "1500.1.0.2.5" when "12" then "1400.0.29.202" when "11" then "1300.0.29.30" else "1200.0.32.29" end end |
.minimum_version ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Bump these if things are badly broken (e.g. no SDK for this macOS) without this. Generally this will be the first stable CLT release on that macOS version.
349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'os/mac/xcode.rb', line 349 def self.minimum_version macos = MacOS.version case macos when "15" then "16.0.0" when "14" then "15.0.0" when "13" then "14.0.0" when "12" then "13.0.0" when "11" then "12.5.0" when "10.15" then "11.0.0" else "#{macos}.0.0" end end |
.outdated? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
371 372 373 374 375 376 |
# File 'os/mac/xcode.rb', line 371 def self.outdated? clang_version = detect_clang_version return false unless clang_version ::Version.new(clang_version) < latest_clang_version end |
.reinstall_instructions(reason: "resolve your issues") ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
293 294 295 296 297 298 299 300 301 302 303 |
# File 'os/mac/xcode.rb', line 293 def self.reinstall_instructions(reason: "resolve your issues") <<~EOS If that doesn't #{reason}, run: sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install Alternatively, manually download them from: #{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)}. You should download the Command Line Tools for Xcode #{MacOS::Xcode.latest_version}. EOS end |
.sdk(version = nil) ⇒ SDK?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
268 269 270 |
# File 'os/mac/xcode.rb', line 268 def self.sdk(version = nil) sdk_locator.sdk_if_applicable(version) end |
.sdk_locator ⇒ CLTSDKLocator
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
263 264 265 |
# File 'os/mac/xcode.rb', line 263 def self.sdk_locator @sdk_locator ||= T.let(CLTSDKLocator.new, T.nilable(OS::Mac::CLTSDKLocator)) end |
.sdk_path(version = nil) ⇒ ::Pathname?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
273 274 275 |
# File 'os/mac/xcode.rb', line 273 def self.sdk_path(version = nil) sdk(version)&.path end |
.separate_header_package? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
257 258 259 260 |
# File 'os/mac/xcode.rb', line 257 def self.separate_header_package? odeprecated "MacOS::CLT.separate_header_package?" true end |
.update_instructions ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'os/mac/xcode.rb', line 306 def self.update_instructions return installation_instructions if OS::Mac.version.prerelease? software_update_location = if MacOS.version >= "13" "System Settings" else "System Preferences" end <<~EOS Update them from Software Update in #{software_update_location}. #{reinstall_instructions(reason: "show you any updates")} EOS end |
.version ⇒ ::Version
This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Version string (a pretty long one) of the CLT package. Note that the different ways of installing the CLTs lead to different version numbers.
398 399 400 401 402 403 404 |
# File 'os/mac/xcode.rb', line 398 def self.version if @version ||= T.let(detect_version, T.nilable(String)) ::Version.new @version else ::Version::NULL end end |