2024-08-12 10:30:59 +01:00
|
|
|
# typed: true # rubocop:disable Sorbet/StrictSigil
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-10-10 17:53:31 +02:00
|
|
|
require "system_command"
|
|
|
|
|
2024-09-21 12:24:21 -07:00
|
|
|
module OS
|
|
|
|
module Mac
|
|
|
|
module SystemConfig
|
2025-06-13 16:59:10 +01:00
|
|
|
module ClassMethods
|
|
|
|
extend T::Helpers
|
|
|
|
|
|
|
|
requires_ancestor { T.class_of(::SystemConfig) }
|
|
|
|
|
|
|
|
sig { returns(String) }
|
|
|
|
def describe_clang
|
|
|
|
return "N/A" if ::SystemConfig.clang.null?
|
|
|
|
|
|
|
|
clang_build_info = ::SystemConfig.clang_build.null? ? "(parse error)" : ::SystemConfig.clang_build
|
|
|
|
"#{::SystemConfig.clang} build #{clang_build_info}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def xcode
|
|
|
|
@xcode ||= if MacOS::Xcode.installed?
|
|
|
|
xcode = MacOS::Xcode.version.to_s
|
|
|
|
xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?
|
|
|
|
xcode
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def clt
|
|
|
|
@clt ||= MacOS::CLT.version if MacOS::CLT.installed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def core_tap_config(out = $stdout)
|
|
|
|
dump_tap_config(CoreTap.instance, out)
|
|
|
|
dump_tap_config(CoreCaskTap.instance, out)
|
|
|
|
end
|
|
|
|
|
|
|
|
def dump_verbose_config(out = $stdout)
|
|
|
|
super
|
|
|
|
out.puts "macOS: #{MacOS.full_version}-#{kernel}"
|
|
|
|
out.puts "CLT: #{clt || "N/A"}"
|
|
|
|
out.puts "Xcode: #{xcode || "N/A"}"
|
|
|
|
out.puts "Rosetta 2: #{::Hardware::CPU.in_rosetta2?}" if ::Hardware::CPU.physical_cpu_arm64?
|
|
|
|
end
|
2018-04-07 20:28:56 +01:00
|
|
|
end
|
|
|
|
end
|
2016-04-25 18:01:15 +01:00
|
|
|
end
|
|
|
|
end
|
2025-06-13 16:59:10 +01:00
|
|
|
SystemConfig.singleton_class.prepend(OS::Mac::SystemConfig::ClassMethods)
|