2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # Download the newest version of Closure Compiler, build it and put into Chrome
7 # source tree. Also update externs/chrome_extensions.js.
9 readonly SCRIPT_DIR
="$(cd "$
(dirname "${BASH_SOURCE[0]}")" && pwd)"
10 readonly TEMP_DIR
=$
(mktemp
-d)
12 readonly COMPILER_PATH
="${SCRIPT_DIR}/compiler/compiler.jar"
13 readonly EXTERNS_PATH
="${SCRIPT_DIR}/externs/chrome_extensions.js"
19 get_compiler_version
() {
20 java
-jar "${1}" --version |
grep ^Version
: | cut
-d' ' -f2
24 sha1sum "${EXTERNS_PATH}" | cut
-d' ' -f1
27 trap cleanup SIGINT SIGHUP SIGTERM
29 previous_compiler_version
=$
(get_compiler_version
${COMPILER_PATH})
30 previous_externs_sha1
=$
(get_externs_sha1
)
33 echo "Cloning Closure Compiler repo"
34 git clone https
://github.com
/google
/closure-compiler.git
37 echo "Building Closure Compiler"
40 if [[ "$?" -ne 0 ]]; then
41 echo "Failed to build jar, copying nothing" >&2
46 new_compiler_version
=$
(get_compiler_version
"build/compiler.jar")
48 if [[ "${new_compiler_version}" != "${previous_compiler_version}" ]]; then
49 cp build
/compiler.jar
"${COMPILER_PATH}"
51 echo "Compiler version changed; re-building runner.jar"
52 "${SCRIPT_DIR}/runner/build_runner_jar.py"
53 if [[ "$?" -ne 0 ]]; then
54 echo "Failed to build runner.jar, roll unsuccessful"
59 compiler_jar_range
="compiler.jar: ${previous_compiler_version} -> ${new_compiler_version}"
62 (cat <<EOT && cat contrib/externs/chrome_extensions.js) > "${EXTERNS_PATH}"
63 // SSSSSSSSSSSSSSS TTTTTTTTTTTTTTTTTTTTTTT OOOOOOOOO PPPPPPPPPPPPPPPPP
64 // SS:::::::::::::::ST:::::::::::::::::::::T OO:::::::::OO P::::::::::::::::P
65 // S:::::SSSSSS::::::ST:::::::::::::::::::::T OO:::::::::::::OO P::::::PPPPPP:::::P
66 // S:::::S SSSSSSST:::::TT:::::::TT:::::TO:::::::OOO:::::::OPP:::::P P:::::P
67 // S:::::S TTTTTT T:::::T TTTTTTO::::::O O::::::O P::::P P:::::P
68 // S:::::S T:::::T O:::::O O:::::O P::::P P:::::P
69 // S::::SSSS P::::PPPPPP:::::P
70 // SS::::::SSSSS This file is generated. To update it, P:::::::::::::PP
71 // SSS::::::::SS run bump_compiler_version. P::::PPPPPPPPP
73 // S:::::S T:::::T O:::::O O:::::O P::::P
74 // S:::::S T:::::T O::::::O O::::::O P::::P
75 // SSSSSSS S:::::S TT:::::::TT O:::::::OOO:::::::OPP::::::PP
76 // S::::::SSSSSS:::::S T:::::::::T OO:::::::::::::OO P::::::::P
77 // S:::::::::::::::SS T:::::::::T OO:::::::::OO P::::::::P
78 // SSSSSSSSSSSSSSS TTTTTTTTTTT OOOOOOOOO PPPPPPPPPP
81 new_externs_sha1
=$
(get_externs_sha1
)
83 if [[ "${new_externs_sha1}" != "${previous_externs_sha1}" ]]; then
84 chrome_extensions_range
="chrome_extensions.js: ${previous_externs_sha1} -> ${new_externs_sha1}"
88 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
90 echo "@ ROLL RESULTS:"
92 echo "@ Compiler version:"
93 echo "@ Previous: ${previous_compiler_version}"
94 echo "@ New: ${new_compiler_version}"
96 echo "@ Externs SHA1:"
97 echo "@ Previous: ${previous_externs_sha1}"
98 echo "@ New: ${new_externs_sha1}"
100 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
103 if [[ -z "${compiler_jar_range}" ]] && [[ -z "${chrome_extensions_range}" ]]; then
104 echo "Nothing to update"
106 echo "git commit -a -m 'Bumping closure compiler:"
108 if [[ ! -z "${compiler_jar_range}" ]]; then echo "${compiler_jar_range}"; fi
109 if [[ ! -z "${chrome_extensions_range}" ]]; then echo "${chrome_extensions_range}"; fi