-
Notifications
You must be signed in to change notification settings - Fork 0
/
.globalscripts.sh
223 lines (179 loc) · 5.01 KB
/
.globalscripts.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
#
if [[ "$K221_BE_GLOBALCONFIG" != "true" ]]; then
echo "You need to run BullsEye global config script first."
exit 1
fi
# link library
link_library() {
local USAGE="\
Usage: link_library [-L <filename>] [-l <var>]\n\
-L: Specify the library file path to export.\n\
-l: Specify the variable name to export the library file path. File path would be appended."
local OPT_LDLIB=
local OPT_LDLIB_VAR=
local OPTIND=
while getopts 'hL:l:' OPT; do
case $OPT in
h) echo -e "$USAGE"; return 0;;
L) OPT_LDLIB="$OPTARG";;
l) OPT_LDLIB_VAR="$OPTARG";;
?) echo -e "$USAGE"; return 1;;
esac
done
#
if [[ -n "$OPT_LDLIB_VAR" ]]; then
if [[ -n "$OPT_LDLIB" ]]; then
eval "$OPT_LDLIB_VAR=\"$OPT_LDLIB \$$OPT_LDLIB_VAR\""
else
echo "Please specify the library file by parameter \"-L\" while using \"-l\""
return 1
fi
fi
return 0
}
# make library
make_library () {
local USAGE="\
Usage: make_library [-t <directory>] [-c] [-j <count>] [-L <filename>] [-l <var>]\n\
-t: Specify the task directory to make.\n\
-c: Clean the task directory before make.\n\
-j: Specify the number of jobs to run in parallel.\n\
-L: Specify the library file path to export.\n\
-l: Specify the variable name to export the library file path. File path would be appended."
local MAKE_DIRECTORY=
local MAKE_CLEAN=
local MAKE_JOB_COUNT=1
local OPT_LDLIB=
local OPT_LDLIB_VAR=
local OPTIND=
while getopts 'ht:cj:L:l:' OPT; do
case $OPT in
h) echo -e "$USAGE"; return 0;;
t) MAKE_DIRECTORY="$OPTARG";;
c) MAKE_CLEAN="true";;
j) MAKE_JOB_COUNT="$OPTARG";;
L) OPT_LDLIB="-L $OPTARG";;
l) OPT_LDLIB_VAR="-l $OPTARG";;
?) echo -e "$USAGE"; return 1;;
esac
done
# check necessary arguments
if [[ ! -n "$MAKE_DIRECTORY" ]]; then
echo "Please specify the task directory by parameter \"-t\""
return 1
fi
# make & clean
echo -e "\033[33m[library make] $MAKE_DIRECTORY\033[0m"
test -d "$MAKE_DIRECTORY"
if [ $? -ne 0 ]; then
echo "Cannot enter make path: $MAKE_DIRECTORY"
echo -e "\033[1;31mFailed at make task.\033[0m"
return 1
fi
if [[ "$MAKE_CLEAN" == "true" ]]; then
eval "make -C \"$MAKE_DIRECTORY\" clean"
if [ $? -ne 0 ]; then
echo "Cannot perform make clean at: $MAKE_DIRECTORY"
echo -e "\033[1;31mFailed at make task.\033[0m"
return 1
fi
fi
eval "make -C \"$MAKE_DIRECTORY\" -j $MAKE_JOB_COUNT"
if [ $? -ne 0 ]; then
echo -e "\033[1;31mFailed at make task.\033[0m"
return 1
fi
# post make
link_library $OPT_LDLIB $OPT_LDLIB_VAR
#
return 0
}
# include library
include_library () {
local USAGE="\
Usage: include_library [-I <directory>] [-i <var>]\n\
-I: Specify the library include path to export.\n\
-i: Specify the variable name to export the library include path. GNU CFLAGS would be appended."
local OPT_INCLUDE=
local OPT_INCLUDE_VAR=
local OPTIND=
while getopts 'hI:i:' OPT; do
case $OPT in
h) echo -e "$USAGE"; return 0;;
I) OPT_INCLUDE="$OPTARG";;
i) OPT_INCLUDE_VAR="$OPTARG";;
?) echo -e "$USAGE"; return 1;;
esac
done
#
if [[ -n "$OPT_INCLUDE_VAR" ]]; then
if [[ -n "$OPT_INCLUDE" ]]; then
eval "$OPT_INCLUDE_VAR=\"\$$OPT_INCLUDE_VAR -I$OPT_INCLUDE\""
else
echo "Please specify the library include path by parameter \"-I\" while using \"-i\""
return 1
fi
fi
return 0
}
#
link_library_yasio () {
link_library $* -L "$K221_YASIO_LD_LIBRARY"
return $?
}
#
link_library_jasse2_la32 () {
link_library $* -L "$K221_BE_JASSE2_LA32_LD_LIBRARY"
return $?
}
#
link_library_nscscc2023_la32_soc () {
link_library $* -L "$K221_BE_N1_SOC_LA32_LD_LIBRARY"
return $?
}
#
make_library_yasio () {
make_library $* -t "$K221_YASIO_MAIN" -L "$K221_YASIO_LD_LIBRARY"
return $?
}
#
make_library_jasse2_la32 () {
make_library $* -t "$K221_BE_JASSE2_LA32_MAIN" -L "$K221_BE_JASSE2_LA32_LD_LIBRARY"
return $?
}
#
make_library_nscscc2023_la32_soc () {
make_library $* -t "$K221_BE_N1_SOC_LA32_MAIN" -L "$K221_BE_N1_SOC_LA32_LD_LIBRARY"
return $?
}
#
build_library_yasio () {
make_library_yasio $*
return $?
}
#
build_library_jasse2_la32 () {
make_library_jasse2_la32 $*
return $?
}
#
build_library_nscscc2023_la32_soc () {
make_library_nscscc2023_la32_soc $*
return $?
}
#
include_library_yasio () {
include_library $* -I "$K221_BE_ROOT"
include_library $* -I "$K221_YASIO_ROOT"
return $?
}
#
include_library_jasse2_la32 () {
include_library $* -I "$K221_BE_JASSE2_LA32_ROOT"
return $?
}
#
include_library_nscscc2023_la32_soc () {
include_library $* -I "$K221_BE_N1_SOC_LA32_ROOT"
return $?
}