1#!/usr/bin/env bash
2# Copyright 2020 The Amber Authors
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# Defined to use origin/master instead of origin/main
17# TODO(https://github.com/google/amber/issues/1014): Khronos repos are switching
18# to main
19cpplint=1
20dxc=1
21googletest=1
22json=1
23lodepng=1
24swiftshader=1
25
26# This script assumes it's parent directory is the repo root.
27repo_path=$(dirname "$0")/..
28
29cd "$repo_path"
30
31if [[ $(git diff --stat) != '' ]]; then
32    echo "Working tree is dirty, commit changes before attempting to roll DEPS"
33    exit 1
34fi
35
36old_head=$(git rev-parse HEAD)
37
38for i in $(find third_party -maxdepth 1 -mindepth 1 -type d); do
39  name=`echo "${i%%/}" | cut -f2 -d'/' | tr '-' '_'`
40
41  if [ "x${name}" == "xcpplint" ]; then
42    continue
43  fi
44
45  trunk="origin/main"
46  if [ ! -z ${!name} ]; then
47    trunk="origin/master"
48  fi
49
50  roll-dep --ignore-dirty-tree --roll-to="${trunk}" "${i%%/}";
51done
52
53git rebase --interactive "${old_head}"
54