diff --git a/lib/rscons/builders/object.rb b/lib/rscons/builders/object.rb index 9549311..05d02c0 100644 --- a/lib/rscons/builders/object.rb +++ b/lib/rscons/builders/object.rb @@ -46,8 +46,8 @@ module Rscons end def produces?(target, source, env) - target.has_suffix?(env['OBJSUFFIX']) and KNOWN_SUFFIXES.find do |compiler, suffix_var| - source.has_suffix?(env[suffix_var]) + target.end_with?(*env['OBJSUFFIX']) and KNOWN_SUFFIXES.find do |compiler, suffix_var| + source.end_with?(*env[suffix_var]) end end @@ -58,7 +58,7 @@ module Rscons '_DEPFILE' => target.set_suffix('.mf'), }) 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| v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}" end.first diff --git a/lib/rscons/builders/program.rb b/lib/rscons/builders/program.rb index 9ed50c3..f25924e 100644 --- a/lib/rscons/builders/program.rb +++ b/lib/rscons/builders/program.rb @@ -21,9 +21,9 @@ module Rscons return false unless objects ld = if env["LD"] env["LD"] - elsif sources.find {|s| s.has_suffix?(env["DSUFFIX"])} + elsif sources.find {|s| s.end_with?(*env["DSUFFIX"])} env["DC"] - elsif sources.find {|s| s.has_suffix?(env["CXXSUFFIX"])} + elsif sources.find {|s| s.end_with?(*env["CXXSUFFIX"])} env["CXX"] else env["CC"] diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 16dfdb6..4cd475a 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -254,7 +254,7 @@ module Rscons # Return a list of the converted file names. def build_sources(sources, suffixes, cache, vars) sources.map do |source| - if source.has_suffix?(suffixes) + if source.end_with?(*suffixes) source else converted = nil diff --git a/lib/rscons/monkey/string.rb b/lib/rscons/monkey/string.rb index bb70541..d4f07f9 100644 --- a/lib/rscons/monkey/string.rb +++ b/lib/rscons/monkey/string.rb @@ -1,16 +1,5 @@ # Standard Ruby String class. 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 # to the given suffix. # @param suffix [String] The new suffix.