forked from shoes/shoes-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
330 lines (280 loc) · 9.77 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
require 'rubygems'
require 'rake'
require 'rake/clean'
if RUBY_VERSION != '1.8.7'
require_relative 'platform/skel'
else
require File.join(File.dirname(__FILE__), 'platform/skel')
end
require 'fileutils'
require 'find'
require 'yaml'
include FileUtils
APP = YAML.load_file(File.join(ENV['APP'] || ".", "app.yaml"))
APPNAME = APP['name']
RELEASE_ID, RELEASE_NAME = APP['version'], APP['release']
NAME = APP['shortname'] || APP['name'].downcase.gsub(/\W+/, '')
SONAME = 'shoes'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end
require 'bundler'
Bundler::GemHelper.install_tasks
GIT = ENV['GIT'] || "git"
REVISION = (`#{GIT} rev-list HEAD`.split.length + 1).to_s
VERS = ENV['VERSION'] || "0.r#{REVISION}"
PKG = "#{NAME}-#{VERS}"
APPARGS = APP['run']
FLAGS = %w[DEBUG VIDEO]
VLC_VERSION = (RUBY_PLATFORM =~ /win32/ ? "0.8": `vlc --version 2>/dev/null`.split[2])
VLC_0_8 = VLC_VERSION !~ /^0\.9/
BIN = "*.{bundle,jar,o,so,obj,pdb,pch,res,lib,def,exp,exe,ilk}"
CLEAN.include ["{bin,shoes}/#{BIN}", "req/**/#{BIN}", "dist"]
RUBY_SO = Config::CONFIG['RUBY_SO_NAME']
RUBY_V = Config::CONFIG['ruby_version']
RUBY_1_9 = (RUBY_V =~ /^1\.9/)
if RUBY_1_9
$: << "."
end
if ENV['APP']
%w[dmg icons].each do |subk|
APP[subk].keys.each do |name|
APP[subk][name] = File.join(ENV['APP'], APP[subk][name])
end
end
end
if File.exists? ".git/refs/tags/#{RELEASE_ID}/#{RELEASE_NAME}"
abort "** Rename this release (and add to lib/shoes.rb) #{RELEASE_NAME} has already been tagged."
end
case RUBY_PLATFORM
when /mingw/
require File.expand_path('rakefile_mingw')
Builder = MakeMinGW
when /darwin/
require File.expand_path('rakefile_darwin')
Builder = MakeDarwin
when /linux/
require File.expand_path('rakefile_linux')
Builder = MakeLinux
else
puts "Sorry, your platform [#{RUBY_PLATFORM}] is not supported..."
end
# --------------------------
# common platform tasks
desc "Same as `rake build'"
task :default => [:build]
desc "Does a full compile, with installer"
task :package => [:build, :installer]
task "shoes/version.h" do |t|
File.open(t.name, 'w') do |f|
f << %{#define SHOES_RELEASE_ID #{RELEASE_ID}\n#define SHOES_RELEASE_NAME "#{RELEASE_NAME}"\n#define SHOES_REVISION #{REVISION}\n#define SHOES_BUILD_DATE #{Time.now.strftime("%Y%m%d")}\n#define SHOES_PLATFORM "#{RUBY_PLATFORM}"\n}
end
end
task "dist/VERSION.txt" do |t|
File.open(t.name, 'w') do |f|
f << %{shoes #{RELEASE_NAME.downcase} (0.r#{REVISION}) [#{RUBY_PLATFORM} Ruby#{RUBY_V}]}
%w[VIDEO DEBUG].each { |x| f << " +#{x.downcase}" if ENV[x] }
f << "\n"
end
end
# shoes is small, if any include changes, go ahead and build from scratch.
SRC.zip(OBJ).each do |c, o|
file o => [c] + Dir["shoes/*.h"]
end
# --------------------------
# tasks depending on Builder = MakeLinux|MakeDarwin|MakeMinGW
desc "Does a full compile, for the OS you're running on"
task :build => [:build_os, "dist/VERSION.txt"] do
Builder.common_build
Builder.copy_deps_to_dist
Builder.copy_files_to_dist
Builder.setup_system_resources
end
task "dist/#{NAME}" => ["dist/lib#{SONAME}.#{DLEXT}", "bin/main.o"] + ADD_DLL do |t|
Builder.make_app t.name
end
task "dist/lib#{SONAME}.#{DLEXT}" => ['shoes/version.h'] + OBJ do |t|
Builder.make_so t.name
end
rule ".o" => ".m" do |t|
Builder.cc t
end
rule ".o" => ".c" do |t|
Builder.cc t
end
task :installer do
Builder.make_installer
end
# Like puts, but only if we've --trace'd
def vputs(str)
puts str if Rake.application.options.trace
end
# Here's all of the deps that Shoes needs!
#
# The key is the directory of each dependency. The values are hashes which
# have some elements:
# :url => The url where that dep can be downloaded from
# :config => the option that needs to be passed to ./configure
# :final_file => Basically, if this is built, we dont need to rebuild the dep
#
# That's it!
deps_list = {
"deps/src/pkg-config-0.20" => {
:url => "http://pkg-config.freedesktop.org/releases/pkg-config-0.20.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
},
"deps/src/libpng-1.4.1" => {
:url => "http://sourceforge.net/projects/libpng/files/libpng14/older-releases/1.4.1/libpng-1.4.1.tar.gz/download",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/libpng14.14.dylib",
},
"deps/src/giflib-4.1.6" => {
:url => "http://sourceforge.net/projects/giflib/files/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.gz/download",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/libgif.dylib",
},
"deps/src/gettext-0.17" => {
:url => "http://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/libgettextlib.dylib",
},
"deps/src/libiconv-1.13" => {
:url => "http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/libiconv.dylib",
},
"deps/src/pixman-0.18.0" => {
:url => "http://cgit.freedesktop.org/pixman/snapshot/pixman-0.18.0.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/libpixman-1.dylib",
:autogen => true
},
"deps/src/portaudio" => {
:url => "http://portaudio.com/archives/pa_stable_v19_20071207.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps --disable-mac-universal",
:final_file => "deps/lib/libportaudio.dylib",
},
"deps/src/glib-2.28.1" => {
:url => "http://ftp.gnome.org/pub/gnome/sources/glib/2.28/glib-2.28.1.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps",
:final_file => "deps/lib/glib-2.0",
},
"deps/src/cairo-1.8.10" => {
:url => "http://cairographics.org/releases/cairo-1.8.10.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps --enable-quartz=yes --enable-quartz-font=yes --enable-xlib=no",
:final_file => "deps/lib/libcairo.dylib",
},
"deps/src/pango-1.28.0" => {
:url => "http://ftp.gnome.org/pub/GNOME/sources/pango/1.28/pango-1.28.0.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps --with-x=no",
:final_file => "deps/lib/libpango-1.0.dylib",
},
"deps/src/jpeg-8a" => {
:url => "http://ijg.org/files/jpegsrc.v8a.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps --enable-shared",
:final_file => "deps/lib/libjpeg.dylib",
},
"deps/src/ruby-1.9.1-p378" => {
:url => "http://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.1-p378.tar.gz",
:config => "--prefix=#{File.dirname(__FILE__)}/deps --enable-shared",
:final_file => "deps/lib/libruby.dylib",
},
"deps/src/rubygems-1.3.6.tgz" => {
:url => "http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz",
:config => "",
},
}
# Note: right now, this just works due to the ordering, but really, this should
# be encoded in the tasks: pango needs cairo, and glib. Otherwise it wont build.
# First we want to download all the deps
deps_steps = deps_list.keys
# Then let's build pkg-config
deps_steps << "deps/bin/pkg-config"
# Next set up the environment variables
deps_steps << "set-env"
# Next is all of the deps
deps_steps += deps_list.reject{|k| k =~ /pkg-config/ or k =~ /rubygems/ }.map{|k, v| deps_list[k][:final_file]}
# Then comes rubygems...
deps_steps << "install-rubygems"
# Then finally, rake
deps_steps << "install-rake"
desc "Build dependencies on Snow Leopard"
task "deps" => deps_steps do
vputs "done building deps!"
end
file "deps/bin/pkg-config" => "deps/src/pkg-config-0.20" do
# Let's build pkg-config
cd "deps/src/pkg-config-0.20" do
sh "./configure #{deps_list['deps/src/pkg-config-0.20'][:config]}"
sh "make && make install"
end
end
deps_dir = File.dirname(__FILE__) + "/deps"
deps_list.each do |k, opts|
file opts[:final_file] => k do
cd k do
# sometimes, we need to run autogen.sh to make our configure file.
if opts[:autogen]
sh "sh autogen.sh"
end
# Standard three commands to compile all of this.
sh "./configure #{opts[:config]}"
sh "make && make install"
end
end
end
task "install-rubygems" => "#{deps_dir}/bin/gem" do
# I'm not sure this is still important with ruby1.9.
cd "#{deps_dir}/src/rubygems-1.3.6" do
sh "#{deps_dir}/bin/ruby setup.rb"
end
end
task "install-rake" do
# Same thing: dunno on 1.9
# Gotta find a way for this to only run if it hasn't been yet.
# Probably set a dep based on where it puts the gem, I don't know off the top
# of my head and it's 3am.
sh "#{deps_dir}/bin/gem install rake"
end
# Sets up a bunch of environment variables
task "set-env" do
ENV['MACOSX_DEPLOYMENT_TARGET'] = "10.6"
ENV['PATH'] = "#{deps_dir}/bin:#{ENV['PATH']}"
ENV['CFLAGS'] = "-I#{deps_dir}/include -w"
ENV['LDFLAGS'] = "-L/#{deps_dir}/lib"
ENV['PKG_CONFIG_PATH'] = "#{deps_dir}/lib/pkgconfig"
end
begin
# Let's use mechanize to download the files we need.
require 'mechanize'
agent = Mechanize.new
# We want to make sure that the deps/src directory gets built: that's where
# all of the source code for our dependencies goes
directory "deps/src"
# These tasks all download the source for our dependencies.
#
# We want to loop through the deps list.
deps_list.each do |name, opts|
# Each file depends on having the src directory built
file name => "deps/src" do
# Grab the URL we need to download from.
url = opts[:url]
# get just the filename
url =~ /([^\/]+(?:(?:\.tar\.gz)|(?:\.tgz)))/
f = $1
cd "deps/src" do
vputs "downloading #{url}"
agent.get(url).save
# For some reason, the pixman downloads with quotes.
if File.exists?("\"pixman-0.18.0.tar.gz\"")
mv "\"pixman-0.18.0.tar.gz\"", "pixman-0.18.0.tar.gz"
end
# unzip!
sh "tar -xzf #{f}"
end
end
end
rescue LoadError
puts "mechanize didn't load, can't do the OSX autoinstalling deps rake tasks."
end