OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This script will check out llvm and clang into third_party/llvm and build it. | 6 # This script will check out llvm and clang into third_party/llvm and build it. |
7 | 7 |
8 # Do NOT CHANGE this if you don't know what you're doing -- see | 8 # Do NOT CHANGE this if you don't know what you're doing -- see |
9 # https://code.google.com/p/chromium/wiki/UpdatingClang | 9 # https://code.google.com/p/chromium/wiki/UpdatingClang |
10 # Reverting problematic clang rolls is safe, though. | 10 # Reverting problematic clang rolls is safe, though. |
11 CLANG_REVISION=193323 | 11 CLANG_REVISION=193323 |
| 12 PLUGIN_REVISION= |
12 | 13 |
13 THIS_DIR="$(dirname "${0}")" | 14 THIS_DIR="$(dirname "${0}")" |
14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 15 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" | 16 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" |
16 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" | 17 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" |
17 CLANG_DIR="${LLVM_DIR}/tools/clang" | 18 CLANG_DIR="${LLVM_DIR}/tools/clang" |
18 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" | 19 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" |
19 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" | 20 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" |
20 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" | 21 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" |
21 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" | 22 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" |
| 23 ARCHIVE_REVISION="${CLANG_REVISION}${PLUGIN_REVISION}" |
22 | 24 |
23 # ${A:-a} returns $A if it's set, a else. | 25 # ${A:-a} returns $A if it's set, a else. |
24 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} | 26 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} |
25 | 27 |
26 # Die if any command dies. | 28 # Die if any command dies. |
27 set -e | 29 set -e |
28 | 30 |
29 OS="$(uname -s)" | 31 OS="$(uname -s)" |
30 | 32 |
31 # Parse command line options. | 33 # Parse command line options. |
32 force_local_build= | 34 force_local_build= |
33 mac_only= | 35 mac_only= |
34 run_tests= | 36 run_tests= |
35 bootstrap= | 37 bootstrap= |
36 with_android=yes | 38 with_android=yes |
37 chrome_tools="plugins" | 39 chrome_tools="plugins blink_gc_plugin" |
38 | 40 |
39 if [[ "${OS}" = "Darwin" ]]; then | 41 if [[ "${OS}" = "Darwin" ]]; then |
40 with_android= | 42 with_android= |
41 fi | 43 fi |
42 | 44 |
43 while [[ $# > 0 ]]; do | 45 while [[ $# > 0 ]]; do |
44 case $1 in | 46 case $1 in |
45 --bootstrap) | 47 --bootstrap) |
46 bootstrap=yes | 48 bootstrap=yes |
47 ;; | 49 ;; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 echo "Please upgrade Xcode to at least 3.2.6." | 117 echo "Please upgrade Xcode to at least 3.2.6." |
116 echo | 118 echo |
117 fi | 119 fi |
118 fi | 120 fi |
119 | 121 |
120 | 122 |
121 # Check if there's anything to be done, exit early if not. | 123 # Check if there's anything to be done, exit early if not. |
122 if [[ -f "${STAMP_FILE}" ]]; then | 124 if [[ -f "${STAMP_FILE}" ]]; then |
123 PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}") | 125 PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}") |
124 if [[ -z "$force_local_build" ]] && \ | 126 if [[ -z "$force_local_build" ]] && \ |
125 [[ "${PREVIOUSLY_BUILT_REVISON}" = "${CLANG_REVISION}" ]]; then | 127 [[ "${PREVIOUSLY_BUILT_REVISON}" = "${ARCHIVE_REVISION}" ]]; then |
126 echo "Clang already at ${CLANG_REVISION}" | 128 echo "Clang already at ${ARCHIVE_REVISION}" |
127 exit 0 | 129 exit 0 |
128 fi | 130 fi |
129 fi | 131 fi |
130 # To always force a new build if someone interrupts their build half way. | 132 # To always force a new build if someone interrupts their build half way. |
131 rm -f "${STAMP_FILE}" | 133 rm -f "${STAMP_FILE}" |
132 | 134 |
133 | 135 |
134 # Clobber build files. PCH files only work with the compiler that created them. | 136 # Clobber build files. PCH files only work with the compiler that created them. |
135 # We delete .o files to make sure all files are built with the new compiler. | 137 # We delete .o files to make sure all files are built with the new compiler. |
136 echo "Clobbering build files" | 138 echo "Clobbering build files" |
(...skipping 16 matching lines...) Expand all Loading... |
153 if [[ "${OS}" = "Darwin" ]]; then | 155 if [[ "${OS}" = "Darwin" ]]; then |
154 if [[ -d "${XCODEBUILD_DIR}" ]]; then | 156 if [[ -d "${XCODEBUILD_DIR}" ]]; then |
155 find "${XCODEBUILD_DIR}" -name 'stamp.untar' -exec rm {} + | 157 find "${XCODEBUILD_DIR}" -name 'stamp.untar' -exec rm {} + |
156 fi | 158 fi |
157 fi | 159 fi |
158 | 160 |
159 if [[ -z "$force_local_build" ]]; then | 161 if [[ -z "$force_local_build" ]]; then |
160 # Check if there's a prebuilt binary and if so just fetch that. That's faster, | 162 # Check if there's a prebuilt binary and if so just fetch that. That's faster, |
161 # and goma relies on having matching binary hashes on client and server too. | 163 # and goma relies on having matching binary hashes on client and server too. |
162 CDS_URL=https://commondatastorage.googleapis.com/chromium-browser-clang | 164 CDS_URL=https://commondatastorage.googleapis.com/chromium-browser-clang |
163 CDS_FILE="clang-${CLANG_REVISION}.tgz" | 165 CDS_FILE="clang-${ARCHIVE_REVISION}.tgz" |
164 CDS_OUT_DIR=$(mktemp -d -t clang_download.XXXXXX) | 166 CDS_OUT_DIR=$(mktemp -d -t clang_download.XXXXXX) |
165 CDS_OUTPUT="${CDS_OUT_DIR}/${CDS_FILE}" | 167 CDS_OUTPUT="${CDS_OUT_DIR}/${CDS_FILE}" |
166 if [ "${OS}" = "Linux" ]; then | 168 if [ "${OS}" = "Linux" ]; then |
167 CDS_FULL_URL="${CDS_URL}/Linux_x64/${CDS_FILE}" | 169 CDS_FULL_URL="${CDS_URL}/Linux_x64/${CDS_FILE}" |
168 elif [ "${OS}" = "Darwin" ]; then | 170 elif [ "${OS}" = "Darwin" ]; then |
169 CDS_FULL_URL="${CDS_URL}/Mac/${CDS_FILE}" | 171 CDS_FULL_URL="${CDS_URL}/Mac/${CDS_FILE}" |
170 fi | 172 fi |
171 echo Trying to download prebuilt clang | 173 echo Trying to download prebuilt clang |
172 if which curl > /dev/null; then | 174 if which curl > /dev/null; then |
173 curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \ | 175 curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \ |
174 rm -rf "${CDS_OUT_DIR}" | 176 rm -rf "${CDS_OUT_DIR}" |
175 elif which wget > /dev/null; then | 177 elif which wget > /dev/null; then |
176 wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}" | 178 wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}" |
177 else | 179 else |
178 echo "Neither curl nor wget found. Please install one of these." | 180 echo "Neither curl nor wget found. Please install one of these." |
179 exit 1 | 181 exit 1 |
180 fi | 182 fi |
181 if [ -f "${CDS_OUTPUT}" ]; then | 183 if [ -f "${CDS_OUTPUT}" ]; then |
182 rm -rf "${LLVM_BUILD_DIR}/Release+Asserts" | 184 rm -rf "${LLVM_BUILD_DIR}/Release+Asserts" |
183 mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts" | 185 mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts" |
184 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}/Release+Asserts" | 186 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}/Release+Asserts" |
185 echo clang "${CLANG_REVISION}" unpacked | 187 echo clang "${ARCHIVE_REVISION}" unpacked |
186 echo "${CLANG_REVISION}" > "${STAMP_FILE}" | 188 echo "${ARCHIVE_REVISION}" > "${STAMP_FILE}" |
187 rm -rf "${CDS_OUT_DIR}" | 189 rm -rf "${CDS_OUT_DIR}" |
188 exit 0 | 190 exit 0 |
189 else | 191 else |
190 echo Did not find prebuilt clang at r"${CLANG_REVISION}", building | 192 echo Did not find prebuilt clang at r"${ARCHIVE_REVISION}", building |
191 fi | 193 fi |
192 fi | 194 fi |
193 | 195 |
194 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then | 196 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then |
195 echo "Android NDK not found at ${ANDROID_NDK_DIR}" | 197 echo "Android NDK not found at ${ANDROID_NDK_DIR}" |
196 echo "The Android NDK is needed to build a Clang whose -fsanitize=address" | 198 echo "The Android NDK is needed to build a Clang whose -fsanitize=address" |
197 echo "works on Android. See " | 199 echo "works on Android. See " |
198 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how" | 200 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how" |
199 echo "to install the NDK, or pass --without-android." | 201 echo "to install the NDK, or pass --without-android." |
200 exit 1 | 202 exit 1 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 rm -rf "${TOOL_DST_DIR}" | 306 rm -rf "${TOOL_DST_DIR}" |
305 cp -R "${TOOL_SRC_DIR}" "${TOOL_DST_DIR}" | 307 cp -R "${TOOL_SRC_DIR}" "${TOOL_DST_DIR}" |
306 rm -rf "${TOOL_BUILD_DIR}" | 308 rm -rf "${TOOL_BUILD_DIR}" |
307 mkdir -p "${TOOL_BUILD_DIR}" | 309 mkdir -p "${TOOL_BUILD_DIR}" |
308 cp "${TOOL_SRC_DIR}/Makefile" "${TOOL_BUILD_DIR}" | 310 cp "${TOOL_SRC_DIR}/Makefile" "${TOOL_BUILD_DIR}" |
309 MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}" -C "${TOOL_BUILD_DIR}" | 311 MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}" -C "${TOOL_BUILD_DIR}" |
310 done | 312 done |
311 | 313 |
312 if [[ -n "$run_tests" ]]; then | 314 if [[ -n "$run_tests" ]]; then |
313 # Run a few tests. | 315 # Run a few tests. |
314 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" | 316 for CHROME_TOOL_DIR in ${chrome_tools}; do |
315 "${PLUGIN_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" | 317 TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}" |
| 318 if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then |
| 319 "${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" |
| 320 fi |
| 321 done |
316 cd "${LLVM_BUILD_DIR}" | 322 cd "${LLVM_BUILD_DIR}" |
317 make check-all | 323 make check-all |
318 cd - | 324 cd - |
319 fi | 325 fi |
320 | 326 |
321 # After everything is done, log success for this revision. | 327 # After everything is done, log success for this revision. |
322 echo "${CLANG_REVISION}" > "${STAMP_FILE}" | 328 echo "${ARCHIVE_REVISION}" > "${STAMP_FILE}" |
OLD | NEW |