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"
54 compiler_jar_range
="compiler.jar: ${previous_compiler_version} -> ${new_compiler_version}"
57 (cat <<EOT && cat contrib/externs/chrome_extensions.js) > "${EXTERNS_PATH}"
58 // SSSSSSSSSSSSSSS TTTTTTTTTTTTTTTTTTTTTTT OOOOOOOOO PPPPPPPPPPPPPPPPP
59 // SS:::::::::::::::ST:::::::::::::::::::::T OO:::::::::OO P::::::::::::::::P
60 // S:::::SSSSSS::::::ST:::::::::::::::::::::T OO:::::::::::::OO P::::::PPPPPP:::::P
61 // S:::::S SSSSSSST:::::TT:::::::TT:::::TO:::::::OOO:::::::OPP:::::P P:::::P
62 // S:::::S TTTTTT T:::::T TTTTTTO::::::O O::::::O P::::P P:::::P
63 // S:::::S T:::::T O:::::O O:::::O P::::P P:::::P
64 // S::::SSSS P::::PPPPPP:::::P
65 // SS::::::SSSSS This file is generated. To update it, P:::::::::::::PP
66 // SSS::::::::SS run bump_compiler_version. P::::PPPPPPPPP
68 // S:::::S T:::::T O:::::O O:::::O P::::P
69 // S:::::S T:::::T O::::::O O::::::O P::::P
70 // SSSSSSS S:::::S TT:::::::TT O:::::::OOO:::::::OPP::::::PP
71 // S::::::SSSSSS:::::S T:::::::::T OO:::::::::::::OO P::::::::P
72 // S:::::::::::::::SS T:::::::::T OO:::::::::OO P::::::::P
73 // SSSSSSSSSSSSSSS TTTTTTTTTTT OOOOOOOOO PPPPPPPPPP
76 new_externs_sha1
=$
(get_externs_sha1
)
78 if [[ "${new_externs_sha1}" != "${previous_externs_sha1}" ]]; then
79 chrome_extensions_range
="chrome_extensions.js: ${previous_externs_sha1} -> ${new_externs_sha1}"
83 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
85 echo "@ ROLL RESULTS:"
87 echo "@ Compiler version:"
88 echo "@ Previous: ${previous_compiler_version}"
89 echo "@ New: ${new_compiler_version}"
91 echo "@ Externs SHA1:"
92 echo "@ Previous: ${previous_externs_sha1}"
93 echo "@ New: ${new_externs_sha1}"
95 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
98 if [[ -z "${compiler_jar_range}" ]] && [[ -z "${chrome_extensions_range}" ]]; then
99 echo "Nothing to update"
101 echo "git commit -a -m 'Bumping closure compiler:"
103 if [[ ! -z "${compiler_jar_range}" ]]; then echo "${compiler_jar_range}"; fi
104 if [[ ! -z "${chrome_extensions_range}" ]]; then echo "${chrome_extensions_range}"; fi