rscons 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -6
- data/lib/rscons/cache.rb +2 -2
- data/lib/rscons/environment.rb +5 -0
- data/lib/rscons/varset.rb +2 -14
- data/lib/rscons/version.rb +1 -1
- data/spec/rscons/environment_spec.rb +14 -0
- data/spec/rscons/varset_spec.rb +0 -6
- metadata +4 -4
data/README.md
CHANGED
@@ -66,7 +66,7 @@ end
|
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
class GenerateFoo < Rscons::Builder
|
69
|
-
def run(target, sources,
|
69
|
+
def run(target, sources, cache, env, vars)
|
70
70
|
cache.mkdir_p(File.dirname(target))
|
71
71
|
File.open(target, "w") do |fh|
|
72
72
|
fh.puts <<EOF
|
@@ -86,12 +86,12 @@ end
|
|
86
86
|
|
87
87
|
```ruby
|
88
88
|
class CmdBuilder < Rscons::Builder
|
89
|
-
def run(target, sources,
|
89
|
+
def run(target, sources, cache, env, vars)
|
90
90
|
cmd = ["cmd", "-i", sources.first, "-o", target]
|
91
|
-
unless cache.up_to_date?(target, cmd, sources,
|
91
|
+
unless cache.up_to_date?(target, cmd, sources, env)
|
92
92
|
cache.mkdir_p(File.dirname(target))
|
93
93
|
system(cmd)
|
94
|
-
cache.register_build(target, cmd, sources,
|
94
|
+
cache.register_build(target, cmd, sources, env)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -105,9 +105,9 @@ end
|
|
105
105
|
|
106
106
|
```ruby
|
107
107
|
class CmdBuilder < Rscons::Builder
|
108
|
-
def run(target, sources,
|
108
|
+
def run(target, sources, cache, env, vars)
|
109
109
|
cmd = ["cmd", "-i", sources.first, "-o", target]
|
110
|
-
standard_build("CmdBld #{target}", target, cmd, sources,
|
110
|
+
standard_build("CmdBld #{target}", target, cmd, sources, env, cache)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
data/lib/rscons/cache.rb
CHANGED
@@ -117,7 +117,7 @@ module Rscons
|
|
117
117
|
# command used to build target must be identical
|
118
118
|
return false unless @cache[:targets][target][:command] == command
|
119
119
|
|
120
|
-
cached_deps = @cache[:targets][target][:deps]
|
120
|
+
cached_deps = @cache[:targets][target][:deps] || []
|
121
121
|
cached_deps_fnames = cached_deps.map { |dc| dc[:fname] }
|
122
122
|
if options[:strict_deps]
|
123
123
|
# depedencies passed in must exactly equal those in the cache
|
@@ -129,7 +129,7 @@ module Rscons
|
|
129
129
|
|
130
130
|
# set of user dependencies must match
|
131
131
|
user_deps = env.get_user_deps(target) || []
|
132
|
-
cached_user_deps = @cache[:targets][target][:user_deps]
|
132
|
+
cached_user_deps = @cache[:targets][target][:user_deps] || []
|
133
133
|
cached_user_deps_fnames = cached_user_deps.map { |dc| dc[:fname] }
|
134
134
|
return false unless user_deps == cached_user_deps_fnames
|
135
135
|
|
data/lib/rscons/environment.rb
CHANGED
@@ -185,6 +185,11 @@ module Rscons
|
|
185
185
|
@varset.merge(extra_vars).expand_varref(command_template)
|
186
186
|
end
|
187
187
|
|
188
|
+
# Expand a construction variable reference (String or Array)
|
189
|
+
def expand_varref(varref)
|
190
|
+
@varset.expand_varref(varref)
|
191
|
+
end
|
192
|
+
|
188
193
|
# Execute a builder command
|
189
194
|
# @param short_desc [String] Message to print if the Environment's echo
|
190
195
|
# mode is set to :short
|
data/lib/rscons/varset.rb
CHANGED
@@ -17,20 +17,8 @@ module Rscons
|
|
17
17
|
|
18
18
|
# Access the value of variable as a particular type
|
19
19
|
# @param key [String, Symbol] The variable name.
|
20
|
-
|
21
|
-
|
22
|
-
# the variable value will be returned. If the variable is an Array and
|
23
|
-
# type is :string, the first element from the variable value will be
|
24
|
-
# returned.
|
25
|
-
def [](key, type = nil)
|
26
|
-
val = @vars[key]
|
27
|
-
if type == :array and not val.is_a?(Array)
|
28
|
-
[val]
|
29
|
-
elsif type == :scalar and val.is_a?(Array)
|
30
|
-
val.first
|
31
|
-
else
|
32
|
-
val
|
33
|
-
end
|
20
|
+
def [](key)
|
21
|
+
@vars[key]
|
34
22
|
end
|
35
23
|
|
36
24
|
# Assign a value to a variable.
|
data/lib/rscons/version.rb
CHANGED
@@ -199,6 +199,20 @@ module Rscons
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
+
describe "#expand_varref" do
|
203
|
+
it "returns the fully expanded variable reference" do
|
204
|
+
env = Environment.new
|
205
|
+
env["path"] = ["dir1", "dir2"]
|
206
|
+
env["flags"] = ["-x", "-y", "${specialflag}"]
|
207
|
+
env["specialflag"] = "-z"
|
208
|
+
env.expand_varref(["-p${path}", "${flags}"]).should == ["-pdir1", "-pdir2", "-x", "-y", "-z"]
|
209
|
+
env.expand_varref("foo").should == "foo"
|
210
|
+
expect {env.expand_varref("${foo}")}.to raise_error /expand.a.variable.reference/
|
211
|
+
env.expand_varref("${specialflag}").should == "-z"
|
212
|
+
env.expand_varref("${path}").should == ["dir1", "dir2"]
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
202
216
|
describe "#execute" do
|
203
217
|
context "with echo: :short" do
|
204
218
|
context "with no errors" do
|
data/spec/rscons/varset_spec.rb
CHANGED
@@ -30,12 +30,6 @@ module Rscons
|
|
30
30
|
v["qax"].should == [3, 6]
|
31
31
|
v["qux"].should == {a: :b}
|
32
32
|
end
|
33
|
-
it "allows accessing a non-array converted to an array" do
|
34
|
-
v["fuz", :array].should == ["a string"]
|
35
|
-
end
|
36
|
-
it "allows accessing an array as a single value" do
|
37
|
-
v["qax", :scalar].should == 3
|
38
|
-
end
|
39
33
|
end
|
40
34
|
|
41
35
|
describe :[]= do
|
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: 0.3.
|
4
|
+
version: 0.3.1
|
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:
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-core
|
@@ -215,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
segments:
|
217
217
|
- 0
|
218
|
-
hash: -
|
218
|
+
hash: -725097361
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
none: false
|
221
221
|
requirements:
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash: -
|
227
|
+
hash: -725097361
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project:
|
230
230
|
rubygems_version: 1.8.23
|