development_tools: allow Symbols to be located

Fixes error seen in Homebrew/homebrew-core#138452.
`DevelopmentTools.default_compiler` can return a `Symbol` like `:clang`.
Make sure its result can be fed to `DevelopmentTools.locate`.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
This commit is contained in:
Ruoyu Zhong 2023-08-04 11:26:30 +08:00
parent a2b49440e7
commit 99607e8ec4
No known key found for this signature in database
GPG Key ID: DCAF462CAB59907D
3 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@ require "version"
# @private # @private
class DevelopmentTools class DevelopmentTools
class << self class << self
sig { params(tool: String).returns(T.nilable(Pathname)) } sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) }
def locate(tool) def locate(tool)
# Don't call tools (cc, make, strip, etc.) directly! # Don't call tools (cc, make, strip, etc.) directly!
# Give the name of the binary you look for as a string to this method # Give the name of the binary you look for as a string to this method

View File

@ -3,7 +3,7 @@
class DevelopmentTools class DevelopmentTools
class << self class << self
sig { params(tool: String).returns(T.nilable(Pathname)) } sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) }
def locate(tool) def locate(tool)
(@locate ||= {}).fetch(tool) do |key| (@locate ||= {}).fetch(tool) do |key|
@locate[key] = if needs_build_formulae? && @locate[key] = if needs_build_formulae? &&

View File

@ -10,7 +10,7 @@ class DevelopmentTools
undef installed?, default_compiler, curl_handles_most_https_certificates?, undef installed?, default_compiler, curl_handles_most_https_certificates?,
subversion_handles_most_https_certificates? subversion_handles_most_https_certificates?
sig { params(tool: String).returns(T.nilable(Pathname)) } sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) }
def locate(tool) def locate(tool)
(@locate ||= {}).fetch(tool) do |key| (@locate ||= {}).fetch(tool) do |key|
@locate[key] = if (located_tool = generic_locate(tool)) @locate[key] = if (located_tool = generic_locate(tool))