blob: 42b53cd72794c76fc6109d801acb7ae64d08b69e [file] [log] [blame]
Kelvin Zhang14bca5e2021-12-15 19:19:35 +08001#!/bin/bash
yang.li09520922022-01-12 15:51:51 +08002#
yang.liffa60e52022-01-11 14:38:56 +08003# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
yang.li09520922022-01-12 15:51:51 +08004#
yang.liffa60e52022-01-11 14:38:56 +08005# SPDX-License-Identifier: MIT
yang.li09520922022-01-12 15:51:51 +08006#
yang.liffa60e52022-01-11 14:38:56 +08007
xiaohu.huangf0eed9c2024-07-16 17:26:45 +08008#Used filter mode and set the repository list with manual mode,plese use '#' to split
9#For example:source scripts/build_all.sh rtos_sdk/arch/arm64#rtos_sdk/libc#
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080010[ -z "$OUTPUT_DIR" ] && OUTPUT_DIR=$PWD/output
11[ ! -d $OUTPUT_DIR ] && mkdir -p $OUTPUT_DIR
12
13[ -z "$BUILD_LOG" ] && BUILD_LOG="$OUTPUT_DIR/build.log"
xiaohu.huang57285492024-06-26 15:47:07 +080014[ -z "$LAST_BUILD_FAILURE" ] && LAST_BUILD_FAILURE="$OUTPUT_DIR/.last_build_failure"
Kelvin Zhangb56b9502022-09-01 15:18:43 +080015
xiaohu.huangf0eed9c2024-07-16 17:26:45 +080016if [ "$1" == "auto" ]; then
17 CHG_REPO=$(python3 scripts/repositories_changed_filter.py)
18else
19 CHG_REPO="$1"
20fi
21if [ "$CHG_REPO" == "" ]; then
22 use_filter=0
23else
24 echo "Changed repositories:$CHG_REPO"
25 use_filter=1
26fi
27
28failed_numer=0
29
Kelvin Zhang7abf25b2022-09-15 11:18:34 +080030# Clear build.log
31cat <<EOF > $BUILD_LOG
32EOF
33
Kelvin Zhangdfd28382022-04-02 20:32:27 +080034source scripts/publish.sh
Kelvin Zhang14bca5e2021-12-15 19:19:35 +080035
Kelvin Zhangd64c8832022-04-02 19:56:24 +080036if [[ "$SUBMIT_TYPE" == "daily" ]] || [[ "$SUBMIT_TYPE" == "release" ]]; then
Kelvin Zhang7abf25b2022-09-15 11:18:34 +080037 echo "======== Building document ========" | tee -a $BUILD_LOG
Kelvin Zhang1cbf9ed2022-09-13 16:27:50 +080038 make docs >> $BUILD_LOG 2>&1
bin.chene4efbd12023-07-13 19:23:42 +080039 LOCAL_DOC_PATH="$OUTPUT_DIR/docs/arm64/html"
Kelvin Zhang1cbf9ed2022-09-13 16:27:50 +080040 if [ -d $LOCAL_DOC_PATH ]; then
41 pushd $LOCAL_DOC_PATH >/dev/null
42 publish_docoment
43 if [ $? -ne 0 ]; then
44 echo "Failed to update document!"
45 else
46 echo "Document updated."
47 fi
48 popd >/dev/null
Kelvin Zhang23075212022-02-11 18:26:18 +080049 else
Kelvin Zhang1cbf9ed2022-09-13 16:27:50 +080050 echo "$LOCAL_DOC_PATH not exist!"
Kelvin Zhang23075212022-02-11 18:26:18 +080051 fi
Kelvin Zhang1cbf9ed2022-09-13 16:27:50 +080052 echo -e "======== Done ========\n" | tee -a $BUILD_LOG
Kelvin Zhang09786122022-02-11 15:56:08 +080053fi
54
Kelvin Zhangc37221a2022-09-07 15:18:12 +080055echo "======== Building all projects ========" | tee -a $BUILD_LOG
Kelvin Zhang69dc9fb2022-02-18 16:44:04 +080056
Kelvin Zhangb56b9502022-09-01 15:18:43 +080057source scripts/gen_build_combination.sh
Kelvin Zhangd91e47e2022-08-31 20:44:20 +080058
59nr=0
Kelvin Zhang14bca5e2021-12-15 19:19:35 +080060while IFS= read -r LINE; do
Kelvin Zhangd91e47e2022-08-31 20:44:20 +080061 nr=$((nr+1))
Kelvin Zhangc18bac62022-03-14 10:31:57 +080062
63 check_project "$LINE"
64 [ "$?" -ne 0 ] && continue
Kelvin Zhangd91e47e2022-08-31 20:44:20 +080065 source scripts/env.sh $LINE >> $BUILD_LOG 2>&1
66 [ "$?" -ne 0 ] && echo "Ignore unsupported combination! $LINE" && continue
kelvin.zhang05852a72022-01-19 10:30:24 +080067 make distclean
Kelvin Zhang461d2e12022-11-21 20:51:42 +080068 [ "$?" -ne 0 ] && echo "Failed to make distclean! $LINE" && return 2
xiaohu.huangf0eed9c2024-07-16 17:26:45 +080069 if [ "$use_filter" -eq 1 ]; then
70 make config >> $BUILD_LOG 2>&1
71 array=($LINE)
72 python3 scripts/projects_changed_filter.py "$OUTPUT_DIR" "$LINE" "$CHG_REPO"
73 is_need_compile=$?
74 if [ "$is_need_compile" -eq 1 ]; then
75 echo -n -e "$nr. Building $LINE ...\t"
76 make >> $BUILD_LOG 2>&1
77 else
78 echo -n -e "$nr. $LINE is not changed, building none...\t"
79 :
80 fi
81 else
82 echo -n -e "$nr. Building $LINE ...\t"
83 make >> $BUILD_LOG 2>&1
84 fi
Kelvin Zhang461d2e12022-11-21 20:51:42 +080085 [ "$?" -ne 0 ] && echo "failed!" && cat $BUILD_LOG && touch $LAST_BUILD_FAILURE && echo -e "\nAborted with errors!\n" && return 3
Kelvin Zhangb56b9502022-09-01 15:18:43 +080086 grep -qr "warning: " $BUILD_LOG
Kelvin Zhangaf928822022-11-22 17:39:26 +080087 [ "$?" -eq 0 ] && echo "with warnings!" && cat $BUILD_LOG && touch $LAST_BUILD_FAILURE && echo -e "\nAborted with warnings!\n" && return 1
88 echo "OK"
Kelvin Zhangff0a2b32022-11-08 14:17:14 +080089 rm -f $LAST_BUILD_FAILURE
fugui.zhang89409e12024-07-03 14:10:05 +080090 if [[ "$SUBMIT_TYPE" == "daily" || "$SUBMIT_TYPE" == "patch" ]]; then
Kelvin Zhangb56b9502022-09-01 15:18:43 +080091 if [[ "$ARCH" == "arm64" ]] && [[ "$PRODUCT" == "speaker" ]]; then
Kelvin Zhangd91e47e2022-08-31 20:44:20 +080092 make_image >> $BUILD_LOG 2>&1
93 fi
94 publish_images >> $BUILD_LOG 2>&1
Kelvin Zhang461d2e12022-11-21 20:51:42 +080095 [ "$?" -ne 0 ] && echo "Failed to publish images!" && return 4
bin.chen439b9342022-01-18 13:35:42 +080096 fi
shijie.xiongbc5d3672022-04-01 17:52:16 +080097done <"$BUILD_COMBINATION"
98
fugui.zhangb2737ec2024-08-26 18:21:29 +080099[[ "$SUBMIT_TYPE" == "daily" || "$SUBMIT_TYPE" == "patch" ]] && post_publish_images >> $BUILD_LOG 2>&1 && show_download_url
Kelvin Zhangb56b9502022-09-01 15:18:43 +0800100
Kelvin Zhangc37221a2022-09-07 15:18:12 +0800101echo -e "======== Done ========\n" | tee -a $BUILD_LOG