[IRBuilder] Add Align argument for CreateMaskedExpandLoad and CreateMaskedCompressSto...
[llvm-project.git] / llvm / utils / docker / scripts / checkout.sh
blob8fe7c6141d86b2b9ac8870370f20f86606a90bec
1 #!/usr/bin/env bash
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 #===-----------------------------------------------------------------------===//
10 set -e
12 function show_usage() {
13 cat << EOF
14 Usage: checkout.sh [options]
16 Checkout git sources into /tmp/clang-build/src. Used inside a docker container.
18 Available options:
19 -h|--help show this help message
20 -b|--branch git branch to checkout, i.e. 'main',
21 'release/10.x'
22 (default: '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
26 following command:
27 'git cherry-pick \$rev)'.
28 EOF
31 LLVM_GIT_REV=""
32 CHERRYPICKS=""
33 LLVM_BRANCH=""
35 while [[ $# -gt 0 ]]; do
36 case "$1" in
37 -r|--revision)
38 shift
39 LLVM_GIT_REV="$1"
40 shift
42 -c|--cherrypick)
43 shift
44 CHERRYPICKS="$CHERRYPICKS $1"
45 shift
47 -b|--branch)
48 shift
49 LLVM_BRANCH="$1"
50 shift
52 -h|--help)
53 show_usage
54 exit 0
57 echo "Unknown option: $1"
58 exit 1
59 esac
60 done
62 if [ "$LLVM_BRANCH" == "" ]; then
63 LLVM_BRANCH="main"
66 if [ "$LLVM_GIT_REV" != "" ]; then
67 GIT_REV_ARG="$LLVM_GIT_REV"
68 echo "Checking out git revision $LLVM_GIT_REV."
69 else
70 GIT_REV_ARG=""
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"
81 pushd "$CHECKOUT_DIR"
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
87 done
89 popd
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" \
102 "$CHECKOUT_DIR"
104 pushd $CHECKOUT_DIR
105 git checkout -q $GIT_REV_ARG
106 popd
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"
119 else
120 echo "Skipping checksumming checks..."
123 echo "Done"