rant 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +13 -0
- data/README +7 -1
- data/Rantfile +10 -14
- data/TODO +3 -0
- data/devel-notes +5 -0
- data/doc/advanced.rdoc +46 -0
- data/doc/c.rdoc +64 -0
- data/doc/examples/c_dependencies/Rantfile +27 -0
- data/doc/examples/c_dependencies/include/hello.h +7 -0
- data/doc/examples/c_dependencies/include/util.h +7 -0
- data/doc/examples/c_dependencies/src/main.c +9 -0
- data/doc/examples/c_dependencies/src/util.c +9 -0
- data/doc/examples/directedrule/Rantfile +0 -1
- data/doc/rantfile.rdoc +12 -9
- data/doc/rubyproject.rdoc +26 -0
- data/lib/rant/c/include.rb +51 -0
- data/lib/rant/import/autoclean.rb +16 -9
- data/lib/rant/import/c/dependencies.rb +127 -0
- data/lib/rant/import/directedrule.rb +8 -4
- data/lib/rant/import/rubypackage.rb +2 -1
- data/lib/rant/import/subfile.rb +41 -0
- data/lib/rant/import/truth.rb +6 -1
- data/lib/rant/import/win32/rubycmdwrapper.rb +37 -0
- data/lib/rant/import.rb +26 -3
- data/lib/rant/rantenv.rb +0 -32
- data/lib/rant/rantfile.rb +207 -194
- data/lib/rant/rantlib.rb +83 -150
- data/lib/rant/rantsys.rb +7 -10
- data/lib/rant/rantvar.rb +4 -6
- data/lib/rant.rb +57 -0
- data/rantmethods.rb +1 -47
- data/setup.rb +2 -2
- data/test/Rantfile +6 -1
- data/test/c/source.c +23 -0
- data/test/c/test_parse_includes.rb +41 -0
- data/test/import/c/dependencies/Rantfile +34 -0
- data/test/import/c/dependencies/bar.h +2 -0
- data/test/import/c/dependencies/foo.h +5 -0
- data/test/import/c/dependencies/hello.c +7 -0
- data/test/import/c/dependencies/include/foo.h +0 -0
- data/test/import/c/dependencies/include/sub/sub.h +8 -0
- data/test/import/c/dependencies/include/with space.h +7 -0
- data/test/import/c/dependencies/src/abc +5 -0
- data/test/import/c/dependencies/src/abc.c +5 -0
- data/test/import/c/dependencies/src/bar.c +11 -0
- data/test/import/c/dependencies/test_c_dependencies.rb +92 -0
- data/test/import/c/dependencies/test_on_the_fly.rb +44 -0
- data/test/import/directedrule/Rantfile +7 -2
- data/test/import/directedrule/test_directedrule.rb +6 -0
- data/test/import/subfile/Rantfile +28 -0
- data/test/import/subfile/autoclean.rf +16 -0
- data/test/import/subfile/test_subfile.rb +91 -0
- data/test/import/truth/Rantfile +7 -0
- data/test/import/truth/test_truth.rb +3 -0
- data/test/project2/buildfile +2 -0
- data/test/project2/test_project.rb +5 -3
- data/test/rant-import/Rantfile +4 -0
- data/test/rant-import/test_rant-import.rb +104 -1
- data/test/rule.rf +6 -0
- data/test/test_autosubfiletask.rb +59 -0
- data/test/test_clean.rb +48 -5
- data/test/test_dirtask.rb +45 -1
- data/test/test_examples.rb +25 -3
- data/test/test_filelist.rb +14 -2
- data/test/test_lighttask.rb +4 -6
- data/test/test_rant_interface.rb +8 -8
- data/test/test_rantfile_api.rb +37 -1
- data/test/test_rule.rb +6 -3
- data/test/test_source.rb +28 -1
- data/test/test_sourcenode.rb +163 -0
- data/test/test_task.rb +2 -2
- data/test/test_var.rb +3 -3
- data/test/tutil.rb +23 -2
- metadata +45 -3
- data/test/test_metatask.rb +0 -29
data/lib/rant/rantlib.rb
CHANGED
@@ -60,7 +60,7 @@ class String
|
|
60
60
|
if new_ext
|
61
61
|
self.sub(/#{Regexp.escape ext}$/, new_ext)
|
62
62
|
else
|
63
|
-
self.sub(
|
63
|
+
self.sub(/(\.[^.]*$)|$/, ".#{ext}")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -138,8 +138,8 @@ module RantContext
|
|
138
138
|
rac.subdirs(*args)
|
139
139
|
end
|
140
140
|
|
141
|
-
def source rantfile
|
142
|
-
rac.source(rantfile)
|
141
|
+
def source(opt, rantfile = nil)
|
142
|
+
rac.source(opt, rantfile)
|
143
143
|
end
|
144
144
|
|
145
145
|
def sys(*args, &block)
|
@@ -213,8 +213,8 @@ module Rant
|
|
213
213
|
@@rac.args.replace(args.flatten)
|
214
214
|
@@rac.run
|
215
215
|
else
|
216
|
-
@@rac = Rant::RantApp.new
|
217
|
-
@@rac.run
|
216
|
+
@@rac = Rant::RantApp.new
|
217
|
+
@@rac.run(args)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -295,12 +295,13 @@ class Rant::RantApp
|
|
295
295
|
# A list of all registered plugins.
|
296
296
|
attr_reader :plugins
|
297
297
|
# The context in which Rantfiles are loaded. RantContext methods
|
298
|
-
# may be called through
|
299
|
-
# plugins).
|
298
|
+
# may be called through this object (e.g. from plugins).
|
300
299
|
attr_reader :context
|
301
300
|
alias cx context
|
302
301
|
# A hash with all tasks. For fast task lookup use this hash with
|
303
302
|
# the taskname as key.
|
303
|
+
#
|
304
|
+
# See also: #resolve, #make
|
304
305
|
attr_reader :tasks
|
305
306
|
# A list of all imports (code loaded with +import+).
|
306
307
|
attr_reader :imports
|
@@ -314,6 +315,11 @@ class Rant::RantApp
|
|
314
315
|
attr_reader :resolve_hooks
|
315
316
|
|
316
317
|
def initialize *args
|
318
|
+
unless args.empty?
|
319
|
+
STDERR.puts caller[0]
|
320
|
+
STDERR.puts "Warning: Giving arguments Rant::RantApp.new " +
|
321
|
+
"is deprecated. Give them to the #run method."
|
322
|
+
end
|
317
323
|
@args = args.flatten
|
318
324
|
# Rantfiles will be loaded in the context of this object.
|
319
325
|
@context = RantAppContext.new(self)
|
@@ -336,7 +342,7 @@ class Rant::RantApp
|
|
336
342
|
@var.query :ignore, :AutoList, []
|
337
343
|
@imports = []
|
338
344
|
|
339
|
-
|
345
|
+
#@task_show = nil
|
340
346
|
@task_desc = nil
|
341
347
|
|
342
348
|
@orig_pwd = nil
|
@@ -358,8 +364,6 @@ class Rant::RantApp
|
|
358
364
|
end
|
359
365
|
|
360
366
|
def rootdir
|
361
|
-
#od = @opts[:directory]
|
362
|
-
#od ? od.dup : ""
|
363
367
|
@opts[:directory]
|
364
368
|
end
|
365
369
|
|
@@ -440,8 +444,9 @@ class Rant::RantApp
|
|
440
444
|
end
|
441
445
|
|
442
446
|
# Returns 0 on success and 1 on failure.
|
443
|
-
def run
|
447
|
+
def run *args
|
444
448
|
@run = true
|
449
|
+
@args.concat(args.flatten)
|
445
450
|
# remind pwd
|
446
451
|
@orig_pwd = Dir.pwd
|
447
452
|
# Process commandline.
|
@@ -479,10 +484,6 @@ class Rant::RantApp
|
|
479
484
|
goto "#"
|
480
485
|
@plugins.each { |plugin| plugin.rant_done }
|
481
486
|
return 0
|
482
|
-
rescue Rant::RantfileException
|
483
|
-
err_msg "Invalid Rantfile: " + $!.message
|
484
|
-
$stderr.puts "rant aborted!"
|
485
|
-
return 1
|
486
487
|
rescue Rant::RantError
|
487
488
|
ch = get_ch_from_backtrace($!.backtrace)
|
488
489
|
if ch
|
@@ -509,9 +510,6 @@ class Rant::RantApp
|
|
509
510
|
end
|
510
511
|
|
511
512
|
###### methods accessible through RantContext ####################
|
512
|
-
def show *args
|
513
|
-
@task_show = *args.join("\n")
|
514
|
-
end
|
515
513
|
|
516
514
|
def desc *args
|
517
515
|
if args.empty? || (args.size == 1 && args.first.nil?)
|
@@ -539,12 +537,10 @@ class Rant::RantApp
|
|
539
537
|
ch = Rant::Lib::parse_caller_elem(clr)
|
540
538
|
name = nil
|
541
539
|
pre = []
|
542
|
-
ln = ch[:ln] || 0
|
543
|
-
file = ch[:file]
|
544
540
|
# validate args
|
545
541
|
generator = args.shift
|
546
542
|
unless generator.respond_to? :rant_generate
|
547
|
-
|
543
|
+
abort_at(ch,
|
548
544
|
"First argument to `gen' has to be a task-generator.")
|
549
545
|
end
|
550
546
|
# ask generator to produce a task for this application
|
@@ -603,7 +599,7 @@ class Rant::RantApp
|
|
603
599
|
Rant::CODE_IMPORTS << import_name
|
604
600
|
rescue LoadError
|
605
601
|
abort(pos_text(file, ln),
|
606
|
-
"no such plugin library
|
602
|
+
"no such plugin library -- #{lc_pl_name}")
|
607
603
|
end
|
608
604
|
end
|
609
605
|
pl_class = nil
|
@@ -611,7 +607,7 @@ class Rant::RantApp
|
|
611
607
|
pl_class = ::Rant::Plugin.const_get(pl_name)
|
612
608
|
rescue NameError, ArgumentError
|
613
609
|
abort(pos_text(file, ln),
|
614
|
-
"
|
610
|
+
"no such plugin -- #{pl_name}")
|
615
611
|
end
|
616
612
|
|
617
613
|
plugin = pl_class.rant_plugin_new(self, ch, *args, &block)
|
@@ -629,15 +625,14 @@ class Rant::RantApp
|
|
629
625
|
# and a new file task.
|
630
626
|
def enhance targ, &block
|
631
627
|
prepare_task(targ, block) { |name,pre,blk|
|
632
|
-
t =
|
633
|
-
if Rant::MetaTask === t
|
634
|
-
t = t.last
|
635
|
-
end
|
628
|
+
t = resolve(name).last
|
636
629
|
if t
|
637
630
|
unless t.respond_to? :enhance
|
638
631
|
abort("Can't enhance task `#{name}'")
|
639
632
|
end
|
640
633
|
t.enhance(pre, &blk)
|
634
|
+
# Important: return from method, don't break to
|
635
|
+
# prepare_task which would add task t again
|
641
636
|
return t
|
642
637
|
end
|
643
638
|
warn_msg "enhance \"#{name}\": no such task",
|
@@ -646,16 +641,21 @@ class Rant::RantApp
|
|
646
641
|
}
|
647
642
|
end
|
648
643
|
|
649
|
-
|
644
|
+
# Returns the value of the last expression executed in +rantfile+.
|
645
|
+
def source(opt, rantfile = nil)
|
646
|
+
unless rantfile
|
647
|
+
rantfile = opt
|
648
|
+
opt = nil
|
649
|
+
end
|
650
|
+
make_rf = opt != :n && opt != :now
|
650
651
|
rf, is_new = rantfile_for_path(rantfile)
|
651
652
|
return false unless is_new
|
652
|
-
|
653
|
-
unless
|
654
|
-
abort("source: No such file
|
653
|
+
make rantfile if make_rf
|
654
|
+
unless File.exist? rf.path
|
655
|
+
abort("source: No such file -- #{rantfile}")
|
655
656
|
end
|
656
657
|
|
657
658
|
load_file rf
|
658
|
-
true
|
659
659
|
end
|
660
660
|
|
661
661
|
# Search the given directories for Rantfiles.
|
@@ -665,12 +665,9 @@ class Rant::RantApp
|
|
665
665
|
ln = cinf[:ln] || 0
|
666
666
|
file = cinf[:file]
|
667
667
|
args.each { |arg|
|
668
|
-
#if arg.is_a? Symbol
|
669
|
-
# arg = arg.to_s
|
670
668
|
if arg.respond_to? :to_str
|
671
669
|
arg = arg.to_str
|
672
|
-
|
673
|
-
unless arg.is_a? String
|
670
|
+
else
|
674
671
|
abort(pos_text(file, ln),
|
675
672
|
"subdirs: arguments must be strings")
|
676
673
|
end
|
@@ -686,15 +683,13 @@ class Rant::RantApp
|
|
686
683
|
rantfiles_in_dir.each { |f|
|
687
684
|
loaded = true
|
688
685
|
rf, is_new = rantfile_for_path(f)
|
689
|
-
if is_new
|
690
|
-
load_file rf
|
691
|
-
end
|
686
|
+
load_file rf if is_new
|
692
687
|
}
|
693
688
|
ensure
|
694
689
|
#puts " going back to project dir: #{prev_subdir}"
|
695
690
|
goto_project_dir prev_subdir
|
696
691
|
end
|
697
|
-
unless loaded ||
|
692
|
+
unless loaded || @opts[:no_warn_subdir]
|
698
693
|
warn_msg(pos_text(file, ln),
|
699
694
|
"subdirs: No Rantfile in subdir `#{arg}'.")
|
700
695
|
end
|
@@ -704,22 +699,14 @@ class Rant::RantApp
|
|
704
699
|
end
|
705
700
|
|
706
701
|
def sys(*args, &block)
|
707
|
-
|
708
|
-
@sys
|
709
|
-
else
|
710
|
-
@sys.sh(*args)
|
711
|
-
end
|
702
|
+
args.empty? ? @sys : @sys.sh(*args)
|
712
703
|
end
|
713
704
|
|
714
705
|
# The [] and []= operators may be used to set/get values from this
|
715
706
|
# object (like a hash). It is intended to let the different
|
716
707
|
# modules, plugins and tasks to communicate with each other.
|
717
708
|
def var(*args, &block)
|
718
|
-
|
719
|
-
@var
|
720
|
-
else
|
721
|
-
@var.query(*args, &block)
|
722
|
-
end
|
709
|
+
args.empty? ? @var : @var.query(*args, &block)
|
723
710
|
end
|
724
711
|
##################################################################
|
725
712
|
|
@@ -771,7 +758,6 @@ class Rant::RantApp
|
|
771
758
|
}
|
772
759
|
name_length < 7 && name_length = 7
|
773
760
|
cmd_length = prefix.length + name_length
|
774
|
-
# TODO: show what's done if rant is invoked without argument
|
775
761
|
unless tlist.first.full_name == def_target
|
776
762
|
defaults = list_task_names(
|
777
763
|
resolve(def_target)).join(', ')
|
@@ -802,13 +788,7 @@ class Rant::RantApp
|
|
802
788
|
rsl
|
803
789
|
end
|
804
790
|
private :list_task_names
|
805
|
-
|
806
|
-
# Increase verbosity.
|
807
|
-
def more_verbose
|
808
|
-
@opts[:verbose] += 1
|
809
|
-
@opts[:quiet] = false
|
810
|
-
end
|
811
|
-
|
791
|
+
|
812
792
|
# This is actually an integer indicating the verbosity level.
|
813
793
|
# Usual values range from 0 to 3.
|
814
794
|
def verbose
|
@@ -839,7 +819,7 @@ class Rant::RantApp
|
|
839
819
|
# Print a command message as would be done from a call to a
|
840
820
|
# Sys method.
|
841
821
|
def cmd_msg cmd
|
842
|
-
|
822
|
+
puts cmd unless quiet?
|
843
823
|
end
|
844
824
|
|
845
825
|
###### public methods regarding plugins ##########################
|
@@ -889,20 +869,15 @@ class Rant::RantApp
|
|
889
869
|
# The target list is a list of strings, not Task objects!
|
890
870
|
if target_list.empty?
|
891
871
|
def_tasks = resolve "default"
|
892
|
-
#have_default = @rantfiles.any? { |f|
|
893
|
-
# f.tasks.any? { |t| t.name == "default" }
|
894
|
-
#}
|
895
872
|
unless def_tasks.empty?
|
896
873
|
target_list << "default"
|
897
874
|
else
|
898
|
-
first = nil
|
899
875
|
@rantfiles.each { |f|
|
900
876
|
unless f.tasks.empty?
|
901
|
-
|
877
|
+
target_list << f.tasks.first.full_name
|
902
878
|
break
|
903
879
|
end
|
904
880
|
}
|
905
|
-
target_list << first
|
906
881
|
end
|
907
882
|
end
|
908
883
|
target_list
|
@@ -915,15 +890,15 @@ class Rant::RantApp
|
|
915
890
|
matching_tasks = 0
|
916
891
|
target_list.each do |target|
|
917
892
|
goto "#"
|
918
|
-
if
|
919
|
-
abort("Don't know how to
|
893
|
+
if make(target) == 0
|
894
|
+
abort("Don't know how to make `#{target}'.")
|
920
895
|
end
|
921
896
|
end
|
922
897
|
end
|
923
898
|
|
924
899
|
# Invoke all tasks necessary to build +target+. Returns the number
|
925
900
|
# of tasks invoked.
|
926
|
-
def
|
901
|
+
def make target, opt = {}
|
927
902
|
opt[:force] = true if @force_targets.delete(target)
|
928
903
|
matching_tasks = 0
|
929
904
|
old_subdir = @current_subdir
|
@@ -941,12 +916,12 @@ class Rant::RantApp
|
|
941
916
|
Dir.chdir old_pwd
|
942
917
|
matching_tasks
|
943
918
|
end
|
944
|
-
public :
|
919
|
+
public :make
|
920
|
+
alias build make
|
945
921
|
|
922
|
+
# Currently always returns an array (which might actually be a
|
923
|
+
# an empty array, but never nil).
|
946
924
|
def resolve task_name, rel_project_dir = @current_subdir
|
947
|
-
#select_tasks_by_name task_name, rel_project_dir
|
948
|
-
# Note: first lines copied from +select_tasks_by_name+
|
949
|
-
# for efficiency reasons
|
950
925
|
s = @tasks[expand_path(rel_project_dir, task_name)]
|
951
926
|
case s
|
952
927
|
when nil
|
@@ -956,8 +931,8 @@ class Rant::RantApp
|
|
956
931
|
return s if s
|
957
932
|
}
|
958
933
|
[]
|
959
|
-
when Rant::
|
960
|
-
else # assuming
|
934
|
+
when Rant::Node: [s]
|
935
|
+
else # assuming list of tasks
|
961
936
|
s
|
962
937
|
end
|
963
938
|
end
|
@@ -972,9 +947,6 @@ class Rant::RantApp
|
|
972
947
|
# returns true.
|
973
948
|
def select_tasks
|
974
949
|
selection = []
|
975
|
-
### pre 0.2.10 ##################
|
976
|
-
# @rantfile.reverse.each { |rf|
|
977
|
-
#################################
|
978
950
|
@rantfiles.each { |rf|
|
979
951
|
rf.tasks.each { |t|
|
980
952
|
selection << t if yield t
|
@@ -984,32 +956,6 @@ class Rant::RantApp
|
|
984
956
|
end
|
985
957
|
public :select_tasks
|
986
958
|
|
987
|
-
# Returns an array (might be a MetaTask) with all tasks that have
|
988
|
-
# the given name.
|
989
|
-
def select_tasks_by_name name, project_dir = @current_subdir
|
990
|
-
# pre 0.3.1
|
991
|
-
#s = @tasks[name]
|
992
|
-
s = @tasks[expand_path(project_dir, name)]
|
993
|
-
case s
|
994
|
-
when nil: []
|
995
|
-
when Rant::Worker: [s]
|
996
|
-
else # assuming MetaTask
|
997
|
-
s
|
998
|
-
end
|
999
|
-
end
|
1000
|
-
public :select_tasks_by_name
|
1001
|
-
|
1002
|
-
# Get the first task for which yield returns true. Returns nil if
|
1003
|
-
# yield never returned true.
|
1004
|
-
def select_task
|
1005
|
-
@rantfiles.reverse.each { |rf|
|
1006
|
-
rf.tasks.each { |t|
|
1007
|
-
return t if yield t
|
1008
|
-
}
|
1009
|
-
}
|
1010
|
-
nil
|
1011
|
-
end
|
1012
|
-
|
1013
959
|
def load_rantfiles
|
1014
960
|
# Take care: When rant isn't invoked from commandline,
|
1015
961
|
# some "rant code" could already have run!
|
@@ -1042,24 +988,28 @@ class Rant::RantApp
|
|
1042
988
|
end
|
1043
989
|
end
|
1044
990
|
|
991
|
+
# Returns the value of the last expression executed in +rantfile+.
|
992
|
+
# +rantfile+ has to be an Rant::Rantfile instance.
|
1045
993
|
def load_file rantfile
|
1046
|
-
msg 1, "source #{rantfile
|
994
|
+
msg 1, "source #{rantfile}"
|
995
|
+
rv = nil
|
1047
996
|
begin
|
1048
|
-
path = rantfile.
|
1049
|
-
@context.instance_eval(File.read(path), path)
|
997
|
+
path = rantfile.path
|
998
|
+
rv = @context.instance_eval(File.read(path), path)
|
1050
999
|
rescue NameError => e
|
1051
|
-
abort("Name error when loading `#{rantfile
|
1000
|
+
abort("Name error when loading `#{rantfile}':",
|
1052
1001
|
e.message, e.backtrace)
|
1053
1002
|
rescue LoadError => e
|
1054
|
-
abort("Load error when loading `#{rantfile
|
1003
|
+
abort("Load error when loading `#{rantfile}':",
|
1055
1004
|
e.message, e.backtrace)
|
1056
1005
|
rescue ScriptError => e
|
1057
|
-
abort("Script error when loading `#{rantfile
|
1006
|
+
abort("Script error when loading `#{rantfile}':",
|
1058
1007
|
e.message, e.backtrace)
|
1059
1008
|
end
|
1060
1009
|
unless @rantfiles.include?(rantfile)
|
1061
1010
|
@rantfiles << rantfile
|
1062
1011
|
end
|
1012
|
+
rv
|
1063
1013
|
end
|
1064
1014
|
private :load_file
|
1065
1015
|
|
@@ -1071,9 +1021,9 @@ class Rant::RantApp
|
|
1071
1021
|
files = []
|
1072
1022
|
::Rant::RANTFILES.each { |rfn|
|
1073
1023
|
path = dir ? File.join(dir, rfn) : rfn
|
1074
|
-
# We
|
1075
|
-
#
|
1076
|
-
#
|
1024
|
+
# We don't accept rantfiles with pathes that differ only
|
1025
|
+
# in case. This protects from loading the same file twice
|
1026
|
+
# on case insensitive file systems.
|
1077
1027
|
unless files.find { |f| f.downcase == path.downcase }
|
1078
1028
|
files << path if test(?f, path)
|
1079
1029
|
end
|
@@ -1091,14 +1041,9 @@ class Rant::RantApp
|
|
1091
1041
|
cmd_opts.quiet = true
|
1092
1042
|
cmd_opts.each { |opt, value|
|
1093
1043
|
case opt
|
1094
|
-
when "--verbose":
|
1095
|
-
when "--quiet"
|
1096
|
-
@opts[:quiet] = true
|
1097
|
-
@opts[:verbose] = -1
|
1098
|
-
when "--err-commands"
|
1099
|
-
@opts[:err_commands] = true
|
1044
|
+
when "--verbose": @opts[:verbose] += 1
|
1100
1045
|
when "--version"
|
1101
|
-
|
1046
|
+
puts "rant #{Rant::VERSION}"
|
1102
1047
|
raise Rant::RantDoneException
|
1103
1048
|
when "--help"
|
1104
1049
|
show_help
|
@@ -1111,12 +1056,9 @@ class Rant::RantApp
|
|
1111
1056
|
@arg_rantfiles << value
|
1112
1057
|
when "--force-run"
|
1113
1058
|
@force_targets << value
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
@opts[:stop_after_load] = true
|
1118
|
-
when "--trace-abort"
|
1119
|
-
@opts[:trace_abort] = true
|
1059
|
+
else
|
1060
|
+
# simple switch
|
1061
|
+
@opts[opt.sub(/^--/, '').tr('-', "_").to_sym] = true
|
1120
1062
|
end
|
1121
1063
|
}
|
1122
1064
|
rescue GetoptLong::Error => e
|
@@ -1138,18 +1080,10 @@ class Rant::RantApp
|
|
1138
1080
|
def prepare_task(targ, block, clr = caller[2])
|
1139
1081
|
#STDERR.puts "prepare task (#@current_subdir):\n #{targ.inspect}"
|
1140
1082
|
|
1141
|
-
# Allow override of caller,
|
1083
|
+
# Allow override of caller, useful for plugins and libraries
|
1142
1084
|
# that define tasks.
|
1143
1085
|
if targ.is_a? Hash
|
1144
|
-
targ.reject! { |k, v|
|
1145
|
-
case k
|
1146
|
-
when :__caller__
|
1147
|
-
clr = v
|
1148
|
-
true
|
1149
|
-
else
|
1150
|
-
false
|
1151
|
-
end
|
1152
|
-
}
|
1086
|
+
targ.reject! { |k, v| clr = v if k == :__caller__ }
|
1153
1087
|
end
|
1154
1088
|
cinf = Hash === clr ? clr : Rant::Lib::parse_caller_elem(clr)
|
1155
1089
|
|
@@ -1174,11 +1108,10 @@ class Rant::RantApp
|
|
1174
1108
|
case et
|
1175
1109
|
when nil
|
1176
1110
|
@tasks[n] = task
|
1177
|
-
when Rant::
|
1178
|
-
mt =
|
1179
|
-
mt << et << task
|
1111
|
+
when Rant::Node
|
1112
|
+
mt = [et, task]
|
1180
1113
|
@tasks[n] = mt
|
1181
|
-
else # assuming
|
1114
|
+
else # assuming list of tasks
|
1182
1115
|
et << task
|
1183
1116
|
end
|
1184
1117
|
end
|
@@ -1192,14 +1125,15 @@ class Rant::RantApp
|
|
1192
1125
|
# and the second is an array with the prerequisites.
|
1193
1126
|
# The third is the file name of +clr+, the fourth is the line number
|
1194
1127
|
# of +clr+.
|
1195
|
-
def normalize_task_arg(targ,
|
1128
|
+
def normalize_task_arg(targ, ch)
|
1129
|
+
# pre 0.3.7: ch in parameter list was clr
|
1196
1130
|
# TODO: check the code calling this method so that we can
|
1197
1131
|
# assume clr is already a hash
|
1198
|
-
ch = Hash === clr ? clr : Rant::Lib::parse_caller_elem(clr)
|
1132
|
+
#ch = Hash === clr ? clr : Rant::Lib::parse_caller_elem(clr)
|
1133
|
+
|
1199
1134
|
name = nil
|
1200
1135
|
pre = []
|
1201
|
-
ln = ch[:ln]
|
1202
|
-
file = ch[:file]
|
1136
|
+
ln, file = ch[:ln], ch[:file]
|
1203
1137
|
|
1204
1138
|
# process and validate targ
|
1205
1139
|
if targ.is_a? Hash
|
@@ -1255,15 +1189,14 @@ class Rant::RantApp
|
|
1255
1189
|
# the rantfile was created and added, otherwise the rantfile
|
1256
1190
|
# already existed.
|
1257
1191
|
def rantfile_for_path path
|
1258
|
-
#
|
1259
|
-
# (don't forget the calls from Rant::Path#absolute_path)
|
1192
|
+
# all rantfiles have an absolute path as path attribute
|
1260
1193
|
abs_path = File.expand_path(path)
|
1261
|
-
if @rantfiles.any? { |rf| rf.
|
1262
|
-
file = @rantfiles.find { |rf| rf.
|
1194
|
+
if @rantfiles.any? { |rf| rf.path == abs_path }
|
1195
|
+
file = @rantfiles.find { |rf| rf.path == abs_path }
|
1263
1196
|
[file, false]
|
1264
1197
|
else
|
1265
1198
|
# create new Rantfile object
|
1266
|
-
file = Rant::Rantfile.new
|
1199
|
+
file = Rant::Rantfile.new abs_path
|
1267
1200
|
file.project_subdir = @current_subdir
|
1268
1201
|
@rantfiles << file
|
1269
1202
|
[file, true]
|
@@ -1311,8 +1244,8 @@ class Rant::RantApp
|
|
1311
1244
|
end
|
1312
1245
|
elsif Rant::CommandError === orig
|
1313
1246
|
msg << orig.message if @opts[:err_commands]
|
1314
|
-
|
1315
|
-
msg << orig.message
|
1247
|
+
elsif !(Rant::RantAbortException === orig)
|
1248
|
+
msg << orig.message << orig.backtrace[0..4]
|
1316
1249
|
end
|
1317
1250
|
end
|
1318
1251
|
err_msg msg unless msg.empty?
|
data/lib/rant/rantsys.rb
CHANGED
@@ -192,15 +192,12 @@ module Rant
|
|
192
192
|
if File::ALT_SEPARATOR
|
193
193
|
# TODO: check for FS case sensitivity?
|
194
194
|
def mk_all_rx(file)
|
195
|
-
|
196
|
-
/(^|(#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+)
|
197
|
-
#{Regexp.escape(file)}
|
195
|
+
/(^|(#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+)#{Regexp.escape(file)}
|
198
196
|
((#{ESC_SEPARATOR}|#{ESC_ALT_SEPARATOR})+|$)/x
|
199
197
|
end
|
200
198
|
else
|
201
199
|
def mk_all_rx(file)
|
202
|
-
/(^|#{ESC_SEPARATOR}+)
|
203
|
-
#{Regexp.escape(file)}
|
200
|
+
/(^|#{ESC_SEPARATOR}+)#{Regexp.escape(file)}
|
204
201
|
(#{ESC_SEPARATOR}+|$)/x
|
205
202
|
end
|
206
203
|
end
|
@@ -213,7 +210,7 @@ module Rant
|
|
213
210
|
end
|
214
211
|
|
215
212
|
def apply_select blk
|
216
|
-
@files = @files.select
|
213
|
+
@files = @files.select(&blk)
|
217
214
|
end
|
218
215
|
private :apply_select
|
219
216
|
|
@@ -381,7 +378,7 @@ module Rant
|
|
381
378
|
|
382
379
|
def each_entry &block
|
383
380
|
@lists.each { |list|
|
384
|
-
list.each
|
381
|
+
list.each(&block)
|
385
382
|
}
|
386
383
|
end
|
387
384
|
|
@@ -417,7 +414,7 @@ module Rant
|
|
417
414
|
def message
|
418
415
|
if !@msg && cmd
|
419
416
|
if status
|
420
|
-
"Command failed with status #{status.
|
417
|
+
"Command failed with status #{status.exitstatus}:\n" +
|
421
418
|
"[#{cmd}]"
|
422
419
|
else
|
423
420
|
"Command failed:\n[#{cmd}]"
|
@@ -476,8 +473,8 @@ module Rant
|
|
476
473
|
end
|
477
474
|
end
|
478
475
|
|
479
|
-
# Returns a string that can be used as a valid path argument
|
480
|
-
# shell respecting portability issues.
|
476
|
+
# Returns a string that can be used as a valid path argument
|
477
|
+
# on the shell respecting portability issues.
|
481
478
|
def sp path
|
482
479
|
Env.shell_path path
|
483
480
|
end
|
data/lib/rant/rantvar.rb
CHANGED
@@ -16,15 +16,16 @@
|
|
16
16
|
# If you're looking for general info about Rant, read the
|
17
17
|
# README[link:files/README.html].
|
18
18
|
module Rant
|
19
|
-
VERSION = '0.3.
|
19
|
+
VERSION = '0.3.8'
|
20
20
|
|
21
21
|
# Those are the filenames for rantfiles.
|
22
22
|
# Case matters!
|
23
23
|
RANTFILES = [ "Rantfile",
|
24
24
|
"rantfile",
|
25
25
|
"Rantfile.rb",
|
26
|
-
"rantfile.rb"
|
26
|
+
"rantfile.rb"
|
27
27
|
]
|
28
|
+
SUB_RANTFILES = ["subrant"]
|
28
29
|
|
29
30
|
# Names of plugins and imports for which code was loaded.
|
30
31
|
# Files that where loaded with the `import' commant are directly
|
@@ -41,9 +42,6 @@ module Rant
|
|
41
42
|
class RantError < StandardError
|
42
43
|
end
|
43
44
|
|
44
|
-
class RantfileException < RantError
|
45
|
-
end
|
46
|
-
|
47
45
|
# This module is a namespace for generator classes.
|
48
46
|
module Generators
|
49
47
|
end
|
@@ -168,7 +166,7 @@ module Rant
|
|
168
166
|
begin
|
169
167
|
id = Constraints.const_get(id)
|
170
168
|
rescue
|
171
|
-
raise NotAConstraintFactoryError.new(
|
169
|
+
raise NotAConstraintFactoryError.new(id), caller
|
172
170
|
end
|
173
171
|
end
|
174
172
|
unless id.respond_to? :rant_constraint
|
data/lib/rant.rb
CHANGED
@@ -2,6 +2,63 @@
|
|
2
2
|
|
3
3
|
require 'rant/rantlib'
|
4
4
|
|
5
|
+
module RantContext
|
6
|
+
# Needed for irb, which defines its own +source+ method.
|
7
|
+
def source_rf(*args, &block)
|
8
|
+
rac.source(*args, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
module Rant
|
12
|
+
class FileList
|
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
|
+
end
|
27
|
+
module Node
|
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
|
+
end
|
50
|
+
class RantApp
|
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
|
+
end
|
60
|
+
end
|
61
|
+
|
5
62
|
def rac
|
6
63
|
Rant.rac
|
7
64
|
end
|