rscons 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/build_tests/build_dir/build.rb +1 -1
- data/build_tests/custom_builder/build.rb +1 -2
- data/lib/rscons/cache.rb +2 -2
- data/lib/rscons/environment.rb +3 -4
- data/lib/rscons/varset.rb +2 -2
- data/lib/rscons/version.rb +1 -1
- data/spec/build_tests_spec.rb +35 -23
- data/spec/rscons/environment_spec.rb +11 -0
- data/spec/rscons/monkey/module_spec.rb +6 -0
- data/spec/rscons/varset_spec.rb +114 -0
- data/spec/spec_helper.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWYzYjNkYTFlM2JlMGE1YWU0MDU0YTI0Zjg5Zjk4NDFiODViMmMyNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmEzYWRmNDQ1NTIyZjE2ZTY2ZmU3MTljNDkzNmQxYzNkODcyNGNlYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWE5NGFhMjNhNWM2NTE1ZGNmZDk1ZDUxZjNhMzFhYzQ0Mjk4YzZmNzg0YjJk
|
10
|
+
NzgzMmVlOWM3ZmFkNTM3ODY0MjBkOWNmMTM0NTdmNGIyZjE1MTg0MWMyZDJm
|
11
|
+
ZjU1ZWIwMmY0NjE3NTkyYzI1MzMzYTBkYjcwNjcwOWM5ZTE1NzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzdkOWE1Nzk2NzIwZjQ4YTZhNGI5ZjFiZjEzYWJjMDcwN2IzOTJhOGVmNjQy
|
14
|
+
ZGQ3ZTNkNzIxYTQ1OTI5MTZlMDYzOGU3YThkYmNlNzlkMjM3NDhiMDdiZmIz
|
15
|
+
NGIyZDZhYzI0ZTdhMzYwODMxMDU3NTcwZTA0Njg2YTI1YjljZmI=
|
data/lib/rscons/cache.rb
CHANGED
@@ -129,12 +129,12 @@ module Rscons
|
|
129
129
|
# @param command [Array] The command used to build the target.
|
130
130
|
# @param deps [Array] List of dependencies for the target.
|
131
131
|
def register_build(target, command, deps)
|
132
|
-
@cache[:targets][target] = {
|
132
|
+
@cache[:targets][target.encode(__ENCODING__)] = {
|
133
133
|
command: command,
|
134
134
|
checksum: calculate_checksum(target),
|
135
135
|
deps: deps.map do |dep|
|
136
136
|
{
|
137
|
-
fname: dep,
|
137
|
+
fname: dep.encode(__ENCODING__),
|
138
138
|
checksum: lookup_checksum(dep),
|
139
139
|
}
|
140
140
|
end
|
data/lib/rscons/environment.rb
CHANGED
@@ -6,7 +6,7 @@ module Rscons
|
|
6
6
|
# contains a collection of construction variables, options, builders, and
|
7
7
|
# rules for building targets.
|
8
8
|
class Environment
|
9
|
-
# [
|
9
|
+
# [Hash] of {"builder_name" => builder_object} pairs.
|
10
10
|
attr_reader :builders
|
11
11
|
|
12
12
|
# Create an Environment object.
|
@@ -53,7 +53,7 @@ module Rscons
|
|
53
53
|
@builders.each do |builder_name, builder|
|
54
54
|
env.add_builder(builder)
|
55
55
|
end
|
56
|
-
env.append(@varset)
|
56
|
+
env.append(@varset.clone)
|
57
57
|
env.append(variables)
|
58
58
|
|
59
59
|
if block_given?
|
@@ -78,7 +78,6 @@ module Rscons
|
|
78
78
|
# Source files from src_dir will produce object files under obj_dir.
|
79
79
|
def build_dir(src_dir, obj_dir)
|
80
80
|
src_dir = src_dir.gsub('\\', '/') if src_dir.is_a?(String)
|
81
|
-
obj_dir = obj_dir.gsub('\\', '/')
|
82
81
|
@build_dirs << [src_dir, obj_dir]
|
83
82
|
end
|
84
83
|
|
@@ -92,7 +91,7 @@ module Rscons
|
|
92
91
|
if src_dir.is_a?(Regexp)
|
93
92
|
build_fname.sub!(src_dir, obj_dir)
|
94
93
|
else
|
95
|
-
build_fname.sub!(
|
94
|
+
build_fname.sub!(%r{^#{src_dir}/}, "#{obj_dir}/")
|
96
95
|
end
|
97
96
|
build_fname.gsub!('\\', '/')
|
98
97
|
end
|
data/lib/rscons/varset.rb
CHANGED
@@ -24,9 +24,9 @@ module Rscons
|
|
24
24
|
# returned.
|
25
25
|
def [](key, type = nil)
|
26
26
|
val = @vars[key]
|
27
|
-
if type == :array and val.is_a?(
|
27
|
+
if type == :array and not val.is_a?(Array)
|
28
28
|
[val]
|
29
|
-
elsif type == :
|
29
|
+
elsif type == :scalar and val.is_a?(Array)
|
30
30
|
val.first
|
31
31
|
else
|
32
32
|
val
|
data/lib/rscons/version.rb
CHANGED
data/spec/build_tests_spec.rb
CHANGED
@@ -13,12 +13,30 @@ describe Rscons do
|
|
13
13
|
|
14
14
|
def build_testdir
|
15
15
|
if File.exists?("build.rb")
|
16
|
-
|
16
|
+
build_rb = File.read("build.rb")
|
17
|
+
File.open("build.rb", "w") do |fh|
|
18
|
+
fh.puts(<<EOF + build_rb)
|
19
|
+
require "simplecov"
|
20
|
+
|
21
|
+
SimpleCov.start do
|
22
|
+
root("#{@owd}")
|
23
|
+
command_name("build_test_#{@build_test_name}")
|
24
|
+
add_filter("spec")
|
25
|
+
end
|
26
|
+
|
27
|
+
require "rscons"
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
IO.popen(%{ruby -I #{@owd}/lib build.rb}) do |io|
|
31
|
+
io.readlines.reject do |line|
|
32
|
+
line =~ /^Coverage report/
|
33
|
+
end
|
34
|
+
end.map(&:strip)
|
17
35
|
end
|
18
|
-
get_build_output
|
19
36
|
end
|
20
37
|
|
21
38
|
def test_dir(build_test_directory)
|
39
|
+
@build_test_name = build_test_directory
|
22
40
|
FileUtils.cp_r("build_tests/#{build_test_directory}", 'build_tests_run')
|
23
41
|
Dir.chdir("build_tests_run")
|
24
42
|
build_testdir
|
@@ -35,10 +53,6 @@ describe Rscons do
|
|
35
53
|
end
|
36
54
|
end
|
37
55
|
|
38
|
-
def get_build_output
|
39
|
-
File.read('build.out').lines.map(&:strip)
|
40
|
-
end
|
41
|
-
|
42
56
|
###########################################################################
|
43
57
|
# Tests
|
44
58
|
###########################################################################
|
@@ -116,36 +130,34 @@ describe Rscons do
|
|
116
130
|
it 'builds object files in a different build directory' do
|
117
131
|
lines = test_dir('build_dir')
|
118
132
|
`./build_dir`.should == "Hello from two()\n"
|
119
|
-
File.exists?('
|
120
|
-
File.exists?('
|
133
|
+
File.exists?('build_one/one.o').should be_true
|
134
|
+
File.exists?('build_two/two.o').should be_true
|
121
135
|
end
|
122
136
|
|
123
137
|
it 'cleans built files' do
|
124
138
|
lines = test_dir('build_dir')
|
125
139
|
`./build_dir`.should == "Hello from two()\n"
|
126
|
-
File.exists?('
|
127
|
-
File.exists?('
|
140
|
+
File.exists?('build_one/one.o').should be_true
|
141
|
+
File.exists?('build_two/two.o').should be_true
|
128
142
|
Rscons.clean
|
129
|
-
File.exists?('
|
130
|
-
File.exists?('
|
131
|
-
File.exists?('
|
132
|
-
File.exists?('
|
133
|
-
File.exists?('build').should be_false
|
143
|
+
File.exists?('build_one/one.o').should be_false
|
144
|
+
File.exists?('build_two/two.o').should be_false
|
145
|
+
File.exists?('build_one').should be_false
|
146
|
+
File.exists?('build_two').should be_false
|
134
147
|
File.exists?('src/one/one.c').should be_true
|
135
148
|
end
|
136
149
|
|
137
150
|
it 'does not clean created directories if other non-rscons-generated files reside there' do
|
138
151
|
lines = test_dir('build_dir')
|
139
152
|
`./build_dir`.should == "Hello from two()\n"
|
140
|
-
File.exists?('
|
141
|
-
File.exists?('
|
142
|
-
File.open('
|
153
|
+
File.exists?('build_one/one.o').should be_true
|
154
|
+
File.exists?('build_two/two.o').should be_true
|
155
|
+
File.open('build_two/tmp', 'w') { |fh| fh.puts "dum" }
|
143
156
|
Rscons.clean
|
144
|
-
File.exists?('
|
145
|
-
File.exists?('
|
146
|
-
File.exists?('
|
147
|
-
File.exists?('
|
148
|
-
File.exists?('build').should be_true
|
157
|
+
File.exists?('build_one/one.o').should be_false
|
158
|
+
File.exists?('build_two/two.o').should be_false
|
159
|
+
File.exists?('build_one').should be_false
|
160
|
+
File.exists?('build_two').should be_true
|
149
161
|
File.exists?('src/one/one.c').should be_true
|
150
162
|
end
|
151
163
|
|
@@ -1,5 +1,16 @@
|
|
1
1
|
module Rscons
|
2
2
|
describe Environment do
|
3
|
+
describe '.clone' do
|
4
|
+
it 'should create unique copies of each construction variable' do
|
5
|
+
env = Environment.new
|
6
|
+
env["CPPPATH"] << "path1"
|
7
|
+
env2 = env.clone
|
8
|
+
env2["CPPPATH"] << "path2"
|
9
|
+
env["CPPPATH"].should == ["path1"]
|
10
|
+
env2["CPPPATH"].should == ["path1", "path2"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
3
14
|
describe '.parse_makefile_deps' do
|
4
15
|
it 'handles dependencies on one line' do
|
5
16
|
File.should_receive(:read).with('makefile').and_return(<<EOS)
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Rscons
|
2
|
+
describe VarSet do
|
3
|
+
describe '.initialize' do
|
4
|
+
it "initializes variables from a Hash" do
|
5
|
+
v = VarSet.new({"one" => 1, "two" => :two})
|
6
|
+
v["one"].should == 1
|
7
|
+
v["two"].should == :two
|
8
|
+
end
|
9
|
+
it "initializes variables from another VarSet" do
|
10
|
+
v = VarSet.new({"one" => 1})
|
11
|
+
v2 = VarSet.new(v)
|
12
|
+
v2["one"].should == 1
|
13
|
+
end
|
14
|
+
it "makes a deep copy of the given VarSet" do
|
15
|
+
v = VarSet.new({"array" => [1, 2, 3]})
|
16
|
+
v2 = VarSet.new(v)
|
17
|
+
v["array"] << 4
|
18
|
+
v["array"].should == [1, 2, 3, 4]
|
19
|
+
v2["array"].should == [1, 2, 3]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe :[] do
|
24
|
+
v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
|
25
|
+
"qax" => [3, 6], "qux" => {a: :b}})
|
26
|
+
it "allows accessing a variable with its verbatim value if type is not specified" do
|
27
|
+
v["fuz"].should == "a string"
|
28
|
+
v["foo"].should == 42
|
29
|
+
v["bar"].should == :baz
|
30
|
+
v["qax"].should == [3, 6]
|
31
|
+
v["qux"].should == {a: :b}
|
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
|
+
end
|
40
|
+
|
41
|
+
describe :[]= do
|
42
|
+
it "allows assigning to variables" do
|
43
|
+
v = VarSet.new("CFLAGS" => ["-Wall", "-O3"])
|
44
|
+
v["CPPPATH"] = ["one", "two"]
|
45
|
+
v["CFLAGS"].should == ["-Wall", "-O3"]
|
46
|
+
v["CPPPATH"].should == ["one", "two"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.append' do
|
51
|
+
it "adds values from a Hash to the VarSet" do
|
52
|
+
v = VarSet.new("LDFLAGS" => "-lgcc")
|
53
|
+
v.append("LIBS" => "gcc", "LIBPATH" => ["mylibs"])
|
54
|
+
v.vars.keys.should =~ ["LDFLAGS", "LIBS", "LIBPATH"]
|
55
|
+
end
|
56
|
+
it "adds values from another VarSet to the VarSet" do
|
57
|
+
v = VarSet.new("CPPPATH" => ["mydir"])
|
58
|
+
v2 = VarSet.new("CFLAGS" => ["-O0"], "CPPPATH" => ["different_dir"])
|
59
|
+
v.append(v2)
|
60
|
+
v.vars.keys.should =~ ["CPPPATH", "CFLAGS"]
|
61
|
+
v["CPPPATH"].should == ["different_dir"]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.merge' do
|
66
|
+
it "returns a new VarSet merged with the given Hash" do
|
67
|
+
v = VarSet.new("foo" => "yoda")
|
68
|
+
v2 = v.merge("baz" => "qux")
|
69
|
+
v.vars.keys.should == ["foo"]
|
70
|
+
v2.vars.keys.should =~ ["foo", "baz"]
|
71
|
+
end
|
72
|
+
it "returns a new VarSet merged with the given VarSet" do
|
73
|
+
v = VarSet.new("foo" => ["a", "b"], "bar" => 42)
|
74
|
+
v2 = v.merge(VarSet.new("bar" => 33, "baz" => :baz))
|
75
|
+
v2["foo"] << "c"
|
76
|
+
v["foo"].should == ["a", "b"]
|
77
|
+
v["bar"].should == 42
|
78
|
+
v2["foo"].should == ["a", "b", "c"]
|
79
|
+
v2["bar"].should == 33
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '.expand_varref' do
|
84
|
+
v = VarSet.new("CFLAGS" => ["-Wall", "-O2"],
|
85
|
+
"CC" => "gcc",
|
86
|
+
"CPPPATH" => ["dir1", "dir2"],
|
87
|
+
"compiler" => "$CC",
|
88
|
+
"cmd" => ["$CC", "-c", "$CFLAGS", "-I$[CPPPATH]"])
|
89
|
+
it "expands to the string itself if the string is not a variable reference" do
|
90
|
+
v.expand_varref("CC").should == "CC"
|
91
|
+
v.expand_varref("CPPPATH").should == "CPPPATH"
|
92
|
+
v.expand_varref("str").should == "str"
|
93
|
+
end
|
94
|
+
it "expands a single variable reference beginning with a '$'" do
|
95
|
+
v.expand_varref("$CC").should == "gcc"
|
96
|
+
v.expand_varref("$CPPPATH").should == ["dir1", "dir2"]
|
97
|
+
end
|
98
|
+
it "expands a single variable reference in $[arr] notation" do
|
99
|
+
v.expand_varref("prefix$[CFLAGS]suffix").should == ["prefix-Wallsuffix", "prefix-O2suffix"]
|
100
|
+
v.expand_varref(v["cmd"]).should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
|
101
|
+
end
|
102
|
+
it "expands a variable reference recursively" do
|
103
|
+
v.expand_varref("$compiler").should == "gcc"
|
104
|
+
v.expand_varref("$cmd").should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
|
105
|
+
end
|
106
|
+
it "raises an error when array notation is applied to a non-array variable" do
|
107
|
+
expect { v.expand_varref("$[CC]") }.to raise_error /Array.expected/
|
108
|
+
end
|
109
|
+
it "raises an error when a variable reference refers to a non-existent variable" do
|
110
|
+
expect { v.expand_varref("$not_here") }.to raise_error /Could.not.find.variable..not_here/
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Holtrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -185,6 +185,8 @@ files:
|
|
185
185
|
- rscons.gemspec
|
186
186
|
- spec/build_tests_spec.rb
|
187
187
|
- spec/rscons/environment_spec.rb
|
188
|
+
- spec/rscons/monkey/module_spec.rb
|
189
|
+
- spec/rscons/varset_spec.rb
|
188
190
|
- spec/spec_helper.rb
|
189
191
|
homepage: https://github.com/holtrop/rscons
|
190
192
|
licenses:
|
@@ -213,5 +215,7 @@ summary: Software construction library inspired by SCons and implemented in Ruby
|
|
213
215
|
test_files:
|
214
216
|
- spec/build_tests_spec.rb
|
215
217
|
- spec/rscons/environment_spec.rb
|
218
|
+
- spec/rscons/monkey/module_spec.rb
|
219
|
+
- spec/rscons/varset_spec.rb
|
216
220
|
- spec/spec_helper.rb
|
217
221
|
has_rdoc:
|