Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 339 lines (325 sloc) 12.522 kb
6d571b4 @alloy Moved guts of the code in Rakefile into seperate files in rakelib.
alloy authored
1 require File.expand_path('../builder', __FILE__)
2
3 desc "Build known objects"
4 task :objects => [:config_h, :dtrace_h, :revision_h] do
5 sh "/usr/bin/ruby tool/compile_prelude.rb prelude.rb miniprelude.c.new"
6 if !File.exist?('miniprelude.c') or File.read('miniprelude.c') != File.read('miniprelude.c.new')
7 mv('miniprelude.c.new', 'miniprelude.c')
8 else
9 rm('miniprelude.c.new')
10 end
11 if !File.exist?('prelude.c')
12 touch('prelude.c') # create empty file nevertheless
13 end
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')
19 rm_f('parse.o')
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
30 $builder.build
31 end
32
33 desc "Create miniruby"
34 task :miniruby => :objects do
35 $builder.link_executable('miniruby', OBJS - ['prelude'])
36 end
37
38 desc "Create config file"
39 task :rbconfig => :miniruby do
40 rbconfig = <<EOS
41 # This file was created when MacRuby was built. Any changes made to this file
42 # will be lost the next time MacRuby is built.
43
44 module RbConfig
45 RUBY_VERSION == "#{NEW_RUBY_VERSION}" or
46 raise "ruby lib version (#{NEW_RUBY_VERSION}) doesn't match executable version (\#{RUBY_VERSION})"
47
48 TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/#{NEW_RUBY_VERSION}/#{NEW_RUBY_PLATFORM}")
49 DESTDIR = '' unless defined? DESTDIR
50 CONFIG = {}
51 CONFIG["DESTDIR"] = DESTDIR
52 CONFIG["INSTALL"] = '/usr/bin/install -c'
53 CONFIG["prefix"] = (TOPDIR || DESTDIR + "#{FRAMEWORK_USR}")
54 CONFIG["EXEEXT"] = ""
55 CONFIG["ruby_install_name"] = "#{RUBY_INSTALL_NAME}"
56 CONFIG["RUBY_INSTALL_NAME"] = "#{RUBY_INSTALL_NAME}"
57 CONFIG["RUBY_SO_NAME"] = "#{RUBY_SO_NAME}"
58 CONFIG["SHELL"] = "/bin/sh"
59 CONFIG["PATH_SEPARATOR"] = ":"
60 CONFIG["PACKAGE_NAME"] = ""
61 CONFIG["PACKAGE_TARNAME"] = ""
62 CONFIG["PACKAGE_VERSION"] = ""
63 CONFIG["PACKAGE_STRING"] = ""
64 CONFIG["PACKAGE_BUGREPORT"] = ""
65 CONFIG["exec_prefix"] = "$(prefix)"
66 CONFIG["bindir"] = "$(exec_prefix)/bin"
67 CONFIG["sbindir"] = "$(exec_prefix)/sbin"
68 CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
69 CONFIG["datarootdir"] = "$(prefix)/share"
70 CONFIG["datadir"] = "$(datarootdir)"
71 CONFIG["sysconfdir"] = "$(prefix)/etc"
72 CONFIG["sharedstatedir"] = "$(prefix)/com"
73 CONFIG["localstatedir"] = "$(prefix)/var"
74 CONFIG["includedir"] = "$(prefix)/include"
75 CONFIG["oldincludedir"] = "/usr/include"
76 CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"
77 CONFIG["infodir"] = "$(datarootdir)/info"
78 CONFIG["htmldir"] = "$(docdir)"
79 CONFIG["dvidir"] = "$(docdir)"
80 CONFIG["pdfdir"] = "$(docdir)"
81 CONFIG["psdir"] = "$(docdir)"
82 CONFIG["libdir"] = "$(exec_prefix)/lib"
83 CONFIG["localedir"] = "$(datarootdir)/locale"
84 CONFIG["mandir"] = "$(datarootdir)/man"
85 CONFIG["DEFS"] = ""
86 CONFIG["ECHO_C"] = "\\\\\\\\c"
87 CONFIG["ECHO_N"] = ""
88 CONFIG["ECHO_T"] = ""
89 CONFIG["LIBS"] = ""
90 CONFIG["build_alias"] = ""
91 CONFIG["host_alias"] = ""
92 CONFIG["target_alias"] = ""
93 CONFIG["BASERUBY"] = "ruby"
94 CONFIG["MAJOR"], CONFIG["MINOR"], CONFIG["TEENY"] = [#{NEW_RUBY_VERSION.scan(/\d+/).map { |x| "\"" + x + "\"" }.join(', ')}]
95 CONFIG["build"] = "i686-apple-darwin9.0.0"
96 CONFIG["build_cpu"] = "i686"
97 CONFIG["build_vendor"] = "apple"
98 CONFIG["build_os"] = "darwin9.0.0"
99 CONFIG["host"] = "i686-apple-darwin9.0.0"
100 CONFIG["host_cpu"] = "i686"
101 CONFIG["host_vendor"] = "apple"
102 CONFIG["host_os"] = "darwin9.0.0"
103 CONFIG["target"] = "i686-apple-darwin9.0.0"
104 CONFIG["target_cpu"] = "i686"
105 CONFIG["target_vendor"] = "apple"
106 CONFIG["target_os"] = "darwin9.0"
107 CONFIG["CC"] = "gcc"
108 CONFIG["CFLAGS"] = "-fno-common -pipe $(cflags)"
109 CONFIG["LDFLAGS"] = ""
110 CONFIG["CPPFLAGS"] = "$(cppflags)"
111 CONFIG["OBJEXT"] = "o"
112 CONFIG["CXX"] = "g++"
113 CONFIG["CXXFLAGS"] = ""
114 CONFIG["CPP"] = "gcc -E"
115 CONFIG["GREP"] = "/usr/bin/grep"
116 CONFIG["EGREP"] = "/usr/bin/grep -E"
117 CONFIG["GNU_LD"] = "no"
118 CONFIG["CPPOUTFILE"] = "-o conftest.i"
119 CONFIG["OUTFLAG"] = "-o "
120 CONFIG["COUTFLAG"] = "-o "
121 CONFIG["RANLIB"] = "ranlib"
122 CONFIG["AR"] = "ar"
123 CONFIG["AS"] = "as"
124 CONFIG["ASFLAGS"] = ""
125 CONFIG["NM"] = ""
126 CONFIG["WINDRES"] = ""
127 CONFIG["DLLWRAP"] = ""
128 CONFIG["OBJDUMP"] = ""
129 CONFIG["LN_S"] = "ln -s"
130 CONFIG["SET_MAKE"] = ""
131 CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
132 CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
133 CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
134 CONFIG["RM"] = "rm -f"
135 CONFIG["CP"] = "cp"
136 CONFIG["MAKEDIRS"] = "mkdir -p"
137 CONFIG["ALLOCA"] = ""
138 CONFIG["DLDFLAGS"] = ""
139 CONFIG["ARCH_FLAG"] = "#{ARCHFLAGS}"
140 CONFIG["STATIC"] = ""
141 CONFIG["CCDLFLAGS"] = "-fno-common"
142 CONFIG["LDSHARED"] = "$(CC) -dynamic -bundle -undefined suppress -flat_namespace #{ARCHFLAGS}"
143 CONFIG["LDSHAREDXX"] = "$(CXX) -dynamic -bundle -undefined suppress -flat_namespace"
144 CONFIG["DLEXT"] = "bundle"
145 CONFIG["DLEXT2"] = ""
146 CONFIG["LIBEXT"] = "a"
147 CONFIG["LINK_SO"] = ""
148 CONFIG["LIBPATHFLAG"] = " -L%s"
149 CONFIG["RPATHFLAG"] = ""
150 CONFIG["LIBPATHENV"] = "DYLD_LIBRARY_PATH"
151 CONFIG["TRY_LINK"] = ""
152 CONFIG["STRIP"] = "strip -A -n"
153 CONFIG["EXTSTATIC"] = ""
154 CONFIG["setup"] = "Setup"
155 CONFIG["PREP"] = "miniruby$(EXEEXT)"
156 CONFIG["EXTOUT"] = ".ext"
157 CONFIG["ARCHFILE"] = ""
158 CONFIG["RDOCTARGET"] = "install-doc"
159 CONFIG["cppflags"] = ""
160 CONFIG["cflags"] = "$(optflags) $(debugflags) $(warnflags)"
161 CONFIG["optflags"] = "-O2"
162 CONFIG["debugflags"] = "-g"
163 CONFIG["warnflags"] = "-Wall -Wno-parentheses"
164 CONFIG["LIBRUBY_LDSHARED"] = "gcc -dynamiclib -undefined suppress -flat_namespace"
165 CONFIG["LIBRUBY_DLDFLAGS"] = "-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)"
166 CONFIG["rubyw_install_name"] = ""
167 CONFIG["RUBYW_INSTALL_NAME"] = ""
168 CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
169 CONFIG["LIBRUBY_SO"] = "lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib"
170 CONFIG["LIBRUBY_ALIASES"] = "lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib"
171 CONFIG["LIBRUBY"] = "$(LIBRUBY_SO)"
172 CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
173 CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static #{LDFLAGS}"
174 CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
175 CONFIG["SOLIBS"] = ""
176 CONFIG["DLDLIBS"] = ""
177 CONFIG["ENABLE_SHARED"] = "yes"
178 CONFIG["ENABLE_STATIC"] = "#{ENABLE_STATIC_LIBRARY}"
179 CONFIG["MAINLIBS"] = ""
180 CONFIG["COMMON_LIBS"] = ""
181 CONFIG["COMMON_MACROS"] = ""
182 CONFIG["COMMON_HEADERS"] = ""
183 CONFIG["EXPORT_PREFIX"] = ""
184 CONFIG["THREAD_MODEL"] = "pthread"
185 CONFIG["MAKEFILES"] = "Makefile"
186 CONFIG["arch"] = "#{NEW_RUBY_PLATFORM}"
187 CONFIG["sitearch"] = "#{NEW_RUBY_PLATFORM}"
188 CONFIG["sitedir"] = "$(libdir)/ruby/site_ruby"
189 CONFIG["vendordir"] = "$(prefix)/lib/ruby/vendor_ruby"
190 CONFIG["configure_args"] = ""
191 CONFIG["rubyhdrdir"] = "$(includedir)/ruby-$(MAJOR).$(MINOR).$(TEENY)"
192 CONFIG["sitehdrdir"] = "$(rubyhdrdir)/site_ruby"
193 CONFIG["vendorhdrdir"] = "$(rubyhdrdir)/vendor_ruby"
194 CONFIG["NROFF"] = "/usr/bin/nroff"
195 CONFIG["MANTYPE"] = "doc"
196 CONFIG["ruby_version"] = "$(MAJOR).$(MINOR).$(TEENY)"
197 CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
198 CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
199 CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
200 CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
201 CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
202 CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
203 CONFIG["topdir"] = File.dirname(__FILE__)
204 MAKEFILE_CONFIG = {}
205 CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
206 def RbConfig::expand(val, config = CONFIG)
207 val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do
208 var = $&
209 if !(v = $1 || $2)
210 '$'
211 elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]]
212 pat, sub = $1, $2
213 config[v] = false
214 RbConfig::expand(key, config)
215 config[v] = key
216 key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat
217 key
218 else
219 var
220 end
221 end
222 val
223 end
224 CONFIG.each_value do |val|
225 RbConfig::expand(val)
226 end
227 end
228 Config = RbConfig # compatibility for ruby-1.8.4 and older.
229 CROSS_COMPILING = nil
230 RUBY_FRAMEWORK = true
231 RUBY_FRAMEWORK_VERSION = RbConfig::CONFIG['ruby_version']
232 EOS
233 if !File.exist?('rbconfig.rb') or File.read('rbconfig.rb') != rbconfig
234 File.open('rbconfig.rb', 'w') { |io| io.print rbconfig }
235 end
236 end
237
238 namespace :macruby do
239 desc "Build dynamic libraries for MacRuby"
240 task :dylib => [:rbconfig, :miniruby] do
241 sh("./miniruby -I. -I./lib -rrbconfig tool/compile_prelude.rb prelude.rb gem_prelude.rb prelude.c.new")
242 if !File.exist?('prelude.c') or File.read('prelude.c') != File.read('prelude.c.new')
243 mv('prelude.c.new', 'prelude.c')
244 $builder.build(['prelude'])
245 else
246 rm('prelude.c.new')
247 end
248 dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
249 $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub', 'miniprelude'])
250 major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
251 ["lib#{RUBY_SO_NAME}.#{major}.#{minor}.dylib", "lib#{RUBY_SO_NAME}.dylib"].each do |dylib_alias|
252 if !File.exist?(dylib_alias) or File.readlink(dylib_alias) != dylib
253 rm_f(dylib_alias)
254 ln_s(dylib, dylib_alias)
255 end
256 end
257 end
258
259 desc "Build static libraries for MacRuby"
260 task :static => :dylib do
261 $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub', 'miniprelude'])
262 end
263
264 desc "Build MacRuby"
265 task :build => :dylib do
266 $builder.link_executable(RUBY_INSTALL_NAME, ['main', 'gc-stub'], "-L. -l#{RUBY_SO_NAME} -lobjc")
267 end
268 end
269
270 DESTDIR = (ENV['DESTDIR'] or "")
271 EXTOUT = (ENV['EXTOUT'] or ".ext")
272 INSTALLED_LIST = '.installed.list'
273 SCRIPT_ARGS = "--make=\"/usr/bin/make\" --dest-dir=\"#{DESTDIR}\" --extout=\"#{EXTOUT}\" --mflags=\"\" --make-flags=\"\""
274 EXTMK_ARGS = "#{SCRIPT_ARGS} --extension --extstatic"
275 INSTRUBY_ARGS = "#{SCRIPT_ARGS} --data-mode=0644 --prog-mode=0755 --installed-list #{INSTALLED_LIST} --mantype=\"doc\" --sym-dest-dir=\"#{SYM_INSTDIR}\""
276
277 desc "Build extensions"
278 task :extensions => [:miniruby, "macruby:static"] do
279 sh "./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ext/extmk.rb #{EXTMK_ARGS}"
280 end
281
282 namespace :framework do
283 desc "Create the plist file for the framework"
284 task :info_plist do
285 plist = <<EOS
286 <?xml version="1.0" encoding="UTF-8"?>
287 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
288 <plist version="1.0">
289 <dict>
290 <key>CFBundleDevelopmentRegion</key>
291 <string>English</string>
292 <key>CFBundleExecutable</key>
293 <string>Ruby</string>
294 <key>CFBundleName</key>
295 <string>Ruby</string>
296 <key>CFBundleGetInfoString</key>
297 <string>MacRuby Runtime and Library</string>
298 <key>CFBundleIconFile</key>
299 <string></string>
300 <key>CFBundleIdentifier</key>
301 <string>com.apple.macruby</string>
302 <key>CFBundleInfoDictionaryVersion</key>
303 <string>#{MACRUBY_VERSION}</string>
304 <key>CFBundlePackageType</key>
305 <string>FMWK</string>
306 <key>CFBundleShortVersionString</key>
307 <string>#{MACRUBY_VERSION}</string>
308 <key>CFBundleSignature</key>
309 <string>????</string>
310 <key>CFBundleVersion</key>
311 <string>MacRuby-#{MACRUBY_VERSION}</string>
312 <key>NSPrincipalClass</key>
313 <string></string>
314 </dict>
315 </plist>
316 EOS
317 File.open('framework/Info.plist', 'w') { |io| io.print plist }
318 end
319
320 desc "Install the framework"
321 task :install => :info_plist do
322 sh "./miniruby instruby.rb #{INSTRUBY_ARGS}"
323 end
324 end
325
326 namespace :clean do
327 desc "Clean local build files"
328 task :local do
329 $builder.clean
330 ['parse.c', 'lex.c', INSTALLED_LIST, 'Makefile', *Dir['*.inc']].each { |x| rm_f(x) }
331 end
332
333 desc "Clean extension build files"
334 task :ext do
335 if File.exist?('./miniruby')
336 sh "./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ext/extmk.rb #{EXTMK_ARGS} -- clean"
337 end
338 end
339 end
Something went wrong with that request. Please try again.