remove String#has_suffix? monkey-patch; use String#end_with?
This commit is contained in:
parent
b43c473762
commit
fa7d17675b
@ -46,8 +46,8 @@ module Rscons
|
|||||||
end
|
end
|
||||||
|
|
||||||
def produces?(target, source, env)
|
def produces?(target, source, env)
|
||||||
target.has_suffix?(env['OBJSUFFIX']) and KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
target.end_with?(*env['OBJSUFFIX']) and KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||||
source.has_suffix?(env[suffix_var])
|
source.end_with?(*env[suffix_var])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ module Rscons
|
|||||||
'_DEPFILE' => target.set_suffix('.mf'),
|
'_DEPFILE' => target.set_suffix('.mf'),
|
||||||
})
|
})
|
||||||
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||||
sources.first.has_suffix?(env[suffix_var])
|
sources.first.end_with?(*env[suffix_var])
|
||||||
end.tap do |v|
|
end.tap do |v|
|
||||||
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
|
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
|
||||||
end.first
|
end.first
|
||||||
|
@ -21,9 +21,9 @@ module Rscons
|
|||||||
return false unless objects
|
return false unless objects
|
||||||
ld = if env["LD"]
|
ld = if env["LD"]
|
||||||
env["LD"]
|
env["LD"]
|
||||||
elsif sources.find {|s| s.has_suffix?(env["DSUFFIX"])}
|
elsif sources.find {|s| s.end_with?(*env["DSUFFIX"])}
|
||||||
env["DC"]
|
env["DC"]
|
||||||
elsif sources.find {|s| s.has_suffix?(env["CXXSUFFIX"])}
|
elsif sources.find {|s| s.end_with?(*env["CXXSUFFIX"])}
|
||||||
env["CXX"]
|
env["CXX"]
|
||||||
else
|
else
|
||||||
env["CC"]
|
env["CC"]
|
||||||
|
@ -254,7 +254,7 @@ module Rscons
|
|||||||
# Return a list of the converted file names.
|
# Return a list of the converted file names.
|
||||||
def build_sources(sources, suffixes, cache, vars)
|
def build_sources(sources, suffixes, cache, vars)
|
||||||
sources.map do |source|
|
sources.map do |source|
|
||||||
if source.has_suffix?(suffixes)
|
if source.end_with?(*suffixes)
|
||||||
source
|
source
|
||||||
else
|
else
|
||||||
converted = nil
|
converted = nil
|
||||||
|
@ -1,16 +1,5 @@
|
|||||||
# Standard Ruby String class.
|
# Standard Ruby String class.
|
||||||
class String
|
class String
|
||||||
# Check if the given string ends with any of the supplied suffixes
|
|
||||||
# @param suffix [String, Array] The suffix to look for.
|
|
||||||
# @return a true value if the string ends with one of the suffixes given.
|
|
||||||
def has_suffix?(suffix)
|
|
||||||
if suffix
|
|
||||||
suffix = [suffix] if suffix.is_a?(String)
|
|
||||||
suffix = suffix.flatten
|
|
||||||
suffix.find {|s| self.end_with?(s)}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return a new string with the suffix (dot character and extension) changed
|
# Return a new string with the suffix (dot character and extension) changed
|
||||||
# to the given suffix.
|
# to the given suffix.
|
||||||
# @param suffix [String] The new suffix.
|
# @param suffix [String] The new suffix.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user