-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ad
executable file
·223 lines (201 loc) · 5.46 KB
/
build.ad
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
#!/bin/sh
################################################################################
##
## Adrian C. Miranda <adriancmiranda@gmail.com>
##
## References:
## http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html
##
## To make build executable:
## $ chmod 775 build.ad
##
## Usage:
## $ cd path/to/work
## $ sh build.ad help
##
## @todo:
## $ Hit esc in compile error.
##
################################################################################
#
#
# > config
#
#
################################################################################
#
# info
#
appname="boot"
#
# structure
#
bin="publish"
src="sources"
#
# build index
#
as="$src/classes/$appname.as"
swf="$bin/$appname.swf"
air="$bin/$appname.air"
html="$bin/index.html"
#
# class paths
#
sourcespath="$src/classes/ $src/libs/"
librarypath="$src/swc/"
#
# previews
#
preview0=$swf
preview1=$html
preview2="http://localhost:8000/"
#
# support
#
targetplayer=11.1
flashlog="/Users/adrianmiranda/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt"
flexsdk="/Users/adrianmiranda/addons/SDKs/flex_sdk_4.6.0"
airsdk="/Users/adrianmiranda/addons/SDKs/air_sdk_3.6.0"
adt="$airsdk/bin/adt"
swc="$flexsdk/frameworks/libs/framework.swc $librarypath"
mxmlc="$flexsdk/bin/mxmlc"
asdoc="$flexsdk/bin/asdoc"
vars="-define CONFIG::LOGGING true -define CONFIG::PLATFORM true -define CONFIG::MOCK false"
################################################################################
#
#
# > exec
#
#
################################################################################
#
# utils
#
function float_condition() {
local cond=0
if [[ $# -gt 0 ]]; then
cond=$(echo "$*" | bc -q 2>/dev/null)
if [[ -z "$cond" ]]; then cond=0; fi
if [[ "$cond" != 0 && "$cond" != 1 ]]; then cond=0; fi
fi
local stat=$((cond == 0))
return $stat
}
#
# define target player
#
if float_condition ''$targetplayer' > 10.1'; then
vars="-target-player=$targetplayer $vars -define CONFIG::FLASH_10_1 false"
else
vars="-target-player=$targetplayer $vars -define CONFIG::FLASH_10_1 true"
fi
if [ "$1" = "air" ]; then
vars="$vars -define CONFIG::AIR true -define CONFIG::WEB false"
else
vars="$vars -define CONFIG::AIR false -define CONFIG::WEB true"
fi
#
# set options
#
if [ "$2" = "r" ]; then # release
options="-static-link-runtime-shared-libraries=true -use-network=false -incremental=false -keep=false -debug=false $vars"
else # debug
options="-static-link-runtime-shared-libraries=true -use-network=false -incremental=false -keep=false -debug=true $vars"
fi
#
# run mxmlc
#
if [ "$1" != "help" ] && [ "$1" != "bytes" ] && [ "$1" != "l" ] && [ "$1" != "ll" ] && [ "$1" != "llh" ]; then
echo ":: Building $swf in $bin \n"
startTime=`eval date +%s`
$mxmlc $as -o $swf -source-path $sourcespath -library-path $swc $options
endTime=`eval date +%s`
#
# run adt
#
if [ "$1" = "air" ]; then
echo "\n:: Building $air in $bin \n"
# revision
revision=`cat revision`
echo "REVISION $revision"
echo $((revision+1)) > revision
# update xml config (http://www.grymoire.com/Unix/Sed.html)
APP_SWF_TREATED=`echo $swf | sed 's/\./\\\\./g'`
sed -e "s/APP_REVISION/$revision/g" \
-e "s/APP_NAME/$appname/g" $appname.xml > $appname-app.xml
# -e "s/APP_SWF/$APP_SWF_TREATED/g" $appname.xml > $appname-app.xml
# remove previous versions
rm -Rf *.air *.dmg *.ipa
# uinstall previous version
# $adt -uninstallApp -platformsdk $airsdk -appid $appname
# create certificate
$adt -certificate -cn AM -ou AM -o AM -c BR -validityPeriod 2 1024-RSA certificate.p12 "$appname"
# dependencies
directories="$bin/content"
# compile air
$adt -version
$adt -package -storetype pkcs12 -keystore certificate.p12 -storepass "$appname" $air $appname-app.xml $swf $directories
if [ "$2" = "r" ]; then
echo "+> Installing $appname"
open $air
fi
fi
let PTIME=($endTime - $startTime)
echo "\n:: Decommisioning Previous Compile"
echo ":: Built in $PTIME seconds"
fi
#
# debug in terminal
#
if [ "$2" = "d" ]; then
tail -f "$flashlog"
fi
#
# launch previews
#
if [ "$1" = "r" ] || [ "$1" = "l" ]; then # run
echo " + Launch Booting Instances in player"
open $preview0
elif [ "$1" = "rl" ] || [ "$1" = "ll" ]; then # run local
echo " + Launch Booting Instances in browser"
open $preview1
elif [ "$1" = "ssr" ]; then # search strings recursively in files
if [ "$3" ]; then
echo " + Rerouting search to $3"
cd "$3"
fi
echo ":: Searching in ./$3 by $2 \n"
find ./ -exec grep -Hn "$2" {} \;
echo "\n:: Decommisioning Previous Search \n"
elif [ "$1" = "rlh" ] || [ "$1" = "llh" ]; then # run localhost
echo " + Rerouting $preview2 to $bin"
cd "$bin"
open $preview2
echo " +> Booting $preview2 in $bin"
echo " [ Press ctrl+c to get out ] \n"
python -m SimpleHTTPServer
echo " << traffic successfully CANCELED"
elif [ "$1" = "bytes" ]; then # run localhost
echo "bytes\tfile"
if [ "$2" ]; then
cd "$2"
else
cd "$bin"
fi
du -a
echo "--"
elif [ "$1" = "help" ] || [ "$1" = "h" ]; then # help user
echo "usage: sh build.ad [l][ll][llh][r][rl][rlh][ssr[=<string>][=<path>]][help]"
echo "\tsh build.ad <command> [<args>]"
echo "\nThe most commonly used git commands are:"
echo " l\tLaunch"
echo " ll\tLaunch local"
echo " llh\tLaunch localhost"
echo " r\tRun"
echo " rl\tRun local"
echo " rlh\tRun localhost"
echo " ssr\tSearch strings recursively in files"
echo " air\tGenerate Air file"
echo "See 'sh build.ad <command>' for more information on a specific command."
fi