blob: fc0c0533687798a1c1a3d9b8adbc000892bf8c69 [file] [log] [blame]
Paul Duffin15625bc2017-03-15 15:12:51 +00001#!/bin/bash
2#
3# Copyright 2017 The Android Open Source Project.
4#
5# Retrieves the current Dexmaker to source code into the current directory, excluding portions related
6# to mockito's internal build system and javadoc.
7
8# Force stop on first error.
9set -e
10
11if [ $# -ne 1 ]; then
12 echo "$0 <version>" >&2
13 exit 1;
14fi
15
16if [ -z "$ANDROID_BUILD_TOP" ]; then
17 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2
18 exit 1
19fi
20
21VERSION=${1}
22
23SOURCE="https://github.com/linkedin/dexmaker"
24INCLUDE="
25 LICENSE
Philip P. Moltmann70402ca2018-08-28 16:57:52 +000026
Paul Duffin15625bc2017-03-15 15:12:51 +000027 dexmaker
28 dexmaker-mockito
Philip P. Moltmann0ad4f182018-08-28 16:38:42 +000029 dexmaker-mockito-inline
Philip P. Moltmann70402ca2018-08-28 16:57:52 +000030 dexmaker-mockito-inline-extended
31
Philip P. Moltmann0ad4f182018-08-28 16:38:42 +000032 dexmaker-mockito-inline-dispatcher
Philip P. Moltmann70402ca2018-08-28 16:57:52 +000033
34 dexmaker-tests
35 dexmaker-mockito-tests
36 dexmaker-mockito-inline-tests
37 dexmaker-mockito-inline-extended-tests
Paul Duffin15625bc2017-03-15 15:12:51 +000038 "
39
40EXCLUDE="
41 "
42
43working_dir="$(mktemp -d)"
44trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT
45
46echo "Fetching Dexmaker source into $working_dir"
47git clone $SOURCE $working_dir/source
Philip P. Moltmann43b4c622017-11-20 09:38:54 -080048ORG_DIR=$(pwd)
49cd $working_dir/source
50git checkout $VERSION
51SHA=$(git rev-parse $VERSION)
52cd $ORG_DIR
Paul Duffin15625bc2017-03-15 15:12:51 +000053
54for include in ${INCLUDE}; do
55 echo "Updating $include"
56 rm -rf $include
57 mkdir -p $(dirname $include)
58 cp -R $working_dir/source/$include $include
59done;
60
61for exclude in ${EXCLUDE}; do
62 echo "Excluding $exclude"
63 rm -r $exclude
64done;
65
Philip P. Moltmann43b4c622017-11-20 09:38:54 -080066# Remove 3rd party code
67rm -r dexmaker-mockito-inline/external
Paul Duffin15625bc2017-03-15 15:12:51 +000068
69echo "Updating README.version"
70
71# Update the version.
Philip P. Moltmann43b4c622017-11-20 09:38:54 -080072perl -pi -e "s|^Version: .*$|Version: ${VERSION} (${SHA})|" "README.version"
Paul Duffin15625bc2017-03-15 15:12:51 +000073
74# Remove any documentation about local modifications.
75mv README.version README.tmp
76grep -B 100 "Local Modifications" README.tmp > README.version
77echo " None" >> README.version
78rm README.tmp
79
80echo "Done"