rant 0.3.8 → 0.4.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.
- data/NEWS +19 -0
- data/README +51 -24
- data/Rantfile +7 -8
- data/doc/advanced.rdoc +3 -1
- data/doc/package.rdoc +280 -0
- data/doc/rantfile.rdoc +9 -19
- data/doc/rubyproject.rdoc +24 -16
- data/lib/rant/archive/minitar.rb +983 -0
- data/lib/rant/archive/rubyzip/ioextras.rb +122 -0
- data/lib/rant/archive/rubyzip/stdrubyext.rb +114 -0
- data/lib/rant/archive/rubyzip/tempfile_bugfixed.rb +195 -0
- data/lib/rant/archive/rubyzip.rb +1575 -0
- data/lib/rant/import/archive/tgz.rb +49 -0
- data/lib/rant/import/archive/zip.rb +67 -0
- data/lib/rant/import/archive.rb +312 -0
- data/lib/rant/import/autoclean.rb +2 -2
- data/lib/rant/import/c/dependencies.rb +3 -3
- data/lib/rant/import/clean.rb +1 -1
- data/lib/rant/import/directedrule.rb +1 -1
- data/lib/rant/import/package/tgz.rb +35 -0
- data/lib/rant/import/package/zip.rb +36 -0
- data/lib/rant/import/rubydoc.rb +1 -1
- data/lib/rant/import/rubypackage.rb +19 -77
- data/lib/rant/import/rubytest.rb +1 -1
- data/lib/rant/import/subfile.rb +28 -14
- data/lib/rant/import/win32/rubycmdwrapper.rb +1 -1
- data/lib/rant/import.rb +36 -16
- data/lib/rant/plugin/csharp.rb +1 -1
- data/lib/rant/rantenv.rb +2 -13
- data/lib/rant/rantfile.rb +11 -11
- data/lib/rant/rantlib.rb +7 -3
- data/lib/rant/rantsys.rb +53 -2
- data/lib/rant/rantvar.rb +62 -1
- data/misc/TODO +41 -0
- data/{devel-notes → misc/devel-notes} +6 -0
- data/misc/mt.rb +3 -0
- data/misc/t.rb +18 -0
- data/test/import/c/dependencies/test_c_dependencies.rb +18 -0
- data/test/import/package/MANIFEST +4 -0
- data/test/import/package/Rantfile +49 -0
- data/test/import/package/deep/sub/sub/f1 +1 -0
- data/test/import/package/sub/f1 +1 -0
- data/test/import/package/sub2/f1 +1 -0
- data/test/import/package/test_package.rb +425 -0
- data/test/import/subfile/Rantfile +8 -0
- data/test/import/subfile/test_subfile.rb +12 -0
- data/test/project_rb1/rantfile.rb +3 -4
- data/test/project_rb1/test_project_rb1.rb +16 -40
- data/test/rant-import/test_rant-import.rb +3 -3
- data/test/test_filelist.rb +39 -2
- data/test/tutil.rb +89 -3
- metadata +35 -6
- data/TODO +0 -21
- data/lib/rant/import/package.rb +0 -258
- /data/{rantmethods.rb → misc/rantmethods.rb} +0 -0
data/NEWS
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
|
2
2
|
= Rant NEWS
|
3
3
|
|
4
|
+
== Rant 0.4.0
|
5
|
+
|
6
|
+
Unless you extended Rant with a custom generator, you can upgrade from
|
7
|
+
0.3.8 without changing any dependent code.
|
8
|
+
|
9
|
+
Incompatible changes:
|
10
|
+
* _Internal_: A generator has to respond to +rant_gen+ instead of
|
11
|
+
+rant_generate+.
|
12
|
+
|
13
|
+
New features:
|
14
|
+
* Creating zip and gzipped tar archives on all supported platforms
|
15
|
+
without installing extra software. Seamless integration with
|
16
|
+
rant-import.
|
17
|
+
Read doc/package.rdoc[link:files/doc/package_rdoc.html].
|
18
|
+
* The standard RubyPackage tasks create zip and gzipped tar archives
|
19
|
+
(and optional gem packages) on all platforms, including Windows,
|
20
|
+
now.
|
21
|
+
* rant-import recognizes the new directives +uncomment+ and +remove+.
|
22
|
+
|
4
23
|
== Rant 0.3.8
|
5
24
|
|
6
25
|
This version should be fully backwards compatible to 0.3.6.
|
data/README
CHANGED
@@ -12,13 +12,15 @@ Rant currently features:
|
|
12
12
|
* Defining custom tasks
|
13
13
|
* Automated packaging, testing and RDoc generation for Ruby
|
14
14
|
applications and libraries.
|
15
|
+
* The <em>rant-import</em> command creates a monolithic rant script,
|
16
|
+
so you don't depend on an rant installation anymore.
|
17
|
+
* Creating gzipped tar and zip archives -- without installing
|
18
|
+
additional software.
|
15
19
|
* Primitive support for compiling C# sources portably with csc, cscc
|
16
20
|
and mcs.
|
17
21
|
* Dependency checking for C/C++ source files.
|
18
22
|
* A _configure_ plugin for easy environment and build-parameter
|
19
23
|
checking (but not like autoconf!) which saves data in a yaml file.
|
20
|
-
* The <em>rant-import</em> command creates a monolithic rant script,
|
21
|
-
so you don't depend on an rant installation anymore.
|
22
24
|
|
23
25
|
As programmers usually want to see code, here is a short and very
|
24
26
|
basic example of rant usage:
|
@@ -37,7 +39,7 @@ Running rant in the directory of this file:
|
|
37
39
|
will ensure that the "data" file in the "backup" directory is up to
|
38
40
|
date.
|
39
41
|
|
40
|
-
This document was written for version 0.
|
42
|
+
This document was written for version 0.4.0 of Rant. Most things
|
41
43
|
described here will work for older/newer versions of Rant, but look at
|
42
44
|
the README file in the Rant distribution you've installed for exact
|
43
45
|
documentation of your Rant version.
|
@@ -70,6 +72,8 @@ Independent from Rant? The <tt>rant-import</tt> command::
|
|
70
72
|
read doc/rant-import.rdoc[link:files/doc/rant-import_rdoc.html]
|
71
73
|
Advanced Rantfiles::
|
72
74
|
read doc/advanced.rdoc[link:files/doc/advanced_rdoc.html]
|
75
|
+
Packaging (creating zip/tgz archives)::
|
76
|
+
read doc/package.rdoc[link:files/doc/package_rdoc.html]
|
73
77
|
Compiling C/C++::
|
74
78
|
read doc/c.rdoc[link:files/doc/c_rdoc.html]
|
75
79
|
Using the Configure plugin::
|
@@ -148,38 +152,38 @@ The file COPYING[link:../../COPYING] in the Rant package contains a
|
|
148
152
|
copy of the LGPL. Of course your Rantfiles don't need to be licenced
|
149
153
|
under the terms of the LGPL.
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
Rant was started in February 2005. It has been written and is
|
154
|
-
maintained by Stefan Lang (mailto:langstefan@gmx.at).
|
155
|
+
---
|
155
156
|
|
156
|
-
|
157
|
+
The file <tt>lib/rant/archive/minitar.rb</tt> is Copyright 2004
|
158
|
+
Mauricio Julio Fernandez Pradier and Austin Ziegler. It is licensed
|
159
|
+
under the GNU General Public Licence or Ruby's licence.
|
157
160
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
161
|
+
The file <tt>lib/rant/archive/rubyzip.rb</tt> and the files in the
|
162
|
+
<tt>lib/rant/archive/rubyzip</tt> directory were written by Thomas
|
163
|
+
Sondergaard. They are distributed under the same license as ruby. See
|
164
|
+
http://www.ruby-lang.org/en/LICENSE.txt.
|
162
165
|
|
163
|
-
|
164
|
-
* I had to compile with cscc on Linux.
|
165
|
-
* compile with csc on Windows.
|
166
|
-
* automate PDF and HTML generation from Docbook
|
166
|
+
== Other info
|
167
167
|
|
168
|
-
|
169
|
-
|
170
|
-
(needed for Docbook processing).
|
168
|
+
Rant was started in February 2005. It has been written and is
|
169
|
+
maintained by Stefan Lang (mailto:langstefan@gmx.at).
|
171
170
|
|
172
|
-
|
173
|
-
basic concept and syntax of Rake and of course I could have written
|
174
|
-
code for Rake (e.g. with a so called _Tasklib_) to support portable C#
|
175
|
-
compilation. But it was a bit quirky and because I like to work with
|
176
|
-
Ruby, I decided to write my own build tool.
|
171
|
+
=== Credits
|
177
172
|
|
178
173
|
Rant has taken the basic syntax of a _task_ and some other concepts
|
179
174
|
from Rake.
|
180
175
|
So thanks to Jim Weirich, the author of
|
181
176
|
Rake[http://rubyforge.org/projects/rake].
|
182
177
|
|
178
|
+
Rant comes with parts of archive-tar-minitar to create (gzipped) tar
|
179
|
+
archives on platforms where no +tar+ command is available.
|
180
|
+
archive-tar-minitar is developed by Mauricio Julio Fernandez Pradier
|
181
|
+
and Austin Ziegler.
|
182
|
+
|
183
|
+
Rant comes with parts of rubyzip to create zip archives on platforms
|
184
|
+
where no +zip+ command is available. rubyzip is developed by Thomas
|
185
|
+
Sondergaard.
|
186
|
+
|
183
187
|
=== Goals of Rant
|
184
188
|
|
185
189
|
* Most important is to be a very *flexible* build tool. This currently
|
@@ -212,3 +216,26 @@ know...
|
|
212
216
|
|
213
217
|
If you encounter problems with Rant on any platform (with Ruby 1.8.1
|
214
218
|
or higher) please write a bugreport!
|
219
|
+
|
220
|
+
=== Why did you write another build tool?
|
221
|
+
|
222
|
+
Because I wasn't satisfied by any other build tool. Before I started
|
223
|
+
Rant, I had to write a program in C#. The program had to run under
|
224
|
+
Windows, but I wanted to develop under Linux. Also I decided to write
|
225
|
+
the documentation in Docbook.
|
226
|
+
|
227
|
+
So there where quite a few problems arising:
|
228
|
+
* I had to compile with cscc on Linux.
|
229
|
+
* compile with csc on Windows.
|
230
|
+
* automate PDF and HTML generation from Docbook
|
231
|
+
|
232
|
+
_Nant_ would have been ok to compile the C# sources. But it isn't
|
233
|
+
suited for more general tasks as clueing togheter other programs
|
234
|
+
(needed for Docbook processing).
|
235
|
+
|
236
|
+
Then I tried to use _Rake_ and it was the other way round. I liked the
|
237
|
+
basic concept and syntax of Rake and of course I could have written
|
238
|
+
code for Rake (e.g. with a so called _Tasklib_) to support portable C#
|
239
|
+
compilation. But it was a bit quirky and because I like to work with
|
240
|
+
Ruby, I decided to write my own build tool.
|
241
|
+
|
data/Rantfile
CHANGED
@@ -5,10 +5,9 @@ import %w(rubytest rubydoc rubypackage autoclean win32/rubycmdwrapper)
|
|
5
5
|
|
6
6
|
task :default => :test
|
7
7
|
|
8
|
-
|
9
|
-
dist_files
|
10
|
-
|
11
|
-
bin_files = sys["bin/*"]
|
8
|
+
dist_files = sys["{bin,lib,test,doc,misc}/**/*"]
|
9
|
+
dist_files.shun("html", "coverage")
|
10
|
+
dist_files += sys["*"].no_dir.exclude("InstalledFiles", "Session.vim")
|
12
11
|
rdoc_opts = %w(-S -c UTF-8 --title Rant --main README)
|
13
12
|
|
14
13
|
gen RubyPackage, "rant" do |t|
|
@@ -103,7 +102,6 @@ gen RubyTest, :tall do |g|
|
|
103
102
|
g.libs << "test"
|
104
103
|
g.test_files = sys["test/**/test_*.rb"]
|
105
104
|
end
|
106
|
-
task :testall => %w(test testp1 testp2 testrb1 testplugins)
|
107
105
|
|
108
106
|
desc "Remove autogenerated files."
|
109
107
|
gen AutoClean, :clean
|
@@ -126,10 +124,11 @@ task "to-win" => :package do
|
|
126
124
|
win_dir = "/mnt/data_fat/stefan/Ruby"
|
127
125
|
Dir["pkg/*"].each { |f|
|
128
126
|
target = File.join(win_dir, File.basename(f))
|
129
|
-
|
127
|
+
file target => f do |t|
|
130
128
|
sys.rm_rf target if test(?e, target)
|
131
129
|
sys.cp_r f, t.name
|
132
|
-
end
|
130
|
+
end
|
131
|
+
rac.make target
|
133
132
|
}
|
134
133
|
end
|
135
134
|
|
@@ -142,4 +141,4 @@ if Env.on_windows?
|
|
142
141
|
enhance :install => (gen Win32::RubyCmdWrapper, sys["bin/*"])
|
143
142
|
end
|
144
143
|
|
145
|
-
# vim:ft=ruby
|
144
|
+
# vim:ft=ruby
|
data/doc/advanced.rdoc
CHANGED
@@ -101,7 +101,7 @@ Use the +Clean+ generator in your Rantfiles:
|
|
101
101
|
=== Let Rant cleanup for you
|
102
102
|
|
103
103
|
Use the +AutoClean+ generator which will remove all files generated by
|
104
|
-
any filetask (
|
104
|
+
any filetask (including those created by rules):
|
105
105
|
|
106
106
|
import "autoclean"
|
107
107
|
|
@@ -285,5 +285,7 @@ Rantfile basics::
|
|
285
285
|
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|
286
286
|
Support for C/C++::
|
287
287
|
doc/c.rdoc[link:files/doc/c_rdoc.html]
|
288
|
+
Packaging::
|
289
|
+
doc/package.rdoc[link:files/doc/package_rdoc.html]
|
288
290
|
Rant Overview::
|
289
291
|
README[link:files/README.html]
|
data/doc/package.rdoc
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
|
2
|
+
== Packaging
|
3
|
+
|
4
|
+
Usually you want to create some archive file(s) to distribute your
|
5
|
+
software. Rant supports creation of zip and gzipped tar archives. The
|
6
|
+
good news is that you don't have to install any extra software because
|
7
|
+
Rant integrates parts of Mauricio Julio Fernandez Pradier and Austin
|
8
|
+
Ziegler's archive-tar-minitar and Thomas Sondergaard's rubyzip.
|
9
|
+
|
10
|
+
Rant provides two techniques, which will be described in the following
|
11
|
+
sections.
|
12
|
+
|
13
|
+
=== The Package::* generators
|
14
|
+
|
15
|
+
The Package namespace provides two generators, namely
|
16
|
+
<tt>Package::Tgz</tt> and <tt>Package::Zip</tt>. Let's look at some
|
17
|
+
examples to create gzipped tar archives:
|
18
|
+
|
19
|
+
Put this into your Rantfile:
|
20
|
+
|
21
|
+
import "package/tgz"
|
22
|
+
gen Package::Tgz, "foo", :files => sys["{bin,lib,test}/**/*"]
|
23
|
+
|
24
|
+
This creates a file task called <tt>foo.tgz</tt>. If you run it with
|
25
|
+
|
26
|
+
% rant foo.tgz
|
27
|
+
|
28
|
+
rant will create a directory called <tt>foo</tt>, link all selected
|
29
|
+
files (in this case all files under bin/, lib/, test/ and all their
|
30
|
+
subdirectories, recursively) to foo/ and then create the archive
|
31
|
+
<tt>foo.tgz</tt> from the <tt>foo</tt> directory. This means that the
|
32
|
+
archive contains exactly one toplevel directory (<tt>foo</tt>) which
|
33
|
+
in turn contains the selected files. Most Open Source software is
|
34
|
+
packaged up this way. Also usual is to add a version number to the
|
35
|
+
package name:
|
36
|
+
|
37
|
+
import "package/tgz"
|
38
|
+
gen Package::Tgz, "foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
39
|
+
|
40
|
+
Now the created file task (and thus the archive file) is called
|
41
|
+
<tt>foo-1.0.1.tgz</tt>, and the toplevel directory in the archive is
|
42
|
+
called <tt>foo-1.0.1</tt>.
|
43
|
+
|
44
|
+
TAKE CARE:: If the directory <tt>foo</tt> or whatever the name
|
45
|
+
of the package is, exists, it will be removed if
|
46
|
+
you invoke the package task!
|
47
|
+
|
48
|
+
To avoid such clashes, you can tell Rant to place the package in a
|
49
|
+
subdirectory, e.g. <tt>pkg</tt>:
|
50
|
+
|
51
|
+
import "package/tgz"
|
52
|
+
gen Package::Tgz, "pkg/foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
53
|
+
|
54
|
+
Now the task is called <tt>pkg/foo-1.0.1.tgz</tt>. Rant automatically
|
55
|
+
creates the pkg/ directory when required. Behind the scenes, Rant
|
56
|
+
defines a <tt>Directory</tt> task for the pkg/ directory.
|
57
|
+
|
58
|
+
=== Cleaning up with AutoClean
|
59
|
+
|
60
|
+
The AutoClean generator knows which files/directories have been
|
61
|
+
created by our packaging tasks. Just put this lines into the Rantfile:
|
62
|
+
|
63
|
+
import "package/tgz", "autoclean"
|
64
|
+
|
65
|
+
gen Package::Tgz, "pkg/foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
66
|
+
|
67
|
+
gen AutoClean
|
68
|
+
|
69
|
+
If you invoke rant with <tt>autoclean</tt> as argument now:
|
70
|
+
% rant autoclean
|
71
|
+
it will recursively remove the +pkg+ and the <tt>foo-1.0.1</tt>
|
72
|
+
directories. This could be a problem if you have source files (or
|
73
|
+
other precious files) in the pkg/ directory. In this case change the
|
74
|
+
syntax to:
|
75
|
+
|
76
|
+
import "package/tgz", "autoclean"
|
77
|
+
|
78
|
+
gen Package::Tgz, "pkg", "foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
79
|
+
|
80
|
+
gen AutoClean
|
81
|
+
|
82
|
+
The file name for the package is still <tt>pkg/foo-1.0.1.tgz</tt> like
|
83
|
+
in the previous example, but now rant assumes that the +pkg+ directory
|
84
|
+
belongs to your source base and doesn't create a Directory task for
|
85
|
+
it. If you invoke the +autoclean+ task now, it won't remove the +pkg+
|
86
|
+
directory, just the <tt>pkg/foo-1.0.1.tgz</tt> archive and the
|
87
|
+
<tt>pkg/foo-1.0.1</tt> directory.
|
88
|
+
|
89
|
+
<b>If you intend to use AutoClean, you should definitely read
|
90
|
+
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html].</b>
|
91
|
+
|
92
|
+
=== Writing a MANIFEST
|
93
|
+
|
94
|
+
Rant can automatically write a +MANIFEST+ file where it lists all
|
95
|
+
files which come into the package. Just give the <tt>:manifest</tt>
|
96
|
+
flag:
|
97
|
+
|
98
|
+
import "package/tgz"
|
99
|
+
gen Package::Tgz, "pkg/foo", :manifest,
|
100
|
+
:version => "1.0.1",
|
101
|
+
:files => sys["{bin,lib,test}/**/*"]
|
102
|
+
|
103
|
+
Now Rant will write/update a file called +MANIFEST+ whenever the
|
104
|
+
package task (<tt>pkg/foo-1.0.1.tgz</tt>) is invoked. +MANIFEST+ will
|
105
|
+
then contain a list of all files (each path on a separate line, as
|
106
|
+
usual). Of course the +MANIFEST+ file will also be in the archive.
|
107
|
+
|
108
|
+
You can use another name instead of +MANIFEST+. In the following
|
109
|
+
example we use +contents+:
|
110
|
+
|
111
|
+
import "package/tgz"
|
112
|
+
gen Package::Tgz, "pkg/foo",
|
113
|
+
:manifest => "contents",
|
114
|
+
:version => "1.0.1",
|
115
|
+
:files => sys["{bin,lib,test}/**/*"]
|
116
|
+
|
117
|
+
=== Reading a MANIFEST
|
118
|
+
|
119
|
+
If you manually maintain a MANIFEST file with all files which belong
|
120
|
+
to your software package, you can tell Rant to read it:
|
121
|
+
|
122
|
+
import "package/tgz"
|
123
|
+
gen Package::Tgz, "pkg/foo", :manifest, :version => "1.0.1"
|
124
|
+
|
125
|
+
Because we didn't specify the list of files to package with the
|
126
|
+
<tt>:files</tt> option, but gave the <tt>:manifest</tt> flag, Rant
|
127
|
+
will read the list of files to package from a file called +MANIFEST+.
|
128
|
+
|
129
|
+
=== Giving a non-standard file extension
|
130
|
+
|
131
|
+
If you want another file extension than the default <tt>.tgz</tt> or
|
132
|
+
<tt>.zip</tt> you can specify it with the <tt>:extension</tt> option:
|
133
|
+
|
134
|
+
import "package/tgz"
|
135
|
+
gen Package::Tgz, "pkg/foo", :manifest,
|
136
|
+
:version => "1.0.1",
|
137
|
+
:extension => ".tar.gz"
|
138
|
+
|
139
|
+
=== Creating zip packages
|
140
|
+
|
141
|
+
To create a zip package, use exactly the same syntax and options as
|
142
|
+
for tgz packages. Just <tt>import "package/zip"</tt> and use the
|
143
|
+
<tt>Pakage::Zip</tt> generator:
|
144
|
+
|
145
|
+
import "package/zip"
|
146
|
+
gen Package::Zip, "foo", :files => sys["{bin,lib,test}/**/*"]
|
147
|
+
|
148
|
+
This has the same effect as our first example, with the only
|
149
|
+
difference that a <tt>foo.zip</tt> archive will be created. As already
|
150
|
+
mentioned, you can give the same options and flags as to the
|
151
|
+
<tt>Package::Tgz</tt> generator and or course you can use both in the
|
152
|
+
same Rantfile:
|
153
|
+
|
154
|
+
import "package/zip", "package/tgz"
|
155
|
+
gen Package::Zip, "foo", :files => sys["{bin,lib,test}/**/*"]
|
156
|
+
gen Package::Tgz, "foo", :files => sys["{bin,lib,test}/**/*"]
|
157
|
+
|
158
|
+
=== The Archive::* generators
|
159
|
+
|
160
|
+
Like the <tt>Package::</tt> namespace, the <tt>Archive::</tt>
|
161
|
+
namespace also provides two generators, namely <tt>Archive::Tgz</tt>
|
162
|
+
and <tt>Archive::Zip</tt>. They require the same syntax and recognize
|
163
|
+
the same options. So what's the difference? The <tt>Archive::*</tt>
|
164
|
+
generators don't move the selected files into a toplevel directory.
|
165
|
+
Let's look at an example:
|
166
|
+
|
167
|
+
import "archive/tgz", "package/tgz"
|
168
|
+
gen Package::Tgz, "foo", :files => sys["{bin,lib,test}/**/*"]
|
169
|
+
gen Archive::Tgz, "bar", :files => sys["{bin,lib,test}/**/*"]
|
170
|
+
|
171
|
+
This creates a file task <tt>foo.tgz</tt> and a file task
|
172
|
+
<tt>bar.tgz</tt>. The difference is, that <tt>foo.tgz</tt> contains a
|
173
|
+
toplevel directory +foo+ which in turn contains the +bin+, +lib+ and
|
174
|
+
+test+ directories, but <tt>bar.tgz</tt> directly contains the +bin+,
|
175
|
+
+lib+ and +test+ directories:
|
176
|
+
|
177
|
+
Created with <tt>Package::Tgz</tt>:
|
178
|
+
foo.tgz
|
179
|
+
foo/
|
180
|
+
bin/
|
181
|
+
.
|
182
|
+
.
|
183
|
+
lib/
|
184
|
+
.
|
185
|
+
.
|
186
|
+
test/
|
187
|
+
.
|
188
|
+
.
|
189
|
+
|
190
|
+
Created with <tt>Archive::Tgz</tt>:
|
191
|
+
bar.tgz
|
192
|
+
bin/
|
193
|
+
.
|
194
|
+
.
|
195
|
+
lib/
|
196
|
+
.
|
197
|
+
.
|
198
|
+
test/
|
199
|
+
|
200
|
+
Of course the same difference is between the <tt>Package::Zip</tt> and
|
201
|
+
<tt>Archive::Zip</tt> generators.
|
202
|
+
|
203
|
+
=== Creating a shortcut, dependencies
|
204
|
+
|
205
|
+
Imagine you have a package task which creates a tgz package and a task
|
206
|
+
which should upload the package to a server. This means that the
|
207
|
+
upload task depends on the package task. You could do this like in the
|
208
|
+
following Rantfile:
|
209
|
+
|
210
|
+
import "package/tgz"
|
211
|
+
|
212
|
+
gen Package::Tgz, "pkg", "foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
213
|
+
|
214
|
+
task :upload => "pkg/foo-1.0.1.tgz" do |t|
|
215
|
+
sys "<some command to upload the archive file>"
|
216
|
+
end
|
217
|
+
|
218
|
+
That's not very convinient and it's tedious to always update the
|
219
|
+
dependency when you change the version number. But the package
|
220
|
+
generator returns an object with information about the created package
|
221
|
+
tasks:
|
222
|
+
|
223
|
+
import "package/tgz"
|
224
|
+
|
225
|
+
pkg =
|
226
|
+
gen Package::Tgz, "pkg", "foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
227
|
+
|
228
|
+
task :upload => pkg.path do |t|
|
229
|
+
sys "<some command to upload the archive file>"
|
230
|
+
end
|
231
|
+
|
232
|
+
Here we assign this object to the +pkg+ variable. The
|
233
|
+
<tt>pkg.path</tt> method returns the path to our tgz archive.
|
234
|
+
|
235
|
+
Another handy use case is to create a shortcut:
|
236
|
+
|
237
|
+
import "package/tgz"
|
238
|
+
|
239
|
+
pkg =
|
240
|
+
gen Package::Tgz, "pkg", "foo", :version => "1.0.1", :files => sys["{bin,lib,test}/**/*"]
|
241
|
+
|
242
|
+
desc "Create package for distribution."
|
243
|
+
task :package => pkg.path
|
244
|
+
|
245
|
+
Now you can invoke the package task from the commandline:
|
246
|
+
|
247
|
+
% rant -T
|
248
|
+
rant package # Create package for distribution.
|
249
|
+
% rant package
|
250
|
+
<messages about tgz creation>
|
251
|
+
|
252
|
+
|
253
|
+
=== Some random notes
|
254
|
+
|
255
|
+
* Symbolic links are always dereferenced, i.e. the file/directory the
|
256
|
+
link points to will be in the archive, not the symbolic link. Rant
|
257
|
+
will probably provide an option to store the symbolic links in the
|
258
|
+
future.
|
259
|
+
* Directories are not included recursively:
|
260
|
+
gen Package::Tgz, "foo", :files => sys["lib"]
|
261
|
+
Assuming +lib+ is a directory, <tt>foo.tgz</tt> will contain only
|
262
|
+
the empty directory <tt>foo/lib</tt>, no matter how many
|
263
|
+
files/subdirectories +lib+ contains. If you want to package +lib+
|
264
|
+
with all subdirectories and files it contains, use the following
|
265
|
+
pattern:
|
266
|
+
gen Package::Tgz, "foo", :files => sys["lib/**/*"]
|
267
|
+
* Consider the directory where all files are linked to by the
|
268
|
+
Package::* generators as byproducts and don't rely on their
|
269
|
+
creation.
|
270
|
+
|
271
|
+
== See also
|
272
|
+
|
273
|
+
Rantfile basics::
|
274
|
+
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|
275
|
+
Advanced Rantfiles::
|
276
|
+
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html]
|
277
|
+
Support for C/C++::
|
278
|
+
doc/c.rdoc[link:files/doc/c_rdoc.html]
|
279
|
+
Rant Overview::
|
280
|
+
README[link:files/README.html]
|
data/doc/rantfile.rdoc
CHANGED
@@ -170,20 +170,6 @@ explain it a little bit. The +sys+ function can be used in three ways:
|
|
170
170
|
sys.ruby "arg1", "arg2", ... # invoke the ruby interpreter
|
171
171
|
sys.safe_ln "src", "dest" # create a hardlink or fall back to
|
172
172
|
# copying
|
173
|
-
If you're tired of typing <tt>sys.</tt> all the time, you can include
|
174
|
-
the Rant::Sys module in your Rantfile (though it is not recommended
|
175
|
-
to do this):
|
176
|
-
include Rant::Sys
|
177
|
-
task :clean do
|
178
|
-
rm_f "myprog"
|
179
|
-
end
|
180
|
-
Then you can invoke these methods without the <tt>sys</tt> function.
|
181
|
-
Note:: You are highly encouraged to not <tt>include Rant::Sys</tt>
|
182
|
-
into your Rantfile as this introduces many methods in the
|
183
|
-
global namespace, which can cause name clashes with other
|
184
|
-
libraries. Of course if you have just some tasks to remove
|
185
|
-
backup files in your home directory and do not use other Ruby
|
186
|
-
libraries in your Rantfile, it is no problem.
|
187
173
|
|
188
174
|
2. <b>Running external commands</b>
|
189
175
|
|
@@ -206,8 +192,8 @@ Note:: You are highly encouraged to not <tt>include Rant::Sys</tt>
|
|
206
192
|
read the ri docs to get an overview:
|
207
193
|
ri Dir::glob
|
208
194
|
|
209
|
-
From now on we'll call <tt>sys[...]</tt> the <
|
210
|
-
operator</
|
195
|
+
From now on we'll call <tt>sys[...]</tt> the <em>glob
|
196
|
+
operator</em>.
|
211
197
|
|
212
198
|
You can give more patterns:
|
213
199
|
c_files = sys["**/*.h", "**/*.c"]
|
@@ -215,7 +201,7 @@ Note:: You are highly encouraged to not <tt>include Rant::Sys</tt>
|
|
215
201
|
directory and all subdirectories.
|
216
202
|
|
217
203
|
The object returned by the glob operator _behaves_ like a list of
|
218
|
-
|
204
|
+
strings, so it is possible to pass it to methods expecting an array.
|
219
205
|
If you're getting errors or experience strange behaviour convert
|
220
206
|
the list explicetely to an array:
|
221
207
|
sys.touch c_files.to_a
|
@@ -423,7 +409,11 @@ because it refers to a main Rantfile.
|
|
423
409
|
|
424
410
|
Advanced Rantfiles::
|
425
411
|
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html]
|
426
|
-
|
427
|
-
|
412
|
+
Support for C/C++::
|
413
|
+
doc/c.rdoc[link:files/doc/c_rdoc.html]
|
414
|
+
Packaging::
|
415
|
+
doc/package.rdoc[link:files/doc/package_rdoc.html]
|
428
416
|
Ruby project howto::
|
429
417
|
doc/rubyproject.rdoc[link:files/doc/rubyproject_rdoc.html]
|
418
|
+
Rant Overview::
|
419
|
+
README[link:files/README.html]
|
data/doc/rubyproject.rdoc
CHANGED
@@ -17,10 +17,10 @@ You can find this little project in test/project_rb1 directory of the
|
|
17
17
|
Rant package. You'll probably have more files in your project, but we
|
18
18
|
will try to write our Rantfile as generic as possible:
|
19
19
|
|
20
|
-
import %w(rubytest rubydoc rubypackage)
|
20
|
+
import %w(rubytest rubydoc rubypackage clean)
|
21
21
|
|
22
|
-
lib_files =
|
23
|
-
dist_files = lib_files + %w(rantfile.rb README) +
|
22
|
+
lib_files = sys["lib/**/*.rb"]
|
23
|
+
dist_files = lib_files + %w(rantfile.rb README) + sys["{test,bin}/*"]
|
24
24
|
|
25
25
|
desc "Run unit tests."
|
26
26
|
gen RubyTest do |t|
|
@@ -34,7 +34,7 @@ will try to write our Rantfile as generic as possible:
|
|
34
34
|
end
|
35
35
|
|
36
36
|
desc "Create packages."
|
37
|
-
gen RubyPackage,
|
37
|
+
gen RubyPackage, "wgrep" do |t|
|
38
38
|
t.version = "1.0.0"
|
39
39
|
t.summary = "Simple grep program."
|
40
40
|
t.files = dist_files
|
@@ -43,15 +43,16 @@ will try to write our Rantfile as generic as possible:
|
|
43
43
|
t.package_task
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
desc "Remove autogenerated and backup files."
|
47
|
+
gen Clean
|
48
|
+
var[:clean].include "doc", "pkg", "*~"
|
49
49
|
|
50
50
|
To verify how our tasks are named:
|
51
51
|
% rant -T
|
52
52
|
rant test # Run unit tests.
|
53
53
|
rant doc # Generate html documentation.
|
54
54
|
rant package # Create packages.
|
55
|
+
rant clean # Remove autogenerated and backup files.
|
55
56
|
|
56
57
|
Let's examine the code by running the tasks:
|
57
58
|
% rant test
|
@@ -109,25 +110,30 @@ The most interesting task is the +package+ task:
|
|
109
110
|
Version: 1.0.0
|
110
111
|
File: wgrep-1.0.0.gem
|
111
112
|
mv wgrep-1.0.0.gem pkg
|
112
|
-
This is what it does
|
113
|
+
This is what it does:
|
113
114
|
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
|
115
|
-
3. Create a .zip file in the +pkg+ directory
|
115
|
+
2. Create a tar.gz file in the +pkg+ directory.
|
116
|
+
3. Create a .zip file in the +pkg+ directory.
|
116
117
|
4. Create a RubyGem in +pkg+.
|
117
|
-
The
|
118
|
-
|
119
|
-
available. And the RubyGem will only be created if RubyGems is
|
120
|
-
available on your system.
|
118
|
+
The RubyGem will only be created if RubyGems is available on your
|
119
|
+
system.
|
121
120
|
|
122
121
|
The gem specification also contains the RDoc options we have given to
|
123
122
|
the +RubyDoc+ generator and the +has_rdoc+ attribute is set to true.
|
124
123
|
No need to duplicate this information in our Rantfile.
|
125
124
|
|
125
|
+
And if we want to remove all autogenerated files (and backup files) we
|
126
|
+
run the +clean+ task:
|
127
|
+
% rant clean
|
128
|
+
rm -rf doc
|
129
|
+
rm -rf pkg
|
130
|
+
rm -f README~
|
131
|
+
|
126
132
|
=== More about the RubyPackage generator
|
127
133
|
|
128
134
|
The argument given to the RubyPackage generator is used as package
|
129
|
-
name (here "wgrep")
|
130
|
-
gen RubyPackage,
|
135
|
+
name (here "wgrep"):
|
136
|
+
gen RubyPackage, "wgrep" do |t|
|
131
137
|
|
132
138
|
The line which actually creates the package task(s) is this one:
|
133
139
|
t.package_task
|
@@ -234,3 +240,5 @@ Rant Overview::
|
|
234
240
|
README[link:files/README.html]
|
235
241
|
Writing an Rantfile::
|
236
242
|
doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html]
|
243
|
+
Advanced Rantfiles::
|
244
|
+
doc/advanced.rdoc[link:files/doc/advanced_rdoc.html]
|