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 | |
58 if grep -q 'src/third_party/llvm":' "${DEPS_FILE}"; then | 37 if grep -q 'src/third_party/llvm":' "${DEPS_FILE}"; then |
59 echo LLVM pulled in through DEPS, skipping LLVM update step | 38 echo LLVM pulled in through DEPS, skipping LLVM update step |
60 else | 39 else |
61 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" | 40 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" |
62 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ | 41 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
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 | |
68 fi | 42 fi |
69 | 43 |
70 if grep -q 'src/third_party/llvm/tools/clang":' "${DEPS_FILE}"; then | 44 if grep -q 'src/third_party/llvm/tools/clang":' "${DEPS_FILE}"; then |
71 echo clang pulled in through DEPS, skipping clang update step | 45 echo clang pulled in through DEPS, skipping clang update step |
72 else | 46 else |
73 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 47 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
74 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 48 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
75 fi | 49 fi |
76 | 50 |
77 # Echo all commands. | 51 # Echo all commands. |
78 set -x | 52 set -x |
79 | 53 |
80 # Build clang (in a separate directory). | 54 # Build clang (in a separate directory). |
81 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, | 55 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, |
82 # so if you change it you also need to change these links. | 56 # so if you change it you also need to change these links. |
83 mkdir -p "${LLVM_BUILD_DIR}" | 57 mkdir -p "${LLVM_BUILD_DIR}" |
84 cd "${LLVM_BUILD_DIR}" | 58 cd "${LLVM_BUILD_DIR}" |
85 if [ ! -f ./config.status ]; then | 59 if [ ! -f ./config.status ]; then |
86 ../llvm/configure \ | 60 ../llvm/configure \ |
87 --enable-optimized \ | 61 --enable-optimized \ |
88 --disable-threads \ | |
89 --disable-pthreads \ | |
90 --without-llvmgcc \ | 62 --without-llvmgcc \ |
91 --without-llvmgxx | 63 --without-llvmgxx |
92 fi | 64 fi |
93 | 65 |
94 NUM_JOBS=3 | 66 NUM_JOBS=3 |
95 if [ "$(uname -s)" = "Linux" ]; then | 67 if [ "$(uname -s)" = "Linux" ]; then |
96 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" | 68 NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" |
97 elif [ "$(uname -s)" = "Darwin" ]; then | 69 elif [ "$(uname -s)" = "Darwin" ]; then |
98 NUM_JOBS="$(sysctl -n hw.ncpu)" | 70 NUM_JOBS="$(sysctl -n hw.ncpu)" |
99 fi | 71 fi |
100 make -j"${NUM_JOBS}" | 72 make -j"${NUM_JOBS}" |
101 cd - | 73 cd - |
102 | 74 |
103 # Build plugin. | 75 # Build plugin. |
104 # Copy it into the clang tree and use clang's build system to compile the | 76 # Copy it into the clang tree and use clang's build system to compile the |
105 # plugin. | 77 # plugin. |
106 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" | 78 PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" |
107 PLUGIN_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-plugin" | 79 PLUGIN_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-plugin" |
108 PLUGIN_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-plugin" | 80 PLUGIN_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-plugin" |
109 rm -rf "${PLUGIN_DST_DIR}" | 81 rm -rf "${PLUGIN_DST_DIR}" |
110 cp -R "${PLUGIN_SRC_DIR}" "${PLUGIN_DST_DIR}" | 82 cp -R "${PLUGIN_SRC_DIR}" "${PLUGIN_DST_DIR}" |
111 rm -rf "${PLUGIN_BUILD_DIR}" | 83 rm -rf "${PLUGIN_BUILD_DIR}" |
112 mkdir -p "${PLUGIN_BUILD_DIR}" | 84 mkdir -p "${PLUGIN_BUILD_DIR}" |
113 cp "${PLUGIN_SRC_DIR}/Makefile" "${PLUGIN_BUILD_DIR}" | 85 cp "${PLUGIN_SRC_DIR}/Makefile" "${PLUGIN_BUILD_DIR}" |
114 make -j"${NUM_JOBS}" -C "${PLUGIN_BUILD_DIR}" | 86 make -j"${NUM_JOBS}" -C "${PLUGIN_BUILD_DIR}" |
115 | 87 |
116 # After everything is done, log success for this revision. | 88 # After everything is done, log success for this revision. |
117 echo "${CLANG_REVISION}" > "${STAMP_FILE}" | 89 echo "${CLANG_REVISION}" > "${STAMP_FILE}" |
OLD | NEW |