system_config: fix clang version output on Linux

If you have Homebrew LLVM installed, `brew config` will show

    Clang: 12.0.1 build (parse error)

because Homebrew LLVM does not give a build number. Some installations
from the system package manager do have this information, so let's show
it if it's available but skip complaining if not.

I've kept the original code for macOS because we always expect Apple's
build number to show there.
This commit is contained in:
Carlo Cabrera 2021-10-07 11:24:20 +08:00
parent 4d5af40662
commit 25fe428ed2
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 13 additions and 3 deletions

View File

@ -7,7 +7,7 @@ module SystemConfig
class << self class << self
include SystemCommand::Mixin include SystemCommand::Mixin
undef describe_homebrew_ruby undef describe_homebrew_ruby, describe_clang
def describe_homebrew_ruby def describe_homebrew_ruby
s = describe_homebrew_ruby_version s = describe_homebrew_ruby_version
@ -19,6 +19,13 @@ module SystemConfig
end end
end end
def describe_clang
return "N/A" if clang.null?
clang_build_info = clang_build.null? ? "(parse error)" : clang_build
"#{clang} build #{clang_build_info}"
end
def xcode def xcode
@xcode ||= if MacOS::Xcode.installed? @xcode ||= if MacOS::Xcode.installed?
xcode = MacOS::Xcode.version.to_s xcode = MacOS::Xcode.version.to_s

View File

@ -76,8 +76,11 @@ module SystemConfig
def describe_clang def describe_clang
return "N/A" if clang.null? return "N/A" if clang.null?
clang_build_info = clang_build.null? ? "(parse error)" : clang_build if clang_build.null?
"#{clang} build #{clang_build_info}" clang.to_s
else
"#{clang} build #{clang_build}"
end
end end
def describe_path(path) def describe_path(path)