xref: /aosp_15_r20/external/swiftshader/third_party/SPIRV-Tools/utils/roll_deps.sh (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1#!/usr/bin/env bash
2# Copyright (c) 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Attempts to roll all entries in DEPS to tip-of-tree and create a commit.
17#
18# Depends on roll-dep from depot_tools
19# (https://chromium.googlesource.com/chromium/tools/depot_tools) being in PATH.
20
21set -eo pipefail
22
23function ExitIfIsInterestingError() {
24  local return_code=$1
25  if [[ ${return_code} -ne 0 && ${return_code} -ne 2 ]]; then
26    exit ${return_code}
27  fi
28  return 0
29}
30
31
32dependencies=("external/effcee/"
33              "external/googletest/"
34              "external/re2/"
35              "external/spirv-headers/")
36
37
38branch="origin/main"
39
40# This script assumes it's parent directory is the repo root.
41repo_path=$(dirname "$0")/..
42
43cd "$repo_path"
44
45if [[ $(git diff --stat) != '' ]]; then
46    echo "Working tree is dirty, commit changes before attempting to roll DEPS"
47    exit 1
48fi
49
50echo "*** Ignore messages about running 'git cl upload' ***"
51
52old_head=$(git rev-parse HEAD)
53
54set +e
55
56for dep in ${dependencies[@]}; do
57  echo "Rolling $dep"
58  roll-dep --ignore-dirty-tree --roll-to="${branch}" "${dep}"
59  ExitIfIsInterestingError $?
60done
61