Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 237 lines (216 sloc) 7.855 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
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
10 task :files => [:config_h, :dtrace_h, :revision_h, :mark_gc] do
11 end
12
13 def build_objects
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
14 if !File.exist?('parse.c') or File.mtime('parse.y') > File.mtime('parse.c')
15 sh("/usr/bin/bison -o y.tab.c parse.y")
16 sh("/usr/bin/sed -f ./tool/ytab.sed -e \"/^#/s!y\.tab\.c!parse.c!\" y.tab.c > parse.c.new")
17 if !File.exist?('parse.c') or File.read('parse.c.new') != File.read('parse.c')
18 mv('parse.c.new', 'parse.c')
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
19 rm_f(File.join($builder.objsdir, 'parse.o'))
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
20 else
21 rm('parse.c.new')
22 end
23 end
24 if !File.exist?('lex.c') or File.read('lex.c') != File.read('lex.c.blt')
25 cp('lex.c.blt', 'lex.c')
26 end
27 if !File.exist?('node_name.inc') or File.mtime('include/ruby/node.h') > File.mtime('node_name.inc')
28 sh("/usr/bin/ruby -n tool/node_name.rb include/ruby/node.h > node_name.inc")
29 end
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
30 kernel_data_c = File.join($builder.objsdir, 'kernel_data.c')
31 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
32 # Locate llvm-gcc...
33 path = ENV['PATH'].split(':')
34 path.unshift('/Developer/usr/bin')
35 llvm_gcc = path.map { |x| File.join(x, 'llvm-gcc') }.find { |x| File.exist?(x) }
36 unless llvm_gcc
37 $stderr.puts "Cannot locate llvm-gcc in given path: #{path}"
38 exit 1
39 end
40 opt = File.join(LLVM_PATH, 'bin/opt')
41 unless File.exist?(opt)
42 $stderr.puts "Cannot locate opt in given LLVM path: #{LLVM_PATH}"
43 end
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
44 sh "echo '' > #{kernel_data_c}"
45 cflags = $builder.cflags.scan(/-I[^\s]+/).join(' ')
46 cflags << ' ' << $builder.cflags.scan(/-D[^\s]+/).join(' ')
47 $builder.archs.each do |x|
48 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
49 # 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
50 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
51 sh "#{opt} -O3 #{output} -o=#{output}"
39f25b7 honor current builder archs when generating kernel bitcode
Laurent Sansonetti authored
52 # Convert the bitcode into a C static array. We append a null byte to the
53 # bitcode file because xxd doesn't, and it's needed by the bitcode
54 # reader later at runtime.
55 cp output, "#{output}.old"
49a913c make sure there is a null byte at end of the kernel bitcode since it'…
Laurent Sansonetti authored
56 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
57 sh "/usr/bin/xxd -i #{output} >> #{kernel_data_c}"
58 mv "#{output}.old", output
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
59 end
60 end
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
61 dispatcher_o = File.join($builder.objsdir, 'dispatcher.o')
62 t = File.exist?(dispatcher_o) ? File.mtime(dispatcher_o) : nil
0051f18 @takaokouji run markgc if modified dispatcher.o or vm.o.
takaokouji authored
63 vm_o = File.join($builder.objsdir, 'vm.o')
64 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
65 $builder.build
0051f18 @takaokouji run markgc if modified dispatcher.o or vm.o.
takaokouji authored
66 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
67 # dispatcher.o must be marked as GC compliant to avoid a linker problem.
58460dd remove the prelude crap
Laurent Sansonetti authored
68 # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow)
69 # write barriers.
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
70 sh "./markgc #{dispatcher_o}"
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
71 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
72 end
73
74 desc "Create miniruby"
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
75 task :miniruby => :files do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
76 $builder.config = FULL_CONFIG
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
77 build_objects
58460dd remove the prelude crap
Laurent Sansonetti authored
78 $builder.link_executable('miniruby', OBJS)
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
79 end
80
81 desc "Create config file"
82 task :rbconfig => :miniruby do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
83 require File.expand_path('../builder/templates', __FILE__)
84 Builder.create_rbconfig
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
85 end
86
87 namespace :macruby do
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
88 desc "Build dynamic library"
89 task :dylib => [:rbconfig, :files] do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
90 $builder.config = FULL_CONFIG
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
91 build_objects
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
92 dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
58460dd remove the prelude crap
Laurent Sansonetti authored
93 $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub'])
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
94 major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
95 ["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
96 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
97 rm_f(dylib_alias)
98 ln_s(dylib, dylib_alias)
99 end
100 end
101 end
102
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
103 desc "Build static library"
104 task :static => :files do
2ffe02b do not build libmacruby-static anymore (by default)
Laurent Sansonetti authored
105 if ENABLE_STATIC_LIBRARY
106 $builder.config = STATIC_CONFIG
107 build_objects
108 $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub'])
109 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
110 end
111
112 desc "Build MacRuby"
a6a5d3e started to trim out the static library
Laurent Sansonetti authored
113 task :build => [:dylib, :static] do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
114 $builder.config = FULL_CONFIG
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
115 $builder.link_executable(RUBY_INSTALL_NAME, ['main', 'gc-stub'], "-L. -l#{RUBY_SO_NAME} -lobjc")
116 end
117 end
118
119 DESTDIR = (ENV['DESTDIR'] or "")
120 EXTOUT = (ENV['EXTOUT'] or ".ext")
121 INSTALLED_LIST = '.installed.list'
122 SCRIPT_ARGS = "--make=\"/usr/bin/make\" --dest-dir=\"#{DESTDIR}\" --extout=\"#{EXTOUT}\" --mflags=\"\" --make-flags=\"\""
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
123 INSTRUBY_ARGS = "#{SCRIPT_ARGS} --data-mode=0644 --prog-mode=0755 --installed-list #{INSTALLED_LIST} --mantype=\"doc\" --sym-dest-dir=\"#{SYM_INSTDIR}\" --rdoc-output=\"doc\""
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
124
125 desc "Build extensions"
126 task :extensions => [:miniruby, "macruby:static"] do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
127 Builder::Ext.build
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
128 end
129
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
130 desc "Generate RDoc files"
131 task :doc => [:macruby, :extensions] do
132 doc_op = './doc'
133 unless File.exist?(doc_op)
134 sh "DYLD_LIBRARY_PATH=. ./macruby -I. -I./lib -I./ext/libyaml -I./ext/etc bin/rdoc --ri --op \"#{doc_op}\""
135 end
136 end
137
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
138 AOT_STDLIB = [
139 'rbconfig.rb',
140 'lib/date.rb',
141 'lib/date/**/*.rb',
70e1800 added erb to the aot list
Laurent Sansonetti authored
142 'lib/erb.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
143 'lib/fileutils.rb',
144 'lib/irb.rb',
145 'lib/irb/**/*.rb',
4f163cb add all net/* libraries to the aot list
Laurent Sansonetti authored
146 'lib/net/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
147 'lib/optparse.rb',
148 #'lib/stringio.rb', #spec fails
cfd0f9e added rexml to the AOT list
Laurent Sansonetti authored
149 'lib/rexml.rb',
150 'lib/rexml/**/*.rb',
53c50f1 now AOT compiling rubygems
Laurent Sansonetti authored
151 'lib/rubygems.rb',
152 'lib/rubygems/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
153 'lib/thread.rb',
154 'lib/time.rb',
155 'lib/timeout.rb',
764c005 forgot uri.rb
Laurent Sansonetti authored
156 'lib/uri.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
157 'lib/uri/**/*.rb',
aeafee7 adding xmlrpc to the AOT list
Laurent Sansonetti authored
158 'lib/xmlrpc/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
159 'lib/yaml.rb',
160 'lib/yaml/rubytypes.rb',
8116003 run rubyc on extensions's ruby files too
Laurent Sansonetti authored
161 'ext/**/lib/**/*.rb'
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
162 ]
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
163 namespace :stdlib do
164 desc "AOT compile the stdlib"
165 task :build => [:miniruby, 'macruby:dylib'] do
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
166 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
167 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
168 Dir.glob(pattern).map do |path|
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
169 out = File.join(File.dirname(path), File.basename(path, '.rb') + '.rbo')
170 if !File.exist?(out) or File.mtime(path) > File.mtime(out) or File.mtime('./miniruby') > File.mtime(out)
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
171 "./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
172 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
173 end
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
174 end.flatten.compact
95da69a @alloy Moved the parallel_execute method to Builder and make it accept array…
alloy authored
175 Builder.parallel_execute(commands)
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
176 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
177 end
178
0bc95cf fixed rbconfig.rb to use absolute paths + fixed TRY_LINK to use g++, …
Laurent Sansonetti authored
179 desc "Same as extensions"
180 task :ext => 'extensions'
181
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
182 namespace :framework do
183 desc "Create the plist file for the framework"
184 task :info_plist do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
185 require File.expand_path('../builder/templates', __FILE__)
186 Builder.create_framework_info_plist
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
187 end
188
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored
189 desc "Install the extensions"
190 task :install_ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
191 Builder::Ext.install
8116003 run rubyc on extensions's ruby files too
Laurent Sansonetti authored
192 # Install the extensions rbo.
5943bc5 respect DESTDIR
Laurent Sansonetti authored
193 dest_site = File.join(DESTDIR, RUBY_SITE_LIB2)
8116003 run rubyc on extensions's ruby files too
Laurent Sansonetti authored
194 Dir.glob('ext/**/lib/**/*.rbo').each do |path|
195 ext_name, sub_path = path.scan(/^ext\/(.+)\/lib\/(.+)$/)[0]
196 next unless EXTENSIONS.include?(ext_name)
197 sub_dir = File.dirname(sub_path)
5943bc5 respect DESTDIR
Laurent Sansonetti authored
198 sh "/usr/bin/install -c -m 0755 #{path} #{File.join(dest_site, sub_dir)}"
8116003 run rubyc on extensions's ruby files too
Laurent Sansonetti authored
199 end
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored
200 end
201
202 desc "Install the framework"
203 task :install => [:info_plist, :install_ext] do
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
204 sh "./miniruby instruby.rb #{INSTRUBY_ARGS}"
205 end
206 end
207
208 namespace :clean do
209 desc "Clean local build files"
210 task :local do
922141d rewrote the builder script to be more flexible/configurable
Laurent Sansonetti authored
211 CONFIGS.each { |x| rm_rf(x.objsdir) }
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored
212 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
213 list.concat(Dir['*.inc'])
214 list.concat(Dir['lib*.{dylib,a}'])
215 list.each { |x| rm_f(x) }
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
216 end
217
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored
218 desc "Clean .rbo build files"
219 task :rbo do
220 list = []
221 list.concat(Dir['*.rbo'])
222 list.concat(Dir['lib/**/*.rbo'])
8a5b5dc rake clean:rbo: make sure to remove the C extensions' rbo files too
Laurent Sansonetti authored
223 list.concat(Dir['ext/**/*.rbo'])
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored
224 list.each { |x| rm_f(x) }
225 end
226
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
227 desc "Clean extension build files"
228 task :ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
229 Builder::Ext.clean
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
230 end
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
231
232 desc "Clean the RDoc files"
233 task :doc do
234 rm_rf('doc')
235 end
b0f57d9 blocked the rake all/install tasks for now
Laurent Sansonetti authored
236 end
Something went wrong with that request. Please try again.