Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 292 lines (266 sloc) 9.105 kB
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
1 require File.expand_path('../builder/builder', __FILE__)
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
2
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
3 desc "Build the markgc tool"
4 task :mark_gc do
5 if !File.exist?('markgc')
2c6aafe revert r3931
Laurent Sansonetti authored
6 sh "/usr/bin/gcc -std=c99 markgc.c -o markgc -Wno-format"
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
7 end
8 end
9
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
10 desc "Build the plblockimp library for imp_implementationWithBlock() support."
11 task :plblockimp do
12 # Prepare assembly trampolines for plblockimp
13 plblockimp_sources = []
14 plblockimp_targets = []
15 ARCHS.each do |a|
16 tramp_sources = ["", "_stret"].map { |s|
17 "plblockimp/#{a}/blockimp_#{a}#{s}.tramp"
18 }
19 tramp_sources.each do |s|
20 unless sh "plblockimp/gentramp.sh #{s} #{a} plblockimp/"
21 $stderr.puts "Failed to generate trampolines for plblockimp"
22 exit 1
23 end
24 end
25 plblockimp_sources.concat( ["", "_stret"].map { |s|
26 "plblockimp/blockimp_#{a}#{s}_config.c"
27 } )
28 as_sources = ["", "_stret"].map { |s|
29 "plblockimp/blockimp_#{a}#{s}.s"
30 }
31 as_sources.each do |s|
32 t = s.sub(%r{\.s$}, ".o")
9e9e2d1 @Watson1978 just compile plblockimp when need it
Watson1978 authored
33 if !File.exist?(t) || File.mtime(t) < File.mtime(s)
34 unless sh "as -arch #{a} -o #{t} #{s}"
35 $stderr.puts "Failed to assemble trampolines for plblockimp"
36 exit 1
37 end
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
38 end
39 plblockimp_targets << t
40 end
41 end
42
43 # Build plblockimp as an object file for later linking
44 plblockimp_sources.concat( ["blockimp.c", "trampoline_table.c"].map { |s|
45 "plblockimp/#{s}"
46 } )
47 cflags = $builder.cflags.scan(%r{-[^D][^\s]*}).join(' ').sub(%r{-arch},'')
48 plblockimp_sources.each do |s|
49 t = s.sub(%r{.c$}, ".o")
50 a = ARCHS.map { |x| "-arch #{x}" }.join(' ')
9e9e2d1 @Watson1978 just compile plblockimp when need it
Watson1978 authored
51 if !File.exist?(t) || File.mtime(t) < File.mtime(s)
52 unless sh "#{CC} #{a} -c #{cflags} -DPL_BLOCKIMP_PRIVATE -o #{t} #{s}"
53 exit 1
54 end
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
55 end
56 plblockimp_targets << t
57 end
9e9e2d1 @Watson1978 just compile plblockimp when need it
Watson1978 authored
58
59 need_compile = false
60 obj = "#{$builder.objsdir}/plblockimp.o"
61 plblockimp_targets.each do |t|
62 if !File.exist?(obj) || File.mtime(obj) < File.mtime(t)
63 need_compile = true
64 break
65 end
66 end
67
68 if need_compile
69 plbi_o = plblockimp_targets.join(' ')
70 unless sh "ld #{plbi_o} -r -o #{$builder.objsdir}/plblockimp.o"
71 $stderr.puts "Failed to link plblockimp components"
72 exit 1
73 end
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
74 end
75 end
76
77 task :files => [:config_h, :dtrace_h, :revision_h, :mark_gc, :plblockimp] do
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
78 end
79
80 def build_objects
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
81 if !File.exist?('parse.c') or File.mtime('parse.y') > File.mtime('parse.c')
82 sh("/usr/bin/bison -o y.tab.c parse.y")
83 sh("/usr/bin/sed -f ./tool/ytab.sed -e \"/^#/s!y\.tab\.c!parse.c!\" y.tab.c > parse.c.new")
84 if !File.exist?('parse.c') or File.read('parse.c.new') != File.read('parse.c')
85 mv('parse.c.new', 'parse.c')
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
86 rm_f(File.join($builder.objsdir, 'parse.o'))
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
87 else
88 rm('parse.c.new')
89 end
90 end
91 if !File.exist?('lex.c') or File.read('lex.c') != File.read('lex.c.blt')
92 cp('lex.c.blt', 'lex.c')
93 end
94 if !File.exist?('node_name.inc') or File.mtime('include/ruby/node.h') > File.mtime('node_name.inc')
95 sh("/usr/bin/ruby -n tool/node_name.rb include/ruby/node.h > node_name.inc")
96 end
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
97 kernel_data_c = File.join($builder.objsdir, 'kernel_data.c')
98 if !File.exist?(kernel_data_c) or File.mtime('kernel.c') > File.mtime(kernel_data_c)
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
99 # Locate llvm-gcc...
100 path = ENV['PATH'].split(':')
101 path.unshift('/Developer/usr/bin')
102 llvm_gcc = path.map { |x| File.join(x, 'llvm-gcc') }.find { |x| File.exist?(x) }
103 unless llvm_gcc
104 $stderr.puts "Cannot locate llvm-gcc in given path: #{path}"
105 exit 1
106 end
107 opt = File.join(LLVM_PATH, 'bin/opt')
108 unless File.exist?(opt)
109 $stderr.puts "Cannot locate opt in given LLVM path: #{LLVM_PATH}"
110 end
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
111 sh "echo '' > #{kernel_data_c}"
112 cflags = $builder.cflags.scan(/-I[^\s]+/).join(' ')
113 cflags << ' ' << $builder.cflags.scan(/-D[^\s]+/).join(' ')
114 $builder.archs.each do |x|
115 output = File.join($builder.objsdir, "kernel-#{x}.bc")
49a913c make sure there is a null byte at end of the kernel bitcode since it'…
Laurent Sansonetti authored
116 # Compile the IR for the kernel.c source file & optimize it.
cbb0951 @vincentisambart made the signed integer mathematical operations wrap to fix #1281
vincentisambart authored
117 sh "#{llvm_gcc} -arch #{x} -fexceptions -fno-stack-protector -fwrapv #{cflags} --emit-llvm -c kernel.c -o #{output}"
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
118 sh "#{opt} -O3 #{output} -o=#{output}"
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
119 # Convert the bitcode into a C static array. We append a null byte to the
120 # bitcode file because xxd doesn't, and it's needed by the bitcode
121 # reader later at runtime.
122 cp output, "#{output}.old"
49a913c make sure there is a null byte at end of the kernel bitcode since it'…
Laurent Sansonetti authored
123 sh "/bin/dd if=/dev/zero count=1 bs=1 conv=notrunc >> #{output} 2>/dev/null"
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
124 sh "/usr/bin/xxd -i #{output} >> #{kernel_data_c}"
125 mv "#{output}.old", output
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
126 end
127 end
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
128
129
130
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
131 dispatcher_o = File.join($builder.objsdir, 'dispatcher.o')
132 t = File.exist?(dispatcher_o) ? File.mtime(dispatcher_o) : nil
0051f18 @takaokouji run markgc if modified dispatcher.o or vm.o.
takaokouji authored
133 vm_o = File.join($builder.objsdir, 'vm.o')
134 t_vm = File.exist?(vm_o) ? File.mtime(vm_o) : nil
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
135 $builder.build
0051f18 @takaokouji run markgc if modified dispatcher.o or vm.o.
takaokouji authored
136 if t == nil or File.mtime(dispatcher_o) > t or t_vm == nil or File.mtime(vm_o) > t_vm
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
137 # dispatcher.o must be marked as GC compliant to avoid a linker problem.
58460dd remove the prelude crap
Laurent Sansonetti authored
138 # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow)
139 # write barriers.
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
140 sh "./markgc #{dispatcher_o}"
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
141 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
142 end
143
144 desc "Create miniruby"
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
145 task :miniruby => :files do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
146 $builder.config = FULL_CONFIG
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
147 build_objects
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
148 $builder.link_executable('miniruby', OBJS + ['plblockimp'])
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
149 end
150
151 desc "Create config file"
152 task :rbconfig => :miniruby do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
153 require File.expand_path('../builder/templates', __FILE__)
154 Builder.create_rbconfig
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
155 end
156
157 namespace :macruby do
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
158 desc "Build dynamic library"
159 task :dylib => [:rbconfig, :files] do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
160 $builder.config = FULL_CONFIG
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
161 build_objects
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
162 dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
5bf56cf @macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6…
macrotis authored
163 $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub'] + ['plblockimp'])
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
164 major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
165 ["lib#{RUBY_SO_NAME}.#{major}.#{minor}.dylib", "lib#{RUBY_SO_NAME}.dylib"].each do |dylib_alias|
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
166 if !File.exist?(dylib_alias) or File.readlink(dylib_alias) != dylib
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
167 rm_f(dylib_alias)
168 ln_s(dylib, dylib_alias)
169 end
170 end
171 end
172
173 desc "Build MacRuby"
bd3420d @ferrous26 Remove the option to compile MacRuby statically
ferrous26 authored
174 task :build => [:dylib] do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
175 $builder.config = FULL_CONFIG
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
176 $builder.link_executable(RUBY_INSTALL_NAME, ['main', 'gc-stub'], "-L. -l#{RUBY_SO_NAME} -lobjc")
177 end
178 end
179
180 DESTDIR = (ENV['DESTDIR'] or "")
181 EXTOUT = (ENV['EXTOUT'] or ".ext")
182 INSTALLED_LIST = '.installed.list'
183
184 desc "Build extensions"
bd3420d @ferrous26 Remove the option to compile MacRuby statically
ferrous26 authored
185 task :extensions => [:miniruby] do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
186 Builder::Ext.build
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
187 end
188
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
189 desc "Generate RDoc files"
190 task :doc => [:macruby, :extensions] do
191 doc_op = './doc'
192 unless File.exist?(doc_op)
193 sh "DYLD_LIBRARY_PATH=. ./macruby -I. -I./lib -I./ext/libyaml -I./ext/etc bin/rdoc --ri --op \"#{doc_op}\""
194 end
195 end
196
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
197 AOT_STDLIB = [
198 'rbconfig.rb',
199 'lib/date.rb',
200 'lib/date/**/*.rb',
70e1800 added erb to the aot list
Laurent Sansonetti authored
201 'lib/erb.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
202 'lib/fileutils.rb',
203 'lib/irb.rb',
204 'lib/irb/**/*.rb',
4f163cb add all net/* libraries to the aot list
Laurent Sansonetti authored
205 'lib/net/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
206 'lib/optparse.rb',
207 #'lib/stringio.rb', #spec fails
88b213c @Watson1978 make RBO of rake
Watson1978 authored
208 'lib/rake.rb',
209 'lib/rake/**/*.rb',
cfd0f9e added rexml to the AOT list
Laurent Sansonetti authored
210 'lib/rexml.rb',
211 'lib/rexml/**/*.rb',
adaf2e5 @ferrous26 Don't forget to compile ubygems!
ferrous26 authored
212 'lib/{r,}ubygems.rb',
53c50f1 now AOT compiling rubygems
Laurent Sansonetti authored
213 'lib/rubygems/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
214 'lib/thread.rb',
215 'lib/time.rb',
216 'lib/timeout.rb',
764c005 forgot uri.rb
Laurent Sansonetti authored
217 'lib/uri.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
218 'lib/uri/**/*.rb',
aeafee7 adding xmlrpc to the AOT list
Laurent Sansonetti authored
219 'lib/xmlrpc/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
220 'lib/yaml.rb',
221 'lib/yaml/rubytypes.rb',
8116003 run rubyc on extensions's ruby files too
Laurent Sansonetti authored
222 'ext/**/lib/**/*.rb'
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
223 ]
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
224 namespace :stdlib do
225 desc "AOT compile the stdlib"
226 task :build => [:miniruby, 'macruby:dylib'] do
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
227 archf = ARCHS.map { |x| "--arch #{x}" }.join(' ')
5741ccc @alloy Add a compile_stdlib option for the builder, which can be set to fals…
alloy authored
228 commands = (COMPILE_STDLIB ? AOT_STDLIB : %w{ rbconfig.rb }).map do |pattern|
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
229 Dir.glob(pattern).map do |path|
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
230 out = File.join(File.dirname(path), File.basename(path, '.rb') + '.rbo')
231 if !File.exist?(out) or File.mtime(path) > File.mtime(out) or File.mtime('./miniruby') > File.mtime(out)
eabb31c @ferrous26 Don't JIT rubyc during stdlib compilation
ferrous26 authored
232 "VM_OPT_LEVEL=0 ./miniruby -I. -I./lib bin/rubyc --internal #{archf} -C \"#{path}\" -o \"#{out}\""
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
233 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
234 end
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
235 end.flatten.compact
95da69a @alloy Moved the parallel_execute method to Builder and make it accept array…
alloy authored
236 Builder.parallel_execute(commands)
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
237 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
238 end
239
0bc95cf fixed rbconfig.rb to use absolute paths + fixed TRY_LINK to use g++, …
Laurent Sansonetti authored
240 desc "Same as extensions"
241 task :ext => 'extensions'
242
588457d @ferrous26 Info.plist should be generated/removed as part of build/clean
ferrous26 authored
243 desc "Create the plist file for the framework"
244 task :info_plist do
245 require File.expand_path('../builder/templates', __FILE__)
246 Builder.create_framework_info_plist
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
247 end
248
249 namespace :clean do
250 desc "Clean local build files"
251 task :local do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
252 CONFIGS.each { |x| rm_rf(x.objsdir) }
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
253 list = ['parse.c', 'lex.c', INSTALLED_LIST, 'Makefile', RUBY_INSTALL_NAME, 'miniruby', 'kernel_data.c']
69528db fixed the clean task to remove binary build producfs too
Laurent Sansonetti authored
254 list.concat(Dir['*.inc'])
255 list.concat(Dir['lib*.{dylib,a}'])
78a1270 @macrotis Clean up files auto-generated for plblockimp trampolines in rake clean
macrotis authored
256 list.concat(Dir['plblockimp/*.o'])
257 ARCHS.each do |a|
258 plbi_s_t = "plblockimp/blockimp_#{a}"
259 ['', '_stret'].each do |x|
260 ['.h', '_config.c', '.s'].each do |y|
261 list << plbi_s_t + x + y
262 end
263 end
264 end
69528db fixed the clean task to remove binary build producfs too
Laurent Sansonetti authored
265 list.each { |x| rm_f(x) }
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
266 end
267
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored
268 desc "Clean .rbo build files"
269 task :rbo do
270 list = []
271 list.concat(Dir['*.rbo'])
272 list.concat(Dir['lib/**/*.rbo'])
8a5b5dc rake clean:rbo: make sure to remove the C extensions' rbo files too
Laurent Sansonetti authored
273 list.concat(Dir['ext/**/*.rbo'])
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored
274 list.each { |x| rm_f(x) }
275 end
276
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
277 desc "Clean extension build files"
278 task :ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
279 Builder::Ext.clean
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
280 end
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
281
282 desc "Clean the RDoc files"
283 task :doc do
284 rm_rf('doc')
285 end
588457d @ferrous26 Info.plist should be generated/removed as part of build/clean
ferrous26 authored
286
287 desc "Clean the Info.plist file"
288 task :info_plist do
289 rm_f('framework/Info.plist')
290 end
b0f57d9 blocked the rake all/install tasks for now
Laurent Sansonetti authored
291 end
Something went wrong with that request. Please try again.