Module: OS::Mac::CLT Private

Defined in:
Library/Homebrew/os/mac/xcode.rb,
Library/Homebrew/os/linux.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper module for querying macOS Command Line Tools information.

Constant Summary collapse

EXECUTABLE_PKG_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The original Mavericks CLT package ID

"com.apple.pkg.CLTools_Executables"
MAVERICKS_NEW_PKG_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

obsolete

"com.apple.pkg.CLTools_Base"
PKG_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"/Library/Developer/CommandLineTools"

Class Method Summary collapse

Class Method Details

.below_minimum_version?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

291
292
293
294
295
# File 'Library/Homebrew/os/mac/xcode.rb', line 291

def below_minimum_version?
  return false unless installed?

  version < minimum_version
end

.detect_clang_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


304
305
306
307
# File 'Library/Homebrew/os/mac/xcode.rb', line 304

def detect_clang_version
  version_output = Utils.popen_read("#{PKG_PATH}/usr/bin/clang --version")
  version_output[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1]
end

.detect_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


324
325
326
327
328
329
330
331
332
333
334
# File 'Library/Homebrew/os/mac/xcode.rb', line 324

def detect_version
  version = nil
  [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_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


309
310
311
# File 'Library/Homebrew/os/mac/xcode.rb', line 309

def detect_version_from_clang_version
  detect_clang_version&.sub(/^(\d+)00\./, "\\1.")
end

.installed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true even if outdated tools are installed

Returns:

  • (Boolean)

218
219
220
# File 'Library/Homebrew/os/mac/xcode.rb', line 218

def installed?
  !version.null?
end

.latest_clang_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Bump these when the new version is distributed through Software Update and our CI systems have been updated.


264
265
266
267
268
269
270
271
272
273
274
275
# File 'Library/Homebrew/os/mac/xcode.rb', line 264

def latest_clang_version
  case MacOS.version
  when "11.0" then "1200.0.22.7"
  when "10.15" then "1103.0.32.59"
  when "10.14" then "1001.0.46.4"
  when "10.13" then "1000.10.44.2"
  when "10.12" then "900.0.39.2"
  when "10.11" then "800.0.42.1"
  when "10.10" then "700.1.81"
  else              "600.0.57"
  end
end

.minimum_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.


280
281
282
283
284
285
286
287
288
289
# File 'Library/Homebrew/os/mac/xcode.rb', line 280

def minimum_version
  case MacOS.version
  when "11.0"  then "12.0.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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

297
298
299
300
301
302
# File 'Library/Homebrew/os/mac/xcode.rb', line 297

def 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. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

226
227
228
# File 'Library/Homebrew/os/mac/xcode.rb', line 226

def provides_sdk?
  version >= "8"
end

.sdk(v = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


234
235
236
# File 'Library/Homebrew/os/mac/xcode.rb', line 234

def sdk(v = nil)
  sdk_locator.sdk_if_applicable(v)
end

.sdk_locatorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


230
231
232
# File 'Library/Homebrew/os/mac/xcode.rb', line 230

def sdk_locator
  @sdk_locator ||= CLTSDKLocator.new
end

.sdk_path(v = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


238
239
240
# File 'Library/Homebrew/os/mac/xcode.rb', line 238

def sdk_path(v = nil)
  sdk(v)&.path
end

.separate_header_package?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

222
223
224
# File 'Library/Homebrew/os/mac/xcode.rb', line 222

def separate_header_package?
  version >= "10" && MacOS.version >= "10.14"
end

.update_instructionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'Library/Homebrew/os/mac/xcode.rb', line 242

def update_instructions
  software_update_location = if MacOS.version >= "10.14"
    "System Preferences"
  else
    "the App Store"
  end

  <<~EOS
    Update them from Software Update in #{software_update_location} or run:
      softwareupdate --all --install --force

    If that doesn't show you an update run:
      sudo rm -rf /Library/Developer/CommandLineTools
      sudo xcode-select --install

    Alternatively, manually download them from:
      #{Formatter.url("https://developer.apple.com/download/more/")}.
  EOS
end

.versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Version string (a pretty long one) of the CLT package. Note, that different ways to install the CLTs lead to different version numbers.


316
317
318
# File 'Library/Homebrew/os/mac/xcode.rb', line 316

def version
  Version::NULL
end