Module: Utils::Clang Private

Defined in:
utils/clang.rb

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.

Class Method Summary collapse

Class Method Details

.write_system_config_files(config_dir:, macos_version:, kernel_version:, arch:) ⇒ void

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.

This method returns an undefined value.

Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'utils/clang.rb', line 14

def self.write_system_config_files(config_dir:, macos_version:, kernel_version:, arch:)
  config_dir.mkpath
  arches = Set.new([:arm64, :x86_64, :aarch64, arch])
  sysroot = if macos_version.blank? || MacOS.version > macos_version
    "#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX.sdk"
  else
    "#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX#{macos_version}.sdk"
  end

  { darwin: kernel_version, macosx: macos_version }.each do |system, version|
    arches.each do |target_arch|
      (config_dir/"#{target_arch}-apple-#{system}#{version}.cfg").atomic_write <<~CONFIG
        -isysroot #{sysroot}
      CONFIG
    end
  end
end