Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (C) 2017 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import argparse |
| 17 | import hashlib |
| 18 | import logging |
| 19 | import os |
| 20 | import shutil |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 21 | import subprocess |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 22 | import sys |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 23 | import tempfile |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 24 | import urllib |
| 25 | import zipfile |
| 26 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 27 | from collections import namedtuple |
| 28 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 29 | # The format for the deps below is the following: |
| 30 | # (target_folder, source_url, sha1, target_platform) |
| 31 | # |source_url| can be either a git repo or a http url. |
| 32 | # If a git repo, |sha1| is the committish that will be checked out. |
| 33 | # If a http url, |sha1| is the shasum of the original file. |
| 34 | # If the url is a .zip or .tgz file it will be automatically deflated under |
| 35 | # |target_folder|, taking care of stripping the root folder if it's a single |
| 36 | # root (to avoid ending up with buildtools/protobuf/protobuf-1.2.3/... and have |
| 37 | # instead just buildtools/protobuf). |
| 38 | # |target_platform| is either 'darwin', 'linux2' or 'all' and applies the dep |
| 39 | # only on the given platform (ask python why linux2 and not just linux). |
| 40 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 41 | # Dependencies required to build code on the host or when targeting desktop OS. |
| 42 | BUILD_DEPS_HOST = [ |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 43 | # GN |
| 44 | ('buildtools/mac/gn', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 45 | 'https://storage.googleapis.com/perfetto/gn-mac-b5b65ca39d93a7cde9fa713be31b114755252f28', |
| 46 | 'b5b65ca39d93a7cde9fa713be31b114755252f28', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 47 | 'darwin' |
| 48 | ), |
| 49 | ('buildtools/linux64/gn', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 50 | 'https://storage.googleapis.com/perfetto/gn-linux64-1370d9c5358868b7b66292821b6fe61950826870', |
| 51 | '1370d9c5358868b7b66292821b6fe61950826870', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 52 | 'linux2' |
| 53 | ), |
| 54 | |
Primiano Tucci | 104bd6d | 2017-10-12 00:10:24 +0200 | [diff] [blame] | 55 | # clang-format |
| 56 | ('buildtools/mac/clang-format', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 57 | 'https://storage.googleapis.com/chromium-clang-format/025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', |
| 58 | '025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', |
Primiano Tucci | 104bd6d | 2017-10-12 00:10:24 +0200 | [diff] [blame] | 59 | 'darwin' |
| 60 | ), |
| 61 | ('buildtools/linux64/clang-format', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 62 | 'https://storage.googleapis.com/chromium-clang-format/942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', |
| 63 | '942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', |
Primiano Tucci | 104bd6d | 2017-10-12 00:10:24 +0200 | [diff] [blame] | 64 | 'linux2' |
| 65 | ), |
| 66 | # Keep the SHA1 in sync with |clang_format_rev| in chromium //buildtools/DEPS. |
| 67 | ('buildtools/clang_format/script', |
| 68 | 'https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 69 | '96636aa0e9f047f17447f2d45a094d0b59ed7917', |
Primiano Tucci | 104bd6d | 2017-10-12 00:10:24 +0200 | [diff] [blame] | 70 | 'all' |
| 71 | ), |
| 72 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 73 | # Ninja |
| 74 | ('buildtools/mac/ninja', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 75 | 'https://storage.googleapis.com/perfetto/ninja-mac-c15b0698da038b2bd2e8970c14c75fadc06b1add', |
| 76 | 'c15b0698da038b2bd2e8970c14c75fadc06b1add', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 77 | 'darwin' |
| 78 | ), |
| 79 | ('buildtools/linux64/ninja', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 80 | 'https://storage.googleapis.com/perfetto/ninja-linux64-c866952bda50c29a669222477309287119bbb7e8', |
| 81 | 'c866952bda50c29a669222477309287119bbb7e8', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 82 | 'linux2' |
| 83 | ), |
| 84 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 85 | # Keep in sync with Android's //external/googletest/README.version. |
| 86 | ('buildtools/googletest.zip', |
| 87 | 'https://github.com/google/googletest/archive/ff07a5de0e81580547f1685e101194ed1a4fcd56.zip', |
| 88 | 'c7edec7d7e6db1fc37a20710de9c4d89e3a3893b', |
| 89 | 'all' |
| 90 | ), |
| 91 | |
Primiano Tucci | 1191e18 | 2019-08-25 06:36:56 +0200 | [diff] [blame] | 92 | # Keep in sync with Android's //external/protobuf/README.version. |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 93 | ('buildtools/protobuf.zip', |
Primiano Tucci | 1191e18 | 2019-08-25 06:36:56 +0200 | [diff] [blame] | 94 | 'https://github.com/google/protobuf/releases/download/v3.0.0-beta-3/protobuf-cpp-3.0.0-beta-3.zip', |
| 95 | '3caec60aa9d8eefc8c3c3201b6b8ca19935edb89', |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 96 | 'all' |
| 97 | ), |
| 98 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 99 | # libc++, libc++abi and libunwind for Linux where we need to rebuild the C++ |
| 100 | # lib from sources. Keep the SHA1s in sync with Chrome's src/buildtools/DEPS. |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 101 | ('buildtools/libcxx', |
| 102 | 'https://chromium.googlesource.com/chromium/llvm-project/libcxx.git', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 103 | '5938e0582bac570a41edb3d6a2217c299adc1bc6', |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 104 | 'all' |
| 105 | ), |
| 106 | ('buildtools/libcxxabi', |
| 107 | 'https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 108 | '0d529660e32d77d9111912d73f2c74fc5fa2a858', |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 109 | 'all' |
| 110 | ), |
Primiano Tucci | 7278dea | 2017-10-31 11:50:32 +0000 | [diff] [blame] | 111 | ('buildtools/libunwind', |
| 112 | 'https://chromium.googlesource.com/external/llvm.org/libunwind.git', |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 113 | '69d9b84cca8354117b9fe9705a4430d789ee599b', |
Primiano Tucci | 7278dea | 2017-10-31 11:50:32 +0000 | [diff] [blame] | 114 | 'all' |
| 115 | ), |
Hector Dearman | 88a1011 | 2017-10-12 11:07:10 +0100 | [diff] [blame] | 116 | |
Primiano Tucci | 335412d | 2019-05-30 16:29:16 +0100 | [diff] [blame] | 117 | # Keep the revision in sync with Chrome's PACKAGE_VERSION in |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 118 | # tools/clang/scripts/update.py. |
| 119 | ('buildtools/clang.tgz', |
Primiano Tucci | d4aa37b | 2019-08-21 13:38:06 +0200 | [diff] [blame] | 120 | 'https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-365097-f7e52fbd-8.tgz', |
| 121 | 'fe1b1e5bd7381ae655661cb9658487389561568d', |
Primiano Tucci | a65497e | 2018-09-26 19:53:58 +0100 | [diff] [blame] | 122 | 'linux2' |
| 123 | ), |
| 124 | |
| 125 | # Keep in sync with chromium DEPS. |
| 126 | ('buildtools/libfuzzer', |
| 127 | 'https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git', |
Florian Mayer | a85b8fa | 2019-07-11 11:00:48 +0100 | [diff] [blame] | 128 | 'b9f51dc8c98065df0c8da13c051046f5bab833db', |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 129 | 'linux2' |
| 130 | ), |
| 131 | |
Hector Dearman | 88a1011 | 2017-10-12 11:07:10 +0100 | [diff] [blame] | 132 | # Benchmarking tool. |
| 133 | ('buildtools/benchmark.zip', |
Lalit Maganti | c99d93c | 2018-03-22 15:09:30 +0000 | [diff] [blame] | 134 | 'https://github.com/google/benchmark/archive/v1.3.0.zip', |
| 135 | 'f387e0df37d54bfd5be239e8d0d3ea2e2c3e34f4', |
Hector Dearman | 88a1011 | 2017-10-12 11:07:10 +0100 | [diff] [blame] | 136 | 'all' |
| 137 | ), |
Primiano Tucci | 38faa6f | 2018-04-01 20:12:08 +0200 | [diff] [blame] | 138 | |
| 139 | # Libbacktrace, for stacktraces in Linux/Android debug builds. |
| 140 | ('buildtools/libbacktrace.zip', |
| 141 | 'https://github.com/ianlancetaylor/libbacktrace/archive/177940370e4a6b2509e92a0aaa9749184e64af43.zip', |
| 142 | 'b723fe9d671d1ab54df1297f6afbf2893a41c3ea', |
| 143 | 'all' |
| 144 | ), |
Lalit Maganti | 6fe26e6 | 2018-05-23 12:14:38 +0100 | [diff] [blame] | 145 | |
| 146 | # Sqlite for the trace processing library. |
Ioannis Ilkos | 178535e | 2018-11-05 17:32:45 +0000 | [diff] [blame] | 147 | # This is the amalgamated source whose compiled output is meant to be faster. |
| 148 | # We still pull the full source for the extensions (not amalgamated). |
Lalit Maganti | 6fe26e6 | 2018-05-23 12:14:38 +0100 | [diff] [blame] | 149 | ('buildtools/sqlite.zip', |
Lalit Maganti | 10d6deb | 2018-11-20 15:15:50 +0000 | [diff] [blame] | 150 | 'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3250300.zip', |
| 151 | 'b78c2cb0d2c9182686c582312479f96a82bf5380', |
Lalit Maganti | 6fe26e6 | 2018-05-23 12:14:38 +0100 | [diff] [blame] | 152 | 'all' |
| 153 | ), |
Ioannis Ilkos | 178535e | 2018-11-05 17:32:45 +0000 | [diff] [blame] | 154 | ('buildtools/sqlite_src.zip', |
Lalit Maganti | 10d6deb | 2018-11-20 15:15:50 +0000 | [diff] [blame] | 155 | 'https://storage.googleapis.com/perfetto/sqlite-src-3250300.zip', |
| 156 | 'd1af2883bb800852946f9bf8ab6055e7698e18ee', |
Ioannis Ilkos | 178535e | 2018-11-05 17:32:45 +0000 | [diff] [blame] | 157 | 'all' |
| 158 | ), |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 159 | |
| 160 | # JsonCpp for legacy json import. Used only by the trace processor in |
| 161 | # standalone builds. |
| 162 | ('buildtools/jsoncpp.zip', |
Lalit Maganti | 36d229a | 2019-07-12 10:09:39 +0000 | [diff] [blame] | 163 | 'https://github.com/open-source-parsers/jsoncpp/archive/1.0.0.zip', |
| 164 | '3219e26f2e249bb46b7d688478208c7ec138fea4', |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 165 | 'all' |
| 166 | ), |
Florian Mayer | 475bd7e | 2018-08-07 20:04:03 +0100 | [diff] [blame] | 167 | |
Florian Mayer | f833566 | 2018-08-08 11:30:32 +0100 | [diff] [blame] | 168 | # These dependencies are for libunwindstack, which is used by src/profiling. |
| 169 | ('buildtools/android-core', |
Florian Mayer | 475bd7e | 2018-08-07 20:04:03 +0100 | [diff] [blame] | 170 | 'https://android.googlesource.com/platform/system/core.git', |
Florian Mayer | 96e1f08 | 2019-07-10 10:42:01 +0100 | [diff] [blame] | 171 | '3f407fcc37b401c91784700c0a691ba8b1f7ef15', |
Florian Mayer | 475bd7e | 2018-08-07 20:04:03 +0100 | [diff] [blame] | 172 | 'all' |
| 173 | ), |
| 174 | |
| 175 | ('buildtools/lzma', |
| 176 | 'https://android.googlesource.com/platform/external/lzma.git', |
| 177 | '7851dce6f4ca17f5caa1c93a4e0a45686b1d56c3', |
| 178 | 'all' |
| 179 | ), |
Hector Dearman | 7f71d0e | 2018-08-09 11:26:10 +0100 | [diff] [blame] | 180 | |
Hector Dearman | e0b993f | 2019-05-24 18:48:16 +0100 | [diff] [blame] | 181 | ('buildtools/zlib', |
| 182 | 'https://android.googlesource.com/platform/external/zlib.git', |
| 183 | 'dfa0646a03b4e1707469e04dc931b09774968fe6', |
| 184 | 'all' |
| 185 | ), |
| 186 | |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 187 | ('buildtools/bionic', |
| 188 | 'https://android.googlesource.com/platform/bionic.git', |
Primiano Tucci | 1721b1a | 2019-02-17 14:18:07 +0000 | [diff] [blame] | 189 | 'a60488109cda997dfd83832731c8527feaa2825e', |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 190 | 'all' |
| 191 | ), |
| 192 | |
Hector Dearman | 7f71d0e | 2018-08-09 11:26:10 +0100 | [diff] [blame] | 193 | # Example traces for regression tests. |
| 194 | ('buildtools/test_data.zip', |
Ryan Savitski | 9f5e33a | 2019-09-24 16:39:51 +0100 | [diff] [blame] | 195 | 'https://storage.googleapis.com/perfetto/test-data-20190920-011709.zip', |
| 196 | '75fc970bf2778d506c9d77f94a6381b04f10b692', |
Hector Dearman | 7f71d0e | 2018-08-09 11:26:10 +0100 | [diff] [blame] | 197 | 'all', |
| 198 | ), |
Hector Dearman | e44ad45 | 2018-09-21 11:51:57 +0100 | [diff] [blame] | 199 | |
Primiano Tucci | 21d41a7 | 2018-09-24 23:12:04 +0100 | [diff] [blame] | 200 | # Linenoise, used only by trace_processor in standalone builds. |
Hector Dearman | e44ad45 | 2018-09-21 11:51:57 +0100 | [diff] [blame] | 201 | ('buildtools/linenoise', |
Primiano Tucci | 21d41a7 | 2018-09-24 23:12:04 +0100 | [diff] [blame] | 202 | 'https://fuchsia.googlesource.com/third_party/linenoise.git', |
| 203 | 'c894b9e59f02203dbe4e2be657572cf88c4230c3', |
Hector Dearman | e44ad45 | 2018-09-21 11:51:57 +0100 | [diff] [blame] | 204 | 'all' |
| 205 | ), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 206 | ] |
| 207 | |
| 208 | # Dependencies required to build Android code. |
| 209 | # URLs and SHA1s taken from: |
| 210 | # - https://dl.google.com/android/repository/repository-11.xml |
| 211 | # - https://dl.google.com/android/repository/sys-img/android/sys-img.xml |
| 212 | BUILD_DEPS_ANDROID = [ |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 213 | # Android NDK |
| 214 | ('buildtools/ndk.zip', |
Florian Mayer | aa5316b | 2018-08-20 17:45:12 -0700 | [diff] [blame] | 215 | 'https://dl.google.com/android/repository/android-ndk-r17b-darwin-x86_64.zip', |
| 216 | 'f990aafaffec0b583d2c5420bfa622e52ac14248', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 217 | 'darwin' |
| 218 | ), |
| 219 | ('buildtools/ndk.zip', |
Florian Mayer | aa5316b | 2018-08-20 17:45:12 -0700 | [diff] [blame] | 220 | 'https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip', |
| 221 | 'dd5762ee7ef4995ad04fe0c45a608c344d99ca9f', |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 222 | 'linux2' |
| 223 | ), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 224 | ] |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 225 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 226 | # Dependencies required to run Android tests. |
| 227 | TEST_DEPS_ANDROID = [ |
Lalit Maganti | 367fcd5 | 2018-02-05 16:06:13 +0000 | [diff] [blame] | 228 | # Android emulator images. |
| 229 | ('buildtools/aosp-arm.zip', |
| 230 | 'https://storage.googleapis.com/perfetto/aosp-02022018-arm.zip', |
| 231 | 'a480d5e7d3ca888b0a58fe15ce76b1791537429a', |
Primiano Tucci | e7ca7c6 | 2018-04-07 08:28:03 +0200 | [diff] [blame] | 232 | 'all' |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 233 | ), |
| 234 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 235 | # platform-tools.zip contains adb binaries. |
| 236 | ('buildtools/android_sdk/platform-tools.zip', |
| 237 | 'https://dl.google.com/android/repository/platform-tools_r26.0.0-darwin.zip', |
| 238 | 'e75b6137dc444f777eb02f44a6d9819b3aabff82', |
| 239 | 'darwin' |
| 240 | ), |
| 241 | ('buildtools/android_sdk/platform-tools.zip', |
| 242 | 'https://dl.google.com/android/repository/platform-tools_r26.0.0-linux.zip', |
| 243 | '00de8a6631405b617c10f68cd11ff2e1cd528e23', |
| 244 | 'linux2' |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 245 | ), |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 246 | |
Lalit Maganti | 367fcd5 | 2018-02-05 16:06:13 +0000 | [diff] [blame] | 247 | # Android emulator binaries. |
| 248 | ('buildtools/emulator', |
| 249 | 'https://android.googlesource.com/platform/prebuilts/android-emulator.git', |
| 250 | '4b260028dc27bc92c39bee9129cb2ba839970956', |
| 251 | 'all' |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 252 | ), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 253 | ] |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 254 | |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 255 | # This variable is updated by tools/roll-catapult-trace-viewer. |
| 256 | CATAPULT_SHA1 = 'ff5d8fd7244680b4d4456c25d5fdc04c76f9ef66' |
| 257 | |
Hector Dearman | 6177b75 | 2019-01-24 10:17:32 +0000 | [diff] [blame] | 258 | TYPEFACES_SHA1 = '756b0a015b8f99f5718f7fdf967d052c1ec55ab3' |
| 259 | |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 260 | UI_DEPS = [ |
| 261 | ('buildtools/nodejs.tgz', |
Primiano Tucci | dca9609 | 2018-05-31 11:47:16 +0100 | [diff] [blame] | 262 | 'https://storage.googleapis.com/perfetto/node-v10.3.0-darwin-x64.tar.gz', |
| 263 | '6d9a122785f38c256add3b25f74adf125497861a', |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 264 | 'darwin' |
| 265 | ), |
| 266 | ('buildtools/nodejs.tgz', |
Primiano Tucci | dca9609 | 2018-05-31 11:47:16 +0100 | [diff] [blame] | 267 | 'https://storage.googleapis.com/perfetto/node-v10.3.0-linux-x64.tar.xz', |
| 268 | '118f6ea19f75089b3f12ac2ddfce357bff872b5e', |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 269 | 'linux2' |
| 270 | ), |
| 271 | ('buildtools/emsdk/emscripten.tgz', |
| 272 | 'https://storage.googleapis.com/perfetto/emscripten-1.37.40.tar.gz', |
| 273 | '588c28221321ebbdfc8e3a6f47ea6106f589669b', |
| 274 | 'all' |
| 275 | ), |
| 276 | ('buildtools/emsdk/llvm.tgz', |
| 277 | 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-darwin.tar.gz', |
| 278 | '7a894ef0a52821c62f6abaac552dc4ce5d424607', |
| 279 | 'darwin' |
| 280 | ), |
| 281 | ('buildtools/emsdk/llvm.tgz', |
Primiano Tucci | fe19990 | 2018-06-04 12:33:04 +0200 | [diff] [blame] | 282 | 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-static-linux.tar.gz', |
| 283 | '478501b9b7a14884e546c84efe209a90052cbb07', |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 284 | 'linux2' |
| 285 | ), |
Hector Dearman | d9628d3 | 2018-10-17 14:38:26 +0100 | [diff] [blame] | 286 | ('buildtools/d8.tgz', |
| 287 | 'https://storage.googleapis.com/perfetto/d8-linux2-5.7.492.65.tar.gz', |
| 288 | '95e82ad7faf0a6f74d950c2aa65e3858b7bdb6c6', |
| 289 | 'linux2' |
| 290 | ), |
| 291 | ('buildtools/d8.tgz', |
| 292 | 'https://storage.googleapis.com/perfetto/d8-darwin-6.6.346.32.tar.gz', |
| 293 | '1abd630619bb1977ab62095570a113d782a1545d', |
| 294 | 'darwin' |
| 295 | ), |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 296 | ('buildtools/catapult_trace_viewer.tgz', |
| 297 | 'https://storage.googleapis.com/perfetto/catapult_trace_viewer-%s.tar.gz' % CATAPULT_SHA1, |
| 298 | CATAPULT_SHA1, |
| 299 | 'all' |
| 300 | ), |
Hector Dearman | 6177b75 | 2019-01-24 10:17:32 +0000 | [diff] [blame] | 301 | ('buildtools/typefaces.tgz', |
| 302 | 'https://storage.googleapis.com/perfetto/typefaces-%s.tar.gz' % TYPEFACES_SHA1, |
| 303 | TYPEFACES_SHA1, |
| 304 | 'all' |
| 305 | ) |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 306 | ] |
| 307 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 308 | ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 309 | |
| 310 | |
| 311 | def ReadFile(path): |
| 312 | if not os.path.exists(path): |
| 313 | return None |
| 314 | with open(path) as f: |
| 315 | return f.read().strip() |
| 316 | |
| 317 | |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 318 | def MkdirRecursive(path): |
| 319 | # Works with both relative and absolute paths |
| 320 | cwd = '/' if path.startswith('/') else ROOT_DIR |
| 321 | for part in path.split('/'): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 322 | cwd = os.path.join(cwd, part) |
| 323 | if not os.path.exists(cwd): |
| 324 | os.makedirs(cwd) |
| 325 | else: |
| 326 | assert(os.path.isdir(cwd)) |
| 327 | |
| 328 | |
| 329 | def HashLocalFile(path): |
| 330 | if not os.path.exists(path): |
| 331 | return None |
| 332 | with open(path, 'rb') as f: |
| 333 | return hashlib.sha1(f.read()).hexdigest() |
| 334 | |
| 335 | |
| 336 | def ExtractZipfilePreservePermissions(zf, info, path): |
| 337 | zf.extract(info.filename, path=path) |
| 338 | target_path = os.path.join(path, info.filename) |
| 339 | min_acls = 0o755 if info.filename.endswith('/') else 0o644 |
| 340 | os.chmod(target_path, (info.external_attr >> 16L) | min_acls) |
| 341 | |
| 342 | |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 343 | def IsGitRepoCheckoutOutAtRevision(path, revision): |
| 344 | return ReadFile(os.path.join(path, '.git', 'HEAD')) == revision |
| 345 | |
| 346 | |
| 347 | def CheckoutGitRepo(path, git_url, revision): |
| 348 | if IsGitRepoCheckoutOutAtRevision(path, revision): |
Eric Seckler | 676421f | 2019-02-12 14:43:31 +0000 | [diff] [blame] | 349 | return False |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 350 | if os.path.exists(path): |
| 351 | shutil.rmtree(path) |
| 352 | MkdirRecursive(path) |
| 353 | logging.info('Fetching %s @ %s into %s', git_url, revision, path) |
Lalit Maganti | 367fcd5 | 2018-02-05 16:06:13 +0000 | [diff] [blame] | 354 | subprocess.check_call(['git', 'init', path], cwd=path) |
| 355 | subprocess.check_call( |
Ryan Savitski | e957ce8 | 2018-11-06 14:53:33 +0000 | [diff] [blame] | 356 | ['git', 'fetch', '--quiet', '--depth', '1', git_url, revision], cwd=path) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 357 | subprocess.check_call(['git', 'checkout', revision, '--quiet'], cwd=path) |
| 358 | assert(IsGitRepoCheckoutOutAtRevision(path, revision)) |
Eric Seckler | 676421f | 2019-02-12 14:43:31 +0000 | [diff] [blame] | 359 | return True |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 360 | |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 361 | |
Deepanjan Roy | acf8c07 | 2018-07-13 11:37:04 -0400 | [diff] [blame] | 362 | def InstallNodeModules(): |
| 363 | ui_dir = os.path.join(ROOT_DIR, 'ui') |
| 364 | logging.info("Running npm install in {0}".format(ui_dir)) |
| 365 | subprocess.check_call( |
| 366 | [os.path.join(ui_dir, 'npm'), 'install', '--no-save'], |
| 367 | cwd=os.path.join(ROOT_DIR, 'ui')) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 368 | |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 369 | |
| 370 | def CheckHashes(): |
| 371 | for deps in [BUILD_DEPS_HOST, |
| 372 | BUILD_DEPS_ANDROID, |
| 373 | TEST_DEPS_ANDROID, |
| 374 | UI_DEPS]: |
| 375 | for rel_path, url, expected_sha1, platform in deps: |
| 376 | if url.endswith('.git'): |
| 377 | continue |
| 378 | logging.info('Downloading %s from %s', rel_path, url) |
| 379 | with tempfile.NamedTemporaryFile(delete=False) as f: |
| 380 | f.close() |
| 381 | urllib.urlretrieve(url, f.name) |
| 382 | actual_sha1 = HashLocalFile(f.name) |
| 383 | os.unlink(f.name) |
| 384 | if (actual_sha1 != expected_sha1): |
| 385 | logging.fatal('SHA1 mismatch for {} expected {} was {}'.format( |
| 386 | url, expected_sha1, actual_sha1)) |
| 387 | |
| 388 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 389 | def Main(): |
| 390 | parser = argparse.ArgumentParser() |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 391 | parser.add_argument('--no-android', action='store_true') |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 392 | parser.add_argument('--ui', action='store_true') |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 393 | parser.add_argument('--check-hashes', help='Check hashes for all URLs', |
| 394 | action='store_true') |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 395 | args = parser.parse_args() |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 396 | if args.check_hashes: |
| 397 | CheckHashes() |
| 398 | return 0 |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 399 | deps = BUILD_DEPS_HOST |
| 400 | if not args.no_android: |
| 401 | deps += BUILD_DEPS_ANDROID + TEST_DEPS_ANDROID |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 402 | if args.ui: |
| 403 | deps += UI_DEPS |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 404 | deps_updated = False |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 405 | for rel_path, url, expected_sha1, platform in deps: |
Lalit Maganti | 367fcd5 | 2018-02-05 16:06:13 +0000 | [diff] [blame] | 406 | if (platform != 'all' and platform != sys.platform): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 407 | continue |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 408 | local_path = os.path.join(ROOT_DIR, rel_path) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 409 | if url.endswith('.git'): |
Eric Seckler | 676421f | 2019-02-12 14:43:31 +0000 | [diff] [blame] | 410 | deps_updated |= CheckoutGitRepo(local_path, url, expected_sha1) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 411 | continue |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 412 | is_zip = local_path.endswith('.zip') or local_path.endswith('.tgz') |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 413 | zip_target_dir = local_path[:-4] if is_zip else None |
| 414 | zip_dir_stamp = os.path.join(zip_target_dir, '.stamp') if is_zip else None |
| 415 | |
| 416 | if ((not is_zip and HashLocalFile(local_path) == expected_sha1) or |
| 417 | (is_zip and ReadFile(zip_dir_stamp) == expected_sha1)): |
| 418 | continue |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 419 | deps_updated = True |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 420 | MkdirRecursive(os.path.dirname(rel_path)) |
| 421 | if HashLocalFile(local_path) != expected_sha1: |
| 422 | download_path = local_path + '.tmp' |
| 423 | logging.info('Downloading %s from %s', local_path, url) |
| 424 | urllib.urlretrieve(url, download_path) |
| 425 | os.chmod(download_path, 0o755) |
Hector Dearman | d9628d3 | 2018-10-17 14:38:26 +0100 | [diff] [blame] | 426 | actual_sha1 = HashLocalFile(download_path) |
| 427 | if (actual_sha1 != expected_sha1): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 428 | os.remove(download_path) |
Hector Dearman | d9628d3 | 2018-10-17 14:38:26 +0100 | [diff] [blame] | 429 | logging.fatal('SHA1 mismatch for {} expected {} was {}'.format( |
| 430 | download_path, expected_sha1, actual_sha1)) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 431 | return 1 |
| 432 | os.rename(download_path, local_path) |
| 433 | assert(HashLocalFile(local_path) == expected_sha1) |
| 434 | |
| 435 | if is_zip: |
| 436 | logging.info('Extracting %s into %s' % (local_path, zip_target_dir)) |
| 437 | assert(os.path.commonprefix((ROOT_DIR, zip_target_dir)) == ROOT_DIR) |
| 438 | if os.path.exists(zip_target_dir): |
| 439 | logging.info('Deleting stale dir %s' % zip_target_dir) |
| 440 | shutil.rmtree(zip_target_dir) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 441 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 442 | # Decompress the archive. |
| 443 | if local_path.endswith('.tgz'): |
| 444 | MkdirRecursive(zip_target_dir) |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 445 | subprocess.check_call(['tar', '-xf', local_path], cwd=zip_target_dir) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 446 | elif local_path.endswith('.zip'): |
| 447 | with zipfile.ZipFile(local_path, 'r') as zf: |
| 448 | for info in zf.infolist(): |
| 449 | ExtractZipfilePreservePermissions(zf, info, zip_target_dir) |
| 450 | |
| 451 | # If the zip contains one root folder, rebase one level up moving all |
| 452 | # its sub files and folders inside |target_dir|. |
| 453 | subdir = os.listdir(zip_target_dir) |
| 454 | if len(subdir) == 1: |
| 455 | subdir = os.path.join(zip_target_dir, subdir[0]) |
| 456 | if os.path.isdir(subdir): |
| 457 | for subf in os.listdir(subdir): |
| 458 | shutil.move(os.path.join(subdir,subf), zip_target_dir) |
| 459 | os.rmdir(subdir) |
| 460 | |
| 461 | # Create stamp and remove the archive. |
| 462 | with open(zip_dir_stamp, 'w') as stamp_file: |
| 463 | stamp_file.write(expected_sha1) |
| 464 | os.remove(local_path) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 465 | |
Deepanjan Roy | acf8c07 | 2018-07-13 11:37:04 -0400 | [diff] [blame] | 466 | if args.ui: |
| 467 | # Needs to happen after nodejs is installed above. |
| 468 | InstallNodeModules() |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 469 | |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 470 | if deps_updated: |
| 471 | # Stale binary files may be compiled against old sysroot headers that aren't |
| 472 | # tracked by gn. |
| 473 | logging.warn('Remember to run "gn clean <output_directory>" ' + |
| 474 | 'to avoid stale binary files.') |
| 475 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 476 | if __name__ == '__main__': |
| 477 | logging.basicConfig(level=logging.INFO) |
| 478 | sys.exit(Main()) |