diff --git a/lib/rscons.rb b/lib/rscons.rb index 6a978a4..9e05eb4 100644 --- a/lib/rscons.rb +++ b/lib/rscons.rb @@ -4,8 +4,6 @@ require "rscons/environment" require "rscons/varset" require "rscons/version" -require "rscons/monkey/string" - # default builders require "rscons/builders/library" require "rscons/builders/object" @@ -43,4 +41,11 @@ module Rscons def self.absolute_path?(path) path =~ %r{^(/|\w:[\\/])} end + + # Return a new path by changing the suffix in path to suffix. + # @param path [String] the path to alter + # @param suffix [String] the new filename suffix + def self.set_suffix(path, suffix) + path.sub(/\.[^.]*$/, suffix) + end end diff --git a/lib/rscons/builders/object.rb b/lib/rscons/builders/object.rb index 05d02c0..3ba0fa3 100644 --- a/lib/rscons/builders/object.rb +++ b/lib/rscons/builders/object.rb @@ -55,7 +55,7 @@ module Rscons vars = vars.merge({ '_TARGET' => target, '_SOURCES' => sources, - '_DEPFILE' => target.set_suffix('.mf'), + '_DEPFILE' => Rscons.set_suffix(target, '.mf'), }) com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var| sources.first.end_with?(*env[suffix_var]) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 1d59cc1..28d6a89 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -102,7 +102,7 @@ module Rscons # Return the file name to be built from source_fname with suffix suffix. # This method takes into account the Environment's build directories. def get_build_fname(source_fname, suffix) - build_fname = source_fname.set_suffix(suffix).gsub('\\', '/') + build_fname = Rscons.set_suffix(source_fname, suffix).gsub('\\', '/') found_match = @build_dirs.find do |src_dir, obj_dir| if src_dir.is_a?(Regexp) build_fname.sub!(src_dir, obj_dir) diff --git a/lib/rscons/monkey/string.rb b/lib/rscons/monkey/string.rb deleted file mode 100644 index dc1f629..0000000 --- a/lib/rscons/monkey/string.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Standard Ruby String class. -class String - # Return a new string with the suffix (dot character and extension) changed - # to the given suffix. - # @param suffix [String] The new suffix. - def set_suffix(suffix = '') - sub(/\.[^.]*$/, suffix) - end -end