llvm.org GIT mirror llvm / 2f9bbd6
Allow to apply cherry-picks when building Docker images. Reviewers: mehdi_amini, ioeric, klimek Reviewed By: ioeric Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41393 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321175 91177308-0d34-0410-b5e6-96231b3b80d8 Ilya Biryukov 1 year, 9 months ago
2 changed file(s) with 44 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2929 'branches/release_40'
3030 (default: 'trunk')
3131 -r|--revision svn revision to checkout
32 -c|--cherrypick revision to cherry-pick. Can be specified multiple times.
33 Cherry-picks are performed in the sorted order using the
34 following command:
35 'svn patch <(svn diff -c \$rev)'.
3236 -p|--llvm-project name of an svn project to checkout. Will also add the
3337 project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
3438 For clang, please use 'clang', not 'cfe'.
9195 DOCKER_TAG="$1"
9296 shift
9397 ;;
94 -i|--install-target|-r|--revision|-b|--branch|-p|--llvm-project)
98 -i|--install-target|-r|--revision|-c|-cherrypick|-b|--branch|-p|--llvm-project)
9599 if [ "$1" == "-i" ] || [ "$1" == "--install-target" ]; then
96100 SEEN_INSTALL_TARGET=1
97101 fi
2424 'branches/release_40'
2525 (default: 'trunk')
2626 -r|--revision svn revision to checkout
27 -c|--cherrypick revision to cherry-pick. Can be specified multiple times.
28 Cherry-picks are performed in the sorted order using the
29 following command:
30 'svn patch <(svn diff -c \$rev)'.
2731 -p|--llvm-project name of an svn project to checkout. Will also add the
2832 project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
2933 For clang, please use 'clang', not 'cfe'.
3943 }
4044
4145 LLVM_SVN_REV=""
46 CHERRYPICKS=""
4247 LLVM_BRANCH=""
4348 CMAKE_ARGS=""
4449 CMAKE_INSTALL_TARGETS=""
7681 LLVM_SVN_REV="$1"
7782 shift
7883 ;;
84 -c|--cherrypick)
85 shift
86 CHERRYPICKS="$CHERRYPICKS $1"
87 shift
88 ;;
7989 -b|--branch)
8090 shift
8191 LLVM_BRANCH="$1"
151161 SVN_REV_ARG=""
152162 echo "Checking out latest svn revision."
153163 fi
164
165 # Sort cherrypicks and remove duplicates.
166 CHERRYPICKS="$(echo "$CHERRYPICKS" | xargs -n1 | sort | uniq | xargs)"
167
168 function apply_cherrypicks() {
169 local CHECKOUT_DIR="$1"
170
171 [ "$CHERRYPICKS" == "" ] || echo "Applying cherrypicks"
172 pushd "$CHECKOUT_DIR"
173
174 # This function is always called on a sorted list of cherrypicks.
175 for CHERRY_REV in $CHERRYPICKS; do
176 echo "Cherry-picking r$CHERRY_REV into $CHECKOUT_DIR"
177
178 local PATCH_FILE="$(mktemp)"
179 svn diff -c $CHERRY_REV > "$PATCH_FILE"
180 svn patch "$PATCH_FILE"
181 rm "$PATCH_FILE"
182 done
183
184 popd
185 }
154186
155187 CLANG_BUILD_DIR=/tmp/clang-build
156188 CLANG_INSTALL_DIR=/tmp/clang-install
171203 svn co -q $SVN_REV_ARG \
172204 "https://llvm.org/svn/llvm-project/$SVN_PROJECT/$LLVM_BRANCH" \
173205 "$CLANG_BUILD_DIR/src/$LLVM_PROJECT"
206
207 # We apply cherrypicks to all repositories regardless of whether the revision
208 # changes this repository or not. For repositories not affected by the
209 # cherrypick, applying the cherrypick is a no-op.
210 apply_cherrypicks "$CLANG_BUILD_DIR/src/$LLVM_PROJECT"
174211 done
175212
176213 if [ $CLANG_TOOLS_EXTRA_ENABLED -ne 0 ]; then
178215 svn co -q $SVN_REV_ARG \
179216 "https://llvm.org/svn/llvm-project/clang-tools-extra/$LLVM_BRANCH" \
180217 "$CLANG_BUILD_DIR/src/clang/tools/extra"
218
219 apply_cherrypicks "$CLANG_BUILD_DIR/src/clang/tools/extra"
181220 fi
182221
183222 CHECKSUMS_FILE="/tmp/checksums/checksums.txt"