rscons 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rscons/environment.rb +7 -5
- data/lib/rscons/varset.rb +20 -11
- data/lib/rscons/version.rb +1 -1
- metadata +4 -4
data/lib/rscons/environment.rb
CHANGED
@@ -263,11 +263,13 @@ module Rscons
|
|
263
263
|
#
|
264
264
|
# @return [Array, String] Expansion of the variable reference.
|
265
265
|
def expand_varref(varref, extra_vars = nil)
|
266
|
-
if extra_vars.nil?
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
266
|
+
vars = if extra_vars.nil?
|
267
|
+
@varset
|
268
|
+
else
|
269
|
+
@varset.merge(extra_vars)
|
270
|
+
end
|
271
|
+
lambda_args = [env: self, vars: vars]
|
272
|
+
vars.expand_varref(varref, lambda_args)
|
271
273
|
end
|
272
274
|
alias_method :build_command, :expand_varref
|
273
275
|
|
data/lib/rscons/varset.rb
CHANGED
@@ -86,29 +86,38 @@ module Rscons
|
|
86
86
|
# Replace "$\{var}" variable references in varref with the expanded
|
87
87
|
# variables' values, recursively.
|
88
88
|
#
|
89
|
-
# @param varref [String, Array]
|
89
|
+
# @param varref [nil, String, Array, Proc]
|
90
|
+
# Value containing references to variables.
|
91
|
+
# @param lambda_args [Array]
|
92
|
+
# Arguments to pass to any lambda variable values to be expanded.
|
90
93
|
#
|
91
|
-
# @return [String, Array]
|
94
|
+
# @return [nil, String, Array]
|
92
95
|
# Expanded value with "$\{var}" variable references replaced.
|
93
|
-
def expand_varref(varref)
|
94
|
-
if varref.is_a?(
|
95
|
-
varref.map do |ent|
|
96
|
-
expand_varref(ent)
|
97
|
-
end.flatten
|
98
|
-
else
|
96
|
+
def expand_varref(varref, lambda_args)
|
97
|
+
if varref.is_a?(String)
|
99
98
|
if varref =~ /^(.*)\$\{([^}]+)\}(.*)$/
|
100
99
|
prefix, varname, suffix = $1, $2, $3
|
101
|
-
varval = expand_varref(self[varname])
|
100
|
+
varval = expand_varref(self[varname], lambda_args)
|
102
101
|
if varval.is_a?(String) or varval.nil?
|
103
|
-
expand_varref("#{prefix}#{varval}#{suffix}")
|
102
|
+
expand_varref("#{prefix}#{varval}#{suffix}", lambda_args)
|
104
103
|
elsif varval.is_a?(Array)
|
105
|
-
varval.map {|vv| expand_varref("#{prefix}#{vv}#{suffix}")}.flatten
|
104
|
+
varval.map {|vv| expand_varref("#{prefix}#{vv}#{suffix}", lambda_args)}.flatten
|
106
105
|
else
|
107
106
|
raise "I do not know how to expand a variable reference to a #{varval.class.name} (from #{varname.inspect} => #{self[varname].inspect})"
|
108
107
|
end
|
109
108
|
else
|
110
109
|
varref
|
111
110
|
end
|
111
|
+
elsif varref.is_a?(Array)
|
112
|
+
varref.map do |ent|
|
113
|
+
expand_varref(ent, lambda_args)
|
114
|
+
end.flatten
|
115
|
+
elsif varref.is_a?(Proc)
|
116
|
+
expand_varref(varref[*lambda_args], lambda_args)
|
117
|
+
elsif varref.nil?
|
118
|
+
nil
|
119
|
+
else
|
120
|
+
raise "Unknown varref type: #{varref.class} (#{varref.inspect})"
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
data/lib/rscons/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
segments:
|
146
146
|
- 0
|
147
|
-
hash:
|
147
|
+
hash: 485166867
|
148
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
segments:
|
155
155
|
- 0
|
156
|
-
hash:
|
156
|
+
hash: 485166867
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
159
|
rubygems_version: 1.8.23.2
|