blob: 8e423480095e29cbc8977e4e4e19be314541827d [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/
253 fi
254
255 if [ "$SEC_SUPPORT" == "Y" ];then
256 if [ -f mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -a ! -d mbtk/toolchain/gcc-arm-arm-none-linux-gnueabihf ];then
257 echo "Dec file : gcc-arm-none-linux-gnueabihf.tar.gz to mbtk/toolchain."
258 tar zxf mbtk/gcc-arm-none-linux-gnueabihf.tar.gz -C mbtk/toolchain
259 fi
260 fi
261}
262
263build_oem()
264{
265 excmd mkdir -p $DIR_BUILD_TARGET/root-mmp/NVM/oem_data
266 excmd rm -rf $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs
267 excmd mkdir -p $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs
268 excmd cp -fpR target/linux/mmp/$ASR_PROJECT_NAME/oem_fs/* $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/oem_fs/
269 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
270 excmd mkdir -p $DIR_BIN/swd/
271 if [ -e ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg ]; then
272 excmd cp -fpR ./$ASR_PROJECT_NAME$ASR_PROJECT_PATCH-ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg;
273 else
274 excmd cp -fpR ./target/linux/mmp/image/ubinize-oem.cfg $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME/ubinize-oem.cfg;
275 fi
276 excmd cd $DIR_BUILD_TARGET/linux-mmp_$ASR_PROJECT_NAME;
277 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
278 excmd cd ../../..
279 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
280}
281
282build_busybox()
283{
284 if [ -d mbtk/busybox-1.36.1 ];then
285 CUR_PWD=`pwd`
286 cd mbtk/busybox-1.36.1
287 [ -f busybox.config ] && cp busybox.config .config
288 make install
289
290 if [ ! -d ../rootfs/bin ];then
291 mkdir ../rootfs/bin
292 fi
293
294 if [ -f _install/bin/busybox ];
295 then
296 cp -f _install/bin/busybox ../rootfs/bin
297 fi
298
299 cd $CUR_PWD
300 fi
301}
302
303build()
304{
305 # 1806
306# if [ "$DECONFIG_FILE" == "defconfig_asr1806p301" ];then
307 excmd make $1/{clean,compile} V=99 2>&1 | tee build.log
308# else
309# excmd make $1/{clean,compile,install} V=99 2>&1 | tee build.log
310# fi
311}
312
313mbtk_version_update()
314{
315 # SDK
316 if [ -f mbtk/mbtk_version ];then
317 PATCH_INDEX=`cat mbtk/mbtk_version | grep PATCH_INDEX | cut -d '=' -f 2`
318 if [ -z $PATCH_INDEX ];then
319 PATCH_INDEX=0
320 fi
321 if [ $PATCH_INDEX -lt 10 ];then
322 PATCH_INDEX=00"$PATCH_INDEX"
323 else
324 if [ $PATCH_INDEX -lt 100 ];then
325 PATCH_INDEX=0"$PATCH_INDEX"
326 fi
327 fi
328
329 # T108v05.02b01_YX.00
330 MBTK_VERSION=${version#*:= }
331 MBTK_VERSION_1=`echo $MBTK_VERSION | cut -d '.' -f 1`
332 MBTK_VERSION_2=`echo $MBTK_VERSION | cut -d '.' -f 2`
333 MBTK_VERSION_3=`echo $MBTK_VERSION | cut -d '.' -f 3`
334 if [[ $MBTK_VERSION_3 == *_* ]];then # 有 '_'
335 MBTK_VERSION_3_1=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 1`
336 MBTK_VERSION_3_2=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 2`
337
338 MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2."$PATCH_INDEX"_$MBTK_VERSION_3_2
339 else
340 MBTK_VERSION=$MBTK_VERSION_1.$MBTK_VERSION_2.$PATCH_INDEX
341 fi
342
343 echo "Version : $MBTK_VERSION"
344 sed -i "s/$version/$MBTK_VERSION/" $versionFile
345 fi
346}
347
348build_menuconfig()
349{
350 build_init
351 make menuconfig
352
353 cp -f .config config/$DECONFIG_FILE
354}
355
356config_init()
357{
358 PROJECT=`cat build_version | grep -w 'PROJECT' | cut -d '=' -f 2`
359# PYTHON_SUPPORT=`cat build_version | grep -w 'PYTHON_SUPPORT' | cut -d '=' -f 2`
360 SEC_SUPPORT=`cat build_version | grep -w 'SEC_SUPPORT' | cut -d '=' -f 2`
361 echo "PROJECT = $PROJECT"
362# echo "PYTHON_SUPPORT = $PYTHON_SUPPORT"
363 echo "SEC_SUPPORT = $SEC_SUPPORT"
364 if [ "$PROJECT" == "L901CD-L" ];then
365 ASR_PROJECT_NAME=asr1903
366 ASR_PROJECT_PATCH=p501
367 elif [ "$PROJECT" == "T108" -o "$PROJECT" == "T108-2" -o "$PROJECT" == "L508_X6" ];then
368 ASR_PROJECT_NAME=asr1806
369 ASR_PROJECT_PATCH=p301
370 else
371 ASR_PROJECT_NAME=asr1803
372 ASR_PROJECT_PATCH=p401
373 fi
374
375 DECONFIG_FILE=defconfig_$ASR_PROJECT_NAME$ASR_PROJECT_PATCH
376
377 if [ "$SEC_SUPPORT" == "Y" ];then
378 if [ "$GLIBC_NAME" == "glibc" ];then
379 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec_glibc
380 else
381 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"sec
382 fi
383 sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\CONFIG_PACKAGE_mbtk-rootfs=y" config/$DECONFIG_FILE
384 else
385 if [ "$GLIBC_NAME" == "glibc" ];then
386 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"_glibc
387 else
388 DIR_BIN=bin/"$ASR_PROJECT_NAME$ASR_PROJECT_PATCH"
389 fi
390 sed -i "/.*CONFIG_PACKAGE_mbtk-rootfs/c\# CONFIG_PACKAGE_mbtk-rootfs is not set" config/$DECONFIG_FILE
391 fi
392}
b.liub17525e2025-05-14 17:22:29 +0800393toolchain_generate()
394{
395 MBTK_TOOLCHAIN_DIR=mbtk_toolchain
396
397 if [ ! -d mbtk/toolchain/linux64 ];then
398 echo "Build in the first."
399 exit 1
400 fi
401
402 [ -d $MBTK_TOOLCHAIN_DIR ] && rm -rf $MBTK_TOOLCHAIN_DIR
403 [ ! -d $MBTK_TOOLCHAIN_DIR ] && mkdir -p $MBTK_TOOLCHAIN_DIR
404
405 echo "Start copy toolchain..."
406 cp -r mbtk/toolchain/linux64 $MBTK_TOOLCHAIN_DIR/toolchain
407
408 echo "Start copy mbtk header files and libs..."
409 mkdir $MBTK_TOOLCHAIN_DIR/mbtk
410 cp -r mbtk/include $MBTK_TOOLCHAIN_DIR/mbtk
411 cp -r mbtk/rootfs/lib $MBTK_TOOLCHAIN_DIR/mbtk
412
413 echo "Start copy mbtk config files..."
414 cp -r mbtk/mbtk_toolchain_config/* $MBTK_TOOLCHAIN_DIR
415
416 echo "Delete unnecessary files..."
417 # rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/usr
418 rm -rf $MBTK_TOOLCHAIN_DIR/toolchain/initial
419 rm $MBTK_TOOLCHAIN_DIR/toolchain/include.zip
420
421 echo "Start packaging toolchain..."
422 tar -zcf mbtk_toolchain.tar.gz mbtk_toolchain/
423
424 echo "Toolchain generate complete."
425}
b.liud440f9f2025-04-18 10:44:31 +0800426
427################################################################
428### Start ########
429################################################################
430if [ ! -f build_version ];then
431 echo "No found file: build_version"
432 exit 1
433else
434 config_init
435fi
436
437start=$(date +"%s.%N")
438starttime=`date +"%Y-%m-%d %H:%M:%S"`
439
440ROOTFS_DIR="mbtk/rootfs"
441ln_lib
442
443if [ -n "$1" ] ;then #有参数
444 if [ ! -d "feeds/" -a "$1" != "menuconfig" ]; then
445 echo "Must make all in the first."
446 exit 1
447 fi
448
449 case "$1" in
450 clean)
451 # Can not remove toolchain.
452 # [ -d mbtk/toolchain ] && rm -rf mbtk/toolchain
453 excmd make distclean
454 ;;
455 kernel)
456 build target/linux
457 ;;
458 oem)
459 if [ "$SEC_SUPPORT" == "Y" ];then
460 echo "No support."
461 else
462 build_oem
463 fi
464 ;;
465 obm)
466 excmd make package/boot/obm-mmp/{clean,compile} V=99 2>&1 | tee build.log
467 excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND.bin $DIR_BIN/swd
468 excmd cp -f $DIR_BIN/"$ASR_PROJECT_NAME"_TLoader_QSPINAND_ProductBuild.bin $DIR_BIN/swd
469 ;;
470 uboot)
471 excmd make package/boot/uboot-mmp/{clean,compile} V=99 2>&1 | tee build.log
472 excmd cp -f $DIR_BIN/openwrt-mmp-"$ASR_PROJECT_NAME"-u-boot.bin $DIR_BIN/swd
473 ;;
474 ffmpeg)
475 build package/feeds/packages/ffmpeg
476 ;;
477 mbtk-rootfs)
478 if [ "$SEC_SUPPORT" == "Y" ];then
479 excmd make package/$1/{clean,compile} V=99 2>&1 | tee build.log
480 else
481 echo "No support."
482 fi
483 ;;
484 openssl)
485 excmd make package/libs/$1/{clean,compile} V=99 2>&1 | tee build.log
486 ;;
487 mbtk)
488 build_mbtk
489 ;;
490 mbtk_clean)
491 build_mbtk_clean
492 ;;
493 rootfs)
494 if [ "$SEC_SUPPORT" == "Y" ];then
495 echo "No support."
496 else
497 build_mbtk
498 build_rootfs
499 fi
500 ;;
501 lte)
502 build package/network/services/lte-telephony
503 ;;
504 audio)
505 build package/services/audio_if
506 ;;
507 fstools)
508 build package/system/fstools
509 ;;
510 ril)
511 build package/services/ril
512 ;;
513 gnss)
514 build package/services/gnss
515 ;;
516 libprop2uci)
517 build package/libs/libprop2uci
518 ;;
519 con_mgr)
520 build package/services/con_mgr
521 ;;
522 ecall)
523 build package/services/ecall_daemon
524 ;;
525 adbd)
526 build package/utils/adbd
527 ;;
528 menuconfig)
529 build_menuconfig
530 ;;
531 openssl)
532 excmd make package/libs/openssl/{clean,compile,install} V=99 2>&1 | tee build.log
533 ;;
534 busybox)
535 build_busybox
536 ;;
b.liub17525e2025-05-14 17:22:29 +0800537 toolchain)
538 toolchain_generate
539 ;;
540 optee)
541 build package/services/optee_app
542 ;;
b.liud440f9f2025-04-18 10:44:31 +0800543 *)
544 SUB_DIR=`find package/ -type d -name "$1" | sed -n '1,1p'`
545 if [ x$SUB_DIR = x ]
546 then
547 echo -e "${red}==Have No module: $1==${NC}"
548 exit 1
549 fi
550 echo -e "Build: ${green}${1}${NC} ${red}${SUB_DIR}${NC}"
551 build $SUB_DIR
552 ;;
553 esac
554else # 全编
555
556 cp $versionFile $versionFile.backup
557 # Change version
558 mbtk_version_update
559
560 # Start build.
561 excmd build_init
562 #if [ -d mbtk/toolchain ];then
563 # build_mbtk
564 #fi
565 # OPT_SEC=y
566 if [ "$SEC_SUPPORT" == "Y" ];then
567 # build mbtk lib in the first.
568 build_mbtk
569
570 excmd make OPT_SEC=y -j8 V=99 2>&1 | tee build.log
571 else
572 excmd make -j8 V=99 2>&1 | tee build.log
573 fi
574
575 mv $versionFile.backup $versionFile
576
577 tail -n1 build.log | grep Error
578 if [ $? -eq "0" ]; then
579 echo "********************Build Fail*****************"
580 else
581 if [ "$SEC_SUPPORT" == "Y" ];then
582 echo "********************Build Success*****************"
583 else
584 echo "********************Build Success*****************"
585 copy_toolchain
586 build_busybox
587 build_mbtk
588 build_rootfs
589 fi
590
591 # ./pack.sh all
592 fi
593fi
594excmd date >> build.log
595end=$(date +"%s.%N")
596endtime=`date +"%Y-%m-%d %H:%M:%S"`
597
598echo -e "${green}***********************************${NC}"
599echo -e "${green}* ${NC}Start time: "$starttime ${green}*${NC}
600echo -e "${green}* ${NC}End time: "$endtime ${green}*${NC}
601timediff $start $end
602echo -e "${green}***********************************${NC}"