rant 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +38 -0
- data/README +4 -2
- data/Rantfile +50 -12
- data/doc/examples/c_cpp/c++/problem_1_1/another_test.cpp +6 -0
- data/doc/examples/c_cpp/c++/problem_1_1/another_test.h +5 -0
- data/doc/examples/c_cpp/c++/problem_1_1/main.cpp +12 -0
- data/doc/examples/c_cpp/c++/problem_1_1/test.cpp +6 -0
- data/doc/examples/c_cpp/c++/problem_1_1/test.h +5 -0
- data/doc/examples/c_cpp/c++/template.rf +15 -0
- data/doc/examples/c_cpp/c/problem_1_1/another_test.c +6 -0
- data/doc/examples/c_cpp/c/problem_1_1/another_test.h +7 -0
- data/doc/examples/c_cpp/c/problem_1_1/main.c +12 -0
- data/doc/examples/c_cpp/c/problem_1_1/test.c +6 -0
- data/doc/examples/c_cpp/c/problem_1_1/test.h +7 -0
- data/doc/examples/c_cpp/c/template.rf +15 -0
- data/doc/examples/c_cpp/root.rant +46 -0
- data/doc/homepage/index.html +115 -0
- data/doc/homepage/rant_home.css +98 -0
- data/doc/rant.1 +129 -0
- data/doc/rant.rdoc +5 -6
- data/doc/rantfile.rdoc +55 -32
- data/doc/subdirs.rdoc +147 -0
- data/lib/rant.rb +47 -49
- data/lib/rant/coregen.rb +20 -20
- data/lib/rant/import.rb +63 -11
- data/lib/rant/import/archive.rb +47 -15
- data/lib/rant/import/archive/tgz.rb +1 -1
- data/lib/rant/import/autoclean.rb +28 -26
- data/lib/rant/import/c/dependencies.rb +1 -1
- data/lib/rant/import/directedrule.rb +1 -4
- data/lib/rant/import/metadata.rb +30 -7
- data/lib/rant/import/nodes/default.rb +67 -13
- data/lib/rant/import/rubypackage.rb +1 -1
- data/lib/rant/import/rubytest.rb +25 -19
- data/lib/rant/import/signedfile.rb +14 -8
- data/lib/rant/import/sys/more.rb +22 -0
- data/lib/rant/import/sys/tgz.rb +43 -0
- data/lib/rant/import/sys/zip.rb +42 -0
- data/lib/rant/node.rb +19 -13
- data/lib/rant/plugin/configure.rb +1 -1
- data/lib/rant/progress.rb +33 -0
- data/lib/rant/rantenv.rb +7 -7
- data/lib/rant/rantlib.rb +246 -256
- data/lib/rant/rantsys.rb +61 -22
- data/lib/rant/rantvar.rb +7 -9
- data/misc/TODO +18 -0
- data/misc/devel-notes +4 -1
- data/test/Rantfile +17 -3
- data/test/deprecated/README +6 -0
- data/test/deprecated/test_0_4_8.rb +41 -0
- data/test/deprecated/test_0_5_2.rb +33 -0
- data/test/import/md5/root.rant +9 -0
- data/test/import/md5/test_md5.rb +45 -0
- data/test/import/metadata/Rantfile +2 -2
- data/test/import/metadata/test_metadata.rb +2 -2
- data/test/import/package/test_package.rb +40 -1
- data/test/import/signedfile/sub1/Rantfile +1 -1
- data/test/import/sys/data/pkg.tgz +0 -0
- data/test/import/sys/data/pkg.zip +0 -0
- data/test/import/sys/data/pkg/bin/test +0 -0
- data/test/import/sys/data/pkg/bin/test.o +0 -0
- data/test/import/sys/data/pkg/test.c +6 -0
- data/test/import/sys/data/pkg/test.h +7 -0
- data/test/import/sys/data/pkg2.zip +0 -0
- data/test/import/sys/test_tgz.rb +38 -0
- data/test/import/sys/test_zip.rb +68 -0
- data/test/import/sys/tgz.rf +6 -0
- data/test/import/sys/zip.rf +15 -0
- data/test/project2/{rantfile.rb → root.rant} +0 -0
- data/test/project2/test_project.rb +3 -8
- data/test/project_rb1/{rantfile.rb → rantfile} +1 -1
- data/test/project_rb1/test_project_rb1.rb +3 -5
- data/test/rant-import/test_rant-import.rb +22 -10
- data/test/subdirs/sub1/Rantfile +1 -1
- data/test/subdirs/sub2/{rantfile.rb → rantfile} +0 -0
- data/test/subdirs/sub2/sub/rantfile +1 -1
- data/test/subdirs2/root.rant +36 -0
- data/test/subdirs2/sub00/sub.rant +8 -0
- data/test/subdirs2/sub1/sub.rant +13 -0
- data/test/subdirs2/test_subdirs2.rb +239 -0
- data/test/test_examples.rb +91 -0
- data/test/test_filetask.rb +51 -11
- data/test/test_rant_interface.rb +24 -0
- data/test/test_rantfile_api.rb +54 -2
- data/test/test_sourcenode.rb +30 -0
- data/test/test_sys.rb +143 -15
- data/test/test_task.rb +16 -22
- data/test/tutil.rb +22 -38
- metadata +67 -9
data/lib/rant.rb
CHANGED
@@ -5,66 +5,64 @@ require 'rant/rantlib'
|
|
5
5
|
module RantContext
|
6
6
|
# Needed for irb, which defines its own +source+ method.
|
7
7
|
def source_rf(*args, &block)
|
8
|
-
|
8
|
+
rac.source(*args, &block)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
module Rant
|
12
12
|
class FileList
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
def inspect
|
14
|
+
# what's the right encoding for object_id ?
|
15
|
+
s = "#<#{self.class}:0x#{"%x" % object_id} "
|
16
|
+
s << "#{@actions.size} actions, #{@files.size} files"
|
17
|
+
if @ignore_rx
|
18
|
+
is = @ignore_rx.inspect.gsub(/\n|\t/, ' ')
|
19
|
+
s << ", ignore#{is.squeeze ' '}"
|
20
|
+
end
|
21
|
+
if @glob_flags != 0
|
22
|
+
s << ", flags:#@glob_flags"
|
23
|
+
end
|
24
|
+
s << ">"
|
25
|
+
end
|
26
26
|
end
|
27
27
|
module Node
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
28
|
+
def inspect
|
29
|
+
s = "#<#{self.class}:0x#{"%x" % object_id} "
|
30
|
+
s << "task_id:#{full_name}, action:#{inspect_action}"
|
31
|
+
s << ", deps:#{inspect_deps}"
|
32
|
+
s << ">"
|
33
|
+
end
|
34
|
+
private
|
35
|
+
def inspect_action
|
36
|
+
(defined? @block) ? @block.inspect : "nil"
|
37
|
+
end
|
38
|
+
def inspect_deps
|
39
|
+
if respond_to? :deps
|
40
|
+
dl = deps
|
41
|
+
s = dl.size.to_s
|
42
|
+
dls = dl.join(",")
|
43
|
+
dls[12..dls.length] = "..." if dls.length > 12
|
44
|
+
s << "[#{dls}]"
|
45
|
+
else
|
46
|
+
"0"
|
47
|
+
end
|
48
|
+
end
|
49
49
|
end
|
50
50
|
class RantApp
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
def inspect
|
52
|
+
s = "#<#{self.class}:0x#{"%x" % object_id} "
|
53
|
+
if current_subdir && !current_subdir.empty?
|
54
|
+
s << "subdir:#{current_subdir}, "
|
55
|
+
end
|
56
|
+
s << "tasks:#{tasks.size}"
|
57
|
+
s << ">"
|
58
|
+
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
|
62
|
+
def rant
|
63
|
+
@__rant__
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
@__rant__ = Rant::RantApp.new
|
67
67
|
|
68
|
-
|
69
|
-
exit Rant.run
|
70
|
-
end
|
68
|
+
include RantContext
|
data/lib/rant/coregen.rb
CHANGED
@@ -51,7 +51,7 @@ module Rant
|
|
51
51
|
# element (and has all other necessary directories as
|
52
52
|
# prerequisites).
|
53
53
|
def self.task(rac, ch, name, prerequisites=[], basedir=nil, &block)
|
54
|
-
dirs = ::Rant::Sys.
|
54
|
+
dirs = ::Rant::Sys.split_all(name)
|
55
55
|
if dirs.empty?
|
56
56
|
rac.abort_at(ch,
|
57
57
|
"Not a valid directory name: `#{name}'")
|
@@ -126,29 +126,29 @@ module Rant
|
|
126
126
|
end
|
127
127
|
esc_target = nil
|
128
128
|
target_rx = case target
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
129
|
+
when String
|
130
|
+
esc_target = Regexp.escape(target)
|
131
|
+
/#{esc_target}$/
|
132
|
+
when Regexp
|
133
|
+
target
|
134
|
+
else
|
135
135
|
rac.abort_at(ch, "rule target has " +
|
136
136
|
"to be a string or regular expression")
|
137
137
|
end
|
138
138
|
src_proc = case src_arg
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
blk = self.new { |task_name|
|
139
|
+
when String
|
140
|
+
unless String === target
|
141
|
+
rac.abort(ch, "rule target has to be " +
|
142
|
+
"a string if source is a string")
|
143
|
+
end
|
144
|
+
lambda { |name| name.sub(/#{esc_target}$/, src_arg) }
|
145
|
+
when Proc: src_arg
|
146
|
+
when nil: lambda { |name| [] }
|
147
|
+
else
|
148
|
+
rac.abort_at(ch, "rule source has to be " +
|
149
|
+
"String or Proc")
|
150
|
+
end
|
151
|
+
blk = self.new { |task_name, rel_project_dir|
|
152
152
|
if target_rx =~ task_name
|
153
153
|
have_src = true
|
154
154
|
src = src_proc[task_name]
|
data/lib/rant/import.rb
CHANGED
@@ -104,16 +104,11 @@ module Rant
|
|
104
104
|
@plugins.concat(@rantapp.plugins.map { |p| p.name })
|
105
105
|
end
|
106
106
|
|
107
|
-
#unless @imports.include? "nodes/default"
|
108
|
-
#@imports.unshift "nodes/default"
|
109
|
-
#end
|
110
|
-
|
111
107
|
if File.exist?(@mono_fn) && !@force
|
112
108
|
abort("#{@mono_fn} exists. Rant won't overwrite this file.",
|
113
109
|
"Add --force to override this restriction.")
|
114
110
|
end
|
115
|
-
|
116
|
-
mf << <<EOH
|
111
|
+
script = <<EOH
|
117
112
|
#!/usr/bin/env ruby
|
118
113
|
|
119
114
|
# #@mono_fn - Monolithic rant script, autogenerated by rant-import #{Rant::VERSION}.
|
@@ -124,10 +119,10 @@ module Rant
|
|
124
119
|
# You can distribute/modify this program under the terms of
|
125
120
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
126
121
|
EOH
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
122
|
+
script << mono_rant_core
|
123
|
+
script << mono_imports
|
124
|
+
script << mono_plugins
|
125
|
+
script << <<EOF
|
131
126
|
|
132
127
|
$".concat([#{@included_files.map{ |f| "'" + f + ".rb'" }.join(", ")}])
|
133
128
|
Rant::CODE_IMPORTS.concat %w(#{@included_imports.join(' ')}
|
@@ -149,7 +144,11 @@ end
|
|
149
144
|
|
150
145
|
exit Rant.run
|
151
146
|
EOF
|
152
|
-
|
147
|
+
msg "Postprocessing..."
|
148
|
+
script = filter_reopen_module(script)
|
149
|
+
File.open @mono_fn, "w" do |mf|
|
150
|
+
mf.write script
|
151
|
+
end
|
153
152
|
msg "Done.",
|
154
153
|
"Included imports: " + @included_imports.join(', '),
|
155
154
|
"Included plugins: " + @included_plugins.join(', '),
|
@@ -366,5 +365,58 @@ EOF
|
|
366
365
|
nil
|
367
366
|
end
|
368
367
|
|
368
|
+
# Takes a script text as argument and returns the same script
|
369
|
+
# but without unnecessary `end module XY' statements.
|
370
|
+
#
|
371
|
+
# Example input:
|
372
|
+
#
|
373
|
+
# 1 module Rant
|
374
|
+
# 2 # more code
|
375
|
+
# 3 end # module Rant
|
376
|
+
# 4
|
377
|
+
# 5
|
378
|
+
# 6 module Rant
|
379
|
+
# 7 # more code
|
380
|
+
#
|
381
|
+
# gives:
|
382
|
+
#
|
383
|
+
# 1 module Rant
|
384
|
+
# 2 # more code
|
385
|
+
# 5
|
386
|
+
# 7 # more code
|
387
|
+
#
|
388
|
+
# Note:: The comment with the module name in line 3 of the
|
389
|
+
# input is very important.
|
390
|
+
def filter_reopen_module(script)
|
391
|
+
lines = []
|
392
|
+
buffer = []
|
393
|
+
identifier = nil # class/module name
|
394
|
+
keyword = nil # class or module
|
395
|
+
script.split(/\n/).each { |line|
|
396
|
+
if identifier
|
397
|
+
if line.strip.empty?
|
398
|
+
buffer << line
|
399
|
+
elsif line =~ /^\s*#{keyword}\s+#{identifier}\s*$/
|
400
|
+
# replace buffer with one empty line
|
401
|
+
lines << ""
|
402
|
+
buffer.clear
|
403
|
+
identifier = keyword = nil
|
404
|
+
else
|
405
|
+
lines.concat buffer
|
406
|
+
buffer.clear
|
407
|
+
identifier = keyword = nil
|
408
|
+
redo
|
409
|
+
end
|
410
|
+
elsif line =~ /\s*end\s*#\s*(module|class)\s+(\w+)\s*$/
|
411
|
+
keyword = $1
|
412
|
+
identifier = $2
|
413
|
+
buffer << line
|
414
|
+
else
|
415
|
+
lines << line
|
416
|
+
end
|
417
|
+
}
|
418
|
+
lines.join("\n") << "\n"
|
419
|
+
end
|
420
|
+
|
369
421
|
end # class RantImport
|
370
422
|
end # module Rant
|
data/lib/rant/import/archive.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
require 'rant/rantlib'
|
11
11
|
require 'rant/import/subfile'
|
12
|
+
#require 'rant/progress' #rant-import:uncomment
|
12
13
|
#require 'rant/tempfile' #rant-import:uncomment
|
13
14
|
|
14
15
|
module Rant::Generators::Archive
|
@@ -82,7 +83,9 @@ module Rant::Generators::Archive
|
|
82
83
|
end
|
83
84
|
}
|
84
85
|
desc = pkg.rac.pop_desc
|
85
|
-
|
86
|
+
if opts[:files] and opts[:manifest] || flags.include?(:manifest)
|
87
|
+
pkg.define_manifest_task
|
88
|
+
end
|
86
89
|
pkg.rac.cx.desc desc
|
87
90
|
pkg.define_task
|
88
91
|
pkg
|
@@ -195,11 +198,9 @@ module Rant::Generators::Archive
|
|
195
198
|
def define_manifest_task
|
196
199
|
return @manifest_task if @manifest_task
|
197
200
|
@manifest_task =
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
yield name
|
202
|
-
end
|
201
|
+
::Rant::Generators::Task.rant_gen(
|
202
|
+
@rac, @ch, [@manifest]) do |t|
|
203
|
+
t.file_target
|
203
204
|
t.needed {
|
204
205
|
# fl refers to @res_files
|
205
206
|
fl = get_files
|
@@ -308,16 +309,47 @@ module Rant::Generators::Archive
|
|
308
309
|
dirs << dir unless dir == "." || dirs.include?(dir)
|
309
310
|
end
|
310
311
|
}
|
312
|
+
require 'rant/progress' #rant-import:remove
|
311
313
|
# create directory structure
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
314
|
+
progress = Rant::ProgressCountdown.new(dirs.size, @rac)
|
315
|
+
dir_msg = "Creating directories under #@dist_path: "
|
316
|
+
msg_len = dir_msg.length
|
317
|
+
unless dirs.empty?
|
318
|
+
@rac.cmd_print dir_msg
|
319
|
+
dirs.each { |dir|
|
320
|
+
FileUtils.mkpath(File.join(@dist_path, dir))
|
321
|
+
progress.inc
|
322
|
+
}
|
323
|
+
@rac.cmd_msg "done"
|
324
|
+
end
|
325
|
+
# link/copy files to package directory
|
326
|
+
f = fl.first
|
327
|
+
if f
|
328
|
+
progress = Rant::ProgressCountdown.new(fl.size, @rac)
|
329
|
+
dest = File.join(@dist_path, f)
|
330
|
+
ln_supported = true
|
331
|
+
begin
|
332
|
+
FileUtils.ln(f, dest)
|
333
|
+
fl.shift
|
334
|
+
@rac.cmd_print "Linking "
|
335
|
+
rescue Exception #Errno::EOPNOTSUPP
|
336
|
+
ln_supported = false
|
337
|
+
@rac.cmd_print "Copying "
|
338
|
+
end
|
339
|
+
@rac.cmd_print \
|
340
|
+
"#{progress.total} files to #@dist_path: ".ljust(msg_len - 8)
|
341
|
+
progress.inc if ln_supported
|
342
|
+
fl.each { |f|
|
343
|
+
dest = File.join(@dist_path, f)
|
344
|
+
if ln_supported
|
345
|
+
FileUtils.ln(f, dest)
|
346
|
+
else
|
347
|
+
FileUtils.cp(f, dest)
|
348
|
+
end
|
349
|
+
progress.inc
|
350
|
+
}
|
351
|
+
@rac.cmd_msg "done"
|
352
|
+
end
|
321
353
|
}
|
322
354
|
end
|
323
355
|
end # class Base
|
@@ -37,7 +37,7 @@ module Rant::Generators::Archive
|
|
37
37
|
end
|
38
38
|
def minitar_tgz fn, files, opts = {:recurse => false}
|
39
39
|
require 'zlib'
|
40
|
-
require 'rant/archive/minitar'
|
40
|
+
require 'rant/archive/minitar' #rant-import:remove
|
41
41
|
@rac.cmd_msg "minitar #{fn}"
|
42
42
|
files = files.to_ary if files.respond_to? :to_ary
|
43
43
|
tgz = Zlib::GzipWriter.new(File.open(fn, 'wb'))
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
require 'rant/rantlib'
|
7
7
|
require 'rant/import/clean'
|
8
|
+
require 'rant/import/sys/more'
|
8
9
|
|
9
10
|
class Rant::Generators::AutoClean
|
10
11
|
def self.rant_gen(rac, ch, args, &block)
|
@@ -21,24 +22,29 @@ class Rant::Generators::AutoClean
|
|
21
22
|
|
22
23
|
# create task
|
23
24
|
rac.task :__caller__ => ch, tname => [] do |t|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
add_common_dirs = {}
|
26
|
+
rac.tasks.each { |name, node|
|
27
|
+
if Array === node
|
28
|
+
f = node.first
|
29
|
+
if f.file_target?
|
30
|
+
add_common_dirs[File.dirname(f.full_name)] = true
|
31
|
+
end
|
32
|
+
node.each { |subw|
|
33
|
+
subw.each_target { |entry| rac.sys.clean entry }
|
28
34
|
}
|
29
35
|
else
|
30
|
-
|
36
|
+
if node.file_target?
|
37
|
+
add_common_dirs[File.dirname(node.full_name)] = true
|
38
|
+
end
|
39
|
+
node.each_target { |entry| rac.sys.clean entry }
|
31
40
|
end
|
32
41
|
}
|
33
42
|
target_rx = nil
|
34
43
|
rac.resolve_hooks.each { |hook|
|
35
44
|
if hook.respond_to? :each_target
|
36
45
|
hook.each_target { |entry|
|
37
|
-
|
38
|
-
|
39
|
-
else
|
40
|
-
rac.cx.sys.rm_rf entry
|
41
|
-
end
|
46
|
+
add_common_dirs[File.expand_path(File.dirname(entry))] = true
|
47
|
+
rac.sys.clean entry
|
42
48
|
}
|
43
49
|
elsif hook.respond_to? :target_rx
|
44
50
|
next(rx) unless (t_rx = hook.target_rx)
|
@@ -46,15 +52,13 @@ class Rant::Generators::AutoClean
|
|
46
52
|
Regexp.union(target_rx, t_rx)
|
47
53
|
end
|
48
54
|
}
|
55
|
+
t.goto_task_home
|
49
56
|
if target_rx
|
50
|
-
rac.
|
51
|
-
rac.
|
57
|
+
rac.vmsg 1, "searching for rule products"
|
58
|
+
rac.sys["**/*"].each { |entry|
|
52
59
|
if entry =~ target_rx
|
53
|
-
|
54
|
-
|
55
|
-
else
|
56
|
-
rac.cx.sys.rm_rf entry
|
57
|
-
end
|
60
|
+
add_common_dirs[File.dirname(entry)] = true
|
61
|
+
rac.sys.clean entry
|
58
62
|
end
|
59
63
|
}
|
60
64
|
end
|
@@ -64,18 +68,16 @@ class Rant::Generators::AutoClean
|
|
64
68
|
sd = rf.project_subdir
|
65
69
|
common.each { |fn|
|
66
70
|
path = sd.empty? ? fn : File.join(sd, fn)
|
67
|
-
clean
|
71
|
+
rac.sys.clean path
|
72
|
+
}
|
73
|
+
}
|
74
|
+
#STDERR.puts add_common_dirs.inspect
|
75
|
+
add_common_dirs.each { |dir, _|
|
76
|
+
common.each { |fn|
|
77
|
+
rac.sys.clean File.join(dir, fn)
|
68
78
|
}
|
69
79
|
}
|
70
80
|
end
|
71
|
-
t.goto_task_home
|
72
81
|
end
|
73
82
|
end
|
74
|
-
def self.clean(rac, entry)
|
75
|
-
if test ?f, entry
|
76
|
-
rac.cx.sys.rm_f entry
|
77
|
-
elsif test ?e, entry
|
78
|
-
rac.cx.sys.rm_rf entry
|
79
|
-
end
|
80
|
-
end
|
81
83
|
end
|