forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roll_closure_compiler
executable file
·149 lines (125 loc) · 4.93 KB
/
roll_closure_compiler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Download the newest version of Closure Compiler, build it and put into Chrome
# source tree. Also update externs/chrome_extensions.js.
java -version 2>&1 | head -1 | egrep -q '\b1\.7'
if [[ $? -ne 0 ]]; then
echo "This script requires Java 1.7" >&2
exit 1
fi
javac -version 2>&1 | egrep -q '\b1\.7'
if [[ $? -ne 0 ]]; then
echo "This script requires JDK 1.7" >&2
exit 1
fi
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly TEMP_DIR=$(mktemp -d)
readonly EXTERNS_DIR="${SCRIPT_DIR}/externs"
readonly README="${SCRIPT_DIR}/README.chromium"
cleanup() {
rm -rf "${TEMP_DIR}"
}
get_sha1() {
sha1sum "$1" | cut -d" " -f1
}
trap cleanup SIGINT SIGHUP SIGTERM
old_head=$(egrep -o "^Revision: [0-9a-f]{5,40}$" "${README}" | cut -d" " -f2)
old_extensions_sha1=$(get_sha1 "${EXTERNS_DIR}/chrome_extensions.js")
old_polymer_sha1=$(get_sha1 "${EXTERNS_DIR}/polymer-1.0.js")
cd "${TEMP_DIR}"
echo "Cloning Closure Compiler repo"
git clone --depth 1 https://github.com/google/closure-compiler.git
cd closure-compiler
new_head=$(git rev-parse HEAD)
if [[ "${new_head}" == "${old_head}" ]]; then
echo "No closure-compiler changes since last roll. Nothing to do."
cleanup
exit 0
else
head_range=$(cat <<EOT
Change log:
https://github.com/google/closure-compiler/compare/${old_head}...${new_head}
EOT
)
fi
echo "Building Closure Compiler"
mvn install -DskipTests=true --projects com.google.javascript:closure-compiler
if [[ "$?" -ne 0 ]]; then
echo "Failed to build jar, copying nothing" >&2
cleanup
exit 1
fi
# TODO(dbeam): this .jar seems to be a bit bigger than the jar previously built
# by ant. I tried many other jars in target/, but none of them were able to
# build the runner.jar without issue.
cp target/closure-compiler-1.0-SNAPSHOT.jar "${SCRIPT_DIR}/compiler/compiler.jar"
echo "Re-building runner.jar"
"${SCRIPT_DIR}/runner/build_runner_jar.py"
if [[ "$?" -ne 0 ]]; then
echo "Failed to build runner.jar, roll unsuccessful"
cleanup
exit 1
fi
readonly WARNING="$(cat <<EOT
// SSSSSSSSSSSSSSS TTTTTTTTTTTTTTTTTTTTTTT OOOOOOOOO PPPPPPPPPPPPPPPPP
// SS:::::::::::::::ST:::::::::::::::::::::T OO:::::::::OO P::::::::::::::::P
// S:::::SSSSSS::::::ST:::::::::::::::::::::T OO:::::::::::::OO P::::::PPPPPP:::::P
// S:::::S SSSSSSST:::::TT:::::::TT:::::TO:::::::OOO:::::::OPP:::::P P:::::P
// S:::::S TTTTTT T:::::T TTTTTTO::::::O O::::::O P::::P P:::::P
// S:::::S T:::::T O:::::O O:::::O P::::P P:::::P
// S::::SSSS P::::PPPPPP:::::P
// SS::::::SSSSS This file is generated. To update it, P:::::::::::::PP
// SSS::::::::SS run roll_closure_compiler. P::::PPPPPPPPP
// SSSSSS::::S P::::P
// S:::::S T:::::T O:::::O O:::::O P::::P
// S:::::S T:::::T O::::::O O::::::O P::::P
// SSSSSSS S:::::S TT:::::::TT O:::::::OOO:::::::OPP::::::PP
// S::::::SSSSSS:::::S T:::::::::T OO:::::::::::::OO P::::::::P
// S:::::::::::::::SS T:::::::::T OO:::::::::OO P::::::::P
// SSSSSSSSSSSSSSS TTTTTTTTTTT OOOOOOOOO PPPPPPPPPP
EOT
)"
(echo "${WARNING}" && cat contrib/externs/chrome_extensions.js) > "${EXTERNS_DIR}/chrome_extensions.js"
(echo "${WARNING}" && cat contrib/externs/polymer-1.0.js) > "${EXTERNS_DIR}/polymer-1.0.js"
new_extensions_sha1=$(get_sha1 "${EXTERNS_DIR}/chrome_extensions.js")
if [[ "${new_extensions_sha1}" != "${old_extensions_sha1}" ]]; then
extensions_range="chrome_extensions.js: ${old_extensions_sha1} -> ${new_extensions_sha1}"
fi
new_polymer_sha1=$(get_sha1 "${EXTERNS_DIR}/polymer-1.0.js")
if [[ "${new_polymer_sha1}" != "${old_polymer_sha1}" ]]; then
polymer_range="polymer-1.0.js: ${old_polymer_sha1} -> ${new_polymer_sha1}"
fi
echo
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "@"
echo "@ ROLL RESULTS:"
echo "@"
echo "@ closure-compiler.git HEAD:"
echo "@ Old: ${old_head}"
echo "@ New: ${new_head}"
echo "@"
echo "@ externs/chrome_extensions.js SHA1:"
echo "@ Old: ${old_extensions_sha1}"
echo "@ New: ${new_extensions_sha1}"
echo "@"
echo "@ externs/polymer-1.0.js SHA1:"
echo "@ Old: ${old_polymer_sha1}"
echo "@ New: ${new_polymer_sha1}"
echo "@"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo
sed -i "s/^Revision: ${old_head}$/Revision: ${new_head}/" "${README}"
echo "git commit -a -m 'Roll closure compiler"
echo
echo "${head_range}"
if [[ ! -z "${extensions_range}" ]]; then echo "${extensions_range}"; fi
if [[ ! -z "${polymer_range}" ]]; then echo "${polymer_range}"; fi
echo
echo "TBR="
echo "BUG='"
echo
echo "git cl upload"
cleanup