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)

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

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.


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

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.


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

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.


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

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)

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

def installed?
  false
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.


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

def latest_clang_version
  case MacOS.version
  when "11.0" then "1200.0.32.21"
  when "10.15" then "1200.0.32.21"
  when "10.14" then "1100.0.33.17"
  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.


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

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)

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

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)

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

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.


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

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.


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

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.


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

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)

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

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.


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

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 the different ways of installing the CLTs lead to different version numbers.


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

def version
  Version::NULL
end