-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
107 lines (83 loc) · 2.81 KB
/
Rakefile
File metadata and controls
107 lines (83 loc) · 2.81 KB
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
require 'nokogiri'
require 'colored'
require 'fileutils'
require File.expand_path(File.join(Dir.pwd, 'config/config.rb'))
include Config
PERL_COLOR_FILTER = %Q{| perl -pe 's/^\\[DEBUG\\].*$/\\e[35m$&\\e[0m/g;s/^\\[INFO\\].*$/\\e[36m$&\\e[0m/g;s/^\\[WARN\\].*$/\\e[33m$&\\e[0m/g;s/^\\[ERROR\\].*$/\\e[31m$&\\e[0m/g;'}
task :default => ["build:iphone"]
namespace :compile do
desc "Compile CoffeeScript into JS"
task :coffee do
compile_coffee
end
end
namespace :build do
desc "Build the app for iPhone and run in simulator"
task :iphone do
File.open("#{PROJECT_ROOT}/Resources/test/enabled.js", 'w') {|f| f.write("")}
build :device => 'iphone'
end
desc "Build the app for android and install to attached device / emulator"
task :android do
File.open("#{PROJECT_ROOT}/Resources/test/enabled.js", 'w') {|f| f.write("")}
build :device => 'android'
end
end
namespace :test do
desc "Run Jasmine tests on iPhone"
task :iphone do
File.open("#{PROJECT_ROOT}/Resources/test/enabled.js", 'w') {|f| f.write("App.tests_enabled = true;")}
build :device => 'iphone'
end
desc "Run Jasmine tests on Android"
task :android do
File.open("#{PROJECT_ROOT}/Resources/test/enabled.js", 'w') {|f| f.write("App.tests_enabled = true;")}
build :device => 'android'
end
end
namespace :clean do
desc "Clean Android build directory"
task :android do
FileUtils.rm_r Dir.glob('build/android/*'), :force => true
puts "Cleaned build/android".blue
end
desc "Clean iPhone build directory"
task :iphone do
FileUtils.rm_r Dir.glob('build/iphone/*'), :force => true
puts "Cleaned build/iphone".blue
end
desc "Clean android and iphone build directories"
task :all do
Rake::Task["clean:iphone"].execute
Rake::Task["clean:android"].execute
end
end
def compile_coffee
puts "Compiling CoffeeScript".blue
failed = false
paths = `find app -name '*.coffee'`.split("\n")
paths.each do |path|
out_dir = path.gsub(/^app/, 'Resources').gsub(/\/[\w-]*\.coffee$/,"")
unless system "coffee -c -b -o #{out_dir} #{path}"
puts "Compilation failed: #{path}".red
failed = true
end
end
puts "Successfully compiled CoffeeScript".green unless failed
not failed
end
def build(options={})
return unless compile_coffee
options[:device] ||= 'iphone'
puts "Building with Titanium... (DEVICE_TYPE: #{options[:device]})".blue
case options[:device]
when 'iphone'
begin
sh %Q{bash -c "#{TI_IPHONE_BUILD} run #{PROJECT_ROOT}/ #{IPHONE_SDK_VERSION} #{APP_ID} #{APP_NAME} #{options[:device]} " #{PERL_COLOR_FILTER}}
rescue
sh %Q{killall "iPhone Simulator"}
end
when 'android'
sh %Q{bash -c "#{TI_ANDROID_BUILD} install #{APP_NAME} #{ANDROID_SDK_DIR} #{PROJECT_ROOT}/ #{APP_ID} #{ANDROID_SDK_ID}" #{PERL_COLOR_FILTER}}
end
end