-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_DDK.sh
executable file
·329 lines (273 loc) · 9.77 KB
/
build_DDK.sh
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
#!/bin/bash
# Texas Instruments Incorporated
#-------------------------------------------------------------------------------
# Texas Instruments OMAP(TM) Platform Software
# (c) Copyright 2011 Texas Instruments Incorporated. All Rights Reserved.
# (c) Copyright 2002-2011 by Imagination Technologies Ltd. All Rights Reserved.
# Use of this software is controlled by the terms and conditions found
# in the license agreement under which this software has been supplied.
#-------------------------------------------------------------------------------
# Script to build the TI GFX Android DDK package
function ECHO {
echo -e $1
}
# Extract an absolute path from a directory passed as an argument
function getabspath() {
_d=`dirname $1`
readlink -f $_d
}
function help {
cat <<EOF
This script automatically builds and installs the DDK.
BEFORE YOU START:
Initialize the Android build environment
cd "YOUR_ANDROID_SRC" ; . build/envsetup.sh; lunch
GPU options:
540 SGX540 (OMAP4430/OMAP4460)
544sc SGX544 single core (OMAP4470)
544 SGX544 multi core (OMAP5)
Main options:
-g <gpu> Build binaries for <gpu> see GPU options
--build Build the binaries for the DDK
--install Install the binaries built by the DDK
--binstall Does both --build and --install
--help Show this help
<type> is one of the following:
release Build the binaries for the DDK in release mode
debug Build the binaries for the DDK in debug mode
timing Build the binaries for the DDK in timing mode
Optional build arguments (only one at a time):
clean Clean built object files
clobber Remove built binaries (doesn't clean up install)
V=1 Increase verbosity level at build time
The following variables are mandatory:
KERNELDIR Source location of kernel
The following variables are optional:
DISCIMAGE Installation location for the DDK binaries. Overrides
Android distribution binary location:
device/ti/proprietary-open/omap4/sgx/
EOF
}
function usage {
ECHO "Usage: build_ddk [-g 540|544sc|544] --build <type> [clean | clobber]"
ECHO "Usage: build_ddk --install BUILD_TYPE"
ECHO "Usage: build_ddk --bench [all | <benchmark> ]"
ECHO "Usage: build_ddk --help"
}
# needs ARG_OPERATION
# sets ARG_PRODUCT
function get_args_androidbuild {
if [ "$ARG_OPERATION" = "--build" ] || \
[ "$ARG_OPERATION" = "--binstall" ] || \
[ "$ARG_OPERATION" = "--install" ] ; then
if [ -z "$ANDROID_PRODUCT_OUT" ] || \
[ -z "$OUT" ] || \
[ -z "$ANDROID_BUILD_TOP" ]; then
ECHO "ERROR: Initialize the Android build environment"
ECHO "cd \"YOUR_ANDROID_SRC\" ; . build/envsetup.sh; lunch"
exit;
else
ARG_PRODUCT=`basename $ANDROID_PRODUCT_OUT`
fi
fi
}
# needs ARG_BUILD_TYPE
function get_args_buildtype {
# Validate build / install modes
if [[ -n "$ARG_BUILD_TYPE" ]] ; then
declare -A mode_types=([debug]="1" [release]="1" [timing]="1")
if [[ -z "${mode_types[$ARG_BUILD_TYPE]}" ]] ; then
ECHO "ERROR: Unknown build type: $ARG_BUILD_TYPE"
exit
fi
fi
}
# Set up global args (ARG_name) depending on operation to be performed
function args_getenv {
ARG_GPU=540
while [ $# -ne 0 ] ; do
if [ "$1" = "--build" ] || \
[ "$1" = "--binstall" ] || \
[ "$1" = "--install" ] ; then
if (( $# < 2)) ; then
ECHO "ERROR: Too few args"; usage; exit;
fi
ARG_OPERATION=$1
get_args_androidbuild
ARG_BUILD_TYPE=$2
get_args_buildtype
ARG_OPTIONAL=${@:3}
break;
elif [ "$1" = "--bench" ] ; then
ARG_BMARK=$2
if [ -z "$DISCIMAGE" ] ; then
ECHO "ERROR: Need to set path to installation directory, i.e.:"
ECHO "export DISCIMAGE=<install location>"
exit 1
fi
ARG_OPERATION=$1
if (( $# < 2 )) ; then
ECHO "ERROR: Too few args"; usage; exit;
fi
break;
elif [ "$1" = "--help" ] ; then
help
usage
exit
elif [ "$1" = "-g" ] ; then
shift;
ARG_GPU=$1
case "$ARG_GPU" in
540)
;;
544sc)
;;
544)
;;
*)
ECHO "ERROR: Unknown GPU type"; usage; exit;
esac
else
ECHO "ERROR: Unknown arg"
usage
exit
fi
shift
done
if [ "$ARG_GPU" = "540" ] ; then
ARG_BUILDPLATDIR=omap4430_android
ARG_BINLOC_PREFIX=binary2_540_120
ARG_KM_SUFFIX=_sgx540_120
elif [ "$ARG_GPU" = "544sc" ] ; then
ARG_BUILDPLATDIR=omap4430_android
ARG_BINLOC_PREFIX=binary2_544_112
ARG_KM_SUFFIX=_sgx544_112
elif [ "$ARG_GPU" = "544" ] ; then
ARG_BUILDPLATDIR=omap5430_android
ARG_BINLOC_PREFIX=binary2_544_tbd
ARG_KM_SUFFIX=_sgx544_105
fi
}
# Needs ANDROID_BUILD_TOP, G_GFXDDKDIR, ARG_BUILDPLATDIR
# Sets BUILD_DIR
function build_getenv {
# Variables to update by this function
BUILD_DIR=
BUILD_DIR_KM=
# Assume args_getenv validated we are in an Android build env
export ANDROID_ROOT="$ANDROID_BUILD_TOP"
# We know at this point we have a valid ARG_PRODUCT
BUILD_DIR=${G_GFXDDKDIR}/eurasia/eurasiacon/build/linux2/$ARG_BUILDPLATDIR
BUILD_DIR_KM=${G_GFXDDKDIR}/eurasia_km/eurasiacon/build/linux2/$ARG_BUILDPLATDIR
}
# Needs G_GFXDDKDIR, ARG_BUILDPLATDIR
# Sets INSTALL_DIR
function install_getenv {
if [ -z "$DISCIMAGE" ] ; then
export DISCIMAGE="$OUT"
fi
INSTALL_DIR=${G_GFXDDKDIR}/eurasia/eurasiacon/build/linux2/$ARG_BUILDPLATDIR
}
function do_build {
BUILD_DIR=
build_getenv
ECHO "-- Building PVR-UM for SGX$ARG_GPU--"
export CROSS_COMPILE=arm-eabi-
# The DDK makefiles will guess the value of EURASIAROOT on the basis
# of the location of the build directory we cd to
pushd $BUILD_DIR
# We could leave OUT as set and the DDK makefiles will install binaries
# on the basis of this location. For now rely on the install step to
# put stuff in the right place in the FS
# local _OUT=$OUT
# unset OUT ### keep OUT value by [email protected] (see commit message)
make TARGET_PRODUCT="$ARG_PRODUCT" BUILD=$ARG_BUILD_TYPE TARGET_SGX=$ARG_GPU $ARG_OPTIONAL
# OUT=$_OUT
popd
ECHO "-- Building PVR-KM for SGX$ARG_GPU--"
pushd $BUILD_DIR_KM
# local _OUT=$OUT
# unset OUT
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TARGET_PRODUCT="$ARG_PRODUCT" BUILD=$ARG_BUILD_TYPE TARGET_SGX=$ARG_GPU $ARG_OPTIONAL
# OUT=$_OUT
popd
}
function do_install {
install_getenv
ECHO "-- Installing PVR-UM to $DISCIMAGE --"
pushd $INSTALL_DIR
local _OUT=$OUT
unset OUT
make TARGET_PRODUCT="$ARG_PRODUCT" BUILD=$ARG_BUILD_TYPE TARGET_SGX=$ARG_GPU install
OUT=$_OUT
popd
ECHO "-- Installing PVR-KM to $DISCIMAGE --"
_TARGET_KM=${G_GFXDDKDIR}/eurasia_km/eurasiacon/${ARG_BINLOC_PREFIX}_${ARG_BUILDPLATDIR}_${ARG_BUILD_TYPE}/target
for _m in omaplfb${ARG_KM_SUFFIX}.ko pvrsrvkm${ARG_KM_SUFFIX}.ko
do
_MOD_LOC="/system/lib/modules"
if [ ! -d "${DISCIMAGE}${_MOD_LOC}" ] ; then
mkdir -p "${DISCIMAGE}${_MOD_LOC}"
fi
_cp_cmd="cp ${_TARGET_KM}/${_m} ${DISCIMAGE}${_MOD_LOC}"
echo "${_m} -> ${_MOD_LOC}/${_m}"
eval "$_cp_cmd"
done
ECHO "\nInstallation complete!"
}
# ##############################################################################
# MAIN - This is where the script starts executing
# ##############################################################################
# We will assume that this script is invoked from the top of the DDK
G_GFXDDKDIR=`getabspath $0`
# Get ARG_OPERATION, ARG_* parameters appropriate for the operation
args_getenv $@
case "$ARG_OPERATION" in
# ##############################################################################
--build)
do_build
;;
# ##############################################################################
--install)
do_install
;;
# ##############################################################################
--binstall)
do_build
do_install
;;
# ##############################################################################
--bench)
declare -A inst_src
inst_src[GridMark3]="${G_GFXDDKDIR}/Perfapps/OGLES*/GridMark3/AndroidARMV7/ReleaseRaw/*"
inst_src[VillageMark]="${G_GFXDDKDIR}/Perfapps/OGLES*/VillageMark/AndroidARMV7/ReleaseRaw/*"
inst_src[TMark]="${G_GFXDDKDIR}/Perfapps/OGLES*/TMark/AndroidARMV7/ReleaseRaw/*"
inst_src[FableMark]="${G_GFXDDKDIR}/Perfapps/OGLES2/FableMark/AndroidARMV7/ReleaseRaw/*"
inst_src[UIMark]="${G_GFXDDKDIR}/Perfapps/MISC/UIMark/PVR2D_SGX/*"
if [[ $ARG_BMARK != "all" && -z "${inst_src[$ARG_BMARK]}" ]] ; then
ECHO "ERROR: Unknown benchmark specified"
exit 1
fi
ECHO "= Installing $ARG_BMARK benchmarks ="
if [ $ARG_BMARK = "all" ] ; then
_failcp=0
for k in "${!inst_src[@]}"
do
_cp_cmd="cp ${inst_src[$k]} ${DISCIMAGE}/system/vendor/bin"
echo DOING "$_cp_cmd"
if [[ $_failcp = "0" ]] ; then
eval "$_cp_cmd"
[[ $? != 0 ]] && break
fi
done
else
_cp_cmd="cp ${inst_src[$ARG_BMARK]} ${DISCIMAGE}/system/vendor/bin"
echo DOING "$_cp_cmd"
eval "$_cp_cmd"
fi
;;
*)
usage
;;
# ##############################################################################
esac