Skip to content
Newer
Older
100644 220 lines (199 sloc) 6.83 KB
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored Jan 27, 2010
1 require File.expand_path('../builder/builder', __FILE__)
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
2
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored Oct 7, 2009
3 desc "Build the markgc tool"
4 task :mark_gc do
5 if !File.exist?('markgc')
2c6aafe revert r3931
Laurent Sansonetti authored Apr 14, 2010
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 Oct 7, 2009
7 end
8 end
9
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
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 Mar 16, 2009
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 Jun 16, 2010
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 Mar 16, 2009
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
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored May 24, 2010
30 if !File.exist?('kernel_data.c') or File.mtime('kernel.c') > File.mtime('kernel_data.c')
31 # Locate llvm-gcc...
32 path = ENV['PATH'].split(':')
33 path.unshift('/Developer/usr/bin')
34 llvm_gcc = path.map { |x| File.join(x, 'llvm-gcc') }.find { |x| File.exist?(x) }
35 unless llvm_gcc
36 $stderr.puts "Cannot locate llvm-gcc in given path: #{path}"
37 exit 1
38 end
39 opt = File.join(LLVM_PATH, 'bin/opt')
40 unless File.exist?(opt)
41 $stderr.puts "Cannot locate opt in given LLVM path: #{LLVM_PATH}"
42 end
43 sh "echo '' > kernel_data.c"
fefda43 pass the same includes from CFLAGS to llvm-gcc
Laurent Sansonetti authored May 24, 2010
44 includes = CFLAGS.scan(/-I[^\s]+/).join(' ')
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored May 24, 2010
45 ARCHS.each do |x|
46 output = "kernel-#{x}.bc"
49a913c make sure there is a null byte at end of the kernel bitcode since it'…
Laurent Sansonetti authored May 24, 2010
47 # Compile the IR for the kernel.c source file & optimize it.
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored Jun 5, 2010
48 sh "#{llvm_gcc} -arch #{x} -fexceptions -fno-stack-protector #{includes} --emit-llvm -c kernel.c -o #{output}"
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored May 24, 2010
49 sh "#{opt} -O3 #{output} -o=#{output}"
49a913c make sure there is a null byte at end of the kernel bitcode since it'…
Laurent Sansonetti authored May 24, 2010
50 # Convert the bitcode into a C static array. We append a null byte to the bitcode file because
51 # xxd doesn't, and it's needed by the bitcode reader later at runtime.
52 sh "/bin/dd if=/dev/zero count=1 bs=1 conv=notrunc >> #{output} 2>/dev/null"
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored May 24, 2010
53 sh "/usr/bin/xxd -i #{output} >> kernel_data.c"
54 sh "/bin/rm #{output}"
55 end
56 end
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
57 dispatcher_o = File.join($builder.objsdir, 'dispatcher.o')
58 t = File.exist?(dispatcher_o) ? File.mtime(dispatcher_o) : nil
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
59 $builder.build
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
60 if t == nil or File.mtime(dispatcher_o) > t
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored Oct 7, 2009
61 # dispatcher.o must be marked as GC compliant to avoid a linker problem.
58460dd remove the prelude crap
Laurent Sansonetti authored May 11, 2010
62 # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow)
63 # write barriers.
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
64 sh "./markgc #{dispatcher_o}"
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored Oct 7, 2009
65 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
66 end
67
68 desc "Create miniruby"
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
69 task :miniruby => :files do
70 $builder.mode = :full
71 build_objects
58460dd remove the prelude crap
Laurent Sansonetti authored May 11, 2010
72 $builder.link_executable('miniruby', OBJS)
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
73 end
74
75 desc "Create config file"
76 task :rbconfig => :miniruby do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored Jan 27, 2010
77 require File.expand_path('../builder/templates', __FILE__)
78 Builder.create_rbconfig
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
79 end
80
81 namespace :macruby do
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
82 desc "Build dynamic library"
83 task :dylib => [:rbconfig, :files] do
84 $builder.mode = :full
85 build_objects
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
86 dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
58460dd remove the prelude crap
Laurent Sansonetti authored May 11, 2010
87 $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 Mar 16, 2009
88 major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
89 ["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 Jan 26, 2010
90 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 Mar 16, 2009
91 rm_f(dylib_alias)
92 ln_s(dylib, dylib_alias)
93 end
94 end
95 end
96
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
97 desc "Build static library"
98 task :static => :files do
99 $builder.mode = :static
100 build_objects
58460dd remove the prelude crap
Laurent Sansonetti authored May 11, 2010
101 $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub'])
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
102 end
103
104 desc "Build MacRuby"
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
105 task :build => [:dylib, :static] do
106 $builder.mode = :full
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
107 $builder.link_executable(RUBY_INSTALL_NAME, ['main', 'gc-stub'], "-L. -l#{RUBY_SO_NAME} -lobjc")
108 end
109 end
110
111 DESTDIR = (ENV['DESTDIR'] or "")
112 EXTOUT = (ENV['EXTOUT'] or ".ext")
113 INSTALLED_LIST = '.installed.list'
114 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 Oct 24, 2009
115 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 Mar 16, 2009
116
117 desc "Build extensions"
118 task :extensions => [:miniruby, "macruby:static"] do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored Jan 26, 2010
119 Builder::Ext.build
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
120 end
121
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored Oct 24, 2009
122 desc "Generate RDoc files"
123 task :doc => [:macruby, :extensions] do
124 doc_op = './doc'
125 unless File.exist?(doc_op)
126 sh "DYLD_LIBRARY_PATH=. ./macruby -I. -I./lib -I./ext/libyaml -I./ext/etc bin/rdoc --ri --op \"#{doc_op}\""
127 end
128 end
129
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
130 AOT_STDLIB = [
131 'rbconfig.rb',
132 'lib/date.rb',
133 'lib/date/**/*.rb',
70e1800 added erb to the aot list
Laurent Sansonetti authored Sep 27, 2009
134 'lib/erb.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
135 'lib/fileutils.rb',
136 'lib/irb.rb',
137 'lib/irb/**/*.rb',
4f163cb add all net/* libraries to the aot list
Laurent Sansonetti authored Sep 26, 2009
138 'lib/net/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
139 'lib/optparse.rb',
140 #'lib/stringio.rb', #spec fails
cfd0f9e added rexml to the AOT list
Laurent Sansonetti authored Mar 29, 2010
141 'lib/rexml.rb',
142 'lib/rexml/**/*.rb',
53c50f1 now AOT compiling rubygems
Laurent Sansonetti authored Oct 5, 2009
143 'lib/rubygems.rb',
144 'lib/rubygems/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
145 'lib/thread.rb',
146 'lib/time.rb',
147 'lib/timeout.rb',
764c005 forgot uri.rb
Laurent Sansonetti authored Sep 26, 2009
148 'lib/uri.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
149 'lib/uri/**/*.rb',
aeafee7 adding xmlrpc to the AOT list
Laurent Sansonetti authored Mar 30, 2010
150 'lib/xmlrpc/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored Sep 26, 2009
151 'lib/yaml.rb',
152 'lib/yaml/rubytypes.rb',
153 ]
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored Oct 21, 2009
154 namespace :stdlib do
155 desc "AOT compile the stdlib"
156 task :build => [:miniruby, 'macruby:dylib'] do
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored Jan 26, 2010
157 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 Feb 28, 2010
158 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 Jan 26, 2010
159 Dir.glob(pattern).map do |path|
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored Oct 21, 2009
160 out = File.join(File.dirname(path), File.basename(path, '.rb') + '.rbo')
161 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 Jan 26, 2010
162 "./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 Oct 21, 2009
163 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored Sep 22, 2009
164 end
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored Jan 26, 2010
165 end.flatten.compact
95da69a @alloy Moved the parallel_execute method to Builder and make it accept array…
alloy authored Jan 26, 2010
166 Builder.parallel_execute(commands)
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored Oct 21, 2009
167 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored Sep 22, 2009
168 end
169
0bc95cf fixed rbconfig.rb to use absolute paths + fixed TRY_LINK to use g++, …
Laurent Sansonetti authored Jul 23, 2009
170 desc "Same as extensions"
171 task :ext => 'extensions'
172
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
173 namespace :framework do
174 desc "Create the plist file for the framework"
175 task :info_plist do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored Jan 27, 2010
176 require File.expand_path('../builder/templates', __FILE__)
177 Builder.create_framework_info_plist
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
178 end
179
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored Jul 24, 2009
180 desc "Install the extensions"
181 task :install_ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored Jan 26, 2010
182 Builder::Ext.install
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored Jul 24, 2009
183 end
184
185 desc "Install the framework"
186 task :install => [:info_plist, :install_ext] do
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
187 sh "./miniruby instruby.rb #{INSTRUBY_ARGS}"
188 end
189 end
190
191 namespace :clean do
192 desc "Clean local build files"
193 task :local do
a6a5d3e started to trim out the static library
Laurent Sansonetti authored Jun 16, 2010
194 rm_rf(FULL_OBJS_DIR)
195 rm_rf(STATIC_OBJS_DIR)
002ed5d now compile some of the VM primitives into bitcode that will be added…
Laurent Sansonetti authored May 24, 2010
196 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 Jul 27, 2009
197 list.concat(Dir['*.inc'])
198 list.concat(Dir['lib*.{dylib,a}'])
199 list.each { |x| rm_f(x) }
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
200 end
201
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored Sep 22, 2009
202 desc "Clean .rbo build files"
203 task :rbo do
204 list = []
205 list.concat(Dir['*.rbo'])
206 list.concat(Dir['lib/**/*.rbo'])
207 list.each { |x| rm_f(x) }
208 end
209
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
210 desc "Clean extension build files"
211 task :ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored Jan 26, 2010
212 Builder::Ext.clean
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored Mar 16, 2009
213 end
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored Oct 24, 2009
214
215 desc "Clean the RDoc files"
216 task :doc do
217 rm_rf('doc')
218 end
b0f57d9 blocked the rake all/install tasks for now
Laurent Sansonetti authored Mar 28, 2009
219 end
Something went wrong with that request. Please try again.