rant 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/NEWS +21 -0
  2. data/README +8 -0
  3. data/Rantfile +30 -16
  4. data/TODO +3 -4
  5. data/devel-notes +16 -0
  6. data/doc/csharp.rdoc +2 -3
  7. data/doc/examples/myprog/README +2 -0
  8. data/doc/examples/myprog/Rantfile +13 -0
  9. data/doc/examples/myprog/src/Rantfile +15 -0
  10. data/doc/examples/myprog/src/lib.c +6 -0
  11. data/doc/examples/myprog/src/lib.h +4 -0
  12. data/doc/examples/myprog/src/main.c +7 -0
  13. data/doc/rantfile.rdoc +108 -3
  14. data/lib/rant/cs_compiler.rb +6 -4
  15. data/lib/rant/import.rb +13 -0
  16. data/lib/rant/import/rubypackage.rb +43 -20
  17. data/lib/rant/plugin/configure.rb +21 -7
  18. data/lib/rant/plugin/csharp.rb +8 -9
  19. data/lib/rant/rantenv.rb +3 -0
  20. data/lib/rant/rantfile.rb +66 -33
  21. data/lib/rant/rantlib.rb +133 -27
  22. data/lib/rant/rantsys.rb +197 -42
  23. data/rantmethods.rb +46 -0
  24. data/setup.rb +18 -4
  25. data/test/plugin/configure/Rantfile +0 -6
  26. data/test/plugin/configure/test_configure.rb +2 -2
  27. data/test/plugin/csharp/test_csharp.rb +7 -2
  28. data/test/plugin/rantfile +45 -0
  29. data/test/plugin/test_conf_csharp.rb +53 -0
  30. data/test/project1/Rantfile +4 -0
  31. data/test/project1/test_project.rb +33 -8
  32. data/test/project2/buildfile +3 -3
  33. data/test/project2/sub1/Rantfile +3 -3
  34. data/test/project2/test_project.rb +6 -4
  35. data/test/project_rb1/test_project_rb1.rb +2 -2
  36. data/test/standalone.rf +10 -0
  37. data/test/subdirs/Rantfile +26 -0
  38. data/test/subdirs/sub1/Rantfile +15 -0
  39. data/test/subdirs/sub2/rantfile.rb +14 -0
  40. data/test/subdirs/sub2/sub/rantfile +15 -0
  41. data/test/subdirs/test_subdirs.rb +96 -0
  42. data/test/test_env.rb +3 -3
  43. data/test/test_filelist.rb +143 -0
  44. data/test/test_lighttask.rb +21 -0
  45. data/test/test_metatask.rb +1 -1
  46. data/test/test_rant_interface.rb +5 -5
  47. data/test/test_sys.rb +7 -1
  48. data/test/test_task.rb +25 -0
  49. data/test/toplevel.rf +0 -1
  50. data/test/tutil.rb +26 -1
  51. metadata +39 -14
data/NEWS ADDED
@@ -0,0 +1,21 @@
1
+
2
+ = Rant NEWS
3
+
4
+ == Rant 0.3.2
5
+
6
+ This version should be fully backwards compatible to 0.3.0.
7
+
8
+ New features:
9
+ * Support splitting your buildfiles up and placing them into multiple
10
+ directories with the +subdirs+ command. Please read
11
+ doc/rantfile.rdoc[link:files/doc/rantfile_rdoc.html] for usage.
12
+ This is especially usefull for bigger projects.
13
+
14
+ == Rant 0.3.0
15
+
16
+ First release of Rant on RubyForge.
17
+
18
+ == See also
19
+
20
+ Rant Overview::
21
+ README[link:files/README.html]
data/README CHANGED
@@ -36,6 +36,11 @@ Running rant in the directory of this file:
36
36
  will ensure that the "data" file in the "backup" directory is up to
37
37
  date.
38
38
 
39
+ This document was written for version 0.3.2 of Rant. Most things
40
+ described here will work for older/newer versions of Rant, but look at
41
+ the README file in the Rant distribution you've installed for exact
42
+ documentation for your Rant version.
43
+
39
44
  == Support
40
45
 
41
46
  The newest version of this document can be found at
@@ -66,6 +71,9 @@ Using the Configure plugin::
66
71
  read doc/configure.rdoc[link:files/doc/configure_rdoc.html]
67
72
  Compiling C#::
68
73
  read doc/csharp.rdoc[link:files/doc/csharp_rdoc.html]
74
+ Upgrading::
75
+ read the NEWS[link:files/NEWS.html] for new features, not
76
+ backwards compatible changes and other issues.
69
77
 
70
78
  == Installation
71
79
 
data/Rantfile CHANGED
@@ -1,16 +1,13 @@
1
- #!/usr/bin/env ruby
2
1
 
3
2
  # Rantfile for Rant :)
4
3
 
5
- require 'rant'
6
-
7
4
  import %w(rubytest rubydoc rubypackage)
8
5
 
9
6
  task :default => :test
10
7
 
11
8
  lib_files = FileList["lib/**/*.rb"]
12
- dist_files = FileList["{bin,lib,test,doc}/**/*"].no_dir("html") +
13
- FileList["*"].no_dir.no_file("InstalledFiles").no_file("Session.vim")
9
+ dist_files = FileList["{bin,lib,test,doc}/**/*"].shun("html", "coverage") +
10
+ FileList["*"].no_dir.exclude("InstalledFiles", "Session.vim")
14
11
 
15
12
  gen RubyPackage, "rant" do |t|
16
13
  t.version = `#{Env::RUBY} run_rant --version`.split[1]
@@ -20,8 +17,8 @@ gen RubyPackage, "rant" do |t|
20
17
  t.executable %w(rant rant-import)
21
18
  t.author = "Stefan Lang"
22
19
  t.email = "langstefan@gmx.at"
23
- t.gem_rubyforge_project = "make"
24
- t.gem_extra_rdoc_files = FileList["**/README"].no_dir("pkg").no_dir("test") + FileList["doc/**/*.rdoc"]
20
+ t.rubyforge_project = "make"
21
+ t.gem_extra_rdoc_files = FileList["**/README", "NEWS"].no_dir("pkg").no_dir("test") + FileList["doc/**/*.rdoc"]
25
22
  t.homepage = "http://make.rubyforge.org"
26
23
  desc "Create packages for distribution."
27
24
  t.package_task
@@ -30,7 +27,7 @@ end
30
27
  desc "Generate documentation."
31
28
  gen RubyDoc do |g|
32
29
  g.dir = "doc/html"
33
- g.files.concat FileList["**/README"].no_dir("pkg").no_dir("test")
30
+ g.files.concat FileList["NEWS", "**/README"].no_dir("pkg").no_dir("test")
34
31
  g.files.concat FileList["doc/**/*.rdoc"]
35
32
  g.opts = %w(-S -c UTF-8 --title Rant --main README)
36
33
  end
@@ -41,15 +38,13 @@ gen RubyTest do |g|
41
38
  g.pattern = 'test_*.rb'
42
39
  end
43
40
 
44
- desc "Run first test-project.",
45
- "Warning: writes to disc."
41
+ desc "Run first test-project."
46
42
  gen RubyTest, :testp1 do |g|
47
43
  g.libs << "test"
48
44
  g.test_files = ["test/project1/test_project.rb"]
49
45
  end
50
46
 
51
- desc "Run second test project.",
52
- "Warning: writes to disc"
47
+ desc "Run second test project."
53
48
  gen RubyTest, :testp2 do |g|
54
49
  g.libs << "test"
55
50
  g.test_files = ["test/project2/test_project.rb"]
@@ -75,6 +70,12 @@ task :cov do
75
70
  end
76
71
  end
77
72
 
73
+ desc "Test project with subdirs."
74
+ gen RubyTest, :tsubdirs do |t|
75
+ t.libs << "test"
76
+ t.test_files = FileList["test/subdirs/test_*.rb"]
77
+ end
78
+
78
79
  desc "Run all tests."
79
80
  gen RubyTest, :tall do |g|
80
81
  g.libs << "test"
@@ -88,17 +89,30 @@ task :clean do
88
89
  sys.rm_rf %w(doc/html pkg test/coverage)
89
90
  end
90
91
 
92
+ desc "Publish html docs on make.rubyfore.org.",
93
+ "Note: scp will prompt for rubyforge password."
94
+ task "publish-docs" => :doc do
95
+ sys "scp -r doc/html/* langi@rubyforge.org:/var/www/gforge-projects/make/"
96
+ end
97
+
91
98
  # Just for quick visual testing of rant...
92
99
  task :please_fail do |t|
93
100
  sys "mix_nix_gibts"
94
101
  end
95
102
 
103
+ task "to-win" => :package do
104
+ win_dir = "/mnt/data_fat/stefan/Ruby"
105
+ Dir["pkg/*"].each { |f|
106
+ target = File.join(win_dir, File.basename(f))
107
+ sys.rm_rf target if test(?e, target)
108
+ sys.cp_r f, target
109
+ }
110
+ end
111
+
96
112
  # for quich rant testing
97
113
  #plugin :Configure
98
114
 
99
115
  # mainly for rant testing
100
- source 'rantmethods.rb'
116
+ #source 'rantmethods.rb'
101
117
 
102
- if $0 == __FILE__
103
- Rant.run
104
- end
118
+ # vim:ft=ruby:
data/TODO CHANGED
@@ -1,6 +1,9 @@
1
1
 
2
2
  = TODO
3
3
 
4
+ == Packaging
5
+ Try minitar if tar is not available.
6
+
4
7
  == C# plugin
5
8
  Define the method +assembly+ for building a file with the C# compiler?
6
9
  Done.
@@ -10,10 +13,6 @@ Done.
10
13
  Add a 'distclean' task that removes all files and directories
11
14
  generatet by any file task.
12
15
 
13
- RDoc task.
14
-
15
- Gem task (+ one that interactively creates a gemspec).
16
-
17
16
  == Java plugin
18
17
 
19
18
  At least for the 1.0.0 release.
@@ -47,4 +47,20 @@ The unit tests contain many assertions of the form
47
47
  which are wrong, because the first argument should be the expected
48
48
  result!
49
49
 
50
+ == <tt>FileList < Array</tt> problems
51
+ There arise some severe problems. E.g. the Array#flatten method:
52
+ [FileList["*.rb"]].flatten
53
+ The +flatten+ method doesn't call *any* method of our FileList but
54
+ it recognizes that it is an Array and copies the elements directly.
55
+ So there is *no* way to resolve the glob pattern and there will never
56
+ any Ruby file be selected!
57
+
58
+ == Subdirectories
59
+ Rant would have to check and eventually +cd+ before doing one of the
60
+ following:
61
+ * Loading an Rantfile (even through +source+).
62
+ * Worker#invoke
63
+ * Worker#needed?
64
+ * RantApp#run before returning.
65
+
50
66
  # vim:tw=70:
@@ -59,9 +59,8 @@ linked against, the +sources+ attribute should be clear and the
59
59
  assembly.
60
60
 
61
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
62
+ Rantfile. We tell rant to build <tt>myprog.exe</tt>:
63
+ % rant myprog.exe
65
64
  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
65
  This was on a Linux system, on Windows you'll probably see a command
67
66
  with csc.
@@ -0,0 +1,2 @@
1
+
2
+ This is the README file for the myprog program.
@@ -0,0 +1,13 @@
1
+ desc "Build myprog."
2
+ file "myprog" => "src/myprog" do
3
+ sys.cp "src/myprog", "myprog"
4
+ end
5
+
6
+ desc "Remove compiler products."
7
+ task :clean => "src/clean" do
8
+ sys.rm_f "myprog"
9
+ end
10
+
11
+ # Tell Rant to look in src for an Rantfile,
12
+ # we could list more directories here.
13
+ subdirs "src"
@@ -0,0 +1,15 @@
1
+ file "lib.o" => %w(lib.c lib.h) do
2
+ sys "cc -c -o lib.o lib.c"
3
+ end
4
+
5
+ file "main.o" => "main.c" do
6
+ sys "cc -c -o main.o main.c"
7
+ end
8
+
9
+ file "myprog" => %w(lib.o main.o) do
10
+ sys "cc -o myprog main.o lib.o"
11
+ end
12
+
13
+ task :clean do
14
+ sys.rm_f Dir["*.o"] + %w(myprog)
15
+ end
@@ -0,0 +1,6 @@
1
+ #include "lib.h"
2
+
3
+ int nothing(void)
4
+ {
5
+ return 0;
6
+ }
@@ -0,0 +1,4 @@
1
+ #ifndef LIB_H
2
+ #define LIB_H
3
+ int nothing(void);
4
+ #endif
@@ -0,0 +1,7 @@
1
+ #include "lib.h"
2
+
3
+ int main(int argc, char** argv)
4
+ {
5
+ nothing();
6
+ return 0;
7
+ }
@@ -31,6 +31,8 @@ methods with the Rant application:
31
31
  on it.
32
32
  +source+:: Takes a filename as argument and causes Rant to read
33
33
  it in as Rantfile.
34
+ +subdirs+:: Takes a list of subdirectories in which Rant should
35
+ look for Rantfiles.
34
36
 
35
37
  === Defining a task
36
38
 
@@ -42,7 +44,7 @@ anything. To associate an action with the task, add a block:
42
44
  task :mytask do
43
45
  puts "Hello, mytask running."
44
46
  end
45
- Put these 3 lines of code into an Rantfile and run rant:
47
+ Put these 3 lines of code into a file called +Rantfile+ and run rant:
46
48
  % rant mytask
47
49
  Hello, mytask running.
48
50
  Note: you could have ommited the mytask argument to rant because it is
@@ -67,7 +69,7 @@ Add prerequisites to create relations between tasks:
67
69
  task :t2 do |t|
68
70
  puts t.name
69
71
  end
70
- In the definition of the "first" task we told Rant that it +depends+
72
+ In the definition of the "first" task we told Rant that it _depends_
71
73
  on task "t1" and task "t2". "t1" and "t2" are called prerequisites for
72
74
  "first". Try it out:
73
75
  % rant first
@@ -164,12 +166,19 @@ FileUtils module:
164
166
  sys.safe_ln "src", "dest" # create a hardlink or fall back to
165
167
  # copying
166
168
  If you're tired of typing <tt>sys.</tt> all the time, you can include
167
- the +Sys+ module in your Rantfile:
169
+ the +Sys+ module in your Rantfile (though it is not recommended to do
170
+ this):
168
171
  include Sys
169
172
  task :clean do
170
173
  rm_f "myprog"
171
174
  end
172
175
  Then you can invoke these methods without the <tt>sys</tt> function.
176
+ Note:: You are highly encouraged to not <tt>include Sys</tt> into
177
+ your Rantfile as this introduces many methods in the global
178
+ namespace, which can cause name clashes with other libraries.
179
+ Of course if you have just some tasks to remove backup files
180
+ in your home directory and do not use other Ruby libraries in
181
+ your Rantfile, it is no problem.
173
182
 
174
183
  === Generators
175
184
 
@@ -219,6 +228,102 @@ Currently the following are coming with Rant:
219
228
  application/library.
220
229
  As these are all Ruby specific, please read the Ruby project howto.
221
230
 
231
+ === The +subdirs+ command
232
+
233
+ The +subdirs+ command allows you to give Rant a list of subdirectories
234
+ (relative to the Rantfile) where it should look for additional
235
+ Rantfiles. The tasks defined in those subdirectories can be referenced
236
+ from your main Rantfile and vice versa.
237
+
238
+ A small example: We are assuming the following files:
239
+ myprog/
240
+ Rantfile # the main Rantfile
241
+ README
242
+ src/
243
+ Rantfile
244
+ main.c
245
+ lib.c
246
+ lib.h
247
+ Then the main Rantfile could look like:
248
+ desc "Build myprog."
249
+ file "myprog" => "src/myprog" do
250
+ sys.cp "src/myprog", "myprog"
251
+ end
252
+
253
+ desc "Remove compiler products."
254
+ task :clean => "src/clean" do
255
+ sys.rm_f "myprog"
256
+ end
257
+
258
+ # Tell Rant to look in src for an Rantfile,
259
+ # we could list more directories here.
260
+ subdirs "src"
261
+ And src/Rantfile:
262
+ file "lib.o" => %w(lib.c lib.h) do
263
+ sys "cc -c -o lib.o lib.c"
264
+ end
265
+
266
+ file "main.o" => "main.c" do
267
+ sys "cc -c -o main.o main.c"
268
+ end
269
+
270
+ file "myprog" => %w(lib.o main.o) do
271
+ sys "cc -o myprog main.o lib.o"
272
+ end
273
+
274
+ task :clean do
275
+ sys.rm_f Dir["*.o"] + %w(myprog)
276
+ end
277
+ Note that we refer to the task in subdirectory simply by prepending
278
+ the directory name and a slash to the task name.
279
+ file "myprog" => "src/myprog" do
280
+ This tells Rant that the "myprog" task depends on the "myprog" task
281
+ defined in the Rantfile in the "src" directory. The same goes for the
282
+ "clean" task.
283
+
284
+ Let's examine what Rant thinks about our build specification:
285
+ myprog % rant -T
286
+ rant myprog # Build myprog.
287
+ rant clean # Remove compiler products.
288
+ Since the "myprog" task is the first in our Rantfile, we don't need to
289
+ specify a task to build myprog:
290
+ myprog % rant
291
+ cc -c -o lib.o lib.c
292
+ cc -c -o main.o main.c
293
+ cc -o myprog main.o lib.o
294
+ cp src/myprog myprog
295
+ And to save disk space, remove generated files:
296
+ myprog % rant clean
297
+ rm -f lib.o main.o myprog
298
+ rm -f myprog
299
+ The nice thing about our buildfiles is, that we can use the
300
+ src/Rantfile independent from our main Rantfile. Consider you are
301
+ working on <tt>lib.c</tt> and only want to check that it compiles
302
+ correctly.
303
+ You can specify the task explicitely:
304
+ myprog % rant src/lib.o
305
+ cc -c -o lib.o lib.c
306
+ But if you are working a long time only in the src/ directory it is
307
+ convinient to do:
308
+ myprog % cd src
309
+ myprog/src % rant lib.o
310
+ cc -c -o lib.o lib.c
311
+ To clean only the src directory:
312
+ myprog/src % rant clean
313
+ rm -f lib.o main.o myprog
314
+ You can find this example project in the doc/examples/myprog directory
315
+ of the Rant distribution.
316
+
317
+ Of course you can also have a subdirectory in src/ containing an
318
+ Rantfile. Simply put a +subdirs+ command into the src/Rantfile. Rant
319
+ integrates well into your file system :)
320
+
321
+ If you want to refer to a task in the main Rantfile from a subdir
322
+ Rantfile, put a # in front of the task name:
323
+ task "a" => "#b"
324
+ But note that this Rantfile won't work as a standalone buildfile,
325
+ because it refers to a main Rantfile.
326
+
222
327
  == See also
223
328
 
224
329
  Rant Overview::
@@ -6,7 +6,7 @@ module Rant
6
6
  # interface to a C# Compiler.
7
7
  class CsCompiler
8
8
 
9
- LIB_SYSTEM_XML = "System.Xml.dll"
9
+ LIB_SYSTEM_XML = "System.Xml.dll"
10
10
  LIB_SYSTEM_DRAWING = "System.Drawing.dll"
11
11
  LIB_SYSTEM_FORMS = "System.Windows.Forms.dll"
12
12
 
@@ -123,12 +123,12 @@ module Rant
123
123
  @entry = nil
124
124
  @optimize = true
125
125
  @warnings = true
126
- @csc = nil
127
126
  @csc_bin = nil
128
127
  end
129
128
 
130
129
  # Command to invoke compiler.
131
130
  def csc
131
+ #puts "#@csc_bin, #@csc_name"
132
132
  @csc_bin || @csc_name
133
133
  end
134
134
 
@@ -136,9 +136,10 @@ module Rant
136
136
  # +cc_bin+, this also tries to determine which interface to
137
137
  # use for this compiler. Finally it sets +cc_bin+.
138
138
  def csc=(cmd)
139
- name = self.class.cs_compiler_name(cmd)
139
+ @csc_bin = cmd.dup
140
+ name = self.class.cs_compiler_name(@csc_bin)
140
141
  @csc_name = name if name
141
- @csc_bin = cmd
142
+ #puts "csc=() setting csc_bin to " + @csc_bin
142
143
  end
143
144
 
144
145
  def csc_name= new_name
@@ -167,6 +168,7 @@ module Rant
167
168
  # This generates the compilation command
168
169
  # for cscc.
169
170
  cc_cmd = csc.dup
171
+ #puts "creating exe command for #{cc_cmd}"
170
172
  cc_cmd << " -e#{entry}" if entry
171
173
  cc_cmd << cc_cmd_args
172
174
  cc_cmd