rscons 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +30 -0
- data/lib/rscons/cache.rb +59 -54
- data/lib/rscons/version.rb +1 -1
- data/spec/build_tests_spec.rb +35 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTQxY2I3MDZhNDdhOGNmMDZkM2ZmZjQ1OWRmZjNkZTgwNDlkYzQ5MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzYwNjZmODZlMzllZjM5Yjg5YTEzZDZkYWRkMmIwYWY3YjkzN2RmOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDQyNzc4MGJmZTY4ZmZhNzU4ZGUwNDdiNDYxNWJjYjMzOTQ4OTAyNzIwM2I2
|
10
|
+
ZDRiMWNmNjQwYWM2YmY3ZWVlOGYxZGU4YmQ1Y2I3YzUyZjJhMDc4YTRhYjQ5
|
11
|
+
ZTQ1NDU0NTM3MGI5YTMzZTgwOTk2MTljMDJkMGJmNjkwODI2ZGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGIzNjA5MWE0MzU2ODUzOTk1YWE0YzExMjBhNzBlNTllMGFjNjE1YmE1Yzg0
|
14
|
+
MzEzZjE4MGMyYzg4YmJmNjFiMWFhODU2MjIxMTg4NThmMTNhMjAwYWQ4MTQw
|
15
|
+
ZTk4ZDY4ZjNiMGVkNmM5MTA5NmRhZWFiOGY3YjdmZDVlODMxOTM=
|
data/README.md
CHANGED
@@ -110,6 +110,29 @@ Rscons::Environment.new do |env|
|
|
110
110
|
end
|
111
111
|
```
|
112
112
|
|
113
|
+
### Example: Custom Builder That Generates Multiple Output Files
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
class CModuleGenerator < Rscons::Builder
|
117
|
+
def run(target, sources, cache, env, vars)
|
118
|
+
c_fname = target
|
119
|
+
h_fname = target.sub(/\.c$/, ".h")
|
120
|
+
cmd = ["generate_c_and_h", sources.first, c_fname, h_fname]
|
121
|
+
unless cache.up_to_date?([c_fname, h_fname], cmd, sources, env)
|
122
|
+
cache.mkdir_p(File.dirname(target))
|
123
|
+
system(cmd)
|
124
|
+
cache.register_build([c_fname, h_fname], cmd, sources, env)
|
125
|
+
end
|
126
|
+
target
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Rscons::Environment.new do |env|
|
131
|
+
env.add_builder(CModuleGenerator.new)
|
132
|
+
env.CModuleGenerator("build/foo.c", "foo_gen.cfg")
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
113
136
|
### Example: Custom Builder Using Builder#standard_build()
|
114
137
|
|
115
138
|
The `standard_build` method from the `Rscons::Builder` base class can be used
|
@@ -218,6 +241,13 @@ cloned_env["CPPPATH"] << "three"
|
|
218
241
|
Documentation for the complete Rscons API can be found at
|
219
242
|
http://rubydoc.info/github/holtrop/rscons/frames.
|
220
243
|
|
244
|
+
## Release Notes
|
245
|
+
|
246
|
+
### v1.1.0
|
247
|
+
|
248
|
+
- Change Cache#up_to_date?() and #register_build() to accept a single target
|
249
|
+
file or an array of target file names
|
250
|
+
|
221
251
|
## Contributing
|
222
252
|
|
223
253
|
1. Fork it
|
data/lib/rscons/cache.rb
CHANGED
@@ -85,16 +85,17 @@ module Rscons
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
# Check if
|
89
|
-
# @param
|
90
|
-
# @param command [Array] The command used to build the target.
|
88
|
+
# Check if target(s) are up to date
|
89
|
+
# @param targets [String, Array] The name(s) of the target file(s).
|
90
|
+
# @param command [String, Array] The command used to build the target.
|
91
91
|
# @param deps [Array] List of the target's dependency files.
|
92
92
|
# @param env [Environment] The Rscons::Environment.
|
93
93
|
# @param options [Hash] Optional options. Can contain the following keys:
|
94
94
|
# :strict_deps::
|
95
95
|
# Only consider a target up to date if its list of dependencies is
|
96
96
|
# exactly equal (including order) to the cached list of dependencies
|
97
|
-
# @return true
|
97
|
+
# @return true if the targets are all up to date, meaning that,
|
98
|
+
# for each target:
|
98
99
|
# - the target exists on disk
|
99
100
|
# - the cache has information for the target
|
100
101
|
# - the target's checksum matches its checksum when it was last built
|
@@ -104,65 +105,69 @@ module Rscons
|
|
104
105
|
# exactly equal to those cached
|
105
106
|
# - each cached dependency file's current checksum matches the checksum
|
106
107
|
# stored in the cache file
|
107
|
-
def up_to_date?(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
108
|
+
def up_to_date?(targets, command, deps, env, options = {})
|
109
|
+
Array(targets).each do |target|
|
110
|
+
# target file must exist on disk
|
111
|
+
return false unless File.exists?(target)
|
112
|
+
|
113
|
+
# target must be registered in the cache
|
114
|
+
return false unless @cache[:targets].has_key?(target)
|
115
|
+
|
116
|
+
# target must have the same checksum as when it was built last
|
117
|
+
return false unless @cache[:targets][target][:checksum] == lookup_checksum(target)
|
118
|
+
|
119
|
+
# command used to build target must be identical
|
120
|
+
return false unless @cache[:targets][target][:command] == command
|
121
|
+
|
122
|
+
cached_deps = @cache[:targets][target][:deps] || []
|
123
|
+
cached_deps_fnames = cached_deps.map { |dc| dc[:fname] }
|
124
|
+
if options[:strict_deps]
|
125
|
+
# depedencies passed in must exactly equal those in the cache
|
126
|
+
return false unless deps == cached_deps_fnames
|
127
|
+
else
|
128
|
+
# all dependencies passed in must exist in cache (but cache may have more)
|
129
|
+
return false unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?
|
130
|
+
end
|
129
131
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
# set of user dependencies must match
|
133
|
+
user_deps = env.get_user_deps(target) || []
|
134
|
+
cached_user_deps = @cache[:targets][target][:user_deps] || []
|
135
|
+
cached_user_deps_fnames = cached_user_deps.map { |dc| dc[:fname] }
|
136
|
+
return false unless user_deps == cached_user_deps_fnames
|
135
137
|
|
136
|
-
|
137
|
-
|
138
|
-
|
138
|
+
# all cached dependencies must have their checksums match
|
139
|
+
(cached_deps + cached_user_deps).each do |dep_cache|
|
140
|
+
return false unless dep_cache[:checksum] == lookup_checksum(dep_cache[:fname])
|
141
|
+
end
|
139
142
|
end
|
140
143
|
|
141
144
|
true
|
142
145
|
end
|
143
146
|
|
144
|
-
# Store cache information about
|
145
|
-
# @param
|
146
|
-
# @param command [Array] The command used to build the target.
|
147
|
+
# Store cache information about target(s) built by a builder
|
148
|
+
# @param targets [String, Array] The name of the target(s) built.
|
149
|
+
# @param command [String, Array] The command used to build the target.
|
147
150
|
# @param deps [Array] List of dependencies for the target.
|
148
151
|
# @param env [Environment] The Rscons::Environment.
|
149
|
-
def register_build(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
152
|
+
def register_build(targets, command, deps, env)
|
153
|
+
Array(targets).each do |target|
|
154
|
+
@cache[:targets][target.encode(__ENCODING__)] = {
|
155
|
+
command: command,
|
156
|
+
checksum: calculate_checksum(target),
|
157
|
+
deps: deps.map do |dep|
|
158
|
+
{
|
159
|
+
fname: dep.encode(__ENCODING__),
|
160
|
+
checksum: lookup_checksum(dep),
|
161
|
+
}
|
162
|
+
end,
|
163
|
+
user_deps: (env.get_user_deps(target) || []).map do |dep|
|
164
|
+
{
|
165
|
+
fname: dep.encode(__ENCODING__),
|
166
|
+
checksum: lookup_checksum(dep),
|
167
|
+
}
|
168
|
+
end,
|
169
|
+
}
|
170
|
+
end
|
166
171
|
end
|
167
172
|
|
168
173
|
# Return a list of targets that have been built
|
data/lib/rscons/version.rb
CHANGED
data/spec/build_tests_spec.rb
CHANGED
@@ -218,9 +218,9 @@ describe Rscons do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'allows Ruby classes as custom builders to be used to construct files' do
|
221
|
-
|
221
|
+
test_dir('custom_builder')
|
222
222
|
class MySource < Rscons::Builder
|
223
|
-
def run(target, sources,
|
223
|
+
def run(target, sources, cache, env, vars)
|
224
224
|
File.open(target, 'w') do |fh|
|
225
225
|
fh.puts <<EOF
|
226
226
|
#define THE_VALUE 5678
|
@@ -241,6 +241,39 @@ EOF
|
|
241
241
|
`./program`.should == "The value is 5678\n"
|
242
242
|
end
|
243
243
|
|
244
|
+
it 'supports custom builders with multiple targets' do
|
245
|
+
test_dir('custom_builder')
|
246
|
+
class CHGen < Rscons::Builder
|
247
|
+
def run(target, sources, cache, env, vars)
|
248
|
+
c_fname = target
|
249
|
+
h_fname = target.sub(/\.c$/, ".h")
|
250
|
+
unless cache.up_to_date?([c_fname, h_fname], "", sources, env)
|
251
|
+
puts "CHGen #{c_fname}"
|
252
|
+
File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"}
|
253
|
+
File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"}
|
254
|
+
cache.register_build([c_fname, h_fname], "", sources, env)
|
255
|
+
end
|
256
|
+
target
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
env = Rscons::Environment.new do |env|
|
261
|
+
env.add_builder(CHGen.new)
|
262
|
+
env.CHGen("inc.c", ["program.c"])
|
263
|
+
env.Program("program", Dir["*.c"] + ["inc.c"])
|
264
|
+
end
|
265
|
+
|
266
|
+
lines.should == ["CHGen inc.c", "CC program.o", "CC inc.o", "LD program"]
|
267
|
+
File.exists?("inc.c").should be_true
|
268
|
+
File.exists?("inc.h").should be_true
|
269
|
+
`./program`.should == "The value is 42\n"
|
270
|
+
|
271
|
+
File.open("inc.c", "w") {|fh| fh.puts "int THE_VALUE = 33;"}
|
272
|
+
env.process
|
273
|
+
lines.should == ["CHGen inc.c"]
|
274
|
+
`./program`.should == "The value is 42\n"
|
275
|
+
end
|
276
|
+
|
244
277
|
it 'allows cloning Environment objects' do
|
245
278
|
test_dir('clone_env')
|
246
279
|
|
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Holtrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|