-
Notifications
You must be signed in to change notification settings - Fork 606
/
Rakefile
199 lines (155 loc) · 4.74 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
require './rakelib/configure'
require './rakelib/build_signature'
include Rake::DSL if Rake.const_defined? :DSL
# Wipe out CDPATH, it interferes with building in some cases,
# see http://github.com/rubinius/rubinius/issues#issue/555
if ENV["CDPATH"]
ENV.delete("CDPATH")
end
# Wipe out RUBYGEMS_GEMDEPS, it causes the build to fail with
# "no such file to load -- tsort" when running rbx extconf.rb
if ENV["RUBYGEMS_GEMDEPS"]
ENV.delete("RUBYGEMS_GEMDEPS")
end
$trace ||= false
$VERBOSE = true
$verbose = Rake.application.options.trace || ARGV.delete("-v")
$cleaning = Rake.application.top_level_tasks.include?("clean")
if !$verbose and respond_to?(:verbose)
verbose(false) if verbose() == :default
end
$:.unshift File.expand_path("../", __FILE__)
$:.unshift File.expand_path("../build/scripts", __FILE__)
BUILD_CONFIG = {} unless Object.const_defined? :BUILD_CONFIG
def load_configuration
config_rb = File.expand_path "../build/config/config.rb", __FILE__
config_h = File.expand_path "../machine/config.h", __FILE__
unless File.exist?(config_rb) and File.exist?(config_h)
if $cleaning
exit 0
else
sh "./configure"
return load_configuration
end
end
load config_rb
BUILD_CONFIG.replace Rubinius::BUILD_CONFIG
end
load_configuration
unless verify_build_signature or $cleaning or ENV["RBX_IGNORE_BUILD_SIGNATURE"]
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
unless ENV["RBX_SUPRESS_DEPRECATION"]
STDERR.puts " *** DEPRECATION NOTICE ***" \
"\n\nUse of Rake is deprecated and will be removed in the future.\n" \
"Use 'build.sh' to configure, build, package, and install Rubinius.\n\n\n"
end
if BUILD_CONFIG[:build_bin]
ENV["PATH"] = "#{BUILD_CONFIG[:build_bin]}:#{ENV["PATH"]}"
end
# Set the build compiler to the configured compiler unless
# the compiler is set via CC environment variable.
ENV['CC'] = BUILD_CONFIG[:cc] unless ENV['CC']
ENV['CXX'] = BUILD_CONFIG[:cxx] unless ENV['CXX']
$dlext = RbConfig::CONFIG["DLEXT"]
$CC = ENV['CC']
class SpecRunner
@at_exit_handler_set = false
@at_exit_status = 0
@flags = nil
def self.at_exit_status
@at_exit_status
end
def self.set_at_exit_handler
return if @at_exit_handler_set
at_exit { exit SpecRunner.at_exit_status }
@at_exit_handler_set = true
end
def self.set_at_exit_status(status)
@at_exit_status = status || 1
end
def self.flags
@flags
end
def self.flags=(value)
@flags = value
end
def initialize
@handler = lambda do |ok, status|
self.class.set_at_exit_status(status.exitstatus) unless ok
end
end
def run(suite=:ci_files)
self.class.set_at_exit_handler
sh("bin/mspec ci :#{suite} #{self.class.flags} -t bin/#{BUILD_CONFIG[:program_name]} -d --background", &@handler)
end
end
task :default => [:spec, :check_status, :install]
def check_status
exit 1 unless SpecRunner.at_exit_status == 0
end
def clean_environment
ENV['GEM_PATH'] = ENV['GEM_HOME'] = nil
ENV['RUBYOPT'] = "--disable-gems"
end
task :check_status do
check_status
end
task :github do
cur = `git config remote.origin.url`.strip
if cur == "git://github.com/evanphx/rubinius.git"
sh "git config remote.origin.url git://github.com/rubinius/rubinius.git"
puts "\nSwitch to git://github.com/rubinius/rubinius.git"
else
sh "git config remote.origin.url git@github.com:rubinius/rubinius.git"
puts "\nSwitch to github.com:rubinius/rubinius.git"
end
end
# See vm.rake for more information
desc "Build Rubinius"
task :build => %w[build:build]
desc "Recompile all ruby system files"
task :rebuild => %w[clean build]
desc 'Remove rubinius build files'
task :clean => %w[
vm:clean
core:clean
clean:crap
]
desc 'Remove rubinius build files and external library build files'
task :distclean => %w[
clean
vm:distclean
]
namespace :clean do
desc "Cleans up editor files and other misc crap"
task :crap do
files = (Dir["*~"] + Dir["**/*~"]).uniq
rm_f files, :verbose => $verbose unless files.empty?
end
end
desc "Run specs in default (configured) mode but do not rebuild on failure"
task :spec => %w[build vm:test] do
clean_environment
spec_runner = SpecRunner.new
spec_runner.run
end
desc "Run specs as in the spec task, but with CI formatting"
task :ci do
SpecRunner.flags = "-V" # show spec file names
Rake::Task["spec"].invoke
end
desc "Print list of items marked to-do in core/ (@todo|TODO)"
task :todos do
# create array with files to be checked
filesA = Dir['core/*.*']
# search for @todo or TODO
filesA.sort!.each do |filename|
File.open(filename) do |file|
file.each do |line|
puts "#{filename} #{file.lineno.to_s}:\t#{line.strip}" if line.include?("@todo") or line.include?("TODO")
end
end
end
end