blob: 2f4863ede63faff4edf38ef2927241ced28c47db [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
Kelvin Zhangdfd28382022-04-02 20:32:27 +080017source scripts/publish.sh
Kelvin Zhangd64c8832022-04-02 19:56:24 +080018
shijie.xiong69cbf042022-04-22 13:32:39 +080019function get_new_package_dir() {
20 filelist=$(ls -t output/packages)
21 fileArry=($filelist)
22 CURRENT_PRODUCTS_DIR_NAME=${fileArry[0]}
23 export CURRENT_PRODUCTS_DIR_NAME
24}
25
shijie.xiongec398682022-09-07 15:57:54 +080026echo "======== Building all packages ========" | tee -a $BUILD_LOG
Kelvin Zhangd64c8832022-04-02 19:56:24 +080027
28source scripts/gen_package_combination.sh
29
30index=0
31while IFS= read -r LINE; do
shijie.xiongec398682022-09-07 15:57:54 +080032 source scripts/pkg_env.sh $index gen_all >> $BUILD_LOG 2>&1
Kelvin Zhangd64c8832022-04-02 19:56:24 +080033 [ "$?" -ne 0 ] && echo "Ignore unsupported combination!" && continue
shijie.xiongec398682022-09-07 15:57:54 +080034 echo -n "$index. Building ... "
35 make package >> $BUILD_LOG 2>&1
shijie.xiong69cbf042022-04-22 13:32:39 +080036 get_new_package_dir
shijie.xiongec398682022-09-07 15:57:54 +080037 [ "$?" -ne 0 ] && echo "failed!" && cat $BUILD_LOG && echo -e "\nAborted with errors!\n" && exit 3
38 grep -qr "warning: " $BUILD_LOG
39 [ "$?" -eq 0 ] && cat $BUILD_LOG && echo -e "\nAborted with warnings!\n" && exit 1
40 echo "OK."
Kelvin Zhangd64c8832022-04-02 19:56:24 +080041 if [[ "$SUBMIT_TYPE" == "release" ]]; then
shijie.xiongec398682022-09-07 15:57:54 +080042 publish_packages >> $BUILD_LOG 2>&1
Kelvin Zhangaa84d882022-04-22 13:38:46 +080043 [ "$?" -ne 0 ] && echo "Failed to publish packages!" && exit 4
Kelvin Zhangd64c8832022-04-02 19:56:24 +080044 fi
45 index=$((index + 1))
46done <"$PACKAGE_COMBINATION"
47
shijie.xiongec398682022-09-07 15:57:54 +080048[[ "$SUBMIT_TYPE" == "release" ]] && post_publish_packages >> $BUILD_LOG 2>&1
49
50echo -e "======== Done ========\n" | tee -a $BUILD_LOG