blob: 43da8c56790003cdcb5fffda6c8fa80a9d585f35 [file] [log] [blame]
Ray Essick247da042018-11-29 14:14:00 -08001#!/bin/bash -e
2#
3# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This tool is used to update libaom source code to a revision of the upstream
Johann39f13222019-01-09 11:48:14 -08008# repository. Modified from Chromium src/third_party/libvpx/update_libvpx.sh
Ray Essick247da042018-11-29 14:14:00 -08009
10# Usage:
11#
12# $ ./update_libaom.sh [branch | revision | file or url containing a revision]
13# When specifying a branch it may be necessary to prefix with origin/
14
15# Tools required for running this tool:
16#
17# 1. Linux / Mac
18# 2. git
19
20export LC_ALL=C
21
Johann39f13222019-01-09 11:48:14 -080022die() {
23 echo "@"
24 exit 1
25}
26
Ray Essick247da042018-11-29 14:14:00 -080027# Location for the remote git repository.
28GIT_REPO="https://aomedia.googlesource.com/aom"
29
30# Update to TOT by default.
31GIT_BRANCH="origin/master"
32
33# Relative path of target checkout.
34LIBAOM_SRC_DIR="libaom"
35
36BASE_DIR=`pwd`
37
38if [ -n "$1" ]; then
39 GIT_BRANCH="$1"
40 if [ -f "$1" ]; then
41 GIT_BRANCH=$(<"$1")
42 elif [[ $1 = http* ]]; then
43 GIT_BRANCH=`curl $1`
44 fi
45fi
46
47prev_hash="$(egrep "^Commit: [[:alnum:]]" README.android | awk '{ print $2 }')"
48echo "prev_hash:$prev_hash"
49
50rm -rf $LIBAOM_SRC_DIR
Johann39f13222019-01-09 11:48:14 -080051mkdir $LIBAOM_SRC_DIR || die "Unable to create ${LIBAOM_SRC_DIR}"
52cd $LIBAOM_SRC_DIR || die "Unable to enter ${LIBAOM_SRC_DIR}"
Ray Essick247da042018-11-29 14:14:00 -080053
54# Start a local git repo.
55git clone $GIT_REPO .
56
57# Switch the content to the desired revision.
58git checkout -b tot $GIT_BRANCH
59
60add="$(git diff-index --diff-filter=A $prev_hash | \
61tr -s [:blank:] ' ' | cut -f6 -d\ )"
62delete="$(git diff-index --diff-filter=D $prev_hash | \
63tr -s [:blank:] ' ' | cut -f6 -d\ )"
64
65# Get the current commit hash.
66hash=$(git log -1 --format="%H")
67
68# README reminder.
Johann39f13222019-01-09 11:48:14 -080069echo "Update README.android:"
70echo "==============="
71echo "Date: $(date +"%A %B %d %Y")"
72echo "Branch: $GIT_BRANCH"
73echo "Commit: $hash"
74echo "==============="
75echo ""
Ray Essick247da042018-11-29 14:14:00 -080076
77# Commit message header.
Johann39f13222019-01-09 11:48:14 -080078echo "Commit message:"
79echo "==============="
80echo "libaom: Pull from upstream"
81echo ""
Ray Essick247da042018-11-29 14:14:00 -080082
Johann39f13222019-01-09 11:48:14 -080083# Output the current commit hash.
84echo "Current HEAD: $hash"
85echo ""
Ray Essick247da042018-11-29 14:14:00 -080086
Johann39f13222019-01-09 11:48:14 -080087# Output log for upstream from current hash.
88if [ -n "$prev_hash" ]; then
89 echo "git log from upstream:"
90 pretty_git_log="$(git log \
Ray Essick247da042018-11-29 14:14:00 -080091 --no-merges \
92 --topo-order \
93 --pretty="%h %s" \
94 --max-count=20 \
95 $prev_hash..$hash)"
Johann39f13222019-01-09 11:48:14 -080096 if [ -z "$pretty_git_log" ]; then
97 echo "No log found. Checking for reverts."
98 pretty_git_log="$(git log \
Ray Essick247da042018-11-29 14:14:00 -080099 --no-merges \
100 --topo-order \
101 --pretty="%h %s" \
102 --max-count=20 \
103 $hash..$prev_hash)"
Johann39f13222019-01-09 11:48:14 -0800104 fi
105 echo "$pretty_git_log"
106 # If it makes it to 20 then it's probably skipping even more.
107 if [ `echo "$pretty_git_log" | wc -l` -eq 20 ]; then
108 echo "<...>"
109 fi
110else
111 # no previous hash
112 echo "git log from upstream:"
113 pretty_git_log="$(git log \
114 --no-merges \
115 --topo-order \
116 --pretty="%h %s" \
117 --max-count=20 \
118 $hash)"
119fi
Ray Essick247da042018-11-29 14:14:00 -0800120
Johann39f13222019-01-09 11:48:14 -0800121# Commit message footer.
Ray Essick247da042018-11-29 14:14:00 -0800122echo ""
123echo "==============="
124
125# Git is useless now, remove the local git repo.
126rm -rf .git .gitignore .gitattributes
127
128# Add and remove files.
129echo "$add" | xargs -I {} git add {}
130echo "$delete" | xargs -I {} git rm --ignore-unmatch {}
131
132# Find empty directories and remove them.
133find . -type d -empty -exec git rm {} \;
134
135chmod 755 build/cmake/*.sh build/cmake/*.pl