rant 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +31 -0
- data/README +3 -1
- data/Rantfile +53 -2
- data/doc/advanced.rdoc +86 -1
- data/doc/c.rdoc +8 -0
- data/doc/homepage/index.html +2 -0
- data/doc/rant.1 +4 -0
- data/doc/rant.rdoc +38 -0
- data/doc/rant_vs_rake.rdoc +13 -0
- data/doc/rantfile.rdoc +93 -63
- data/doc/sys.rdoc +568 -0
- data/lib/rant/coregen.rb +43 -16
- data/lib/rant/import/command.rb +7 -4
- data/lib/rant/import/filelist/more.rb +57 -0
- data/lib/rant/import/metadata.rb +5 -1
- data/lib/rant/import/nodes/default.rb +3 -24
- data/lib/rant/import/signedfile.rb +1 -8
- data/lib/rant/import/sys/more.rb +2 -1
- data/lib/rant/import/var/booleans.rb +65 -0
- data/lib/rant/import/var/lists.rb +34 -0
- data/lib/rant/import/var/numbers.rb +116 -0
- data/lib/rant/import/var/strings.rb +43 -0
- data/lib/rant/import.rb +19 -3
- data/lib/rant/node.rb +39 -6
- data/lib/rant/rantlib.rb +44 -8
- data/lib/rant/rantsys.rb +22 -54
- data/lib/rant/rantvar.rb +89 -256
- data/misc/TODO +18 -0
- data/misc/devel-notes +26 -1
- data/test/action.rant +24 -0
- data/test/deprecated/test_0_5_4.rb +53 -0
- data/test/deprecated/test_0_6_0.rb +1 -1
- data/test/dryrun/Rantfile +10 -0
- data/test/dryrun/foo.c +8 -0
- data/test/dryrun/test_dryrun.rb +31 -0
- data/test/import/c/dependencies/Rantfile +1 -1
- data/test/import/command/Rantfile +1 -1
- data/test/import/sys/test_tgz.rb +22 -0
- data/test/subdirs2/root.rant +11 -1
- data/test/subdirs2/sub1/sub.rant +3 -0
- data/test/subdirs2/test_subdirs2.rb +19 -0
- data/test/test_action.rb +75 -0
- data/test/test_filelist.rb +13 -10
- data/test/test_rant_interface.rb +2 -2
- data/test/test_rule.rb +121 -3
- data/test/test_sys_methods.rb +558 -0
- data/test/test_var.rb +10 -0
- data/test/tutil.rb +81 -8
- metadata +19 -2
data/NEWS
CHANGED
@@ -1,6 +1,37 @@
|
|
1
1
|
|
2
2
|
= Rant NEWS
|
3
3
|
|
4
|
+
== Rant 0.5.0
|
5
|
+
|
6
|
+
Incompatible changes:
|
7
|
+
* The undocumented filelist methods +no_file+, +no_suffix+ and
|
8
|
+
+no_prefix+ require <tt>import "filelist/more"</tt> now.
|
9
|
+
|
10
|
+
Deprecated:
|
11
|
+
* The undocumented <tt>var.is</tt> method. It won't be in release
|
12
|
+
0.5.4 and later.
|
13
|
+
* To use a (numeric) range as variable constraint, you should
|
14
|
+
explicitely <tt>import "var/numbers"</tt> now. Also explicitely
|
15
|
+
<tt>import "var/strings"</tt> to use the <tt>:String</tt>
|
16
|
+
constraint and <tt>import "var/booleans"</tt> to use the
|
17
|
+
<tt>:Bool</tt> constraint. Read <em>Constraining variables</em> in
|
18
|
+
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html].
|
19
|
+
|
20
|
+
Fixes and minor improvements:
|
21
|
+
* Fix a few warnings from ruby 1.8.0/1.8.1.
|
22
|
+
* Prevent infinite rule recursion.
|
23
|
+
* Documentation for common file system operations and path
|
24
|
+
manipulation methods. Read
|
25
|
+
doc/sys.rdoc[link:files/doc/sys_rdoc.html].
|
26
|
+
|
27
|
+
New features:
|
28
|
+
* The <tt>--dry-run</tt> (<tt>-n</tt>) option for +rant+. Read
|
29
|
+
doc/rant.rdoc[link:files/doc/rant_rdoc.html].
|
30
|
+
* +Action+ takes a regular expression now. When rant looks for a
|
31
|
+
task/file that matches the regular expression, the action block will
|
32
|
+
get executed once. Read <em>More selective actions</em> in
|
33
|
+
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html].
|
34
|
+
|
4
35
|
== Rant 0.4.8
|
5
36
|
|
6
37
|
Incompatible changes:
|
data/README
CHANGED
@@ -42,7 +42,7 @@ Running rant in the directory of this file:
|
|
42
42
|
will ensure that the "data" file in the "backup" directory is up to
|
43
43
|
date.
|
44
44
|
|
45
|
-
This document was written for version 0.
|
45
|
+
This document was written for version 0.5.0 of Rant. Most things
|
46
46
|
described here will work for older/newer versions of Rant, but look at
|
47
47
|
the README file in the Rant distribution you've installed for exact
|
48
48
|
documentation of your Rant version.
|
@@ -90,6 +90,8 @@ Using the Configure plugin::
|
|
90
90
|
read doc/configure.rdoc[link:files/doc/configure_rdoc.html]
|
91
91
|
Compiling C#::
|
92
92
|
read doc/csharp.rdoc[link:files/doc/csharp_rdoc.html]
|
93
|
+
Common file system operations::
|
94
|
+
read doc/sys.rdoc[link:files/doc/sys_rdoc.html]
|
93
95
|
Upgrading::
|
94
96
|
read the NEWS[link:files/NEWS.html] for new features, not
|
95
97
|
backwards compatible changes and other issues.
|
data/Rantfile
CHANGED
@@ -35,6 +35,10 @@ gen RubyPackage, "rant#{var :pkg_ext}" do |t|
|
|
35
35
|
t.package_task
|
36
36
|
end
|
37
37
|
|
38
|
+
task "dist-files" do
|
39
|
+
puts dist_files
|
40
|
+
end
|
41
|
+
|
38
42
|
desc "Generate documentation."
|
39
43
|
gen RubyDoc do |g|
|
40
44
|
g.verbose = true
|
@@ -140,7 +144,7 @@ task :t180 do |t|
|
|
140
144
|
# my installed testrb version doesn't work with ruby-1.8.0
|
141
145
|
sys.cd "test"
|
142
146
|
if var[:TEST]
|
143
|
-
sys "ruby180", "-rtest/unit", "-I", sys.expand_path("@lib"),
|
147
|
+
sys "ruby180", "-w", "-rtest/unit", "-I", sys.expand_path("@lib"),
|
144
148
|
"-I", sys.expand_path("."), var[:TEST].sub(/^test\//, '')
|
145
149
|
else
|
146
150
|
sys "ruby180 ts_all.rb"
|
@@ -213,11 +217,58 @@ task "fetch-svn-dump" do
|
|
213
217
|
require 'uri'
|
214
218
|
url = URI.parse("http://svn.berlios.de/svndumps/rant-repos.gz")
|
215
219
|
req = Net::HTTP::Get.new(url.path)
|
220
|
+
ds = Time.now.strftime("%Y-%m-%d")
|
216
221
|
puts "Starting download from: #{url}"
|
217
222
|
res = Net::HTTP.start(url.host, url.port) { |http|
|
218
223
|
http.request(req)
|
219
224
|
}
|
220
|
-
sys.write_to_file "../rant-
|
225
|
+
sys.write_to_file "../rant-repos_#{ds}.gz", res.body
|
226
|
+
end
|
227
|
+
|
228
|
+
task "rb-stats" do
|
229
|
+
files = sys["lib/**/*.rb"]
|
230
|
+
lines = 0
|
231
|
+
code_lines = 0
|
232
|
+
files.each { |fn|
|
233
|
+
l, c = count_rb_lines(fn)
|
234
|
+
lines += l
|
235
|
+
code_lines += c
|
236
|
+
}
|
237
|
+
puts "Number of Ruby files under lib/: #{files.size}"
|
238
|
+
puts " #{lines} total lines"
|
239
|
+
puts " #{code_lines} LOC"
|
240
|
+
|
241
|
+
files.exclude(%r{^lib/rant/archive})
|
242
|
+
|
243
|
+
lines = 0
|
244
|
+
code_lines = 0
|
245
|
+
files.each { |fn|
|
246
|
+
l, c = count_rb_lines(fn)
|
247
|
+
lines += l
|
248
|
+
code_lines += c
|
249
|
+
}
|
250
|
+
puts " without lib/rant/archive/: #{files.size}"
|
251
|
+
puts " #{lines} total lines"
|
252
|
+
puts " #{code_lines} LOC"
|
253
|
+
end
|
254
|
+
|
255
|
+
def count_rb_lines(fn)
|
256
|
+
lines = 0
|
257
|
+
code_lines = 0
|
258
|
+
in_multiline_comment = false
|
259
|
+
File.readlines(fn).each { |line|
|
260
|
+
lines += 1
|
261
|
+
case line
|
262
|
+
when /=end(\s|$)/:
|
263
|
+
in_multiline_comment = false
|
264
|
+
next
|
265
|
+
when /^\s*$/, /^\s*#/: next
|
266
|
+
when /^=begin(\s|$)/
|
267
|
+
in_multiline_comment = true
|
268
|
+
end
|
269
|
+
code_lines += 1 unless in_multiline_comment
|
270
|
+
}
|
271
|
+
[lines, code_lines]
|
221
272
|
end
|
222
273
|
|
223
274
|
# vim:ft=ruby
|
data/doc/advanced.rdoc
CHANGED
@@ -47,7 +47,7 @@ any directory/file named "CVS" or ending in ~. Examples would be:
|
|
47
47
|
xy~
|
48
48
|
src/util.c~
|
49
49
|
|
50
|
-
===
|
50
|
+
=== Selecting files with filelists
|
51
51
|
|
52
52
|
The sys[] operator actually returns a _filelist_ object, which behaves
|
53
53
|
similar to an array. There are many methods for filelist objects, here
|
@@ -195,6 +195,7 @@ tasks and adds them as prerequisites to the final file task.
|
|
195
195
|
Rant allows you to constrain variables which are managed by the +var+
|
196
196
|
command (and thus can be set from the commandline):
|
197
197
|
|
198
|
+
import "var/numbers"
|
198
199
|
var :count, 0..10
|
199
200
|
|
200
201
|
This initializes the variable +count+ to 0 and restricts it to the
|
@@ -221,9 +222,11 @@ And now try to set the count variable from the commandline:
|
|
221
222
|
|
222
223
|
Other available constraints:
|
223
224
|
|
225
|
+
import "var/strings"
|
224
226
|
# variable str is ensured to be a string
|
225
227
|
var :str, :String
|
226
228
|
|
229
|
+
import "var/booleans"
|
227
230
|
# variable b is a bool (always true or false)
|
228
231
|
# can be set to "yes", "no", "1", "0", "true", "false"
|
229
232
|
var :b, :Bool
|
@@ -284,6 +287,88 @@ it plain in the Rantfile.
|
|
284
287
|
An Action block also won't be run when our Rantfile is read by
|
285
288
|
rant-import.
|
286
289
|
|
290
|
+
=== More selective actions
|
291
|
+
|
292
|
+
If a regular expression is given as argument to the Action generator,
|
293
|
+
the block will be executed the first time Rant searches for a task
|
294
|
+
matching this regular expression.
|
295
|
+
|
296
|
+
An artifical example:
|
297
|
+
|
298
|
+
import "sys/more"
|
299
|
+
|
300
|
+
gen Action, /\.t$/ do
|
301
|
+
puts "executing action for files/tasks ending in `.t'"
|
302
|
+
source "t.rant"
|
303
|
+
end
|
304
|
+
|
305
|
+
file "t.rant" do |t|
|
306
|
+
sys.write_to_file t.name, <<-EOF
|
307
|
+
task "a.t" do
|
308
|
+
puts "making a.t"
|
309
|
+
end
|
310
|
+
task "b.t" do
|
311
|
+
puts "making b.t"
|
312
|
+
end
|
313
|
+
EOF
|
314
|
+
end
|
315
|
+
|
316
|
+
task :a do
|
317
|
+
puts "making a"
|
318
|
+
end
|
319
|
+
|
320
|
+
task :default => ["a", "a.t", "b.t"]
|
321
|
+
|
322
|
+
Running rant:
|
323
|
+
|
324
|
+
% rant
|
325
|
+
making a
|
326
|
+
executing action for files/tasks ending in `.t'
|
327
|
+
writing 128 bytes to file `t.rant'
|
328
|
+
making a.t
|
329
|
+
making b.t
|
330
|
+
|
331
|
+
rant performed the following steps:
|
332
|
+
|
333
|
+
1. Invoke task +default+
|
334
|
+
|
335
|
+
2. Invoke first prerequisite of +default+, which happens to be +a+.
|
336
|
+
|
337
|
+
3. Execute action block of task +a+.
|
338
|
+
|
339
|
+
Output: "making a"
|
340
|
+
|
341
|
+
4. Search for a task for the second prerequisite of +default+, which
|
342
|
+
happens to be <tt>a.t</tt>.
|
343
|
+
|
344
|
+
5. Since no task with the name <tt>a.t</tt> exists, it checks for a
|
345
|
+
matching action/rule. The only defined action matches, so the
|
346
|
+
action block is executed.
|
347
|
+
|
348
|
+
Output: "executing action for files/tasks ending in `.t'"
|
349
|
+
|
350
|
+
6. The action block contains a +source+ statement, which will first
|
351
|
+
cause a build of <tt>t.rant</tt>.
|
352
|
+
|
353
|
+
Output: "writing 128 bytes to file `t.rant'"
|
354
|
+
|
355
|
+
After the build, <tt>t.rant</tt> will be read as Rantfile.
|
356
|
+
|
357
|
+
7. The action block is done, the action is "deleted".
|
358
|
+
|
359
|
+
8. Now, Rant finds a task with the name <tt>a.t</tt>, invokes it and
|
360
|
+
executes the associated ruby block.
|
361
|
+
|
362
|
+
Output: "making a.t"
|
363
|
+
|
364
|
+
9. Invoke last prerequisite of +default+, which happens to be
|
365
|
+
<tt>b.t</tt> and execute the associated ruby block.
|
366
|
+
|
367
|
+
Output: "making b.t"
|
368
|
+
|
369
|
+
Generally, an action is usable to autogenerate a (bigger) set of tasks
|
370
|
+
that are needed by a subset of other tasks.
|
371
|
+
|
287
372
|
== See also
|
288
373
|
|
289
374
|
Rantfile basics::
|
data/doc/c.rdoc
CHANGED
@@ -50,6 +50,14 @@ And a good habit would be to wrap the +source+ expression in an
|
|
50
50
|
# invoked.
|
51
51
|
gen Action do source "c_dependencies" end
|
52
52
|
|
53
|
+
or more selective:
|
54
|
+
|
55
|
+
gen C::Dependencies
|
56
|
+
|
57
|
+
# Do dependency checking when Rant looks at the first file
|
58
|
+
# ending in ".h" or ".c"
|
59
|
+
gen Action, /\.(h|c)$/ do source "c_dependencies" end
|
60
|
+
|
53
61
|
For a little example project using the C::Dependency generator look
|
54
62
|
into the doc/examples/c_dependencies[link:../examples/c_dependencies]
|
55
63
|
directory of the Rant distribution.
|
data/doc/homepage/index.html
CHANGED
@@ -90,6 +90,8 @@
|
|
90
90
|
href="http://rubyforge.org/tracker/?func=add&group_id=615&atid=2428">Report a bug</a><br/>
|
91
91
|
<a title="Subversion repository for Rant development"
|
92
92
|
href="http://developer.berlios.de/svn/?group_id=5046">Repository</a><br/>
|
93
|
+
<a title="Browse source code repository."
|
94
|
+
href="http://svn.berlios.de/wsvn/rant">WebSVN</a><br/>
|
93
95
|
</p>
|
94
96
|
</div>
|
95
97
|
|
data/doc/rant.1
CHANGED
@@ -115,6 +115,10 @@ target.
|
|
115
115
|
.TP
|
116
116
|
--force-run TARGET -a TARGET
|
117
117
|
Force rebuild of TARGET and all dependencies.
|
118
|
+
.TP
|
119
|
+
--dry-run -n
|
120
|
+
Print the names of the tasks that would be executed instead
|
121
|
+
of actually executing task actions.
|
118
122
|
.TP
|
119
123
|
--tasks -T
|
120
124
|
Show a list of all described tasks and exit.
|
data/doc/rant.rdoc
CHANGED
@@ -40,6 +40,44 @@ steps (roughly):
|
|
40
40
|
invoked. If the "default" task doesn't exist, the first task will
|
41
41
|
be invoked.
|
42
42
|
|
43
|
+
=== Dry-Run
|
44
|
+
|
45
|
+
If you run rant in dry-run mode, it will print the actions it would
|
46
|
+
execute instead of actually executing them. This can be useful in
|
47
|
+
debugging your Rantfiles. To enable it, give the <tt>--dry-run</tt>,
|
48
|
+
option or its short form, <tt>-n</tt>, on the commandline.
|
49
|
+
|
50
|
+
Example Rantfile:
|
51
|
+
|
52
|
+
import "command"
|
53
|
+
|
54
|
+
task :install => "foo" do
|
55
|
+
sys.install "foo", "/usr/local/bin", :mode => 0755
|
56
|
+
end
|
57
|
+
|
58
|
+
gen Command, "foo", "foo.c", "cc -o $(>) $(<)"
|
59
|
+
|
60
|
+
Running rant in dry-run mode:
|
61
|
+
|
62
|
+
% rant -n
|
63
|
+
Executing "foo"
|
64
|
+
- SHELL
|
65
|
+
cc -o foo foo.c
|
66
|
+
Executing "install"
|
67
|
+
- Ruby Proc at Rantfile:3
|
68
|
+
|
69
|
+
Running rant in "normal" mode:
|
70
|
+
|
71
|
+
% rant
|
72
|
+
cc -o foo foo.c
|
73
|
+
install -c -m 0755 foo /usr/local/bin
|
74
|
+
|
75
|
+
Running rant in dry-run mode again:
|
76
|
+
|
77
|
+
% rant -n
|
78
|
+
Executing "install"
|
79
|
+
- Ruby Proc at Rantfile:3
|
80
|
+
|
43
81
|
== See also
|
44
82
|
|
45
83
|
Rant Overview::
|
data/doc/rant_vs_rake.rdoc
CHANGED
@@ -83,6 +83,19 @@ Rake:
|
|
83
83
|
3. The command (most probably +CFLAGS+) changed since the last build
|
84
84
|
of +foo+.
|
85
85
|
|
86
|
+
* Dependency checking for C/C++ source files
|
87
|
+
|
88
|
+
import "c/dependencies"
|
89
|
+
|
90
|
+
# save dependencies between source/header files in the file
|
91
|
+
# "cdeps"; search for include files in "." and "include" dirs
|
92
|
+
gen C::Dependencies, "cdeps"
|
93
|
+
:search => [".", "include"]
|
94
|
+
|
95
|
+
|
96
|
+
# load dependency information when Rant looks at a C file
|
97
|
+
gen Action, /\.(c|h)/ do source "cdeps" end
|
98
|
+
|
86
99
|
Some other goodies: The +make+ method, the SubFile and AutoClean
|
87
100
|
tasks, special variables and more. Most of this is documented in
|
88
101
|
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html]
|