rant 0.3.6 → 0.3.8

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.
Files changed (75) hide show
  1. data/NEWS +13 -0
  2. data/README +7 -1
  3. data/Rantfile +10 -14
  4. data/TODO +3 -0
  5. data/devel-notes +5 -0
  6. data/doc/advanced.rdoc +46 -0
  7. data/doc/c.rdoc +64 -0
  8. data/doc/examples/c_dependencies/Rantfile +27 -0
  9. data/doc/examples/c_dependencies/include/hello.h +7 -0
  10. data/doc/examples/c_dependencies/include/util.h +7 -0
  11. data/doc/examples/c_dependencies/src/main.c +9 -0
  12. data/doc/examples/c_dependencies/src/util.c +9 -0
  13. data/doc/examples/directedrule/Rantfile +0 -1
  14. data/doc/rantfile.rdoc +12 -9
  15. data/doc/rubyproject.rdoc +26 -0
  16. data/lib/rant/c/include.rb +51 -0
  17. data/lib/rant/import/autoclean.rb +16 -9
  18. data/lib/rant/import/c/dependencies.rb +127 -0
  19. data/lib/rant/import/directedrule.rb +8 -4
  20. data/lib/rant/import/rubypackage.rb +2 -1
  21. data/lib/rant/import/subfile.rb +41 -0
  22. data/lib/rant/import/truth.rb +6 -1
  23. data/lib/rant/import/win32/rubycmdwrapper.rb +37 -0
  24. data/lib/rant/import.rb +26 -3
  25. data/lib/rant/rantenv.rb +0 -32
  26. data/lib/rant/rantfile.rb +207 -194
  27. data/lib/rant/rantlib.rb +83 -150
  28. data/lib/rant/rantsys.rb +7 -10
  29. data/lib/rant/rantvar.rb +4 -6
  30. data/lib/rant.rb +57 -0
  31. data/rantmethods.rb +1 -47
  32. data/setup.rb +2 -2
  33. data/test/Rantfile +6 -1
  34. data/test/c/source.c +23 -0
  35. data/test/c/test_parse_includes.rb +41 -0
  36. data/test/import/c/dependencies/Rantfile +34 -0
  37. data/test/import/c/dependencies/bar.h +2 -0
  38. data/test/import/c/dependencies/foo.h +5 -0
  39. data/test/import/c/dependencies/hello.c +7 -0
  40. data/test/import/c/dependencies/include/foo.h +0 -0
  41. data/test/import/c/dependencies/include/sub/sub.h +8 -0
  42. data/test/import/c/dependencies/include/with space.h +7 -0
  43. data/test/import/c/dependencies/src/abc +5 -0
  44. data/test/import/c/dependencies/src/abc.c +5 -0
  45. data/test/import/c/dependencies/src/bar.c +11 -0
  46. data/test/import/c/dependencies/test_c_dependencies.rb +92 -0
  47. data/test/import/c/dependencies/test_on_the_fly.rb +44 -0
  48. data/test/import/directedrule/Rantfile +7 -2
  49. data/test/import/directedrule/test_directedrule.rb +6 -0
  50. data/test/import/subfile/Rantfile +28 -0
  51. data/test/import/subfile/autoclean.rf +16 -0
  52. data/test/import/subfile/test_subfile.rb +91 -0
  53. data/test/import/truth/Rantfile +7 -0
  54. data/test/import/truth/test_truth.rb +3 -0
  55. data/test/project2/buildfile +2 -0
  56. data/test/project2/test_project.rb +5 -3
  57. data/test/rant-import/Rantfile +4 -0
  58. data/test/rant-import/test_rant-import.rb +104 -1
  59. data/test/rule.rf +6 -0
  60. data/test/test_autosubfiletask.rb +59 -0
  61. data/test/test_clean.rb +48 -5
  62. data/test/test_dirtask.rb +45 -1
  63. data/test/test_examples.rb +25 -3
  64. data/test/test_filelist.rb +14 -2
  65. data/test/test_lighttask.rb +4 -6
  66. data/test/test_rant_interface.rb +8 -8
  67. data/test/test_rantfile_api.rb +37 -1
  68. data/test/test_rule.rb +6 -3
  69. data/test/test_source.rb +28 -1
  70. data/test/test_sourcenode.rb +163 -0
  71. data/test/test_task.rb +2 -2
  72. data/test/test_var.rb +3 -3
  73. data/test/tutil.rb +23 -2
  74. metadata +45 -3
  75. data/test/test_metatask.rb +0 -29
@@ -0,0 +1,41 @@
1
+
2
+ # subfile.rb - "SubFile" generator for Rant.
3
+ #
4
+ # Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
5
+
6
+ require 'rant/rantlib'
7
+
8
+ class Rant::Generators::SubFile
9
+ def self.rant_generate(rac, ch, args, &block)
10
+ case args.size
11
+ when 1
12
+ basedir, fine = nil, args.first
13
+ path = fine
14
+ when 2
15
+ basedir, fine = args
16
+ path = File.join(basedir, fine)
17
+ else
18
+ rac.abort_at(ch, "SubFile takes one or two arguments.")
19
+ end
20
+ file_desc = rac.pop_desc
21
+ rac.prepare_task(path, block, ch) { |name,pre,blk|
22
+ dir, file = File.split(fine.to_s)
23
+ dirp = basedir ? File.join(basedir, dir) : dir
24
+ unless dir == "."
25
+ dt = rac.resolve(dirp)
26
+ if dt.empty?
27
+ dt = [if basedir
28
+ rac.cx.gen(
29
+ ::Rant::Generators::Directory, basedir, dir)
30
+ else
31
+ rac.cx.gen(
32
+ ::Rant::Generators::Directory, dir)
33
+ end]
34
+ end
35
+ pre.concat(dt)
36
+ end
37
+ rac.cx.desc file_desc
38
+ ::Rant::FileTask.new(rac, name, pre, &blk)
39
+ }
40
+ end
41
+ end
@@ -5,7 +5,7 @@
5
5
  # Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
6
6
 
7
7
  module Rant
8
- module Worker
8
+ module Node
9
9
  def %(desc)
10
10
  @description = case @description
11
11
  when nil: desc
@@ -15,6 +15,11 @@ module Rant
15
15
  self
16
16
  end
17
17
  end
18
+ class RacFileList
19
+ def %(fu_sym)
20
+ @rac.cx.sys.send(fu_sym, to_ary)
21
+ end
22
+ end
18
23
  end
19
24
  module RantContext
20
25
  def drag(name, *args, &block)
@@ -0,0 +1,37 @@
1
+
2
+ # rubycmdwrapper.rb - "Win32::RubyCmdWrapper" generator for Rant.
3
+ #
4
+ # Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
5
+
6
+ require 'rant/rantlib'
7
+
8
+ module Rant::Generators
9
+ module Win32
10
+ module RubyCmdWrapper
11
+ def self.rant_generate(rac, ch, args, &block)
12
+ fl = args.first
13
+ unless args.size == 1 and fl.respond_to? :to_ary
14
+ rac.abort_at(ch,
15
+ "Win32::RubyCmdWrapper takes a list of filenames.")
16
+ end
17
+ if fl.respond_to? :exclude
18
+ fl.exclude "*.cmd"
19
+ end
20
+ fl = fl.to_ary
21
+ cmd_files = fl.map { |f| f.sub_ext "cmd" }
22
+ cmd_files.zip(fl).each { |cmd, bin|
23
+ # the .cmd file does not depend on the bin file
24
+ rac.cx.file cmd do |t|
25
+ open(t.name, "w") { |f|
26
+ i_bin = File.join(::Rant::Env::RUBY_BINDIR,
27
+ File.basename(bin))
28
+ rac.cmd_msg "Writing #{t.name}: #{i_bin}"
29
+ f.puts "@#{rac.cx.sys.sp ::Rant::Env::RUBY} #{rac.cx.sys.sp i_bin} %*"
30
+ }
31
+ end
32
+ }
33
+ cmd_files
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/rant/import.rb CHANGED
@@ -31,7 +31,7 @@ module Rant
31
31
  [ "--plugins", "-p", GetoptLong::REQUIRED_ARGUMENT,
32
32
  "Include PLUGINS (comma separated list)." ],
33
33
  [ "--imports", "-i", GetoptLong::REQUIRED_ARGUMENT,
34
- "Include IMPORTS (coma separated list)." ],
34
+ "Include IMPORTS (comma separated list)." ],
35
35
  [ "--force", GetoptLong::NO_ARGUMENT,
36
36
  "Force overwriting of output file." ],
37
37
  [ "--with-comments", GetoptLong::NO_ARGUMENT,
@@ -79,6 +79,7 @@ module Rant
79
79
  @force = false
80
80
  @rantapp = nil
81
81
  @core_imports = []
82
+ @lib_imports = []
82
83
  @included_plugins = []
83
84
  @included_imports = []
84
85
  @skip_comments = true
@@ -95,8 +96,8 @@ module Rant
95
96
  rac_args = %w(--stop-after-load) +
96
97
  @arg_rantfiles.collect { |rf| "-f#{rf}" }
97
98
  rac_args << "-v" unless @quiet
98
- @rantapp = RantApp.new(rac_args)
99
- unless @rantapp.run == 0
99
+ @rantapp = RantApp.new
100
+ unless @rantapp.run(rac_args) == 0
100
101
  abort("Auto-determination of required code failed.")
101
102
  end
102
103
  @imports.concat(@rantapp.imports)
@@ -289,10 +290,16 @@ EOF
289
290
  next if @skip_comments
290
291
  end
291
292
  name = nil
293
+ lib_file = nil
292
294
  if line =~ /\s*(require|load)\s+('|")rant\/(\w+)(\.rb)?('|")/
295
+ # Rant library code
293
296
  name = $3
294
297
  elsif line =~ /\s*(require|load)\s+('|")rant\/(import\/\w+)(\.rb)?('|")/
298
+ # some "import" code
295
299
  name = $3
300
+ elsif line =~ /\s*(require|load)\s+('|")([^\2]+)\2[^r]*rant-import/
301
+ # a require which is explicitely labelled with rant-import
302
+ lib_file = $3
296
303
  end
297
304
  if name
298
305
  next if @core_imports.include? name
@@ -300,6 +307,12 @@ EOF
300
307
  msg "Including `#{name}'", path
301
308
  @core_imports << name
302
309
  rs << resolve_requires(File.read(path))
310
+ elsif lib_file
311
+ next if @lib_imports.include? lib_file
312
+ path = get_lib_path "#{lib_file}.rb"
313
+ msg "Including `#{lib_file}'", path
314
+ @lib_imports << lib_file
315
+ rs << resolve_requires(File.read(path))
303
316
  else
304
317
  line.sub!(/^\s+/, '') if @reduce_whitespace
305
318
  rs << line
@@ -308,6 +321,8 @@ EOF
308
321
  rs
309
322
  end
310
323
 
324
+ private
325
+
311
326
  def get_lib_rant_path(fn)
312
327
  path = File.join(LIB_DIR, fn)
313
328
  return path if File.exist?(path)
@@ -318,5 +333,13 @@ EOF
318
333
  nil
319
334
  end
320
335
 
336
+ def get_lib_path(fn)
337
+ $:.each { |lib_dir|
338
+ path = File.join(lib_dir, fn)
339
+ return path if File.exist?(path)
340
+ }
341
+ nil
342
+ end
343
+
321
344
  end # class RantImport
322
345
  end # module Rant
data/lib/rant/rantenv.rb CHANGED
@@ -4,38 +4,6 @@ require 'rbconfig'
4
4
 
5
5
  module Rant end
6
6
 
7
- class Rant::Path
8
- attr_reader :path
9
- def initialize path, abs_path = nil
10
- @path = path or raise ArgumentError, "path not given"
11
- @abs_path = abs_path
12
- end
13
- def to_s
14
- @path.dup
15
- end
16
- def to_str
17
- @path.dup
18
- end
19
- def exist?
20
- File.exist? @path
21
- end
22
- def file?
23
- test ?f, @path
24
- end
25
- def dir?
26
- test ?d, @path
27
- end
28
- def mtime
29
- File.mtime @path
30
- end
31
- def absolute_path
32
- @abs_path ||= File.expand_path(@path)
33
- end
34
- def dirname
35
- File.dirname absolute_path
36
- end
37
- end
38
-
39
7
  # This module provides some platform indenpendant
40
8
  # (let's hope) environment information.
41
9
  module Rant::Env