Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / closure_compiler / bump_compiler_version
blob45af0533d4efdee56d8b52bd28117649b0c227d5
1 #!/bin/bash
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"
15 cleanup() {
16 rm -rf "${TEMP_DIR}"
19 get_compiler_version() {
20 java -jar "${1}" --version | grep ^Version: | cut -d' ' -f2
23 get_externs_sha1() {
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)
32 cd "${TEMP_DIR}"
33 echo "Cloning Closure Compiler repo"
34 git clone https://github.com/google/closure-compiler.git
36 cd closure-compiler
37 echo "Building Closure Compiler"
38 ant jar
40 if [[ "$?" -ne 0 ]]; then
41 echo "Failed to build jar, copying nothing" >&2
42 cleanup
43 exit 1
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
67 // SSSSSS::::S P::::P
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
74 EOT
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}"
82 echo
83 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
84 echo "@"
85 echo "@ ROLL RESULTS:"
86 echo "@"
87 echo "@ Compiler version:"
88 echo "@ Previous: ${previous_compiler_version}"
89 echo "@ New: ${new_compiler_version}"
90 echo "@"
91 echo "@ Externs SHA1:"
92 echo "@ Previous: ${previous_externs_sha1}"
93 echo "@ New: ${new_externs_sha1}"
94 echo "@"
95 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
96 echo
98 if [[ -z "${compiler_jar_range}" ]] && [[ -z "${chrome_extensions_range}" ]]; then
99 echo "Nothing to update"
100 else
101 echo "git commit -a -m 'Bumping closure compiler:"
102 echo
103 if [[ ! -z "${compiler_jar_range}" ]]; then echo "${compiler_jar_range}"; fi
104 if [[ ! -z "${chrome_extensions_range}" ]]; then echo "${chrome_extensions_range}"; fi
105 echo "TBR="
106 echo "BUG='"
107 echo
108 echo "git cl upload"
111 cleanup