remove String#set_suffix monkey patch

This commit is contained in:
Josh Holtrop 2014-02-14 10:36:15 -05:00
parent 2ffb5d525a
commit 98f8f38715
4 changed files with 9 additions and 13 deletions

View File

@ -4,8 +4,6 @@ require "rscons/environment"
require "rscons/varset" require "rscons/varset"
require "rscons/version" require "rscons/version"
require "rscons/monkey/string"
# default builders # default builders
require "rscons/builders/library" require "rscons/builders/library"
require "rscons/builders/object" require "rscons/builders/object"
@ -43,4 +41,11 @@ module Rscons
def self.absolute_path?(path) def self.absolute_path?(path)
path =~ %r{^(/|\w:[\\/])} path =~ %r{^(/|\w:[\\/])}
end 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 end

View File

@ -55,7 +55,7 @@ module Rscons
vars = vars.merge({ vars = vars.merge({
'_TARGET' => target, '_TARGET' => target,
'_SOURCES' => sources, '_SOURCES' => sources,
'_DEPFILE' => target.set_suffix('.mf'), '_DEPFILE' => Rscons.set_suffix(target, '.mf'),
}) })
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var| com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
sources.first.end_with?(*env[suffix_var]) sources.first.end_with?(*env[suffix_var])

View File

@ -102,7 +102,7 @@ module Rscons
# Return the file name to be built from source_fname with suffix suffix. # Return the file name to be built from source_fname with suffix suffix.
# This method takes into account the Environment's build directories. # This method takes into account the Environment's build directories.
def get_build_fname(source_fname, suffix) 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| found_match = @build_dirs.find do |src_dir, obj_dir|
if src_dir.is_a?(Regexp) if src_dir.is_a?(Regexp)
build_fname.sub!(src_dir, obj_dir) build_fname.sub!(src_dir, obj_dir)

View File

@ -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