blob: de42e61e4b65c0c724a781b52dfe2d49d657b130 [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
17if [ -z "$MANIFEST_URL" ] || [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then
18 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
31
kelvin.zhang5fd25982022-03-04 09:43:01 +080032LAST_MANIFEST_FILE="manifest_last.xml"
33CURRENT_MANIFEST_FILE="manifest.xml"
34DIFF_MANIFEST_FILE="updates.xml"
35
kelvin.zhang01393902022-03-03 20:42:46 +080036#rm -rf $WORK_DIR
37if [ ! -d "$WORK_DIR" ]; then
38 echo -e "\n======== Downloading source code ========"
39 mkdir -p $WORK_DIR
40 cd $WORK_DIR
41 repo init -u ${MANIFEST_URL} -b ${MANIFEST_BRANCH} --repo-url=git://scgit.amlogic.com/tools/repo.git --no-repo-verify
kelvin.zhang5fd25982022-03-04 09:43:01 +080042else
43 echo -e "\n======== Syncing source code ========"
44 cd $WORK_DIR
45 repo forall -c git reset -q --hard origin/$BRANCH_NAME
46 repo manifest -r -o $LAST_MANIFEST_FILE
kelvin.zhang01393902022-03-03 20:42:46 +080047fi
kelvin.zhanga1170fa2022-03-03 20:06:57 +080048
kelvin.zhang5fd25982022-03-04 09:43:01 +080049repo sync -cq -j8
50repo forall -c git reset -q --hard origin/$BRANCH_NAME
51repo manifest -r -o $CURRENT_MANIFEST_FILE
52echo -e "======== Done ========\n"
kelvin.zhang01393902022-03-03 20:42:46 +080053
kelvin.zhang5fd25982022-03-04 09:43:01 +080054if [ -f $LAST_MANIFEST_FILE ] && [ -f $CURRENT_MANIFEST_FILE ]; then
55 comm -23 <(sort $LAST_MANIFEST_FILE) <(sort $CURRENT_MANIFEST_FILE) > $DIFF_MANIFEST_FILE
56
57 if [ -s $DIFF_MANIFEST_FILE ]; then
58 echo "======== Recent Changes ========"
59
60 while IFS= read -r line
61 do
62 keyline=`echo "$line" | grep 'name=.* path='`
63
64 for keyword in $keyline; do
65 [[ $keyword == path=* ]] && repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
66 [[ $keyword == name=* ]] && repo_name=`echo ${keyword#*name=} | sed 's/\"//g'`
67 [[ $keyword == revision=* ]] && repo_version=`echo ${keyword#*revision=} | sed 's/\"//g'`
68 done
69
70 if [ -d "$repo_path" ]; then
71 pushd $repo_path > /dev/null
72 echo -e "\nProject $repo_name"
73 git log $repo_version..HEAD
74 popd > /dev/null
75 fi
76 done < $DIFF_MANIFEST_FILE
77 else
78 echo -e "======== Nothing changed since last build ========"
79 fi
80 rm -f $DIFF_MANIFEST_FILE
81fi
82
83if [ -n "$GERRIT_PROJECT" ] && [ -n "$GERRIT_PATCHSET_NUMBER" ] && [ -n "$GERRIT_CHANGE_NUMBER" ]; then
84 echo -e "\n======== Applying Gerrit patch $GERRIT_CHANGE_NUMBER on Project $GERRIT_PROJECT ========"
85 keyline=`grep "name=\"$GERRIT_PROJECT\"" $CURRENT_MANIFEST_FILE`
86
87 for keyword in $keyline; do
88 if [[ $keyword == path=* ]]; then
89 repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
90 break;
91 fi
92 done
93
94 if [ -d "$repo_path" ]; then
95 pushd $repo_path > /dev/null
96 l2=${GERRIT_CHANGE_NUMBER: -2}
97 git fetch ssh://scgit.amlogic.com:29418/${GERRIT_PROJECT} refs/changes/${l2}/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}
98 git cherry-pick FETCH_HEAD
99 if [ "$?" -ne 0 ]; then
100 echo -e "========= Applying patch failed! =========\n"
101 exit 1
102 fi
103 popd > /dev/null
104 else
105 echo "No such directory! $repo_path"
106 exit 1
107 fi
108 echo -e "======== Done ========\n"
109fi
110
kelvin.zhang2219b412022-03-04 16:44:41 +0800111# Manually cherry pick patches
112./scripts/cherry_pick.sh
113
Kelvin Zhangd64c8832022-04-02 19:56:24 +0800114if [[ "$SUBMIT_TYPE" == "release" ]]; then
115 echo "========= Building all packages ========"
116 ./scripts/build_all_pkg.sh > build.log 2>&1
117 if [ "$?" -eq 0 ]; then
118 echo "======== Done ========"
119 else
120 cat build.log
121 echo -e "\nAborted!"
122 exit 1
123 fi
kelvin.zhang5fd25982022-03-04 09:43:01 +0800124else
Kelvin Zhangd64c8832022-04-02 19:56:24 +0800125 echo "========= Building all projects ========"
126 ./scripts/build_all.sh > build.log 2>&1
127 if [ "$?" -eq 0 ]; then
128 echo "======== Done ========"
129 else
130 cat build.log
131 echo -e "\nAborted!"
132 exit 1
133 fi
kelvin.zhang5fd25982022-03-04 09:43:01 +0800134fi