forked from thejustinwalsh/TestFlightANE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
131 lines (114 loc) · 5.69 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
# Copyright (c) 2012 Justin Walsh, http://thejustinwalsh.com/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require "yaml"
require "Shellwords"
PROJECT = "TestFlight"
ROOT = File.dirname(__FILE__)
$build = []
$config = "debug"
task :default, [:config] => [:build] do |t, args|
end
desc "Bootstrap the environment by copying our template _build.yml to build.yml and prompting the user to edit the file"
task :bootstrap, [:config] do |t, args|
unless File.exists?('config/build.yml')
FileUtils.copy('config/_build.yml', 'config/build.yml')
abort("## Edit config/build.yml to match your environment before continuing!")
end
end
task :load, [:config] => [:bootstrap] do |t, args|
# Default our build configuration to debug
$config = args[:config] || $config;
# Load our build configuration from our yaml file
yaml = YAML::load(File.open('config/build.yml'))
$build = yaml[$config]
end
desc "Build the native extension"
task :build, [:config] => [:load, :ios, :swc, :default_swc] do |t, args|
airsdk = "#{Shellwords.escape($build['airsdk'])}"
adt = "#{airsdk}/bin/adt"
ane = "#{ROOT}/bin/TestFlight.ane"
xml = "#{ROOT}/src/extension.xml"
swc = "#{ROOT}/bin/#{PROJECT}.swc"
swf_dir = "#{ROOT}/bin/#{PROJECT}"
default_swf_dir = "#{ROOT}/bin/default/#{PROJECT}"
ios_platform_options = "#{ROOT}/src/platformoptions.xml"
ios_lib_dir = "#{ROOT}/platform/ios/bin/"
ios_lib = "libTestFlight.a"
# Run adt and package our ane
sh "#{adt} -package -target ane #{ane} #{xml} -swc #{swc} -platform iPhone-ARM -C #{swf_dir} library.swf -C #{ios_lib_dir} #{ios_lib} -platformoptions #{ios_platform_options} -platform default -C #{default_swf_dir} library.swf" do |ok, res|
fail "## adt failed with exitstatus #{res.exitstatus}" if !ok
end
end
desc "Build the swc and library.swf files needed for ane packaging"
task :swc, [:config] => [:load] do |t, args|
debug = ($config == "debug" ? "true" : "false")
debug_define = "CONFIG::debug," + ($config == "debug" ? "true" : "false")
airsdk = "#{Shellwords.escape($build['airsdk'])}"
compc = "#{airsdk}/bin/compc"
flexlib = "#{airsdk}/frameworks"
output_dir = "#{ROOT}/bin"
library = "#{output_dir}/#{PROJECT}.swc"
library_dir = "#{output_dir}/#{PROJECT}"
src = "#{ROOT}/src"
# Remove the swc output directory, then build the swc into a directory
rm_rf library_dir if File.directory? library_dir
sh "#{compc} -swf-version=14 -directory=true -output=#{library_dir} -debug=#{debug} -define=#{debug_define} +flexlib #{flexlib} +configname=air -source-path+=#{src} -include-sources #{src}" do |ok, res|
fail "## compc failed with exitstatus #{res.exitstatus}" if !ok
end
# Build the swc
sh "#{compc} -swf-version=14 -output=#{library} -debug=#{debug} -define=#{debug_define} +flexlib #{flexlib} +configname=air -source-path+=#{src} -include-sources #{src}" do |ok, res|
fail "## compc failed with exitstatus #{res.exitstatus}" if !ok
end
end
desc "Build the default swc and library.swf files needed for ane packaging"
task :default_swc, [:config] => [:load] do |t, args|
debug = ($config == "debug" ? "true" : "false")
debug_define = "CONFIG::debug," + ($config == "debug" ? "true" : "false")
airsdk = "#{Shellwords.escape($build['airsdk'])}"
compc = "#{airsdk}/bin/compc"
flexlib = "#{airsdk}/frameworks"
output_dir = "#{ROOT}/bin/default"
library = "#{output_dir}/#{PROJECT}.swc"
library_dir = "#{output_dir}/#{PROJECT}"
src = "#{ROOT}/platform/default"
# Remove the swc output directory, then build the swc into a directory
rm_rf library_dir if File.directory? library_dir
sh "#{compc} -swf-version=14 -directory=true -output=#{library_dir} -debug=#{debug} -define=#{debug_define} +flexlib #{flexlib} +configname=air -source-path+=#{src} -include-sources #{src}" do |ok, res|
fail "## compc failed with exitstatus #{res.exitstatus}" if !ok
end
# Build the swc
sh "#{compc} -swf-version=14 -output=#{library} -debug=#{debug} -define=#{debug_define} +flexlib #{flexlib} +configname=air -source-path+=#{src} -include-sources #{src}" do |ok, res|
fail "## compc failed with exitstatus #{res.exitstatus}" if !ok
end
end
desc "Build the native library for iOS"
task :ios, [:config] => [:load] do |t, args|
project = "#{ROOT}/platform/ios/TestFlight.xcodeproj"
target = 'TestFlight'
airsdk = Shellwords.escape($build['airsdk'])
iossdk = $build['iossdk']
configuration = $config.capitalize
symroot = "#{ROOT}/platform/ios/build"
# Inform Xcode of the AIR_SDK location so that the build can locate the air framework header, then build the native library
sh "export AIR_SDK=\"#{airsdk}\"; xcodebuild -project #{project} -sdk #{iossdk} -configuration #{configuration} -target #{target} build SYMROOT=#{symroot}" do |ok, res|
fail "## xcodebuild failed with exitstatus #{res.exitstatus}" if !ok
end
end