rant 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/README +203 -0
- data/Rantfile +104 -0
- data/TODO +19 -0
- data/bin/rant +12 -0
- data/bin/rant-import +12 -0
- data/devel-notes +50 -0
- data/doc/configure.rdoc +40 -0
- data/doc/csharp.rdoc +74 -0
- data/doc/rant-import.rdoc +32 -0
- data/doc/rant.rdoc +24 -0
- data/doc/rantfile.rdoc +227 -0
- data/doc/rubyproject.rdoc +210 -0
- data/lib/rant.rb +9 -0
- data/lib/rant/cs_compiler.rb +334 -0
- data/lib/rant/import.rb +291 -0
- data/lib/rant/import/rubydoc.rb +125 -0
- data/lib/rant/import/rubypackage.rb +417 -0
- data/lib/rant/import/rubytest.rb +97 -0
- data/lib/rant/plugin/README +50 -0
- data/lib/rant/plugin/configure.rb +345 -0
- data/lib/rant/plugin/csharp.rb +275 -0
- data/lib/rant/plugin_methods.rb +41 -0
- data/lib/rant/rantenv.rb +217 -0
- data/lib/rant/rantfile.rb +664 -0
- data/lib/rant/rantlib.rb +1118 -0
- data/lib/rant/rantsys.rb +258 -0
- data/lib/rant/rantvar.rb +82 -0
- data/rantmethods.rb +79 -0
- data/run_import +7 -0
- data/run_rant +7 -0
- data/setup.rb +1360 -0
- data/test/Rantfile +2 -0
- data/test/plugin/configure/Rantfile +47 -0
- data/test/plugin/configure/test_configure.rb +58 -0
- data/test/plugin/csharp/Hello.cs +10 -0
- data/test/plugin/csharp/Rantfile +30 -0
- data/test/plugin/csharp/src/A.cs +8 -0
- data/test/plugin/csharp/src/B.cs +8 -0
- data/test/plugin/csharp/test_csharp.rb +99 -0
- data/test/project1/Rantfile +127 -0
- data/test/project1/test_project.rb +203 -0
- data/test/project2/buildfile +14 -0
- data/test/project2/rantfile.rb +20 -0
- data/test/project2/sub1/Rantfile +12 -0
- data/test/project2/test_project.rb +87 -0
- data/test/project_rb1/README +14 -0
- data/test/project_rb1/bin/wgrep +5 -0
- data/test/project_rb1/lib/wgrep.rb +56 -0
- data/test/project_rb1/rantfile.rb +30 -0
- data/test/project_rb1/test/tc_wgrep.rb +21 -0
- data/test/project_rb1/test/text +3 -0
- data/test/project_rb1/test_project_rb1.rb +153 -0
- data/test/test_env.rb +47 -0
- data/test/test_filetask.rb +57 -0
- data/test/test_lighttask.rb +49 -0
- data/test/test_metatask.rb +29 -0
- data/test/test_rant_interface.rb +65 -0
- data/test/test_sys.rb +61 -0
- data/test/test_task.rb +115 -0
- data/test/toplevel.rf +11 -0
- data/test/ts_all.rb +4 -0
- data/test/tutil.rb +95 -0
- metadata +133 -0
data/doc/csharp.rdoc
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
== Compiling C# sources
|
3
|
+
|
4
|
+
Support for C# is currently implemented as plugin. But expect that to
|
5
|
+
change in the near future. Also note that support for C# wasn't
|
6
|
+
heavily tested (but it works because I'm using it).
|
7
|
+
|
8
|
+
It is convinient to use the C# plugin in combination with the
|
9
|
+
Configure plugin. I'll show a short Rantfile first and explain it
|
10
|
+
afterwards.
|
11
|
+
|
12
|
+
conf = plugin :Configure do |conf|
|
13
|
+
desc "Configure build."
|
14
|
+
conf.task
|
15
|
+
desc "Interactive configure."
|
16
|
+
conf.task "ask-config", [:interact]
|
17
|
+
conf.init_modes = [:guess, :interact]
|
18
|
+
end
|
19
|
+
|
20
|
+
plugin :Csharp do |cs|
|
21
|
+
cs.config = conf
|
22
|
+
end
|
23
|
+
|
24
|
+
gen Assembly, "myprog.exe" do |t|
|
25
|
+
t.libs = %w(System.Drawing.dll System.Windows.Forms.dll)
|
26
|
+
t.sources = Dir["src/*.cs"]
|
27
|
+
t.resources = Dir["res/*.*"]
|
28
|
+
end
|
29
|
+
|
30
|
+
First we instantiate the Configure plugin and let it define two tasks
|
31
|
+
for us:
|
32
|
+
<tt>conf.task</tt>:: Creates a task with the name "configure" which
|
33
|
+
will first guess values and ask the user as
|
34
|
+
fallback if it can't guess the value.
|
35
|
+
<tt>conf.task "ask-config", [:interact]</tt>::
|
36
|
+
This task interactively asks the user for all values.
|
37
|
+
Afterwards we set the +init_modes+. Those decide what will be done on
|
38
|
+
a regular rant startup if the +config+ file doesn't exist. We tell it
|
39
|
+
to first guess configure values and to fall back to interactive mode
|
40
|
+
if necessary.
|
41
|
+
|
42
|
+
Then we instantiate the Csharp plugin and connect it with the
|
43
|
+
Configure plugin. As a result of this operation, the Csharp plugin
|
44
|
+
will define three configure _checks_:
|
45
|
+
1. The command to invoke the C# compiler.
|
46
|
+
2. If optimization should be turned on.
|
47
|
+
3. If debug information should be generated.
|
48
|
+
|
49
|
+
And last but not least we let generate a task to compile our program
|
50
|
+
<tt>myprog.exe</tt>. The +Assembly+ generator takes the same argument
|
51
|
+
as a normal task, meaning you could also add prerequisites:
|
52
|
+
gen Assembly, "myprog.exe" => :pre do |t|
|
53
|
+
.
|
54
|
+
.
|
55
|
+
.
|
56
|
+
The +libs+ attribute is a list of libraries the assembly will be
|
57
|
+
linked against, the +sources+ attribute should be clear and the
|
58
|
+
+resources+ attribute is a list of resources to be embedded in the
|
59
|
+
assembly.
|
60
|
+
|
61
|
+
Now let's see what is actually done by rant when we feed it this
|
62
|
+
Rantfile. Because we have only one task defined, there is no need to
|
63
|
+
specify a task on the commandline:
|
64
|
+
% rant
|
65
|
+
cscc -o myprog.exe -Wall -O2 -l System.Drawing.dll -l System.Windows.Forms.dll -fresources=res/MyProg.legend.png src/MyProg.cs src/Util.cs
|
66
|
+
This was on a Linux system, on Windows you'll probably see a command
|
67
|
+
with csc.
|
68
|
+
|
69
|
+
== See also
|
70
|
+
|
71
|
+
Rant Overview::
|
72
|
+
README[link:files/README.html]
|
73
|
+
Writing an Rantfile::
|
74
|
+
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
== The rant-import command
|
3
|
+
|
4
|
+
The rant-import command creates a monolithic rant script tailored to
|
5
|
+
the needs of your project and thus removes the dependency on an Rant
|
6
|
+
installation (but of course one person needs an Rant installation to
|
7
|
+
run rant-import).
|
8
|
+
|
9
|
+
Just run the command with the <tt>--help</tt> option to get a brief
|
10
|
+
help message:
|
11
|
+
% rant-import --help
|
12
|
+
|
13
|
+
Probably the easiest way to create your monolithic rant script is with
|
14
|
+
the <tt>--auto</tt> option:
|
15
|
+
% rant-import --auto ant
|
16
|
+
This will write a monolithic rant script to the file +ant+ in the
|
17
|
+
current directory. To determine which plugins and imports your project
|
18
|
+
is using, it performs step 2 of the rant command as described in
|
19
|
+
doc/rant.rdoc[link:files/doc/rant_rdoc.html], which means that it
|
20
|
+
loads the Rantfile in the current directory.
|
21
|
+
|
22
|
+
That one command should be enough, try it out:
|
23
|
+
% ruby ant
|
24
|
+
This script has the same behaviour as the rant command. Distribute it
|
25
|
+
with your project and nobody else but you needs an Rant installation.
|
26
|
+
|
27
|
+
== See also
|
28
|
+
|
29
|
+
Rant Overview::
|
30
|
+
README[link:files/README.html]
|
31
|
+
Writing an Rantfile::
|
32
|
+
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|
data/doc/rant.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
== The *rant* program
|
3
|
+
|
4
|
+
For a short usage message and a list of options invoke rant with the
|
5
|
+
<tt>--help</tt> option:
|
6
|
+
% rant --help
|
7
|
+
|
8
|
+
When you invoke rant on the commandline it performs the following
|
9
|
+
steps (roughly):
|
10
|
+
|
11
|
+
1. Process commandline options and arguments.
|
12
|
+
An option starts with two dashes or one for the single letter
|
13
|
+
equivalent. Arguments of the form <tt>VAR=VAL</tt> set environment
|
14
|
+
variables. All other arguments are names of tasks to be invoked.
|
15
|
+
2. Load Rantfiles in working directory. Rantfiles with the following
|
16
|
+
names are recognized:
|
17
|
+
Rantfile
|
18
|
+
rantfile
|
19
|
+
Rantfile.rb
|
20
|
+
rantfile.rb
|
21
|
+
3. Calculate task dependencies and invoke required tasks. If no task
|
22
|
+
was given on the commandline, a task called "default" will be
|
23
|
+
invoked. If the "default" task doesn't exist, the first task will
|
24
|
+
be invoked.
|
data/doc/rantfile.rdoc
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
|
2
|
+
== How to write an *Rantfile*
|
3
|
+
|
4
|
+
As already mentioned, an Rantfile is a Ruby script. Additionally, Rant
|
5
|
+
provides methods and classes which aid you in automating your work.
|
6
|
+
|
7
|
+
Centric to the processing done by Rant is the *task*. The Rantfile
|
8
|
+
defines tasks and their dependencies, Rant invokes the required tasks.
|
9
|
+
|
10
|
+
Also important is the <b>Rant application</b>. When the rant command
|
11
|
+
starts, it instantiates one Rant application which will read one or
|
12
|
+
more Rantfiles. The Rantfile communicates with the following list of
|
13
|
+
methods with the Rant application:
|
14
|
+
|
15
|
+
+task+:: Defines a task with prerequisites and an action.
|
16
|
+
+file+:: A special form of task which creates one file.
|
17
|
+
+desc+:: Describes the next defined task. A task with
|
18
|
+
description is considered a "public" task.
|
19
|
+
+gen+:: Takes a _generator_ object as first argument which
|
20
|
+
usually creates one or more tasks. An example would be
|
21
|
+
the +RubyPackage+ generator which produces tasks for
|
22
|
+
packaging.
|
23
|
+
+import+:: Imports additional code which usually provides
|
24
|
+
additional generators. Example: to use the
|
25
|
+
+RubyPackage+ generator you have to <tt>import
|
26
|
+
"rubypackage"</tt> first.
|
27
|
+
+plugin+:: Instantiate a plugin. Example: <tt>plugin
|
28
|
+
:Configure</tt> instantiates the Configure plugin.
|
29
|
+
+sys+:: When given argument(s), runs an external program.
|
30
|
+
Otherwise you can call methods to interact with the OS
|
31
|
+
on it.
|
32
|
+
+source+:: Takes a filename as argument and causes Rant to read
|
33
|
+
it in as Rantfile.
|
34
|
+
|
35
|
+
=== Defining a task
|
36
|
+
|
37
|
+
Just call the +task+ function and give it a task name as argument. The
|
38
|
+
task name may be a string or symbol:
|
39
|
+
task :taskname
|
40
|
+
That's it, your first task. Not very usefull, because it doesn't do
|
41
|
+
anything. To associate an action with the task, add a block:
|
42
|
+
task :mytask do
|
43
|
+
puts "Hello, mytask running."
|
44
|
+
end
|
45
|
+
Put these 3 lines of code into an Rantfile and run rant:
|
46
|
+
% rant mytask
|
47
|
+
Hello, mytask running.
|
48
|
+
Note: you could have ommited the mytask argument to rant because it is
|
49
|
+
the only task in the Rantfile.
|
50
|
+
|
51
|
+
You can add a block parameter which will be a reference to the created
|
52
|
+
task:
|
53
|
+
task :mytask do |t|
|
54
|
+
puts t.name
|
55
|
+
end
|
56
|
+
Running rant now:
|
57
|
+
% rant
|
58
|
+
mytask
|
59
|
+
|
60
|
+
Add prerequisites to create relations between tasks:
|
61
|
+
task :first => [:t1, :t2] do
|
62
|
+
puts t.name
|
63
|
+
end
|
64
|
+
task :t1 do |t|
|
65
|
+
puts t.name
|
66
|
+
end
|
67
|
+
task :t2 do |t|
|
68
|
+
puts t.name
|
69
|
+
end
|
70
|
+
In the definition of the "first" task we told Rant that it +depends+
|
71
|
+
on task "t1" and task "t2". "t1" and "t2" are called prerequisites for
|
72
|
+
"first". Try it out:
|
73
|
+
% rant first
|
74
|
+
t1
|
75
|
+
t2
|
76
|
+
first
|
77
|
+
% rant t1
|
78
|
+
t1
|
79
|
+
% rant t2
|
80
|
+
t2
|
81
|
+
|
82
|
+
=== Defining a file task
|
83
|
+
|
84
|
+
You will notice that rant will run the actions for a normal task
|
85
|
+
always its name is given on the commandline or it is required by
|
86
|
+
another task. Often you want to create a file, e.g. a program by
|
87
|
+
invoking a compiler. In this case, the action needs only to be run if
|
88
|
+
the source files (prerequisites) have changed. Use a file task instead
|
89
|
+
of a normal task.
|
90
|
+
|
91
|
+
In this example we use the <tt>sys.touch</tt> method to test our file
|
92
|
+
task. (This method works the same as the Unix touch command: Update
|
93
|
+
the modification time of a file or create an empty file):
|
94
|
+
file "testfile" do |t|
|
95
|
+
sys.touch t.name
|
96
|
+
end
|
97
|
+
Now run rant:
|
98
|
+
% rant
|
99
|
+
touch testfile
|
100
|
+
This would have been the same with a normal task. But now run rant a
|
101
|
+
second time:
|
102
|
+
% rant
|
103
|
+
This time rant doesn't run the action, because "testfile" is up to
|
104
|
+
date. Of course you can add prerequisites the same way as for a normal
|
105
|
+
task. Additionally you can add filenames as prerequisites. Assuming
|
106
|
+
the files "a.o" and "b.o" are in the same directory as the Rantfile:
|
107
|
+
file "myprog" => %w(a.o b.o) do |t|
|
108
|
+
sys %w(cc -o), t.name, t.prerequisites
|
109
|
+
end
|
110
|
+
Running rant:
|
111
|
+
% rant
|
112
|
+
cc -o myprog a.o b.o
|
113
|
+
Running a second time:
|
114
|
+
% rant
|
115
|
+
Does nothing, myprog is up to date.
|
116
|
+
Don't be irritated by the <tt>%w()</tt> syntax. It creates a list of
|
117
|
+
strings. The following expressions are equivalent:
|
118
|
+
["a", "b", "c"]
|
119
|
+
%w(a b c)
|
120
|
+
|
121
|
+
=== Adding task descriptions
|
122
|
+
|
123
|
+
The +desc+ function lets you describe your tasks. A small example
|
124
|
+
Rantfile:
|
125
|
+
# Generate C source file ls.c with the xgen command.
|
126
|
+
file "ls.c" => %w(ls1.x ls2.x) do |t|
|
127
|
+
sys %w(xgen -o), t.name, t.prerequisites
|
128
|
+
end
|
129
|
+
|
130
|
+
desc "Build ls program."
|
131
|
+
file "ls" => "ls.c" do
|
132
|
+
sys "cc -o ls ls.c"
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "Remove autogenerated files."
|
136
|
+
task :clean do
|
137
|
+
sys.rm_f %w(ls.c ls)
|
138
|
+
end
|
139
|
+
(Note that xgen is a hypothetical command ;)
|
140
|
+
The <tt>--tasks</tt> (or the short form, <tt>-T</tt>) option of rant
|
141
|
+
shows this descriptions:
|
142
|
+
% rant -T
|
143
|
+
rant ls # Build ls program.
|
144
|
+
rant clean # Remove autogenerated files.
|
145
|
+
Only the tasks which have a description are listed.
|
146
|
+
|
147
|
+
=== The +sys+ function
|
148
|
+
|
149
|
+
After using the +sys+ function quite often in the examples, I should
|
150
|
+
explain it a little bit. The +sys+ function can be used in two ways:
|
151
|
+
|
152
|
+
The first form is with no arguments. It returns an object on which you
|
153
|
+
can invoke the methods of the +FileUtils+ module that comes with ruby.
|
154
|
+
Examples are:
|
155
|
+
sys.rm "file1", "file2", ... # remove files
|
156
|
+
sys.cp "src", "dest" # copy from "src" do "dest"
|
157
|
+
sys.mkdir "dir" # create directory "dir"
|
158
|
+
For a list of all available methods invoke ri:
|
159
|
+
% ri FileUtils
|
160
|
+
which will also show documentation for them.
|
161
|
+
Additionally you have the following methos which are not in the
|
162
|
+
FileUtils module:
|
163
|
+
sys.ruby "arg1", "arg2", ... # invoke the ruby interpreter
|
164
|
+
sys.safe_ln "src", "dest" # create a hardlink or fall back to
|
165
|
+
# copying
|
166
|
+
If you're tired of typing <tt>sys.</tt> all the time, you can include
|
167
|
+
the +Sys+ module in your Rantfile:
|
168
|
+
include Sys
|
169
|
+
task :clean do
|
170
|
+
rm_f "myprog"
|
171
|
+
end
|
172
|
+
Then you can invoke these methods without the <tt>sys</tt> function.
|
173
|
+
|
174
|
+
=== Generators
|
175
|
+
|
176
|
+
The *gen* function takes a generator which usually creates one or more
|
177
|
+
tasks for you. Currently are two generators immediately available:
|
178
|
+
+Directory+:: Create directories.
|
179
|
+
+Task+:: Define custom task.
|
180
|
+
|
181
|
+
=== The +Directory+ generator
|
182
|
+
|
183
|
+
An example usage of the +Directory+ generator would be the backup
|
184
|
+
example shown in the README file:
|
185
|
+
file "misc/backup/data" => %w(misc/backup data) do |t|
|
186
|
+
sys.cp "data", t.name
|
187
|
+
end
|
188
|
+
|
189
|
+
gen Directory, "misc/backup"
|
190
|
+
Now rant will create the directories "misc" and "backup" on demand.
|
191
|
+
Assuming "misc/backup" doesn't exist:
|
192
|
+
% rant
|
193
|
+
mkdir misc
|
194
|
+
mkdir misc/backup
|
195
|
+
cp data misc/backup/data
|
196
|
+
|
197
|
+
=== The +Task+ generator
|
198
|
+
|
199
|
+
The +Task+ generator allows you to determine by hand when your task
|
200
|
+
action needs to be run:
|
201
|
+
desc "Install with setup.rb"
|
202
|
+
gen Task, :install do |t|
|
203
|
+
t.needed { !File.exist? "InstalledFiles" }
|
204
|
+
t.act do
|
205
|
+
sys.ruby "setup.rb"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
The +act+ block of the "install" task will only be run if
|
209
|
+
"InstalledFiles" doesn't exist. Of course you can add prerequisites
|
210
|
+
like with any other task.
|
211
|
+
|
212
|
+
=== Importing additional generators
|
213
|
+
|
214
|
+
The +import+ function lets you import additional generators.
|
215
|
+
Currently the following are coming with Rant:
|
216
|
+
+RubyTest+:: Run Test::Unit tests for your Ruby code.
|
217
|
+
+RubyDoc+:: Run RDoc.
|
218
|
+
+RubyPackage+:: Generate tar, zip and gem packages of your Ruby
|
219
|
+
application/library.
|
220
|
+
As these are all Ruby specific, please read the Ruby project howto.
|
221
|
+
|
222
|
+
== See also
|
223
|
+
|
224
|
+
Rant Overview::
|
225
|
+
README[link:files/README.html]
|
226
|
+
Ruby project howto::
|
227
|
+
doc/rubyproject.rdoc[link:files/doc/rubyproject_rdoc.html]
|
@@ -0,0 +1,210 @@
|
|
1
|
+
|
2
|
+
== Ruby project howto
|
3
|
+
|
4
|
+
This section is a brief howto for automating some common tasks like
|
5
|
+
running rdoc, unit tests and packaging.
|
6
|
+
|
7
|
+
We are assuming a project with the following directories and files:
|
8
|
+
Rantfile
|
9
|
+
README
|
10
|
+
bin/
|
11
|
+
wgrep
|
12
|
+
lib/
|
13
|
+
wgrep.rb
|
14
|
+
test/
|
15
|
+
tc_wgrep.rb
|
16
|
+
You can find this little project in test/project_rb1 directory of the
|
17
|
+
Rant package. You'll probably have more files in your project, but we
|
18
|
+
will try to write our Rantfile as generic as possible:
|
19
|
+
|
20
|
+
import %w(rubytest rubydoc rubypackage)
|
21
|
+
|
22
|
+
lib_files = Dir["lib/**/*.rb"]
|
23
|
+
dist_files = lib_files + %w(rantfile.rb README) + Dir["{test,bin}/*"]
|
24
|
+
|
25
|
+
desc "Run unit tests."
|
26
|
+
gen RubyTest do |t|
|
27
|
+
t.test_dir = "test"
|
28
|
+
t.pattern = "tc_*.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Generate html documentation."
|
32
|
+
gen RubyDoc do |t|
|
33
|
+
t.opts = %w(--title wgrep --main README README)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Create packages."
|
37
|
+
gen RubyPackage, :wgrep do |t|
|
38
|
+
t.version = "1.0.0"
|
39
|
+
t.summary = "Simple grep program."
|
40
|
+
t.files = dist_files
|
41
|
+
t.bindir = "bin"
|
42
|
+
t.executable = "wgrep"
|
43
|
+
t.package_task
|
44
|
+
end
|
45
|
+
|
46
|
+
task :clean do
|
47
|
+
sys.rm_rf %w(doc pkg)
|
48
|
+
end
|
49
|
+
|
50
|
+
To verify how our tasks are named:
|
51
|
+
% rant -T
|
52
|
+
rant test # Run unit tests.
|
53
|
+
rant doc # Generate html documentation.
|
54
|
+
rant package # Create packages.
|
55
|
+
|
56
|
+
Let's examine the code by running the tasks:
|
57
|
+
% rant test
|
58
|
+
cd test
|
59
|
+
ruby -I /home/stefan/Ruby/lib/rant/test/project_rb1/lib -S testrb tc_wgrep.rb
|
60
|
+
Loaded suite tc_wgrep.rb
|
61
|
+
Started
|
62
|
+
.
|
63
|
+
Finished in 0.004588 seconds.
|
64
|
+
|
65
|
+
1 tests, 2 assertions, 0 failures, 0 errors
|
66
|
+
cd -
|
67
|
+
The +RubyTest+ generator automatically added the +lib+ directory to
|
68
|
+
the LOAD_PATH for testing. Because we have set the +test_dir+ to
|
69
|
+
"test", it changes to the +test+ directory, evaluates the +pattern+ to
|
70
|
+
collect the testcases and then runs the _testrb_ command.
|
71
|
+
|
72
|
+
To format the documentation:
|
73
|
+
% rant doc
|
74
|
+
|
75
|
+
README:
|
76
|
+
wgrep.rb: mcc....
|
77
|
+
Generating HTML...
|
78
|
+
|
79
|
+
Files: 2
|
80
|
+
Classes: 2
|
81
|
+
Modules: 1
|
82
|
+
Methods: 4
|
83
|
+
Elapsed: 0.335s
|
84
|
+
All of this output originates from RDoc. The +RubyDoc+ generator gives
|
85
|
+
the +lib+ directory and additionally the +opts+ we have set to RDoc.
|
86
|
+
|
87
|
+
The most interesting task is the +package+ task:
|
88
|
+
% rant package
|
89
|
+
mkdir pkg
|
90
|
+
mkdir pkg/wgrep-1.0.0
|
91
|
+
mkdir -p pkg/wgrep-1.0.0/lib
|
92
|
+
mkdir -p pkg/wgrep-1.0.0/test
|
93
|
+
mkdir -p pkg/wgrep-1.0.0/bin
|
94
|
+
ln lib/wgrep.rb pkg/wgrep-1.0.0/lib/wgrep.rb
|
95
|
+
ln rantfile.rb pkg/wgrep-1.0.0/rantfile.rb
|
96
|
+
ln README pkg/wgrep-1.0.0/README
|
97
|
+
ln test/text pkg/wgrep-1.0.0/test/text
|
98
|
+
ln test/tc_wgrep.rb pkg/wgrep-1.0.0/test/tc_wgrep.rb
|
99
|
+
ln bin/wgrep pkg/wgrep-1.0.0/bin/wgrep
|
100
|
+
touch pkg/wgrep-1.0.0
|
101
|
+
cd pkg
|
102
|
+
tar zcf wgrep-1.0.0.tar.gz wgrep-1.0.0
|
103
|
+
cd -
|
104
|
+
cd pkg
|
105
|
+
zip -yqr wgrep-1.0.0.zip wgrep-1.0.0
|
106
|
+
cd -
|
107
|
+
Successfully built RubyGem
|
108
|
+
Name: wgrep
|
109
|
+
Version: 1.0.0
|
110
|
+
File: wgrep-1.0.0.gem
|
111
|
+
mv wgrep-1.0.0.gem pkg
|
112
|
+
This is what it does on my machine:
|
113
|
+
1. Link all package files to the new folder <tt>pkg/wgrep-1.0.0</tt>.
|
114
|
+
2. Create a tar.gz file in the +pkg+ directory with the tar command.
|
115
|
+
3. Create a .zip file in the +pkg+ directory with the zip command.
|
116
|
+
4. Create a RubyGem in +pkg+.
|
117
|
+
The .zip file will only be created if the +zip+ command is available.
|
118
|
+
The .tar.gz file will only be created if the +tar+ command is
|
119
|
+
available. And the RubyGem will only be created if RubyGems is
|
120
|
+
available on your system.
|
121
|
+
|
122
|
+
The gem specification also contains the RDoc options we have given to
|
123
|
+
the +RubyDoc+ generator and the +has_rdoc+ attribute is set to true.
|
124
|
+
No need to duplicate this information in our Rantfile.
|
125
|
+
|
126
|
+
=== More about the RubyPackage generator
|
127
|
+
|
128
|
+
The argument given to the RubyPackage generator is used as package
|
129
|
+
name (here "wgrep") and may be a symbol or string:
|
130
|
+
gen RubyPackage, :wgrep do |t|
|
131
|
+
|
132
|
+
The line which actually creates the package task(s) is this one:
|
133
|
+
t.package_task
|
134
|
+
Optionally you may give it a task name as argument:
|
135
|
+
t.package_task :release
|
136
|
+
Now you can run rant with the argument "release" for packaging:
|
137
|
+
% rant release
|
138
|
+
|
139
|
+
If you want to change the package directory (which defaults to +pkg+)
|
140
|
+
you can set the +pkg_dir+ attribute:
|
141
|
+
t.pkg_dir = "packages"
|
142
|
+
t.package_task
|
143
|
+
|
144
|
+
Perhaps you want to specify explicetely what packages you want to
|
145
|
+
build. To accomplish this, each of the following methods listed takes
|
146
|
+
an optional task name as argument:
|
147
|
+
t.tar_task # create tar.gz archive, task name defaults to "tar"
|
148
|
+
t.zip_task # create zip archive, task name defaults to "zip"
|
149
|
+
t.gem_task # create gem, task name defaults to "gem"
|
150
|
+
An example would be:
|
151
|
+
desc "Create tar.gz package."
|
152
|
+
t.tar_task :archive
|
153
|
+
desc "Create RubyGem."
|
154
|
+
t.gem_task
|
155
|
+
# Not required: Creates a shortcut for the previously defined
|
156
|
+
# package tasks ("archive" and "gem")
|
157
|
+
desc "Create packages."
|
158
|
+
t.package_task
|
159
|
+
|
160
|
+
In our example we had only a few attributes for our package. Here are
|
161
|
+
following two lists with the available attributes.
|
162
|
+
* Attributes that take a single argument:
|
163
|
+
name
|
164
|
+
date
|
165
|
+
description
|
166
|
+
email
|
167
|
+
has_rdoc
|
168
|
+
homepage
|
169
|
+
platform
|
170
|
+
required_ruby_version
|
171
|
+
rubyforge_project
|
172
|
+
summary
|
173
|
+
version
|
174
|
+
* Attributes that take one or more values (if you give a single value
|
175
|
+
it will automatically be converted to a list):
|
176
|
+
author
|
177
|
+
bindir
|
178
|
+
executable
|
179
|
+
extension
|
180
|
+
files
|
181
|
+
rdoc_options
|
182
|
+
requires
|
183
|
+
test_files
|
184
|
+
test_suite
|
185
|
+
The attributes can also be set without the assignment operator:
|
186
|
+
t.executable "mybin"
|
187
|
+
|
188
|
+
Additionally to all this attributes you can explicitely set an
|
189
|
+
attribute for the gem specification by preceding it with +gem_+:
|
190
|
+
t.gem_autorequire = "myproject"
|
191
|
+
|
192
|
+
=== More about the RubyDoc generator
|
193
|
+
|
194
|
+
If an argument is given to the RubyDoc generator, it will be used as
|
195
|
+
task name. The output directory for the html files defaults to +doc+.
|
196
|
+
To change this set the +dir+ attribute:
|
197
|
+
desc "Generate html documentation."
|
198
|
+
gen RubyDoc, :html do |t|
|
199
|
+
t.dir = "doc/html"
|
200
|
+
As rant invokes RDoc programmatically, no command is printed when the
|
201
|
+
task is run. If you want to see one, set the verbose attribute to
|
202
|
+
+true+:
|
203
|
+
t.verbose = true
|
204
|
+
|
205
|
+
== See also
|
206
|
+
|
207
|
+
Rant Overview::
|
208
|
+
README[link:files/README.html]
|
209
|
+
Writing an Rantfile::
|
210
|
+
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|