blob: 77181aedebf7dbbac4923e6b24dd604127b4d17f (
plain)
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
|
#!/bin/bash
TRANSLATION_DIR="../../Translation Editor"
TRANSLATION_SCRIPT="make_translation.py"
# AVAILABLE_LANGUAGES will be calculating according to json files in $TRANSLATION_DIR
AVAILABLE_LANGUAGES=()
BUILD_LANGUAGES=()
AVAILABLE_MODELS=("TS100" "TS80")
BUILD_MODELS=()
usage ()
{
echo "Usage : $(basename "$0") [-l <LANG_CODE>] [-m <TS100|TS80>] [-h]
Parameters :
-l LANG_CODE : Force a specific language (E.g. : EN, FR, NL_BE, ...)
-m MODEL : Force a specific model (E.g. : TS100 or TS80)
-h : Show this help message
INFO : By default, without parameters, the build is for all platforms and all languages" 1>&2
exit 1
}
checkLastCommand ()
{
if [ $? -eq 0 ]
then
echo " [Success]"
echo "*********************************************"
else
forceExit
fi
}
forceExit ()
{
echo " [Error]"
echo "*********************************************"
echo " -- Stop on error --"
exit 1
}
isInArray ()
{
local value="$1" # Save first argument in a variable
shift # Shift all arguments to the left (original $1 gets lost)
local array=("$@") # Rebuild the array with rest of arguments
for item in "${array[@]}"
do
[[ $value == "$item" ]] && return 0
done
return 1
}
while getopts h:l:m: option
do
case "${option}" in
h)
usage
;;
l)
LANGUAGEREQ=${OPTARG}
;;
m)
MODEL=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
echo "*********************************************"
echo " Builder for the"
echo " Alternate Open Source Firmware"
echo " for Miniware TS100 or TS80"
echo " by Ralim"
echo " "
echo "*********************************************"
# Calculate available languages
for f in "$TRANSLATION_DIR"/translation_*.json
do
AVAILABLE_LANGUAGES+=(`echo $f | tr "[:lower:]" "[:upper:]" | sed "s/[^_]*_//" | sed "s/\.JSON//g"`)
done
# Checking requested language
echo "Available languages :"
echo " ${AVAILABLE_LANGUAGES[*]}"
echo "Requested languages :"
if [ -n "$LANGUAGEREQ" ]
then
if isInArray "$LANGUAGEREQ" "${AVAILABLE_LANGUAGES[@]}"
then
echo " $LANGUAGEREQ"
BUILD_LANGUAGES+=("$LANGUAGEREQ")
else
echo " $LANGUAGEREQ doesn't exist"
forceExit
fi
else
echo " [ALL LANGUAGES]"
BUILD_LANGUAGES+=("${AVAILABLE_LANGUAGES[@]}")
fi
echo "*********************************************"
# Checking requested model
echo "Available models :"
echo " ${AVAILABLE_MODELS[*]}"
echo "Requested models :"
if [ -n "$MODEL" ]
then
if isInArray "$MODEL" "${AVAILABLE_MODELS[@]}"
then
echo " $MODEL"
BUILD_MODELS+=("$MODEL")
else
echo " $MODEL doesn't exist"
forceExit
fi
else
echo " [ALL MODELS]"
BUILD_MODELS+=("${AVAILABLE_MODELS[@]}")
fi
echo "*********************************************"
if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ]
then
echo "Generating Translation.cpp"
python3 "$TRANSLATION_DIR/$TRANSLATION_SCRIPT" "$TRANSLATION_DIR"
checkLastCommand
echo "Cleaning previous builds"
rm -rf Hexfile/ >/dev/null
rm -rf Objects/ >/dev/null
make clean >/dev/null
checkLastCommand
for model in "${BUILD_MODELS[@]}"
do
for lang in "${BUILD_LANGUAGES[@]}"
do
echo "Building firmware for $model in $lang"
make -j lang="$lang" model="$model" >/dev/null
checkLastCommand
echo "Cleanup Temp files 1 for $model in $lang"
rm -rf Objects/Core >/dev/null
checkLastCommand
echo "Cleanup Temp files 2 for $model in $lang"
rm -rf Objects/Src >/dev/null
checkLastCommand
done
done
else
echo "Nothing to build. (no model or language specified)"
forceExit
fi
echo " -- Firmwares successfully generated --"
echo "End..."
|