-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
135 lines (112 loc) · 3.35 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
require 'rubygems'
require 'nokogiri'
require 'colored'
require 'betabuilder'
require File.expand_path(File.join(Dir.pwd, 'config/config.rb'))
include Config
BetaBuilder::Tasks.new do |config|
# App Name
config.target = "Tiapp"
# Xcode configuration profile
config.configuration = "Adhoc"
end
task :default => ["build:iphone"]
namespace :setup do
desc "Do all the setup procedures"
task :all do
Rake::Task['setup:xml'].invoke
Rake::Task['setup:entitlements'].invoke
Rake::Task['setup:rakefile'].invoke
end
desc "Copy the tiapp.xml file into build/iphone directory"
task :xml do
copy_xml
end
desc "Create the Entitlements.plist file in build/iphone directory"
task :entitlements do
create_entitlement_plist
end
desc "Copy the Rakefile to the build/iphone directory"
task :rakefile do
copy_rakefile
end
end
namespace :compile do
desc "Compile all assets"
task :all do
compile
end
desc "Compile SASS to JSS"
task :styles do
#compile_sass
end
desc "Compile CoffeeScript into JS"
task :coffee do
compile_coffee
end
end
namespace :build do
desc "Build the app for iPhone"
task :iphone do
build
end
end
def compile
compile_coffee #&& compile_sass
end
def copy_xml
unless File.exists?(File.join(Dir.pwd, 'build/iphone/tiapp.xml'))
puts "Copying tiapp.xml to the build/iphone/ directory.".blue
system("ln -s #{File.join(Dir.pwd, 'tiapp.xml')} #{File.join(Dir.pwd, 'build/iphone')}")
end
end
def create_entitlement_plist
entitlements = File.join(Dir.pwd, 'build/iphone/Entitlements.plist')
unless File.exists?(entitlements)
puts "Creating an Entitlements.plist (build/iphone) file since it doesn't exist.".blue
File.open(entitlements, 'w') do |f|
f.puts <<-LINE
<?xml versio="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>get-task-allow</key>
<false/>
</dict>
</plist>
LINE
end
end
end
def copy_rakefile
unless File.exists?(File.join(Dir.pwd, 'build/iphone/Rakefile'))
puts "Copying Rakefile to the buil/iphone directory.".blue
system("ln -s #{File.join(Dir.pwd, 'Rakefile')} #{File.join(Dir.pwd, 'build/iphone')}")
end
end
def compile_sass
puts "Compiling stylesheets".blue
compilation = system "sass -C -t expand app/ti_app/stylesheets/app.sass > Resources/app.jss"
end
def compile_coffee
puts "Compiling CoffeeScript".blue
paths = `find app/ti_app -name '*.coffee'|grep -v run.coffee`.split("\n")
compilation = (
system "coffee -p --join --bare #{paths.join(' ')} app/ti_app/run.coffee > Resources/ti_app.js" and
system "coffee -p --bare app/app.coffee > Resources/app.js"
)
puts "coffee -p --bare #{paths.join(' ')} app/ti_app/run.coffee > Resources/ti_app.js"
if compilation
puts "Successfully compiled CoffeeScript".green
else
puts "Error compiling CoffeeScript".red
end
compilation
end
def build(options={})
return unless compile
options[:device] ||= 'iphone'
puts "Building with Titanium... (DEVICE_TYPE: #{options[:device]})".blue
sh %Q{bash -c "#{TI_BUILD} run #{PROJECT_ROOT}/ #{IPHONE_SDK_VERSION} #{APP_ID} #{APP_NAME} #{APP_DEVICE} " \
| 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;'}
end