| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 THIS_DIR="$(dirname "${0}")" | 8 THIS_DIR="$(dirname "${0}")" |
| 9 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 9 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
| 10 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" | 10 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 if [ -f "${STAMP_FILE}" ]; then | 27 if [ -f "${STAMP_FILE}" ]; then |
| 28 PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}") | 28 PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}") |
| 29 if [ "${PREVIOUSLY_BUILT_REVISON}" = "${CLANG_REVISION}" ]; then | 29 if [ "${PREVIOUSLY_BUILT_REVISON}" = "${CLANG_REVISION}" ]; then |
| 30 echo "Clang already at ${CLANG_REVISION}" | 30 echo "Clang already at ${CLANG_REVISION}" |
| 31 exit 0 | 31 exit 0 |
| 32 fi | 32 fi |
| 33 fi | 33 fi |
| 34 # To always force a new build if someone interrupts their build half way. | 34 # To always force a new build if someone interrupts their build half way. |
| 35 rm -f "${STAMP_FILE}" | 35 rm -f "${STAMP_FILE}" |
| 36 | 36 |
| 37 # Check if there's a prebuilt binary and if so just fetch that. That's faster, |
| 38 # and goma relies on having matching binary hashes on client and server too. |
| 39 CDS_URL=http://commondatastorage.googleapis.com/chromium-browser-clang |
| 40 CDS_FILE="clang-${CLANG_REVISION}.tgz" |
| 41 echo Trying to download prebuilt clang |
| 42 if [ "$(uname -s)" = "Linux" ]; then |
| 43 wget "${CDS_URL}/Linux_x64/${CDS_FILE}" || rm -f "${CDS_FILE}" |
| 44 elif [ "$(uname -s)" = "Darwin" ]; then |
| 45 curl -L --fail -O "${CDS_URL}/Mac/${CDS_FILE}" || rm -f "${CDS_FILE}" |
| 46 fi |
| 47 if [ -f "${CDS_FILE}" ]; then |
| 48 rm -rf "${LLVM_BUILD_DIR}/Release+Asserts" |
| 49 mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts" |
| 50 tar -xzf "${CDS_FILE}" -C "${LLVM_BUILD_DIR}/Release+Asserts" |
| 51 echo clang "${CLANG_REVISION}" unpacked |
| 52 echo "${CLANG_REVISION}" > "${STAMP_FILE}" |
| 53 exit 0 |
| 54 else |
| 55 echo Did not find prebuilt clang at r"${CLANG_REVISION}", building |
| 56 fi |
| 57 |
| 37 if grep -q 'src/third_party/llvm":' "${DEPS_FILE}"; then | 58 if grep -q 'src/third_party/llvm":' "${DEPS_FILE}"; then |
| 38 echo LLVM pulled in through DEPS, skipping LLVM update step | 59 echo LLVM pulled in through DEPS, skipping LLVM update step |
| 39 else | 60 else |
| 40 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" | 61 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" |
| 41 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" | 62 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ |
| 63 "${LLVM_DIR}"; then |
| 64 echo Checkout failed, retrying |
| 65 rm -rf "${LLVM_DIR}" |
| 66 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
| 67 fi |
| 42 fi | 68 fi |
| 43 | 69 |
| 44 if grep -q 'src/third_party/llvm/tools/clang":' "${DEPS_FILE}"; then | 70 if grep -q 'src/third_party/llvm/tools/clang":' "${DEPS_FILE}"; then |
| 45 echo clang pulled in through DEPS, skipping clang update step | 71 echo clang pulled in through DEPS, skipping clang update step |
| 46 else | 72 else |
| 47 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 73 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
| 48 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 74 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
| 49 fi | 75 fi |
| 50 | 76 |
| 51 # Echo all commands. | 77 # Echo all commands. |
| 52 set -x | 78 set -x |
| 53 | 79 |
| 54 # Build clang (in a separate directory). | 80 # Build clang (in a separate directory). |
| 55 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, | 81 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, |
| 56 # so if you change it you also need to change these links. | 82 # so if you change it you also need to change these links. |
| 57 mkdir -p "${LLVM_BUILD_DIR}" | 83 mkdir -p "${LLVM_BUILD_DIR}" |
| 58 cd "${LLVM_BUILD_DIR}" | 84 cd "${LLVM_BUILD_DIR}" |
| 59 if [ ! -f ./config.status ]; then | 85 if [ ! -f ./config.status ]; then |
| 60 ../llvm/configure \ | 86 ../llvm/configure \ |
| 61 --enable-optimized \ | 87 --enable-optimized \ |
| 88 --disable-threads \ |
| 89 --disable-pthreads \ |
| 62 --without-llvmgcc \ | 90 --without-llvmgcc \ |
| 63 --without-llvmgxx | 91 --without-llvmgxx |
| 64 fi | 92 fi |
| 65 | 93 |
| 66 NUM_JOBS=3 | 94 NUM_JOBS=3 |
| 67 if [ "$(uname -s)" = "Linux" ]; then | 95 if [ "$(uname -s)" = "Linux" ]; then |
| 68 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" | 96 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" |
| 69 elif [ "$(uname -s)" = "Darwin" ]; then | 97 elif [ "$(uname -s)" = "Darwin" ]; then |
| 70 NUM_JOBS="$(sysctl -n hw.ncpu)" | 98 NUM_JOBS="$(sysctl -n hw.ncpu)" |
| 71 fi | 99 fi |
| 72 make -j"${NUM_JOBS}" | 100 make -j"${NUM_JOBS}" |
| 73 cd - | 101 cd - |
| 74 | 102 |
| 75 # Build plugin. | 103 # Build plugin. |
| 76 # Copy it into the clang tree and use clang's build system to compile the | 104 # Copy it into the clang tree and use clang's build system to compile the |
| 77 # plugin. | 105 # plugin. |
| 78 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" | 106 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" |
| 79 PLUGIN_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-plugin" | 107 PLUGIN_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-plugin" |
| 80 PLUGIN_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-plugin" | 108 PLUGIN_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-plugin" |
| 81 rm -rf "${PLUGIN_DST_DIR}" | 109 rm -rf "${PLUGIN_DST_DIR}" |
| 82 cp -R "${PLUGIN_SRC_DIR}" "${PLUGIN_DST_DIR}" | 110 cp -R "${PLUGIN_SRC_DIR}" "${PLUGIN_DST_DIR}" |
| 83 rm -rf "${PLUGIN_BUILD_DIR}" | 111 rm -rf "${PLUGIN_BUILD_DIR}" |
| 84 mkdir -p "${PLUGIN_BUILD_DIR}" | 112 mkdir -p "${PLUGIN_BUILD_DIR}" |
| 85 cp "${PLUGIN_SRC_DIR}/Makefile" "${PLUGIN_BUILD_DIR}" | 113 cp "${PLUGIN_SRC_DIR}/Makefile" "${PLUGIN_BUILD_DIR}" |
| 86 make -j"${NUM_JOBS}" -C "${PLUGIN_BUILD_DIR}" | 114 make -j"${NUM_JOBS}" -C "${PLUGIN_BUILD_DIR}" |
| 87 | 115 |
| 88 # After everything is done, log success for this revision. | 116 # After everything is done, log success for this revision. |
| 89 echo "${CLANG_REVISION}" > "${STAMP_FILE}" | 117 echo "${CLANG_REVISION}" > "${STAMP_FILE}" |
| OLD | NEW |