rscons 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/lib/rscons.rb +75 -5
  2. data/lib/rscons/build_target.rb +36 -0
  3. data/lib/rscons/builder.rb +41 -3
  4. data/lib/rscons/builders/cfile.rb +15 -0
  5. data/lib/rscons/builders/disassemble.rb +15 -0
  6. data/lib/rscons/builders/library.rb +17 -2
  7. data/lib/rscons/builders/object.rb +37 -5
  8. data/lib/rscons/builders/preprocess.rb +15 -0
  9. data/lib/rscons/builders/program.rb +42 -2
  10. data/lib/rscons/cache.rb +26 -6
  11. data/lib/rscons/environment.rb +259 -19
  12. data/lib/rscons/varset.rb +33 -10
  13. data/lib/rscons/version.rb +1 -1
  14. data/rscons.gemspec +8 -10
  15. metadata +38 -103
  16. checksums.yaml +0 -15
  17. data/.gitignore +0 -18
  18. data/.rspec +0 -2
  19. data/Gemfile +0 -4
  20. data/README.md +0 -384
  21. data/Rakefile.rb +0 -26
  22. data/build_tests/build_dir/src/one/one.c +0 -6
  23. data/build_tests/build_dir/src/two/two.c +0 -7
  24. data/build_tests/build_dir/src/two/two.h +0 -6
  25. data/build_tests/clone_env/src/program.c +0 -6
  26. data/build_tests/custom_builder/program.c +0 -7
  27. data/build_tests/d/main.d +0 -6
  28. data/build_tests/header/header.c +0 -7
  29. data/build_tests/header/header.h +0 -6
  30. data/build_tests/library/one.c +0 -8
  31. data/build_tests/library/three.c +0 -0
  32. data/build_tests/library/two.c +0 -0
  33. data/build_tests/simple/simple.c +0 -6
  34. data/build_tests/simple_cc/simple.cc +0 -8
  35. data/build_tests/two_sources/one.c +0 -8
  36. data/build_tests/two_sources/two.c +0 -3
  37. data/spec/build_tests_spec.rb +0 -527
  38. data/spec/rscons/builders/cfile_spec.rb +0 -28
  39. data/spec/rscons/builders/disassemble_spec.rb +0 -17
  40. data/spec/rscons/builders/library_spec.rb +0 -18
  41. data/spec/rscons/builders/object_spec.rb +0 -23
  42. data/spec/rscons/builders/preprocess_spec.rb +0 -18
  43. data/spec/rscons/builders/program_spec.rb +0 -18
  44. data/spec/rscons/cache_spec.rb +0 -271
  45. data/spec/rscons/environment_spec.rb +0 -361
  46. data/spec/rscons/varset_spec.rb +0 -163
  47. data/spec/rscons_spec.rb +0 -26
  48. data/spec/spec_helper.rb +0 -7
@@ -1,163 +0,0 @@
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
- it "allows accessing a variable with its verbatim value if type is not specified" do
25
- v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
26
- "qax" => [3, 6], "qux" => {a: :b}})
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
- end
34
-
35
- describe "#[]=" do
36
- it "allows assigning to variables" do
37
- v = VarSet.new("CFLAGS" => ["-Wall", "-O3"])
38
- v["CPPPATH"] = ["one", "two"]
39
- v["CFLAGS"].should == ["-Wall", "-O3"]
40
- v["CPPPATH"].should == ["one", "two"]
41
- end
42
- end
43
-
44
- describe "#include?" do
45
- it "returns whether the variable is in the VarSet" do
46
- v = VarSet.new("CFLAGS" => [], :foo => :bar)
47
-
48
- expect(v.include?("CFLAGS")).to be_true
49
- expect(v.include?(:CFLAGS)).to be_false
50
- expect(v.include?(:foo)).to be_true
51
- expect(v.include?("foo")).to be_false
52
- expect(v.include?("bar")).to be_false
53
-
54
- v2 = v.clone
55
- v2.append("bar" => [])
56
-
57
- expect(v2.include?("CFLAGS")).to be_true
58
- expect(v2.include?(:CFLAGS)).to be_false
59
- expect(v2.include?(:foo)).to be_true
60
- expect(v2.include?("foo")).to be_false
61
- expect(v2.include?("bar")).to be_true
62
- end
63
- end
64
-
65
- describe '#append' do
66
- it "adds values from a Hash to the VarSet" do
67
- v = VarSet.new("LDFLAGS" => "-lgcc")
68
- v.append("LIBS" => "gcc", "LIBPATH" => ["mylibs"])
69
- expect(v["LDFLAGS"]).to eq("-lgcc")
70
- expect(v["LIBS"]).to eq("gcc")
71
- expect(v["LIBPATH"]).to eq(["mylibs"])
72
- end
73
-
74
- it "adds values from another VarSet to the VarSet" do
75
- v = VarSet.new("CPPPATH" => ["mydir"])
76
- v2 = VarSet.new("CFLAGS" => ["-O0"], "CPPPATH" => ["different_dir"])
77
- v.append(v2)
78
- expect(v["CFLAGS"]).to eq(["-O0"])
79
- expect(v["CPPPATH"]).to eq(["different_dir"])
80
- end
81
-
82
- it "does not pick up subsequent variable changes from a given VarSet" do
83
- v = VarSet.new("dirs" => ["a"])
84
- v2 = VarSet.new
85
- v2.append(v)
86
- v["dirs"] << "b"
87
- expect(v["dirs"]).to eq(["a", "b"])
88
- expect(v2["dirs"]).to eq(["a"])
89
- end
90
- end
91
-
92
- describe '#merge' do
93
- it "returns a new VarSet merged with the given Hash" do
94
- v = VarSet.new("foo" => "yoda")
95
- v2 = v.merge("baz" => "qux")
96
- expect(v["foo"]).to eq("yoda")
97
- expect(v2["foo"]).to eq("yoda")
98
- expect(v2["baz"]).to eq("qux")
99
- end
100
-
101
- it "returns a new VarSet merged with the given VarSet" do
102
- v = VarSet.new("foo" => ["a", "b"], "bar" => 42)
103
- v2 = v.merge(VarSet.new("bar" => 33, "baz" => :baz))
104
- v2["foo"] << "c"
105
- expect(v["foo"]).to eq ["a", "b"]
106
- expect(v["bar"]).to eq 42
107
- expect(v2["foo"]).to eq ["a", "b", "c"]
108
- expect(v2["bar"]).to eq 33
109
- end
110
-
111
- it "does not pick up subsequent variable changes from a given VarSet" do
112
- v = VarSet.new("var" => ["a", "b"], "var2" => ["1", "2"])
113
- v["var2"] << "3"
114
- v2 = v.clone
115
- v["var"] << "c"
116
- expect(v["var"]).to eq(["a", "b", "c"])
117
- expect(v["var2"]).to eq(["1", "2", "3"])
118
- expect(v2["var"]).to eq(["a", "b"])
119
- expect(v2["var2"]).to eq(["1", "2", "3"])
120
- end
121
- end
122
-
123
- describe '#expand_varref' do
124
- v = VarSet.new("CFLAGS" => ["-Wall", "-O2"],
125
- "CC" => "gcc",
126
- "CPPPATH" => ["dir1", "dir2"],
127
- "compiler" => "${CC}",
128
- "cmd" => ["${CC}", "-c", "${CFLAGS}", "-I${CPPPATH}"],
129
- "hash" => {})
130
- it "expands to the string itself if the string is not a variable reference" do
131
- v.expand_varref("CC").should == "CC"
132
- v.expand_varref("CPPPATH").should == "CPPPATH"
133
- v.expand_varref("str").should == "str"
134
- end
135
- it "expands a single variable reference beginning with a '$'" do
136
- v.expand_varref("${CC}").should == "gcc"
137
- v.expand_varref("${CPPPATH}").should == ["dir1", "dir2"]
138
- end
139
- it "expands a single variable reference in ${arr} notation" do
140
- v.expand_varref("prefix${CFLAGS}suffix").should == ["prefix-Wallsuffix", "prefix-O2suffix"]
141
- v.expand_varref(v["cmd"]).should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
142
- end
143
- it "expands a variable reference recursively" do
144
- v.expand_varref("${compiler}").should == "gcc"
145
- v.expand_varref("${cmd}").should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
146
- end
147
- it "resolves multiple variable references in one element by enumerating all combinations" do
148
- v.expand_varref("cflag: ${CFLAGS}, cpppath: ${CPPPATH}, compiler: ${compiler}").should == [
149
- "cflag: -Wall, cpppath: dir1, compiler: gcc",
150
- "cflag: -O2, cpppath: dir1, compiler: gcc",
151
- "cflag: -Wall, cpppath: dir2, compiler: gcc",
152
- "cflag: -O2, cpppath: dir2, compiler: gcc",
153
- ]
154
- end
155
- it "returns an empty string when a variable reference refers to a non-existent variable" do
156
- expect(v.expand_varref("${not_here}")).to eq("")
157
- end
158
- it "raises an error when a variable reference refers to an unhandled type" do
159
- expect { v.expand_varref("${hash}") }.to raise_error /I do not know how to expand a variable reference to a Hash/
160
- end
161
- end
162
- end
163
- end
@@ -1,26 +0,0 @@
1
- describe Rscons do
2
- describe ".clean" do
3
- it "removes all build targets and created directories" do
4
- cache = "cache"
5
- Rscons::Cache.should_receive(:instance).and_return(cache)
6
- cache.should_receive(:targets).and_return(["build/a.out", "build/main.o"])
7
- FileUtils.should_receive(:rm_f).with("build/a.out")
8
- FileUtils.should_receive(:rm_f).with("build/main.o")
9
- cache.should_receive(:directories).and_return(["build/one", "build/one/two", "build", "other"])
10
- File.should_receive(:directory?).with("build/one/two").and_return(true)
11
- Dir.should_receive(:entries).with("build/one/two").and_return([".", ".."])
12
- Dir.should_receive(:rmdir).with("build/one/two")
13
- File.should_receive(:directory?).with("build/one").and_return(true)
14
- Dir.should_receive(:entries).with("build/one").and_return([".", ".."])
15
- Dir.should_receive(:rmdir).with("build/one")
16
- File.should_receive(:directory?).with("build").and_return(true)
17
- Dir.should_receive(:entries).with("build").and_return([".", ".."])
18
- Dir.should_receive(:rmdir).with("build")
19
- File.should_receive(:directory?).with("other").and_return(true)
20
- Dir.should_receive(:entries).with("other").and_return([".", "..", "other.file"])
21
- cache.should_receive(:clear)
22
-
23
- Rscons.clean
24
- end
25
- end
26
- end
@@ -1,7 +0,0 @@
1
- require "simplecov"
2
-
3
- SimpleCov.start do
4
- add_filter "/spec/"
5
- end
6
-
7
- require "rscons"