add Util module and Util.make_relative_path()
This commit is contained in:
parent
778d9ed8b2
commit
36643c1ab1
@ -8,6 +8,7 @@ require_relative "rscons/environment"
|
|||||||
require_relative "rscons/job_set"
|
require_relative "rscons/job_set"
|
||||||
require_relative "rscons/script"
|
require_relative "rscons/script"
|
||||||
require_relative "rscons/threaded_command"
|
require_relative "rscons/threaded_command"
|
||||||
|
require_relative "rscons/util"
|
||||||
require_relative "rscons/varset"
|
require_relative "rscons/varset"
|
||||||
require_relative "rscons/version"
|
require_relative "rscons/version"
|
||||||
|
|
||||||
|
@ -265,15 +265,7 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless found_match
|
unless found_match
|
||||||
if Rscons.absolute_path?(build_fname)
|
build_fname = "#{@build_root}#{extra_path}/#{Util.make_relative_path(build_fname)}"
|
||||||
if build_fname =~ %r{^(\w):(.*)$}
|
|
||||||
build_fname = "#{@build_root}#{extra_path}/_#{$1}#{$2}"
|
|
||||||
else
|
|
||||||
build_fname = "#{@build_root}#{extra_path}/_#{build_fname}"
|
|
||||||
end
|
|
||||||
elsif !build_fname.start_with?("#{@build_root}/")
|
|
||||||
build_fname = "#{@build_root}#{extra_path}/#{build_fname}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
build_fname.gsub('\\', '/')
|
build_fname.gsub('\\', '/')
|
||||||
end
|
end
|
||||||
|
26
lib/rscons/util.rb
Normal file
26
lib/rscons/util.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
module Rscons
|
||||||
|
module Util
|
||||||
|
class << self
|
||||||
|
|
||||||
|
# Make a relative path corresponding to a possibly absolute one.
|
||||||
|
#
|
||||||
|
# @param path [String]
|
||||||
|
# Input path that is possibly absolute.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
# Relative path.
|
||||||
|
def make_relative_path(path)
|
||||||
|
if Rscons.absolute_path?(path)
|
||||||
|
if path =~ %r{^(\w):(.*)$}
|
||||||
|
"_#{$1}#{$2}"
|
||||||
|
else
|
||||||
|
"_#{path}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user