kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: MIT |
| 6 | # |
| 7 | |
Kelvin Zhang | e1cb873 | 2022-03-22 11:39:49 +0800 | [diff] [blame] | 8 | source /etc/profile.d/TOOLSENV.sh |
| 9 | |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 10 | export PATH=/opt/cmake-3.18.4-Linux-x86_64/bin/:$PATH |
| 11 | export PATH=/proj/coverity/cov-analysis/bin/:$PATH |
| 12 | export LM_LICENSE_FILE=/mnt/fileroot/jenkins/Xplorer_key.txt:$LM_LICENSE_FILE |
| 13 | export PATH=/opt/xtensa/XtDevTools/install/tools/RG-2018.9-linux/XtensaTools/bin:$PATH |
| 14 | export XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/builds/RG-2018.9-linux/Amlogic_v0/config |
| 15 | export XTENSA_CORE=Amlogic_v0 |
| 16 | |
Kelvin Zhang | cf64342 | 2022-11-22 15:28:31 +0800 | [diff] [blame] | 17 | if [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 18 | echo "NULL params!" |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
fugui.zhang | 89409e1 | 2024-07-03 14:10:05 +0800 | [diff] [blame] | 22 | if [ "$SUBMIT_TYPE" = "daily" ];then |
| 23 | BUILDCHECK_BASE_PATH=/mnt/fileroot/autobuild/workdir/workspace/RTOS/RTOS_SDK/dailybuild |
| 24 | elif [ "$SUBMIT_TYPE" = "release" ];then |
| 25 | BUILDCHECK_BASE_PATH=/mnt/fileroot/autobuild/workdir/workspace/RTOS/RTOS_SDK/dailybuild_release |
| 26 | elif [ "$SUBMIT_TYPE" = "patch" ];then |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 27 | BUILDCHECK_BASE_PATH=/mnt/fileroot/autobuild/workdir/workspace/RTOS/RTOS_SDK/patchbuild |
kelvin.zhang | 0139390 | 2022-03-03 20:42:46 +0800 | [diff] [blame] | 28 | elif [ "$SUBMIT_TYPE" = "every" ];then |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 29 | BUILDCHECK_BASE_PATH=/mnt/fileroot/jenkins/build-check |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 30 | fi |
| 31 | |
| 32 | MATCH_PATTERN="projects/" |
Kelvin Zhang | e1cb873 | 2022-03-22 11:39:49 +0800 | [diff] [blame] | 33 | BRANCH=${MANIFEST_BRANCH#*${MATCH_PATTERN}} |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 34 | WORK_DIR=$BUILDCHECK_BASE_PATH/$PROJECT_NAME/$BRANCH |
Kelvin Zhang | b263070 | 2022-04-20 11:22:32 +0800 | [diff] [blame] | 35 | OUTPUT_DIR=$WORK_DIR/output |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 36 | |
Kelvin Zhang | fdf8ff0 | 2023-04-21 21:23:30 +0800 | [diff] [blame] | 37 | MANIFEST="$OUTPUT_DIR/manifest.xml" |
Kelvin Zhang | 4982b0b | 2022-08-31 19:15:24 +0800 | [diff] [blame] | 38 | LAST_MANIFEST="$OUTPUT_DIR/last_manifest.xml" |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 39 | DIFF_MANIFEST="$OUTPUT_DIR/diff_manifest.xml" |
Kelvin Zhang | ff0a2b3 | 2022-11-08 14:17:14 +0800 | [diff] [blame] | 40 | LAST_BUILD_FAILURE="$OUTPUT_DIR/.last_build_failure" |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 41 | |
Kelvin Zhang | 461d2e1 | 2022-11-21 20:51:42 +0800 | [diff] [blame] | 42 | GERRIT_SERVER="scgit.amlogic.com" |
| 43 | GERRIT_PORT="29418" |
| 44 | GERRIT_QUERY_RESULT="$OUTPUT_DIR/topic_changes.txt" |
| 45 | |
Kelvin Zhang | b263070 | 2022-04-20 11:22:32 +0800 | [diff] [blame] | 46 | if [ -n "$EXCLUDE_REPOS" ]; then |
| 47 | echo "Exclude repos:" |
| 48 | echo "$EXCLUDE_REPOS" |
| 49 | while IFS= read -r line |
| 50 | do |
| 51 | [ -n "$REPO_SYNC_IPATTERN" ] && REPO_SYNC_IPATTERN+="|" |
| 52 | REPO_SYNC_IPATTERN+="$line" |
| 53 | done <<< "$EXCLUDE_REPOS" |
| 54 | fi |
| 55 | |
| 56 | [ "$FRESH_DOWNLOAD" = "yes" ] && rm -rf $WORK_DIR |
| 57 | |
kelvin.zhang | 0139390 | 2022-03-03 20:42:46 +0800 | [diff] [blame] | 58 | if [ ! -d "$WORK_DIR" ]; then |
| 59 | echo -e "\n======== Downloading source code ========" |
| 60 | mkdir -p $WORK_DIR |
Kelvin Zhang | b263070 | 2022-04-20 11:22:32 +0800 | [diff] [blame] | 61 | mkdir -p $OUTPUT_DIR |
kelvin.zhang | 0139390 | 2022-03-03 20:42:46 +0800 | [diff] [blame] | 62 | cd $WORK_DIR |
Kelvin Zhang | 461d2e1 | 2022-11-21 20:51:42 +0800 | [diff] [blame] | 63 | 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.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 64 | else |
| 65 | echo -e "\n======== Syncing source code ========" |
| 66 | cd $WORK_DIR |
Kelvin Zhang | 442c915 | 2022-05-30 17:29:53 +0800 | [diff] [blame] | 67 | if [ -n "$REPO_SYNC_IPATTERN" ]; then |
| 68 | repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME |
| 69 | else |
| 70 | repo forall -c git reset -q --hard origin/$BRANCH_NAME |
| 71 | fi |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 72 | repo manifest -r -o $LAST_MANIFEST |
kelvin.zhang | 0139390 | 2022-03-03 20:42:46 +0800 | [diff] [blame] | 73 | fi |
kelvin.zhang | a1170fa | 2022-03-03 20:06:57 +0800 | [diff] [blame] | 74 | |
Kelvin Zhang | 81eb1b1 | 2022-06-09 14:35:18 +0800 | [diff] [blame] | 75 | repo sync -cq -j8 --prune |
Kelvin Zhang | 442c915 | 2022-05-30 17:29:53 +0800 | [diff] [blame] | 76 | [ "$?" -ne 0 ] && cd - && echo "Sync error! will do fresh download next time" && exit 1 |
| 77 | if [ -n "$REPO_SYNC_IPATTERN" ]; then |
| 78 | repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME |
| 79 | else |
| 80 | repo forall -c git reset -q --hard origin/$BRANCH_NAME |
| 81 | fi |
Kelvin Zhang | fdf8ff0 | 2023-04-21 21:23:30 +0800 | [diff] [blame] | 82 | repo manifest -r -o $MANIFEST |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 83 | echo -e "======== Done ========\n" |
kelvin.zhang | 0139390 | 2022-03-03 20:42:46 +0800 | [diff] [blame] | 84 | |
Kelvin Zhang | fdf8ff0 | 2023-04-21 21:23:30 +0800 | [diff] [blame] | 85 | if [ -f $LAST_MANIFEST ] && [ -f $MANIFEST ]; then |
| 86 | comm -23 <(sort $LAST_MANIFEST) <(sort $MANIFEST) > $DIFF_MANIFEST |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 87 | |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 88 | if [ -s $DIFF_MANIFEST ]; then |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 89 | echo "======== Recent Changes ========" |
| 90 | |
| 91 | while IFS= read -r line |
| 92 | do |
| 93 | keyline=`echo "$line" | grep 'name=.* path='` |
| 94 | |
| 95 | for keyword in $keyline; do |
| 96 | [[ $keyword == path=* ]] && repo_path=`echo ${keyword#*path=} | sed 's/\"//g'` |
| 97 | [[ $keyword == name=* ]] && repo_name=`echo ${keyword#*name=} | sed 's/\"//g'` |
| 98 | [[ $keyword == revision=* ]] && repo_version=`echo ${keyword#*revision=} | sed 's/\"//g'` |
| 99 | done |
| 100 | |
| 101 | if [ -d "$repo_path" ]; then |
| 102 | pushd $repo_path > /dev/null |
| 103 | echo -e "\nProject $repo_name" |
| 104 | git log $repo_version..HEAD |
| 105 | popd > /dev/null |
| 106 | fi |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 107 | done < $DIFF_MANIFEST |
Kelvin Zhang | e98bd54 | 2022-09-07 15:43:58 +0800 | [diff] [blame] | 108 | echo -e "================\n" |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 109 | else |
Kelvin Zhang | e98bd54 | 2022-09-07 15:43:58 +0800 | [diff] [blame] | 110 | echo -e "======== Nothing changed since last build ========\n" |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 111 | fi |
Kelvin Zhang | 81eb1b1 | 2022-06-09 14:35:18 +0800 | [diff] [blame] | 112 | fi |
| 113 | |
Kelvin Zhang | 461d2e1 | 2022-11-21 20:51:42 +0800 | [diff] [blame] | 114 | source scripts/gerrit_review.sh |
Kelvin Zhang | c07a8db | 2022-09-06 21:06:31 +0800 | [diff] [blame] | 115 | # Cherry pick patches |
Kelvin Zhang | 0f58279 | 2022-08-31 18:52:20 +0800 | [diff] [blame] | 116 | source scripts/cherry_pick.sh |
Kelvin Zhang | a04b9cb | 2022-11-29 15:05:27 +0800 | [diff] [blame] | 117 | [ "$?" -ne 0 ] && gerrit_review_for_gerrit_topic FAIL && exit 1 |
Kelvin Zhang | cf64342 | 2022-11-22 15:28:31 +0800 | [diff] [blame] | 118 | gerrit_review_for_gerrit_topic Start |
kelvin.zhang | 2219b41 | 2022-03-04 16:44:41 +0800 | [diff] [blame] | 119 | |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 120 | # Generate Jenkins trigger |
Kelvin Zhang | fdf8ff0 | 2023-04-21 21:23:30 +0800 | [diff] [blame] | 121 | JENKINS_TRIGGER="$OUTPUT_DIR/jenkins_trigger.txt" |
fugui.zhang | 89409e1 | 2024-07-03 14:10:05 +0800 | [diff] [blame] | 122 | [[ "$SUBMIT_TYPE" == "daily" || "$SUBMIT_TYPE" == "patch" ]] && source scripts/gen_jenkins_trigger.sh |
Kelvin Zhang | 7052f1c | 2022-09-20 11:11:41 +0800 | [diff] [blame] | 123 | |
shijie.xiong | ec39868 | 2022-09-07 15:57:54 +0800 | [diff] [blame] | 124 | if [[ "$MANIFEST_BRANCH" == "$BRANCH_NAME" ]]; then |
| 125 | source scripts/build_all_pkg.sh |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 126 | else |
Kelvin Zhang | 727c3e3 | 2022-08-31 20:57:37 +0800 | [diff] [blame] | 127 | source scripts/build_all.sh |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 128 | fi |
Kelvin Zhang | 461d2e1 | 2022-11-21 20:51:42 +0800 | [diff] [blame] | 129 | |
Kelvin Zhang | a04b9cb | 2022-11-29 15:05:27 +0800 | [diff] [blame] | 130 | [ "$?" -ne 0 ] && gerrit_review_for_gerrit_topic FAIL && exit 1 |
Kelvin Zhang | 461d2e1 | 2022-11-21 20:51:42 +0800 | [diff] [blame] | 131 | gerrit_review_for_gerrit_topic SUCCESS |