blob: 625da979a389b6d4092e3ca4624c0e23141a6b66 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#!/bin/bash
2
3red='\e[0;31m' # 红色
4green='\e[0;32m' # 绿色
5NC='\e[0m' # 没有颜色
6
7export STAGING_DIR=
8DECONFIG_FILE=
9
10# glibc / musl
11GLIBC_NAME=musl
12ASR_PROJECT_NAME=
13ASR_PROJECT_PATCH=
14
15DIR_BUILD_TARGET=build_dir/target-arm_cortex-a7+neon-vfpv4_"$GLIBC_NAME"_eabi
16DIR_STAGING_TARGET=staging_dir/target-arm_cortex-a7+neon-vfpv4_"$GLIBC_NAME"_eabi
17DIR_BIN=
18
19versionFile='mbtk/include/mbtk_device_info.h'
20version=`cat $versionFile | grep -w 'MBTK_DEVICES_REVISION' | cut -d '"' -f 2 `
21
22usage()
23{
24 echo "Usage : ./build.sh <clean/path>"
25}
26
27function excmd()
28{
29 echo -e "${green}Excmd:${NC} $@ ..."
30# && sleep 1
31 $@
32}
33
34function timediff() {
35# time format:date +"%s.%N", such as 1502758855.907197692
36 start_time=$1
37 end_time=$2
38
39 start_s=${start_time%.*}
40 start_nanos=${start_time#*.}
41 end_s=${end_time%.*}
42 end_nanos=${end_time#*.}
43
44 # end_nanos > start_nanos?
45 # Another way, the time part may start with 0, which means
46 # it will be regarded as oct format, use "10#" to ensure
47 # calculateing with decimal
48
49 if [ "$end_nanos" -lt "$start_nanos" ];then
50 end_s=$(( 10#$end_s - 1 ))
51 end_nanos=$(( 10#$end_nanos + 10**9 ))
52 fi
53
54# get timediff
55 time=$(( 10#$end_s - 10#$start_s )).`printf "%03ds" $(( (10#$end_nanos - 10#$start_nanos)/10**6 ))`
56 time_min=$(((end_s - start_s)/60 + 1))
57 echo -e "${green}*${NC} Spend time: "$time \(\~ ${time_min}min\) ${green}***${NC}
58}
59
60init_check()
61{
62
63 if [ ! -f "config/$DECONFIG_FILE" ]; then
64 echo 'Must exec "init.sh" in the first.'
65 exit 1
66 fi
67
68# if [ ! -f "../pack.sh" ]; then
69# echo 'Must exec "init.sh" in the first.'
70# exit 1
71# fi
72
73}
74
75build_init()
76{
77 init_check
78
79 if [ ! -d "feeds/" ]; then
80 echo "Start build inti..."
81 excmd ./scripts/feeds update -a
82 excmd ./scripts/feeds install -a
83
84 echo "$DECONFIG_FILE"
85
86# if [ "$DECONFIG_FILE" == "defconfig_asr1803p401" ];then
87# excmd make prereq
88# fi
89
90 #excmd make $DECONFIG_FILE
91 fi
92
93 if [ -f .config ];then
94 rm .config
95 fi
96
97 excmd make $DECONFIG_FILE
98}
99
100copy_bin()
101{
102 echo "Start copy bin..."
103# [ -f $MBTK_DIR/out/bin/mbtk_audio_set ] && cp -f $MBTK_DIR/out/bin/mbtk_audio_set $MBTK_DIR/bin
104 [ -f $MBTK_DIR/../out/bin/device_info ] && cp -f $MBTK_DIR/../out/bin/device_info $MBTK_DIR/bin
105}
106
107copy_lib()
108{
109 echo "Start copy lib..."
110 [ -f $MBTK_DIR/../out/lib/liblynq_lib.so ] && cp -f $MBTK_DIR/../out/lib/liblynq_lib.so $MBTK_DIR/lib
111# [ -f $MBTK_DIR/../out/lib/libql_lib.so.* ] && cp -f $MBTK_DIR/../out/lib/libql_lib.so.* $MBTK_DIR/lib
112
113 ls $MBTK_DIR/../out/lib/libql_lib.so.*
114 if [ $? -eq 0 ];then
115 cp -f $MBTK_DIR/../out/lib/libql_lib.so.* $MBTK_DIR/lib
116 fi
117
118}
119
120ln_lib()
121{
122 PWD_TEMP=`pwd`
123
124 cd $ROOTFS_DIR/lib
125 if [ -f liblynq_lib.so ];then
126 [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so
127 [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so
128 [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so
129 [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so
130 [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so
131 [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so
132 [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so
133 [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so
134 [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so
135 [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so
136 [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so
137 [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so
138 [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so
139 [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so
140 [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so
141 [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so
142 fi
143
144 cd $PWD_TEMP
145}
146
147build_mbtk()
148{
149 copy_toolchain
150 make -C mbtk/ || exit 1
151
152 ROOTFS_DIR=$DIR_BUILD_TARGET/root-mmp
153 MBTK_DIR=mbtk/rootfs
154
155 if [ "$SEC_SUPPORT" == "Y" ];then
156 # copy_lib
157 if [ -d $ROOTFS_DIR ];then
158 echo "Start build optee_test..."
159 [ -d mbtk/optee_test ] && make clean -C mbtk/optee_test && make -C mbtk/optee_test
160 echo "Should copy to mbtk/rootfs and build.sh if necessary."
161 fi
162 else
163 if [ -f staging_dir/host/bin/sstrip ];then
164 STRIP_FILE=./staging_dir/host/bin/sstrip
165 else
166 STRIP_FILE=./host/linux64/bin/sstrip
167 fi
168
169 if [ ! -d $ROOTFS_DIR ];then
170 mkdir -p $ROOTFS_DIR
171 fi
172
173 excmd cp -rf $MBTK_DIR/* $ROOTFS_DIR/
174
175 CUR_PWD=`pwd`
176 cd $ROOTFS_DIR/etc/rc.d
177 if [ ! -f S15mbtk_boot_normal -a -f ../init.d/mbtk_boot_normal ];then
178 ln -s ../init.d/mbtk_boot_normal S15mbtk_boot_normal
179 fi
180 if [ ! -f S98mbtk_boot_last -a -f ../init.d/mbtk_boot_last ];then
181 ln -s ../init.d/mbtk_boot_last S98mbtk_boot_last
182 fi
183 if [ ! -f S13mbtk_logd -a -f ../init.d/mbtk_logd ];then
184 ln -s ../init.d/mbtk_logd S13mbtk_logd
185 fi
186
187 cd $CUR_PWD
188
189 if [ -d $MBTK_DIR/lib_tmp ];then
190 rm -rf $MBTK_DIR/lib_tmp
191 fi
192
193 if [ -d $MBTK_DIR/bin_tmp ];then
194 rm -rf $MBTK_DIR/bin_tmp
195 fi
196
197 # copy_lib
198
199 copy_bin
200
201 cp -r $MBTK_DIR/lib $MBTK_DIR/lib_tmp
202 cp -r $MBTK_DIR/bin $MBTK_DIR/bin_tmp
203
204 CROSS="arm-openwrt-linux-uclibcgnueabi-" NO_RENAME=1 ; NM="arm-openwrt-linux-uclibcgnueabi-nm" STRIP="$STRIP_FILE" STRIP_KMOD="./scripts/strip-kmod.sh" ./scripts/rstrip.sh $MBTK_DIR/lib_tmp
205 CROSS="arm-openwrt-linux-uclibcgnueabi-" NO_RENAME=1 ; NM="arm-openwrt-linux-uclibcgnueabi-nm" STRIP="$STRIP_FILE" STRIP_KMOD="./scripts/strip-kmod.sh" ./scripts/rstrip.sh $MBTK_DIR/bin_tmp
206
207 cp $MBTK_DIR/lib_tmp/* $ROOTFS_DIR/lib
208 cp $MBTK_DIR/bin_tmp/* $ROOTFS_DIR/bin
209 rm -rf $MBTK_DIR/lib_tmp
210 rm -rf $MBTK_DIR/bin_tmp
211
212 [ -f $ROOTFS_DIR/etc/init.d/wpad ] && rm $ROOTFS_DIR/etc/init.d/wpad
213 ln_lib
214 fi
215}
216
217
218build_mbtk_clean()
219{
220 cd mbtk
221 make clean
222 cd ..
223}
224
225build_rootfs()
226{
227 if [ -f ./staging_dir/host/bin/mksquashfs4 ];then
228 EXEC=./staging_dir/host/bin/mksquashfs4
229 else
230 EXEC=./host/linux64/bin/mksquashfs4
231 fi
232
233 $EXEC $DIR_BUILD_TARGET/root-mmp $DIR_BUILD_TARGET/linux-mmp_"$ASR_PROJECT_NAME"/root.squashfs -nopad -noappend -root-owned -comp xz -Xpreset 8 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -Xbcj arm -b 64k -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1' -processors 1
234 excmd dd if=$DIR_BUILD_TARGET/linux-mmp_"$ASR_PROJECT_NAME"/root.squashfs of=$DIR_BIN/swd/openwrt-mmp-"$ASR_PROJECT_NAME"-root.squashfs
235}
236
237copy_toolchain()
238{
239 # 1806
240 if [ ! -d mbtk/toolchain ];then
241 if [ ! -d owtoolchain/linux64 ];then
242 "Build all in the first."
243 exit 1
244 fi
245 echo "Start Copy Build Toolchain..."
246 mkdir -p mbtk/toolchain
247 cp -r owtoolchain/linux64 mbtk/toolchain/
248 cp -r mbtk/toolchain/linux64/include/* mbtk/toolchain/linux64/usr/include/
249 cp -r $DIR_STAGING_TARGET/usr/* mbtk/toolchain/linux64/usr/
250 cp -r mbtk/toolchain/linux64/usr/include/* mbtk/toolchain/linux64/include/
251 cp -drf $DIR_BUILD_TARGET/audio/obj/olibs/* mbtk/toolchain/linux64/usr/lib/
252 cp -r marvell/services/audio_if/include/* mbtk/toolchain/linux64/include/
b.liuf7f2d6d2025-05-20 15:10:18 +0800253 cp -r mbtk/rootfs/usr/lib/* mbtk/toolchain/linux64/usr/lib/
b.liude66b442025-05-15 15:17:48 +0800254
255 cp -r marvell/services/ril/include/* mbtk/toolchain/linux64/include/
256 cp -r marvell/services/audio/include/* mbtk/toolchain/linux64/include/
257 cp -r marvell/services/audio/include/stub/* mbtk/toolchain/linux64/include/
258 cp -r marvell/services/audio/tinyalsa/include/* mbtk/toolchain/linux64/include/
259 cp -r marvell/services/audio/libaudio-apu/*.h mbtk/toolchain/linux64/include/
260 cp -r marvell/lte-telephony/apps/aud_sw/vcm_ipc/*.h mbtk/toolchain/linux64/include/
b.liud440f9f2025-04-18 10:44:31 +0800261 fi
262
263 if [ "$SEC_SUPPORT" == "Y" ];then
264 if [ -f mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -a ! -d mbtk/toolchain/gcc-arm-arm-none-linux-gnueabihf ];then
265 echo "Dec file : gcc-arm-none-linux-gnueabihf.tar.gz to mbtk/toolchain."
266 tar zxf mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -C mbtk/toolchain
267 fi
268 fi
269}
270
271build_oem()
272{
273 excmd mkdir -p $DIR_BUILD_TARGET/root-mmp/NVM/oem_data
274 excmd rm -rf $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs
275 excmd mkdir -p $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs
276 excmd cp -fpR target/linux/mmp/$ASR_PROJECT_NAME/oem_fs/* $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs/
277 excmd staging_dir/host/bin/mkfs.ubifs -m 2048 -e 126976 -c 156 -F --space-fixup --compr=zlib -o $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubifs -d $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs
278 excmd mkdir -p $DIR_BIN/swd/
279 if [ -e ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg ]; then
280 excmd cp -fpR ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg;
281 else
282 excmd cp -fpR ./target/linux/mmp/image/ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg;
283 fi
284 excmd cd $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME;
285 excmd sed -i 's/vol_size=.*KiB/vol_size=19344KiB/g' ubinize-oem.cfg; ../../../staging_dir/host/bin/ubinize -m 2048 -p 131072 -s 2048 -o ../../../$DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubi ubinize-oem.cfg
286 excmd cd ../../..
287 excmd cp -fpR $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_data.ubi $DIR_BIN/swd/openwrt-mmp-$ASR_PROJECT_NAME-oem_data.ubi
288}
289
290build_busybox()
291{
292 if [ -d mbtk/busybox-1.36.1 ];then
293 CUR_PWD=`pwd`
294 cd mbtk/busybox-1.36.1
295 [ -f busybox.config ] && cp busybox.config .config
296 make install
297
298 if [ ! -d ../rootfs/bin ];then
299 mkdir ../rootfs/bin
300 fi
301
302 if [ -f _install/bin/busybox ];
303 then
304 cp -f _install/bin/busybox ../rootfs/bin
305 fi
306
307 cd $CUR_PWD
308 fi
309}
310
311build()
312{
313 # 1806
314# if [ "$DECONFIG_FILE" == "defconfig_asr1806p301" ];then
315 excmd make $1/{clean,compile} V=99 2>&1 | tee build.log
316# else
317# excmd make $1/{clean,compile,install} V=99 2>&1 | tee build.log
318# fi
319}
320
321mbtk_version_update()
322{
323 # SDK
324 if [ -f mbtk/mbtk_version ];then
325 PATCH_INDEX=`cat mbtk/mbtk_version | grep PATCH_INDEX | cut -d '=' -f 2`
326 if [ -z $PATCH_INDEX ];then
327 PATCH_INDEX=0
328 fi
329 if [ $PATCH_INDEX -lt 10 ];then
330 PATCH_INDEX=00"$PATCH_INDEX"
331 else
332 if [ $PATCH_INDEX -lt 100 ];then
333 PATCH_INDEX=0"$PATCH_INDEX"
334 fi
335 fi
336
337 # T108v05.02b01_YX.00
338 MBTK_VERSION=${version#*:= }
339 MBTK_VERSION_1=`echo $MBTK_VERSION | cut -d '.' -f 1`
340 MBTK_VERSION_2=`echo $MBTK_VERSION | cut -d '.' -f 2`
341 MBTK_VERSION_3=`echo $MBTK_VERSION | cut -d '.' -f 3`
342 if [[ $MBTK_VERSION_3 == *_* ]];then # 有 '_'
343 MBTK_VERSION_3_1=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 1`
344 MBTK_VERSION_3_2=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 2`
345
346 MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2."$PATCH_INDEX"_$MBTK_VERSION_3_2
347 else
348 MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2.$PATCH_INDEX
349 fi
350
351 echo "Version : $MBTK_VERSION"
352 sed -i "s/$version/$MBTK_VERSION/" $versionFile
353 fi
354}
355
356build_menuconfig()
357{
358 build_init
359 make menuconfig
360
361 cp -f .config config/$DECONFIG_FILE
362}
363
364config_init()
365{
366 PROJECT=`cat build_version | grep -w 'PROJECT' | cut -d '=' -f 2`
367# PYTHON_SUPPORT=`cat build_version | grep -w 'PYTHON_SUPPORT' | cut -d '=' -f 2`
368 SEC_SUPPORT=`cat build_version | grep -w 'SEC_SUPPORT' | cut -d '=' -f 2`
369 echo "PROJECT = $PROJECT"
370# echo "PYTHON_SUPPORT = $PYTHON_SUPPORT"
371 echo "SEC_SUPPORT = $SEC_SUPPORT"
372 if [ "$PROJECT" == "L901CD-L" ];then
373 ASR_PROJECT_NAME=asr1903
374 ASR_PROJECT_PATCH=p501
375 elif [ "$PROJECT" == "T108" -o "$PROJECT" == "T108-2" -o "$PROJECT" == "L508_X6" ];then
376 ASR_PROJECT_NAME=asr1806
377 ASR_PROJECT_PATCH=p301
378 else
379 ASR_PROJECT_NAME=asr1803
380 ASR_PROJECT_PATCH=p401
381 fi
382
383 DECONFIG_FILE=defconfig_$ASR_PROJECT_NAME$ASR_PROJECT_PATCH
384
385 if [ "$SEC_SUPPORT" == "Y" ];then
386 if [ "$GLIBC_NAME" == "glibc" ];then
387 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec_glibc
388 else
389 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec
390 fi
391 sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\CONFIG_PACKAGE_mbtk-rootfs=y" config/$DECONFIG_FILE
392 else
393 if [ "$GLIBC_NAME" == "glibc" ];then
394 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"_glibc
395 else
396 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"
397 fi
398 sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\# CONFIG_PACKAGE_mbtk-rootfs is not set" config/$DECONFIG_FILE
399 fi
400}
b.liude66b442025-05-15 15:17:48 +0800401
b.liub17525e2025-05-14 17:22:29 +0800402toolchain_generate()
403{
404 MBTK_TOOLCHAIN_DIR=mbtk_toolchain
405
406 if [ ! -d mbtk/toolchain/linux64 ];then
407 echo "Build in the first."
408 exit 1
409 fi
410
411 [ -d $MBTK_TOOLCHAIN_DIR ] && rm -rf $MBTK_TOOLCHAIN_DIR
412 [ ! -d $MBTK_TOOLCHAIN_DIR ] && mkdir -p $MBTK_TOOLCHAIN_DIR
413
414 echo "Start copy toolchain..."
415 cp -r mbtk/toolchain/linux64 $MBTK_TOOLCHAIN_DIR/toolchain
416
417 echo "Start copy mbtk header files and libs..."
418 mkdir $MBTK_TOOLCHAIN_DIR/mbtk
419 cp -r mbtk/include $MBTK_TOOLCHAIN_DIR/mbtk
420 cp -r mbtk/rootfs/lib $MBTK_TOOLCHAIN_DIR/mbtk
421
422 echo "Start copy mbtk config files..."
423 cp -r mbtk/mbtk_toolchain_config/* $MBTK_TOOLCHAIN_DIR
424
425 echo "Delete unnecessary files..."
426 # rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/usr
b.liuf7f2d6d2025-05-20 15:10:18 +0800427 [ -d $MBTK_TOOLCHAIN_DIR/toolchain/initial ] && rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/initial
428 [ -f $MBTK_TOOLCHAIN_DIR/toolchain/include.zip ] && rm $MBTK_TOOLCHAIN_DIR/toolchain/include.zip
b.liub17525e2025-05-14 17:22:29 +0800429
430 echo "Start packaging toolchain..."
431 tar -zcf mbtk_toolchain.tar.gz mbtk_toolchain/
432
433 echo "Toolchain generate complete."
434}
b.liud440f9f2025-04-18 10:44:31 +0800435
436################################################################
437### Start ########
438################################################################
439if [ ! -f build_version ];then
440 echo "No found file: build_version"
441 exit 1
442else
443 config_init
444fi
445
446start=$(date +"%s.%N")
447starttime=`date +"%Y-%m-%d %H:%M:%S"`
448
449ROOTFS_DIR="mbtk/rootfs"
450ln_lib
451
452if [ -n "$1" ] ;then #有参数
453 if [ ! -d "feeds/" -a "$1" != "menuconfig" ]; then
454 echo "Must make all in the first."
455 exit 1
456 fi
457
458 case "$1" in
459 clean)
460 # Can not remove toolchain.
461 # [ -d mbtk/toolchain ] && rm -rf mbtk/toolchain
462 excmd make distclean
463 ;;
464 kernel)
465 build target/linux
466 ;;
467 oem)
468 if [ "$SEC_SUPPORT" == "Y" ];then
469 echo "No support."
470 else
471 build_oem
472 fi
473 ;;
474 obm)
475 excmd make package/boot/obm-mmp/{clean,compile} V=99 2>&1 | tee build.log
476 excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND.bin $DIR_BIN/swd
477 excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND_ProductBuild.bin $DIR_BIN/swd
478 ;;
479 uboot)
480 excmd make package/boot/uboot-mmp/{clean,compile} V=99 2>&1 | tee build.log
481 excmd cp -f $DIR_BIN/openwrt-mmp-"$ASR_PROJECT_NAME"-u-boot.bin $DIR_BIN/swd
482 ;;
483 ffmpeg)
484 build package/feeds/packages/ffmpeg
485 ;;
486 mbtk-rootfs)
487 if [ "$SEC_SUPPORT" == "Y" ];then
488 excmd make package/$1/{clean,compile} V=99 2>&1 | tee build.log
489 else
490 echo "No support."
491 fi
492 ;;
493 openssl)
494 excmd make package/libs/$1/{clean,compile} V=99 2>&1 | tee build.log
495 ;;
496 mbtk)
497 build_mbtk
498 ;;
499 mbtk_clean)
500 build_mbtk_clean
501 ;;
502 rootfs)
503 if [ "$SEC_SUPPORT" == "Y" ];then
504 echo "No support."
505 else
506 build_mbtk
507 build_rootfs
508 fi
509 ;;
510 lte)
511 build package/network/services/lte-telephony
512 ;;
513 audio)
514 build package/services/audio_if
515 ;;
516 fstools)
517 build package/system/fstools
518 ;;
519 ril)
520 build package/services/ril
521 ;;
522 gnss)
523 build package/services/gnss
524 ;;
525 libprop2uci)
526 build package/libs/libprop2uci
527 ;;
528 con_mgr)
529 build package/services/con_mgr
530 ;;
531 ecall)
532 build package/services/ecall_daemon
533 ;;
534 adbd)
535 build package/utils/adbd
536 ;;
537 menuconfig)
538 build_menuconfig
539 ;;
540 openssl)
541 excmd make package/libs/openssl/{clean,compile,install} V=99 2>&1 | tee build.log
542 ;;
543 busybox)
544 build_busybox
545 ;;
b.liub17525e2025-05-14 17:22:29 +0800546 toolchain)
547 toolchain_generate
548 ;;
549 optee)
550 build package/services/optee_app
551 ;;
b.liud440f9f2025-04-18 10:44:31 +0800552 *)
553 SUB_DIR=`find package/ -type d -name "$1" | sed -n '1,1p'`
554 if [ x$SUB_DIR = x ]
555 then
556 echo -e "${red}==Have No module: $1==${NC}"
557 exit 1
558 fi
559 echo -e "Build: ${green}${1}${NC} ${red}${SUB_DIR}${NC}"
560 build $SUB_DIR
561 ;;
562 esac
563else # 全编
564
565 cp $versionFile $versionFile.backup
566 # Change version
567 mbtk_version_update
568
569 # Start build.
570 excmd build_init
571 #if [ -d mbtk/toolchain ];then
572 # build_mbtk
573 #fi
574 # OPT_SEC=y
575 if [ "$SEC_SUPPORT" == "Y" ];then
576 # build mbtk lib in the first.
577 build_mbtk
578
579 excmd make OPT_SEC=y -j8 V=99 2>&1 | tee build.log
580 else
581 excmd make -j8 V=99 2>&1 | tee build.log
582 fi
583
584 mv $versionFile.backup $versionFile
585
586 tail -n1 build.log | grep Error
587 if [ $? -eq "0" ]; then
588 echo "********************Build Fail*****************"
589 else
590 if [ "$SEC_SUPPORT" == "Y" ];then
591 echo "********************Build Success*****************"
592 else
593 echo "********************Build Success*****************"
594 copy_toolchain
595 build_busybox
596 build_mbtk
597 build_rootfs
598 fi
599
600 # ./pack.sh all
601 fi
602fi
603excmd date >> build.log
604end=$(date +"%s.%N")
605endtime=`date +"%Y-%m-%d %H:%M:%S"`
606
607echo -e "${green}***********************************${NC}"
608echo -e "${green}* ${NC}Start time: "$starttime ${green}*${NC}
609echo -e "${green}* ${NC}End time: "$endtime ${green}*${NC}
610timediff $start $end
611echo -e "${green}***********************************${NC}"