add Environment#expand_path
This commit is contained in:
parent
0de1e8e970
commit
c08a2243b9
@ -337,22 +337,30 @@ module Rscons
|
|||||||
builder.run(target, sources, cache, self, vars)
|
builder.run(target, sources, cache, self, vars)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Expand a path to be relative to the Environment's build root.
|
||||||
|
#
|
||||||
|
# Paths beginning with "^/" are expanded by replacing "^" with the
|
||||||
|
# Environment's build root.
|
||||||
|
#
|
||||||
|
# @param path [String] The path to expand.
|
||||||
|
#
|
||||||
|
# @return [String] The expanded path.
|
||||||
|
def expand_path(path)
|
||||||
|
path.sub(%r{^\^(?=[\\/])}, @build_root)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Expand all target paths that begin with ^/ to be relative to the
|
# Expand all target paths that begin with ^/ to be relative to the
|
||||||
# Environment's build root, if present
|
# Environment's build root, if present
|
||||||
def clean_target_paths!
|
def clean_target_paths!
|
||||||
if @build_root
|
if @build_root
|
||||||
expand = lambda do |path|
|
|
||||||
path.sub(%r{^\^(?=[\\/])}, @build_root)
|
|
||||||
end
|
|
||||||
|
|
||||||
new_targets = {}
|
new_targets = {}
|
||||||
@targets.each_pair do |target, target_params|
|
@targets.each_pair do |target, target_params|
|
||||||
target_params[:sources].map! do |source|
|
target_params[:sources].map! do |source|
|
||||||
expand[source]
|
expand_path(source)
|
||||||
end
|
end
|
||||||
new_targets[expand[target]] = target_params
|
new_targets[expand_path(target)] = target_params
|
||||||
end
|
end
|
||||||
@targets = new_targets
|
@targets = new_targets
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user