blob: 9f22eb47f45879dccea4b17a5674a4fb82680c70 [file] [log] [blame]
Kelvin Zhangd64c8832022-04-02 19:56:24 +08001#!/bin/bash
2#
3# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
4#
5# SPDX-License-Identifier: MIT
6#
7
Kelvin Zhang7052f1c2022-09-20 11:11:41 +08008[ -z "$OUTPUT_DIR" ] && OUTPUT_DIR=$PWD/output
9[ ! -d $OUTPUT_DIR ] && mkdir -p $OUTPUT_DIR
10
11[ -z "$BUILD_LOG" ] && BUILD_LOG="$OUTPUT_DIR/build.log"
12
shijie.xionga73e1172022-09-15 14:11:21 +080013# Clear build.log
14cat <<EOF > $BUILD_LOG
15EOF
16
shijie.xiongfe9f21e2022-09-21 10:52:41 +080017TEMP_LOG="$OUTPUT_DIR/temp.log"
18
Kelvin Zhangdfd28382022-04-02 20:32:27 +080019source scripts/publish.sh
Kelvin Zhangd64c8832022-04-02 19:56:24 +080020
shijie.xiong69cbf042022-04-22 13:32:39 +080021function get_new_package_dir() {
22 filelist=$(ls -t output/packages)
23 fileArry=($filelist)
24 CURRENT_PRODUCTS_DIR_NAME=${fileArry[0]}
25 export CURRENT_PRODUCTS_DIR_NAME
26}
27
shijie.xiongfe9f21e2022-09-21 10:52:41 +080028# compile warning check
29function compile_warning_check(){
30 touch $TEMP_LOG
31 CAT_LINE=`sed -n -e '/UBOOT COMPILE START/=' $1`
32 sed -n "1,${CAT_LINE}p" $1 >> $TEMP_LOG
33}
34
shijie.xiongec398682022-09-07 15:57:54 +080035echo "======== Building all packages ========" | tee -a $BUILD_LOG
Kelvin Zhangd64c8832022-04-02 19:56:24 +080036
37source scripts/gen_package_combination.sh
38
39index=0
40while IFS= read -r LINE; do
shijie.xiongec398682022-09-07 15:57:54 +080041 source scripts/pkg_env.sh $index gen_all >> $BUILD_LOG 2>&1
Kelvin Zhangd64c8832022-04-02 19:56:24 +080042 [ "$?" -ne 0 ] && echo "Ignore unsupported combination!" && continue
shijie.xiongec398682022-09-07 15:57:54 +080043 echo -n "$index. Building ... "
shijie.xiong7b690f92024-05-10 17:35:51 +080044 scripts/gen_package.sh >> $BUILD_LOG 2>&1
shijie.xiong69cbf042022-04-22 13:32:39 +080045 get_new_package_dir
shijie.xiongec398682022-09-07 15:57:54 +080046 [ "$?" -ne 0 ] && echo "failed!" && cat $BUILD_LOG && echo -e "\nAborted with errors!\n" && exit 3
shijie.xiongfe9f21e2022-09-21 10:52:41 +080047 compile_warning_check $BUILD_LOG
48 grep -qr "warning: " $TEMP_LOG
49 [ "$?" -eq 0 ] && cat $BUILD_LOG && echo -e "\nAborted with warnings!\n" && rm $TEMP_LOG && exit 1
shijie.xiongec398682022-09-07 15:57:54 +080050 echo "OK."
fugui.zhang89409e12024-07-03 14:10:05 +080051 if [[ "$SUBMIT_TYPE" == "release" || "$SUBMIT_TYPE" == "patch" ]]; then
shijie.xiongec398682022-09-07 15:57:54 +080052 publish_packages >> $BUILD_LOG 2>&1
Kelvin Zhangaa84d882022-04-22 13:38:46 +080053 [ "$?" -ne 0 ] && echo "Failed to publish packages!" && exit 4
Kelvin Zhangd64c8832022-04-02 19:56:24 +080054 fi
55 index=$((index + 1))
56done <"$PACKAGE_COMBINATION"
57
shijie.xiongfe9f21e2022-09-21 10:52:41 +080058rm $TEMP_LOG
59
shijie.xiongec398682022-09-07 15:57:54 +080060[[ "$SUBMIT_TYPE" == "release" ]] && post_publish_packages >> $BUILD_LOG 2>&1
61
62echo -e "======== Done ========\n" | tee -a $BUILD_LOG