Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 247 lines (216 sloc) 7.876 kb
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
1 require File.expand_path('../builder/builder', __FILE__)
b8cf6a6 @alloy Added available build options to the output of: $ rake -T
alloy authored
2 require 'rake'
3
4 # We monkey-patch the method that Rake uses to display the tasks so we can add
5 # the build options.
6 module Rake
7 class Application
8 def formatted_macruby_options
9 $builder_options.sort_by { |name, _| name }.map do |name, default|
10 default = default.join(',') if default.is_a?(Array)
ac477e5 @alloy Oops, a bit too much indentation.
alloy authored
11 " #{name.ljust(30)} \"#{default}\""
b8cf6a6 @alloy Added available build options to the output of: $ rake -T
alloy authored
12 end.join("\n")
13 end
14
15 alias_method :display_tasks_and_comments_without_macruby_options, :display_tasks_and_comments
16
17 def display_tasks_and_comments
18 display_tasks_and_comments_without_macruby_options
19 puts %{
20 To change any of the default build options, use the rake build task
21 of choice with any of these following option-value pairs:
22
27ca189 @alloy Removed all specfic specs that are to be run from the rake tasks and …
alloy authored
23 Usage: $ rake [task] [option=value, ...]
b8cf6a6 @alloy Added available build options to the output of: $ rake -T
alloy authored
24
25 #{'Option:'.ljust(30)} Default value:
26
27 #{formatted_macruby_options}
28
29 Example:
30
31 $ rake all archs="i386,ppc" framework_instdir="~/Library/Frameworks"
32
33 }
34 end
35 end
36 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
37
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
38 desc "Build the markgc tool"
39 task :mark_gc do
40 if !File.exist?('markgc')
41 sh "/usr/bin/gcc -std=c99 markgc.c -o markgc -Wno-format"
42 end
43 end
44
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
45 desc "Build known objects"
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
46 task :objects => [:config_h, :dtrace_h, :revision_h, :mark_gc] do
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
47 sh "/usr/bin/ruby tool/compile_prelude.rb prelude.rb miniprelude.c.new"
48 if !File.exist?('miniprelude.c') or File.read('miniprelude.c') != File.read('miniprelude.c.new')
49 mv('miniprelude.c.new', 'miniprelude.c')
50 else
51 rm('miniprelude.c.new')
52 end
53 if !File.exist?('prelude.c')
54 touch('prelude.c') # create empty file nevertheless
55 end
56 if !File.exist?('parse.c') or File.mtime('parse.y') > File.mtime('parse.c')
57 sh("/usr/bin/bison -o y.tab.c parse.y")
58 sh("/usr/bin/sed -f ./tool/ytab.sed -e \"/^#/s!y\.tab\.c!parse.c!\" y.tab.c > parse.c.new")
59 if !File.exist?('parse.c') or File.read('parse.c.new') != File.read('parse.c')
60 mv('parse.c.new', 'parse.c')
61 rm_f('parse.o')
62 else
63 rm('parse.c.new')
64 end
65 end
66 if !File.exist?('lex.c') or File.read('lex.c') != File.read('lex.c.blt')
67 cp('lex.c.blt', 'lex.c')
68 end
69 if !File.exist?('node_name.inc') or File.mtime('include/ruby/node.h') > File.mtime('node_name.inc')
70 sh("/usr/bin/ruby -n tool/node_name.rb include/ruby/node.h > node_name.inc")
71 end
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
72 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
73 $builder.build
bd7eba3 objc exceptions should now be catchable in ruby
Laurent Sansonetti authored
74 if t == nil or File.mtime('dispatcher.o') > t
75 # dispatcher.o must be marked as GC compliant to avoid a linker problem.
76 # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow) write
77 # barriers.
78 sh "./markgc ./dispatcher.o"
79 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
80 end
81
82 desc "Create miniruby"
83 task :miniruby => :objects do
84 $builder.link_executable('miniruby', OBJS - ['prelude'])
85 end
86
87 desc "Create config file"
88 task :rbconfig => :miniruby do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
89 require File.expand_path('../builder/templates', __FILE__)
90 Builder.create_rbconfig
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
91 end
92
93 namespace :macruby do
94 desc "Build dynamic libraries for MacRuby"
95 task :dylib => [:rbconfig, :miniruby] do
8c5a2dd let's go further miniruby
Laurent Sansonetti authored
96 =begin
da4daf6 @drernie Rakefile changes (unused) for including gcd_prelude
drernie authored
97 sh("./miniruby -I. -I./lib -rrbconfig tool/compile_prelude.rb prelude.rb gem_prelude.rb gcd_prelude prelude.c.new")
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
98 if !File.exist?('prelude.c') or File.read('prelude.c') != File.read('prelude.c.new')
99 mv('prelude.c.new', 'prelude.c')
100 $builder.build(['prelude'])
101 else
102 rm('prelude.c.new')
103 end
8c5a2dd let's go further miniruby
Laurent Sansonetti authored
104 =end
105 cp('miniprelude.c', 'prelude.c')
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
106 dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
107 $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub', 'miniprelude'])
108 major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
109 ["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
110 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
111 rm_f(dylib_alias)
112 ln_s(dylib, dylib_alias)
113 end
114 end
115 end
116
117 desc "Build static libraries for MacRuby"
118 task :static => :dylib do
119 $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub', 'miniprelude'])
120 end
121
122 desc "Build MacRuby"
123 task :build => :dylib do
124 $builder.link_executable(RUBY_INSTALL_NAME, ['main', 'gc-stub'], "-L. -l#{RUBY_SO_NAME} -lobjc")
125 end
094c682 created a macruby:weak_symbols task which dumps a list of weak symbols
Laurent Sansonetti authored
126
127 # Generates a list of weak symbols in libmacruby.dylib. You must not pass a unexported symbols list to
128 # rake when calling this command.
129 task :weak_symbols => :dylib do
130 sh("nm -m -P -arch i386 libmacruby.1.9.0.dylib | grep 'weak external' | grep -v 'undefined' | egrep -v '__ZT[IS]' | awk '{print$5}' > /tmp/syms-i386")
131 sh("nm -m -P -arch x86_64 libmacruby.1.9.0.dylib | grep 'weak external' | grep -v 'undefined' | egrep -v '__ZT[IS]' | awk '{print$5}' > /tmp/syms-x86_64")
132 sh("cat /tmp/syms-i386 /tmp/syms-x86_64 | uniq > unexported_symbols.list")
133 end
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
134 end
135
136 DESTDIR = (ENV['DESTDIR'] or "")
137 EXTOUT = (ENV['EXTOUT'] or ".ext")
138 INSTALLED_LIST = '.installed.list'
139 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
140 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
141
142 desc "Build extensions"
143 task :extensions => [:miniruby, "macruby:static"] do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
144 Builder::Ext.build
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
145 end
146
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
147 desc "Generate RDoc files"
148 task :doc => [:macruby, :extensions] do
149 doc_op = './doc'
150 unless File.exist?(doc_op)
151 sh "DYLD_LIBRARY_PATH=. ./macruby -I. -I./lib -I./ext/libyaml -I./ext/etc bin/rdoc --ri --op \"#{doc_op}\""
152 end
153 end
154
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
155 AOT_STDLIB = [
156 'rbconfig.rb',
157 'lib/date.rb',
158 'lib/date/**/*.rb',
70e1800 added erb to the aot list
Laurent Sansonetti authored
159 'lib/erb.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
160 'lib/fileutils.rb',
161 'lib/irb.rb',
162 'lib/irb/**/*.rb',
4f163cb add all net/* libraries to the aot list
Laurent Sansonetti authored
163 'lib/net/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
164 'lib/optparse.rb',
165 #'lib/stringio.rb', #spec fails
53c50f1 now AOT compiling rubygems
Laurent Sansonetti authored
166 'lib/rubygems.rb',
167 'lib/rubygems/**/*.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
168 'lib/thread.rb',
169 'lib/time.rb',
170 'lib/timeout.rb',
764c005 forgot uri.rb
Laurent Sansonetti authored
171 'lib/uri.rb',
28d81c6 added a bunch of stdlib files to the aot list
Laurent Sansonetti authored
172 'lib/uri/**/*.rb',
173 'lib/yaml.rb',
174 'lib/yaml/rubytypes.rb',
175 ]
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
176 namespace :stdlib do
177 desc "AOT compile the stdlib"
178 task :build => [:miniruby, 'macruby:dylib'] do
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
179 archf = ARCHS.map { |x| "--arch #{x}" }.join(' ')
180 commands = AOT_STDLIB.map do |pattern|
181 Dir.glob(pattern).map do |path|
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
182 out = File.join(File.dirname(path), File.basename(path, '.rb') + '.rbo')
183 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
184 "./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
185 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
186 end
d6d6b6f @alloy Add a simple way to execute commands in parallel. For the time being …
alloy authored
187 end.flatten.compact
95da69a @alloy Moved the parallel_execute method to Builder and make it accept array…
alloy authored
188 Builder.parallel_execute(commands)
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
189 end
190
191 desc "Touch .rbo files to ignore their build"
192 task :touch do
193 files = ["*.rbo", "lib/**/*.rbo"]
7ee9a50 oops
Laurent Sansonetti authored
194 files.map { |pat| Dir.glob(pat) }.flatten.each { |p| sh "/usr/bin/touch #{p}" }
96df0a7 aot_compile_stdlib becomes stdlib:build + added stdlib:touch for lazy…
Laurent Sansonetti authored
195 end
3ae269b move the AOT compilation of the stdlib into the main build task, intr…
Laurent Sansonetti authored
196 end
197
0bc95cf fixed rbconfig.rb to use absolute paths + fixed TRY_LINK to use g++, …
Laurent Sansonetti authored
198 desc "Same as extensions"
199 task :ext => 'extensions'
200
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
201 namespace :framework do
202 desc "Create the plist file for the framework"
203 task :info_plist do
6db33ad @alloy Move rbconfig and Info.plist creation to a separate file.
alloy authored
204 require File.expand_path('../builder/templates', __FILE__)
205 Builder.create_framework_info_plist
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
206 end
207
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored
208 desc "Install the extensions"
209 task :install_ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
210 Builder::Ext.install
108e7c1 added a framework:install_ext task that only installs extensions
Laurent Sansonetti authored
211 end
212
213 desc "Install the framework"
214 task :install => [:info_plist, :install_ext] do
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
215 sh "./miniruby instruby.rb #{INSTRUBY_ARGS}"
216 end
217 end
218
219 namespace :clean do
220 desc "Clean local build files"
221 task :local do
222 $builder.clean
69528db fixed the clean task to remove binary build producfs too
Laurent Sansonetti authored
223 list = ['parse.c', 'lex.c', INSTALLED_LIST, 'Makefile', RUBY_INSTALL_NAME, 'miniruby']
224 list.concat(Dir['*.inc'])
225 list.concat(Dir['lib*.{dylib,a}'])
226 list.each { |x| rm_f(x) }
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
227 end
228
6b57493 added a task to delete the .rbo files
Laurent Sansonetti authored
229 desc "Clean .rbo build files"
230 task :rbo do
231 list = []
232 list.concat(Dir['*.rbo'])
233 list.concat(Dir['lib/**/*.rbo'])
234 list.each { |x| rm_f(x) }
235 end
236
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
237 desc "Clean extension build files"
238 task :ext do
2be2465 @alloy Move extension builder code to Builder::Ext and clean builder.rake
alloy authored
239 Builder::Ext.clean
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
240 end
43a7ba7 now generating and installing RDoc ri files
Laurent Sansonetti authored
241
242 desc "Clean the RDoc files"
243 task :doc do
244 rm_rf('doc')
245 end
b0f57d9 blocked the rake all/install tasks for now
Laurent Sansonetti authored
246 end
Something went wrong with that request. Please try again.