2 #===- llvm/utils/docker/scripts/checkout.sh ---------------------===//
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===-----------------------------------------------------------------------===//
12 function show_usage
() {
14 Usage: checkout.sh [options]
16 Checkout git sources into /tmp/clang-build/src. Used inside a docker container.
19 -h|--help show this help message
20 -b|--branch git branch to checkout, i.e. 'main',
23 -r|--revision git revision to checkout
24 -c|--cherrypick revision to cherry-pick. Can be specified multiple times.
25 Cherry-picks are performed in the sorted order using the
27 'git cherry-pick \$rev)'.
35 while [[ $# -gt 0 ]]; do
44 CHERRYPICKS
="$CHERRYPICKS $1"
57 echo "Unknown option: $1"
62 if [ "$LLVM_BRANCH" == "" ]; then
66 if [ "$LLVM_GIT_REV" != "" ]; then
67 GIT_REV_ARG
="$LLVM_GIT_REV"
68 echo "Checking out git revision $LLVM_GIT_REV."
71 echo "Checking out latest git revision."
74 # Sort cherrypicks and remove duplicates.
75 CHERRYPICKS
="$(echo "$CHERRYPICKS" | xargs -n1 | sort | uniq | xargs)"
77 function apply_cherrypicks
() {
78 local CHECKOUT_DIR
="$1"
80 [ "$CHERRYPICKS" == "" ] ||
echo "Applying cherrypicks"
83 # This function is always called on a sorted list of cherrypicks.
84 for CHERRY_REV
in $CHERRYPICKS; do
85 echo "Cherry-picking $CHERRY_REV into $CHECKOUT_DIR"
86 EMAIL
="someone@somewhere.net" git cherry-pick
$CHERRY_REV
92 CLANG_BUILD_DIR
=/tmp
/clang-build
94 # Get the sources from git.
95 echo "Checking out sources from git"
96 mkdir
-p "$CLANG_BUILD_DIR/src"
97 CHECKOUT_DIR
="$CLANG_BUILD_DIR/src"
99 echo "Checking out https://github.com/llvm/llvm-project.git to $CHECKOUT_DIR"
100 git clone
-b $LLVM_BRANCH --single-branch \
101 "https://github.com/llvm/llvm-project.git" \
105 git checkout
-q $GIT_REV_ARG
108 # We apply cherrypicks to all repositories regardless of whether the revision
109 # changes this repository or not. For repositories not affected by the
110 # cherrypick, applying the cherrypick is a no-op.
111 apply_cherrypicks
"$CHECKOUT_DIR"
113 CHECKSUMS_FILE
="/tmp/checksums/checksums.txt"
115 if [ -f "$CHECKSUMS_FILE" ]; then
116 echo "Validating checksums for LLVM checkout..."
117 python
"$(dirname $0)/llvm_checksum/llvm_checksum.py" -c "$CHECKSUMS_FILE" \
118 --partial --multi_dir "$CLANG_BUILD_DIR/src"
120 echo "Skipping checksumming checks..."