Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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