blob: 24dcb80488876a3a286c35803bfd51a1420c9bdc [file] [log] [blame]
kelvin.zhanga1170fa2022-03-03 20:06:57 +08001#!/bin/bash
2#
3# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
4#
5# SPDX-License-Identifier: MIT
6#
7
Kelvin Zhange1cb8732022-03-22 11:39:49 +08008source /etc/profile.d/TOOLSENV.sh
9
kelvin.zhanga1170fa2022-03-03 20:06:57 +080010export PATH=/opt/cmake-3.18.4-Linux-x86_64/bin/:$PATH
11export PATH=/proj/coverity/cov-analysis/bin/:$PATH
12export LM_LICENSE_FILE=/mnt/fileroot/jenkins/Xplorer_key.txt:$LM_LICENSE_FILE
13export PATH=/opt/xtensa/XtDevTools/install/tools/RG-2018.9-linux/XtensaTools/bin:$PATH
14export XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/builds/RG-2018.9-linux/Amlogic_v0/config
15export XTENSA_CORE=Amlogic_v0
16
Kelvin Zhangcf643422022-11-22 15:28:31 +080017if [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then
kelvin.zhanga1170fa2022-03-03 20:06:57 +080018 echo "NULL params!"
19 exit 1
20fi
21
Kelvin Zhangd64c8832022-04-02 19:56:24 +080022if [ "$SUBMIT_TYPE" = "daily" -o "$SUBMIT_TYPE" = "release" ];then
kelvin.zhanga1170fa2022-03-03 20:06:57 +080023 BUILDCHECK_BASE_PATH=/mnt/fileroot/autobuild/workdir/workspace/RTOS/RTOS_SDK/patchbuild
kelvin.zhang01393902022-03-03 20:42:46 +080024elif [ "$SUBMIT_TYPE" = "every" ];then
kelvin.zhanga1170fa2022-03-03 20:06:57 +080025 BUILDCHECK_BASE_PATH=/mnt/fileroot/jenkins/build-check
kelvin.zhanga1170fa2022-03-03 20:06:57 +080026fi
27
28MATCH_PATTERN="projects/"
Kelvin Zhange1cb8732022-03-22 11:39:49 +080029BRANCH=${MANIFEST_BRANCH#*${MATCH_PATTERN}}
kelvin.zhanga1170fa2022-03-03 20:06:57 +080030WORK_DIR=$BUILDCHECK_BASE_PATH/$PROJECT_NAME/$BRANCH
Kelvin Zhangb2630702022-04-20 11:22:32 +080031OUTPUT_DIR=$WORK_DIR/output
kelvin.zhanga1170fa2022-03-03 20:06:57 +080032
Kelvin Zhang4982b0b2022-08-31 19:15:24 +080033LAST_MANIFEST="$OUTPUT_DIR/last_manifest.xml"
34CURRENT_MANIFEST="$OUTPUT_DIR/curr_manifest.xml"
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080035DIFF_MANIFEST="$OUTPUT_DIR/diff_manifest.xml"
Kelvin Zhangff0a2b32022-11-08 14:17:14 +080036LAST_BUILD_FAILURE="$OUTPUT_DIR/.last_build_failure"
kelvin.zhang5fd25982022-03-04 09:43:01 +080037
Kelvin Zhang461d2e12022-11-21 20:51:42 +080038GERRIT_SERVER="scgit.amlogic.com"
39GERRIT_PORT="29418"
40GERRIT_QUERY_RESULT="$OUTPUT_DIR/topic_changes.txt"
41
Kelvin Zhangb2630702022-04-20 11:22:32 +080042if [ -n "$EXCLUDE_REPOS" ]; then
43 echo "Exclude repos:"
44 echo "$EXCLUDE_REPOS"
45 while IFS= read -r line
46 do
47 [ -n "$REPO_SYNC_IPATTERN" ] && REPO_SYNC_IPATTERN+="|"
48 REPO_SYNC_IPATTERN+="$line"
49 done <<< "$EXCLUDE_REPOS"
50fi
51
52[ "$FRESH_DOWNLOAD" = "yes" ] && rm -rf $WORK_DIR
53
kelvin.zhang01393902022-03-03 20:42:46 +080054if [ ! -d "$WORK_DIR" ]; then
55 echo -e "\n======== Downloading source code ========"
56 mkdir -p $WORK_DIR
Kelvin Zhangb2630702022-04-20 11:22:32 +080057 mkdir -p $OUTPUT_DIR
kelvin.zhang01393902022-03-03 20:42:46 +080058 cd $WORK_DIR
Kelvin Zhang461d2e12022-11-21 20:51:42 +080059 repo init -u ssh://${GERRIT_SERVER}:${GERRIT_PORT}/${PROJECT_NAME} -b ${MANIFEST_BRANCH} --repo-url=git://${GERRIT_SERVER}/tools/repo.git --no-repo-verify
kelvin.zhang5fd25982022-03-04 09:43:01 +080060else
61 echo -e "\n======== Syncing source code ========"
62 cd $WORK_DIR
Kelvin Zhang442c9152022-05-30 17:29:53 +080063 if [ -n "$REPO_SYNC_IPATTERN" ]; then
64 repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME
65 else
66 repo forall -c git reset -q --hard origin/$BRANCH_NAME
67 fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080068 repo manifest -r -o $LAST_MANIFEST
kelvin.zhang01393902022-03-03 20:42:46 +080069fi
kelvin.zhanga1170fa2022-03-03 20:06:57 +080070
Kelvin Zhang81eb1b12022-06-09 14:35:18 +080071repo sync -cq -j8 --prune
Kelvin Zhang442c9152022-05-30 17:29:53 +080072[ "$?" -ne 0 ] && cd - && echo "Sync error! will do fresh download next time" && exit 1
73if [ -n "$REPO_SYNC_IPATTERN" ]; then
74 repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME
75else
76 repo forall -c git reset -q --hard origin/$BRANCH_NAME
77fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080078repo manifest -r -o $CURRENT_MANIFEST
kelvin.zhang5fd25982022-03-04 09:43:01 +080079echo -e "======== Done ========\n"
kelvin.zhang01393902022-03-03 20:42:46 +080080
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080081if [ -f $LAST_MANIFEST ] && [ -f $CURRENT_MANIFEST ]; then
82 comm -23 <(sort $LAST_MANIFEST) <(sort $CURRENT_MANIFEST) > $DIFF_MANIFEST
kelvin.zhang5fd25982022-03-04 09:43:01 +080083
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080084 if [ -s $DIFF_MANIFEST ]; then
kelvin.zhang5fd25982022-03-04 09:43:01 +080085 echo "======== Recent Changes ========"
86
87 while IFS= read -r line
88 do
89 keyline=`echo "$line" | grep 'name=.* path='`
90
91 for keyword in $keyline; do
92 [[ $keyword == path=* ]] && repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
93 [[ $keyword == name=* ]] && repo_name=`echo ${keyword#*name=} | sed 's/\"//g'`
94 [[ $keyword == revision=* ]] && repo_version=`echo ${keyword#*revision=} | sed 's/\"//g'`
95 done
96
97 if [ -d "$repo_path" ]; then
98 pushd $repo_path > /dev/null
99 echo -e "\nProject $repo_name"
100 git log $repo_version..HEAD
101 popd > /dev/null
102 fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +0800103 done < $DIFF_MANIFEST
Kelvin Zhange98bd542022-09-07 15:43:58 +0800104 echo -e "================\n"
kelvin.zhang5fd25982022-03-04 09:43:01 +0800105 else
Kelvin Zhange98bd542022-09-07 15:43:58 +0800106 echo -e "======== Nothing changed since last build ========\n"
kelvin.zhang5fd25982022-03-04 09:43:01 +0800107 fi
Kelvin Zhang81eb1b12022-06-09 14:35:18 +0800108fi
109
Kelvin Zhang461d2e12022-11-21 20:51:42 +0800110source scripts/gerrit_review.sh
Kelvin Zhangc07a8db2022-09-06 21:06:31 +0800111# Cherry pick patches
Kelvin Zhang0f582792022-08-31 18:52:20 +0800112source scripts/cherry_pick.sh
Kelvin Zhanga04b9cb2022-11-29 15:05:27 +0800113[ "$?" -ne 0 ] && gerrit_review_for_gerrit_topic FAIL && exit 1
Kelvin Zhangcf643422022-11-22 15:28:31 +0800114gerrit_review_for_gerrit_topic Start
kelvin.zhang2219b412022-03-04 16:44:41 +0800115
Kelvin Zhang7052f1c2022-09-20 11:11:41 +0800116# Generate Jenkins trigger
Kelvin Zhang3568dbd2022-11-08 15:18:53 +0800117[ "$SUBMIT_TYPE" = "daily" ] && source scripts/gen_jenkins_trigger.sh
Kelvin Zhang7052f1c2022-09-20 11:11:41 +0800118
shijie.xiongec398682022-09-07 15:57:54 +0800119if [[ "$MANIFEST_BRANCH" == "$BRANCH_NAME" ]]; then
120 source scripts/build_all_pkg.sh
kelvin.zhang5fd25982022-03-04 09:43:01 +0800121else
Kelvin Zhang727c3e32022-08-31 20:57:37 +0800122 source scripts/build_all.sh
kelvin.zhang5fd25982022-03-04 09:43:01 +0800123fi
Kelvin Zhang461d2e12022-11-21 20:51:42 +0800124
Kelvin Zhanga04b9cb2022-11-29 15:05:27 +0800125[ "$?" -ne 0 ] && gerrit_review_for_gerrit_topic FAIL && exit 1
Kelvin Zhang461d2e12022-11-21 20:51:42 +0800126gerrit_review_for_gerrit_topic SUCCESS