forked from mozilla-b2g/B2G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·87 lines (79 loc) · 2.63 KB
/
build.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
#!/bin/bash
# We want to figure out if we need to re-run the firmware
# extraction routine. The first time we run build.sh, we
# store the hash of important files. On subsequent runs,
# we check if the hash is the same as the previous run.
# If the hashes differ, we use a per-device script to redo
# the firmware extraction
function configure_device() {
hash_file="$OUT/firmware.hash"
# Make sure that our assumption that device codenames are unique
# across vendors is true
if [ $(ls -d device/*/$DEVICE 2> /dev/null | wc -l) -gt 1 ] ; then
echo $DEVICE is ambiguous \"$(ls -d device/*/$DEVICE 2> /dev/null)\"
return 1
fi
# Select which blob setup script to use, if any. We currently
# assume that $DEVICE maps to the filesystem location, which is true
# for the devices we support now (oct 2012) that do not require blobs.
# The emulator uses a $DEVICE of 'emulator' but its device/ directory
# uses the 'goldfish' name.
if [ -f device/*/$DEVICE/download-blobs.sh ] ; then
important_files="device/*/$DEVICE/download-blobs.sh"
script="cd device/*/$DEVICE && ./download-blobs.sh"
elif [ -f device/*/$DEVICE/extract-files.sh ] ; then
important_files="device/*/$DEVICE/extract-files.sh"
script="cd device/*/$DEVICE && ./extract-files.sh"
else
important_files=
script=
fi
# If we have files that are important to look at, we need
# to check if they've changed
if [ -n "$important_files" ] ; then
new_hash=$(cat $important_files | openssl sha1)
if [ -f "$hash_file" ] ; then
old_hash=$(cat "$hash_file")
fi
if [ "$old_hash" != "$new_hash" ] ; then
echo Blob setup script has changed, re-running &&
sh -c "$script" &&
mkdir -p "$(dirname "$hash_file")" &&
echo "$new_hash" > "$hash_file"
fi
else
rm -f $hash_file
fi
return $?
}
unset CDPATH
. setup.sh &&
if [ -f patches/patch.sh ] ; then
. patches/patch.sh
fi &&
configure_device &&
time nice -n19 make $MAKE_FLAGS $@
ret=$?
echo -ne \\a
if [ $ret -ne 0 ]; then
echo
echo \> Build failed\! \<
echo
echo Build with \|./build.sh -j1\| for better messages
echo If all else fails, use \|rm -rf objdir-gecko\| to clobber gecko and \|rm -rf out\| to clobber everything else.
else
if echo $DEVICE | grep generic > /dev/null ; then
echo Run \|./run-emulator.sh\| to start the emulator
exit 0
fi
case "$1" in
"gecko")
echo Run \|./flash.sh gecko\| to update gecko
;;
*)
echo Run \|./flash.sh\| to flash all partitions of your device
;;
esac
exit 0
fi
exit $ret