Module: OS::Mac::CLT Private
- Defined in:
- os/mac/xcode.rb,
os/linux.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.
The original Mavericks CLT package ID
"com.apple.pkg.CLTools_Executables"
- MAVERICKS_NEW_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.
obsolete
"com.apple.pkg.CLTools_Base"
- 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
-
.installed? ⇒ Boolean
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
-
.provides_sdk? ⇒ Boolean
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
Version string (a pretty long one) of the CLT package.
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.
369 370 371 372 373 |
# File 'os/mac/xcode.rb', line 369 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.
384 385 386 387 |
# File 'os/mac/xcode.rb', line 384 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 416 417 |
# File 'os/mac/xcode.rb', line 407 def self.detect_version version = T.let(nil, T.nilable(String)) [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id| next unless File.exist?("#{PKG_PATH}/usr/bin/clang") version = MacOS.pkgutil_info(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.
390 391 392 |
# File 'os/mac/xcode.rb', line 390 def self.detect_version_from_clang_version detect_clang_version&.sub(/^(\d+)0(\d)\./, "\\1.\\2.") 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.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'os/mac/xcode.rb', line 297 def self.installation_instructions if MacOS.version == "10.14" # This is not available from `xcode-select` <<~EOS Install the Command Line Tools for Xcode 11.3.1 from: #{Formatter.url(MacOS::Xcode::APPLE_DEVELOPER_DOWNLOAD_URL)} EOS else <<~EOS Install the Command Line Tools: xcode-select --install EOS end end |
.installed? ⇒ Boolean
Returns true even if outdated tools are installed.
98 99 100 |
# File 'os/linux.rb', line 98 def self.installed? false 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.
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'os/mac/xcode.rb', line 338 def self.latest_clang_version case MacOS.version when "13" then "1403.0.22.14.1" when "12" then "1400.0.29.202" when "11" then "1300.0.29.30" when "10.15" then "1200.0.32.29" when "10.14" then "1100.0.33.17" when "10.13" then "1000.10.44.2" when "10.12" then "900.0.39.2" else "800.0.42.1" 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.
355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'os/mac/xcode.rb', line 355 def self.minimum_version case MacOS.version 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" when "10.14" then "10.0.0" when "10.13" then "9.0.0" when "10.12" then "8.0.0" else "1.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.
376 377 378 379 380 381 |
# File 'os/mac/xcode.rb', line 376 def self.outdated? clang_version = detect_clang_version return false unless clang_version ::Version.new(clang_version) < latest_clang_version end |
.provides_sdk? ⇒ 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.
277 278 279 |
# File 'os/mac/xcode.rb', line 277 def self.provides_sdk? version >= "8" 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.
287 288 289 |
# File 'os/mac/xcode.rb', line 287 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.
282 283 284 |
# File 'os/mac/xcode.rb', line 282 def self.sdk_locator @sdk_locator ||= CLTSDKLocator.new 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.
292 293 294 |
# File 'os/mac/xcode.rb', line 292 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.
272 273 274 |
# File 'os/mac/xcode.rb', line 272 def self.separate_header_package? version >= "10" && MacOS.version >= "10.14" 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.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'os/mac/xcode.rb', line 313 def self.update_instructions software_update_location = if MacOS.version >= "13" "System Settings" elsif MacOS.version >= "10.14" "System Preferences" else "the App Store" end <<~EOS Update them from Software Update in #{software_update_location}. If that doesn't show you any updates, 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 |