forked from ohboyohboyohboy/antlr3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile
134 lines (110 loc) · 3.99 KB
/
rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/ruby
# encoding: utf-8
####################################################################################################
################################### establish project environment ##################################
####################################################################################################
load './config/antlr3.rb'
#rake = Rake.application
#def rake.standard_exception_handling
# begin
# yield
# rescue SystemExit => ex
# raise
# rescue OptionParser::InvalidOption => ex
# exit( false )
# rescue Exception => ex
# $stderr.puts( '=' * 80 )
# $stderr.puts( "#{ name } aborted!" )
# $stderr.puts( "#{ ex.class }: #{ ex.message }" )
# $stderr.puts( '-' * 80 )
# for trace in ex.backtrace
# $stderr.puts( " - #{ trace }" )
# end
# exit( false )
# end
#end
def run_task( name )
Rake::Task.task_defined?( name ) or file( name )
case task = Rake::Task[ name ]
when Rake::FileTask then task.needed? and task.invoke
else task.invoke
end
end
def abs( path ); File.expand_path( path ); end
def rel( target, reference = Dir.pwd )
pair = [ target, reference ].map! do |path|
File.expand_path( path.to_s ).split( File::Separator ).tap do |list|
if list.empty? then list << String.new( File::Separator )
elsif list.first.empty? then list.first.replace( File::Separator )
end
end
end
target_list, reference_list = pair
while target_list.first == reference_list.first
target_list.shift
reference_list.shift or break
end
relative_list = Array.new( reference_list.length, '..' )
relative_list.empty? and relative_list << '.'
relative_list.concat( target_list ).compact!
return relative_list.join( File::Separator )
end
####################################################################################################
######################################### task definitions #########################################
####################################################################################################
# tasks concerning the development environment
task :update do
$project.load_task 'update_gems'
end
desc "setup project development environment and download/update bundled gems"
task :boot => %w( update ) do
$project.load_environment
end
# task :default => %w( setup )
# $project.booted? or run_task( :setup )
if $project.booted?
# tasks concerning the ANTLR java package
desc "update the antlr jar if necessary"
task :antlr do
$project.load_task 'antlr'
end
for task_lib in %w( notes package coverage publish test doc )
$project.load_task( task_lib )
end
desc( "clean up all project by-products" )
task :clean => %w( test:clean package:clobber doc:clobber doc:samples:clobber )
$project.load_task( 'private/*' )
interactive = ( $stdout.tty? && $stdin.tty? )
task_list = Rake.application.options.show_tasks
if $project.bundler_stale? and interactive and not task_list
puts( <<-END.here_indent! )
| ** Warning **
| Bundler config `#{ $project.bundler.config }' appears to have been modified recently.
| Your locally installed gems may be out of date and some tasks may
| fail due to missing packages.
|
| Do you want to run the setup task to update the local gem installations
| in the vendor directory before continuing? Note: this will access the
| internet and possibly download new source packages to ./vendor
|
END
if $project.confirm( "Update before continuing?" )
Rake::Task[ :setup ].invoke
puts( "-- Successfully updated local gems --" )
else
puts( "-- Skipping bundler update --" )
puts( "** You can run the update manually later via `rake setup'" )
verbose( false ) { touch( $project.bundler.environment ) }
end
puts( "" )
end
else
puts( <<-END.here_indent! )
| ** Note **
| The development environment has not been established.
| Thus, most rake tasks will not be active until you run:
|
| ruby ./bootstrap.rb
|
END
end