Primiano Tucci | 34bc559 | 2021-02-19 17:53:36 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 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 |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 17 | import dataclasses as dc |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 18 | import hashlib |
| 19 | import logging |
| 20 | import os |
| 21 | import shutil |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 22 | import subprocess |
Primiano Tucci | 857ed73 | 2020-12-19 18:11:42 +0100 | [diff] [blame] | 23 | import stat |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 24 | import sys |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 25 | import tempfile |
Primiano Tucci | 16fed02 | 2023-05-05 17:11:32 +0100 | [diff] [blame] | 26 | import time |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 27 | import zipfile |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 28 | import bz2 |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 29 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 30 | from collections import namedtuple |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 31 | from platform import system, machine |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 32 | |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 33 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 34 | # The format for the deps below is the following: |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 35 | # (target_folder, source_url, sha1, target_os, target_arch) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 36 | # |source_url| can be either a git repo or a http url. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 37 | # If a git repo, |checksum| is the SHA1 committish that will be checked out. |
| 38 | # If a http url, |checksum| is the SHA256 of the downloaded file. |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 39 | # If the url is a .zip, .tgz, or .tbz2 file it will be automatically deflated under |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 40 | # |target_folder|, taking care of stripping the root folder if it's a single |
| 41 | # root (to avoid ending up with buildtools/protobuf/protobuf-1.2.3/... and have |
| 42 | # instead just buildtools/protobuf). |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 43 | # |target_os| is either 'darwin', 'linux', 'windows' or 'all' |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 44 | # |target_arch| is either 'x64', 'arm64' or 'all' |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 45 | # in both cases the dep only applies on matching platforms |
| 46 | # |target_arch| can be 'all' when 'target_os' is not 'all' for example in the |
| 47 | # case of MacOS universal binaries. |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 48 | @dc.dataclass |
| 49 | class Dependency: |
| 50 | target_folder: str |
| 51 | source_url: str |
| 52 | checksum: str |
| 53 | target_os: str |
| 54 | target_arch: str |
| 55 | submodules: bool = False |
| 56 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 57 | |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 58 | # This is to remove old directories when build tools get {re,}moved. This is to |
| 59 | # avoid accidentally referring to stale dir in custom user scripts. |
| 60 | CLEANUP_OLD_DIRS = [ |
| 61 | 'buildtools/nodejs', # Moved to buildtools/{mac,linux64}/nodejs |
| 62 | 'buildtools/emsdk', # Moved to buildtools/{mac,linux64}/emsdk |
| 63 | 'buildtools/test_data', # Moved to test/data by r.android.com/1539381 . |
| 64 | 'buildtools/d8', # Removed by r.android.com/1424334 . |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 65 | |
Hector Dearman | d310930 | 2023-12-07 20:32:05 +0000 | [diff] [blame^] | 66 | # Build tools moved to third_party/ by r.android.com/2327602 . |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 67 | 'buildtools/mac/clang-format', |
| 68 | 'buildtools/mac/gn', |
| 69 | 'buildtools/mac/ninja', |
| 70 | 'buildtools/linux64/clang-format', |
| 71 | 'buildtools/linux64/gn', |
| 72 | 'buildtools/linux64/ninja', |
| 73 | 'buildtools/win/clang-format.exe', |
| 74 | 'buildtools/win/gn.exe', |
| 75 | 'buildtools/win/ninja.exe', |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 76 | ] |
| 77 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 78 | # Dependencies required to build code on the host or when targeting desktop OS. |
Florian Mayer | 54c4e38 | 2021-04-20 15:51:23 +0100 | [diff] [blame] | 79 | BUILD_DEPS_TOOLCHAIN_HOST = [ |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 80 | # GN. From https://chrome-infra-packages.appspot.com/dl/gn/gn/. |
Primiano Tucci | d8afe87 | 2022-02-07 23:18:59 +0000 | [diff] [blame] | 81 | # git_revision:0725d7827575b239594fbc8fd5192873a1d62f44 . |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 82 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 83 | 'third_party/gn/gn', |
Primiano Tucci | d8afe87 | 2022-02-07 23:18:59 +0000 | [diff] [blame] | 84 | 'https://storage.googleapis.com/perfetto/gn-mac-1968-0725d782', |
| 85 | '9ced623a664560bba38bbadb9b91158ca4186358c847e17ab7d982b351373c2e', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 86 | 'darwin', 'x64'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 87 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 88 | 'third_party/gn/gn', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 89 | 'https://storage.googleapis.com/perfetto/gn-mac-arm64-1968-0725d782', |
| 90 | 'd22336b5210b4dad5e36e8c28ce81187f491822cf4d8fd0a257b30d6bee3fd3f', |
| 91 | 'darwin', 'arm64'), |
| 92 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 93 | 'third_party/gn/gn', |
Primiano Tucci | d8afe87 | 2022-02-07 23:18:59 +0000 | [diff] [blame] | 94 | 'https://storage.googleapis.com/perfetto/gn-linux64-1968-0725d782', |
| 95 | 'f706aaa0676e3e22f5fc9ca482295d7caee8535d1869f99efa2358177b64f5cd', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 96 | 'linux', 'x64'), |
Primiano Tucci | e644010 | 2020-12-01 12:41:03 +0100 | [diff] [blame] | 97 | Dependency( |
Hector Dearman | d310930 | 2023-12-07 20:32:05 +0000 | [diff] [blame^] | 98 | 'third_party/gn/gn', |
| 99 | 'https://storage.googleapis.com/perfetto/gn-linux-arm64-1968-0725d782', |
| 100 | 'c2a372cd4f911028d8bc351fbf24835c9b1194fcc92beadf6c5a2b3addae973c', |
| 101 | 'linux', 'arm64'), |
| 102 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 103 | 'third_party/gn/gn.exe', |
Primiano Tucci | d8afe87 | 2022-02-07 23:18:59 +0000 | [diff] [blame] | 104 | 'https://storage.googleapis.com/perfetto/gn-win-1968-0725d782', |
| 105 | '001f777f023c7a6959c778fb3a6b6cfc63f6baef953410ecdeaec350fb12285b', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 106 | 'windows', 'x64'), |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 107 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 108 | # clang-format |
Daniele Di Proietto | c963036 | 2023-06-15 13:28:03 +0000 | [diff] [blame] | 109 | # From |
| 110 | # https://chromium.googlesource.com/chromium/src/buildtools/+/refs/heads/master/mac/clang-format.arm64.sha1 |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 111 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 112 | 'third_party/clang-format/clang-format', |
Daniele Di Proietto | c963036 | 2023-06-15 13:28:03 +0000 | [diff] [blame] | 113 | 'https://storage.googleapis.com/chromium-clang-format/5553d7a3d912b7d49381ad68c9a56740601a57a0', |
| 114 | 'e077990b2ea6807f6abc71b4cf1e487719d7e40574baddd2b51187fdcc8db803', |
| 115 | 'darwin', 'arm64'), |
| 116 | # From |
| 117 | # https://chromium.googlesource.com/chromium/src/buildtools/+/refs/heads/master/mac/clang-format.x64.sha1 |
| 118 | Dependency( |
| 119 | 'third_party/clang-format/clang-format', |
| 120 | 'https://storage.googleapis.com/chromium-clang-format/87d69aeff220c916b85b5d6d162fa5668aa9d64f', |
| 121 | '71179a8788a009cfd589636d50f0eb9f95f58b0cfda4351430bed7c0a48c080b', |
| 122 | 'darwin', 'x64'), |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 123 | # From https://chromium.googlesource.com/chromium/src/buildtools/+/refs/heads/master/linux64/clang-format.sha1 |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 124 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 125 | 'third_party/clang-format/clang-format', |
Daniele Di Proietto | c963036 | 2023-06-15 13:28:03 +0000 | [diff] [blame] | 126 | 'https://storage.googleapis.com/chromium-clang-format/1facab3101fc6da6b9467543f27f0622b966bc19', |
| 127 | '5e459118d8ac825452e9e1f2717e4de5a36399dc6cc6aec7ec483ad27a0c927e', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 128 | 'linux', 'x64'), |
Primiano Tucci | e644010 | 2020-12-01 12:41:03 +0100 | [diff] [blame] | 129 | # From https://chromium.googlesource.com/chromium/src/buildtools/+/refs/heads/master/win/clang-format.exe.sha1 |
| 130 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 131 | 'third_party/clang-format/clang-format.exe', |
Daniele Di Proietto | c963036 | 2023-06-15 13:28:03 +0000 | [diff] [blame] | 132 | 'https://storage.googleapis.com/chromium-clang-format/2e569921b9884daf157021d6ae9e21991cd6cf81', |
| 133 | '2227376ada89ea832995b832222b722a27c4d5d8d59e9c4d7842877f99a1e30d', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 134 | 'windows', 'x64'), |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 135 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 136 | # Keep the SHA1 in sync with |clang_format_rev| in chromium //buildtools/DEPS. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 137 | Dependency( |
| 138 | 'buildtools/clang_format/script', |
Daniele Di Proietto | c963036 | 2023-06-15 13:28:03 +0000 | [diff] [blame] | 139 | 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format.git', |
| 140 | 'f97059df7f8b205064625cdb5f97b56668a125ef', 'all', 'all'), |
Primiano Tucci | 104bd6d | 2017-10-12 00:10:24 +0200 | [diff] [blame] | 141 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 142 | # Ninja |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 143 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 144 | 'third_party/ninja/ninja', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 145 | 'https://storage.googleapis.com/perfetto/ninja-mac-x64_and_arm64-182', |
| 146 | '36e8b7aaa06911e1334feb664dd731a1cd69a15eb916a231a3d10ff65fca2c73', |
| 147 | 'darwin', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 148 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 149 | 'third_party/ninja/ninja', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 150 | 'https://storage.googleapis.com/perfetto/ninja-linux64-182', |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 151 | '54ac6a01362190aaabf4cf276f9c8982cdf11b225438940fdde3339be0f2ecdc', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 152 | 'linux', 'x64'), |
Primiano Tucci | e644010 | 2020-12-01 12:41:03 +0100 | [diff] [blame] | 153 | Dependency( |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 154 | 'third_party/ninja/ninja.exe', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 155 | 'https://storage.googleapis.com/perfetto/ninja-win-182', |
| 156 | '09ced0fcd1a4dec7d1b798a2cf9ce5d20e5d2fbc2337343827f192ce47d0f491', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 157 | 'windows', 'x64'), |
Hector Dearman | d310930 | 2023-12-07 20:32:05 +0000 | [diff] [blame^] | 158 | Dependency( |
| 159 | 'third_party/ninja/ninja', |
| 160 | 'https://storage.googleapis.com/perfetto/ninja-linux-arm64-1111', |
| 161 | '05031a734ec4310a51b2cfe9f0096b26fce25ab4ff19e5b51abe6371de066cc5', |
| 162 | 'linux', 'arm64'), |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 163 | |
Florian Mayer | 54c4e38 | 2021-04-20 15:51:23 +0100 | [diff] [blame] | 164 | # Keep the revision in sync with Chrome's PACKAGE_VERSION in |
| 165 | # tools/clang/scripts/update.py. |
| 166 | Dependency( |
| 167 | 'buildtools/linux64/clang.tgz', |
Lalit Maganti | bdddf76 | 2022-11-02 20:23:03 +0000 | [diff] [blame] | 168 | 'https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-llvmorg-16-init-8697-g60809cd2-1.tgz', |
| 169 | '5ae35f85e0d32136795c6b223bf64263d46678dd4a24fea4e9039e58a32670de', |
Florian Mayer | 54c4e38 | 2021-04-20 15:51:23 +0100 | [diff] [blame] | 170 | 'linux', 'x64'), |
| 171 | Dependency( |
| 172 | 'buildtools/win/clang.tgz', |
Lalit Maganti | bdddf76 | 2022-11-02 20:23:03 +0000 | [diff] [blame] | 173 | 'https://commondatastorage.googleapis.com/chromium-browser-clang/Win/clang-llvmorg-16-init-8697-g60809cd2-1.tgz', |
| 174 | '086faec822acba5b9c0308c6a8be34424031027d757efa2b81805aed18ffc521', |
Florian Mayer | 54c4e38 | 2021-04-20 15:51:23 +0100 | [diff] [blame] | 175 | 'windows', 'x64'), |
| 176 | ] |
| 177 | |
| 178 | BUILD_DEPS_HOST = [ |
Daniele Di Proietto | ce01ef1 | 2022-05-19 11:46:53 +0100 | [diff] [blame] | 179 | # Keep in sync with Android's //external/googletest/METADATA. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 180 | Dependency( |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 181 | 'buildtools/googletest', |
| 182 | 'https://android.googlesource.com/platform/external/googletest.git', |
Daniele Di Proietto | ce01ef1 | 2022-05-19 11:46:53 +0100 | [diff] [blame] | 183 | '609281088cfefc76f9d0ce82e1ff6c30cc3591e5', 'all', 'all'), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 184 | |
Primiano Tucci | f550b25 | 2019-12-03 11:06:02 +0000 | [diff] [blame] | 185 | # Keep in sync with Chromium's //third_party/protobuf. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 186 | Dependency( |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 187 | 'buildtools/protobuf', |
Lalit Maganti | 0ec3ec3 | 2023-02-07 23:54:01 +0000 | [diff] [blame] | 188 | 'https://chromium.googlesource.com/external/github.com/protocolbuffers/protobuf.git', |
| 189 | 'fe271ab76f2ad2b2b28c10443865d2af21e27e0e', # refs/tags/v3.20.3 |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 190 | 'all', |
| 191 | 'all'), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 192 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 193 | # libc++, libc++abi and libunwind for Linux where we need to rebuild the C++ |
| 194 | # lib from sources. Keep the SHA1s in sync with Chrome's src/buildtools/DEPS. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 195 | Dependency( |
| 196 | 'buildtools/libcxx', |
Primiano Tucci | 4e8d6c9 | 2020-09-23 14:40:33 +0200 | [diff] [blame] | 197 | 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git', |
Lalit Maganti | bdddf76 | 2022-11-02 20:23:03 +0000 | [diff] [blame] | 198 | 'f8571eaba606bde2eb8cd34b30104ca33e7c207e', 'all', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 199 | Dependency( |
| 200 | 'buildtools/libcxxabi', |
Primiano Tucci | 4e8d6c9 | 2020-09-23 14:40:33 +0200 | [diff] [blame] | 201 | 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git', |
Lalit Maganti | bdddf76 | 2022-11-02 20:23:03 +0000 | [diff] [blame] | 202 | '8dd405113a4f3694e910b79785dd7fb7535a888a', 'all', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 203 | Dependency( |
| 204 | 'buildtools/libunwind', |
Primiano Tucci | 4e8d6c9 | 2020-09-23 14:40:33 +0200 | [diff] [blame] | 205 | 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git', |
Lalit Maganti | bdddf76 | 2022-11-02 20:23:03 +0000 | [diff] [blame] | 206 | 'aabcd8753678f1536e15eb6385a948470debdae4', 'all', 'all'), |
Hector Dearman | 88a1011 | 2017-10-12 11:07:10 +0100 | [diff] [blame] | 207 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 208 | # Keep in sync with chromium DEPS. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 209 | Dependency( |
| 210 | 'buildtools/libfuzzer', |
| 211 | 'https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 212 | 'debe7d2d1982e540fbd6bd78604bf001753f9e74', 'linux', 'all'), |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 213 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 214 | # Benchmarking tool. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 215 | Dependency( |
| 216 | 'buildtools/benchmark', |
| 217 | 'https://chromium.googlesource.com/external/github.com/google/benchmark.git', |
Lalit Maganti | 4329f23 | 2022-04-25 14:49:02 +0100 | [diff] [blame] | 218 | 'e991355c02b93fe17713efe04cbc2e278e00fdbd', 'all', 'all'), |
Primiano Tucci | 38faa6f | 2018-04-01 20:12:08 +0200 | [diff] [blame] | 219 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 220 | # Libbacktrace, for stacktraces in Linux/Android debug builds. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 221 | # From https://github.com/ianlancetaylor/libbacktrace/archive/177940370e4a6b2509e92a0aaa9749184e64af43.zip |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 222 | Dependency( |
| 223 | 'buildtools/libbacktrace.zip', |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 224 | 'https://storage.googleapis.com/perfetto/libbacktrace-177940370e4a6b2509e92a0aaa9749184e64af43.zip', |
| 225 | '21ac9a4209f7aeef766c482be53a7fa365063c031c7077e2070b491202983b31', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 226 | 'all', 'all'), |
Lalit Maganti | 6fe26e6 | 2018-05-23 12:14:38 +0100 | [diff] [blame] | 227 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 228 | # Sqlite for the trace processing library. |
| 229 | # This is the amalgamated source whose compiled output is meant to be faster. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 230 | # We still pull the full source for the extensions (which are not available |
| 231 | # in the amalgamation). |
Ryan Savitski | 3175111 | 2022-04-02 00:49:07 +0100 | [diff] [blame] | 232 | # If updating the version, also update bazel/deps.bzl. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 233 | Dependency( |
| 234 | 'buildtools/sqlite.zip', |
Lalit Maganti | b706914 | 2022-09-02 15:43:20 +0100 | [diff] [blame] | 235 | 'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3390200.zip', |
| 236 | '87775784f8b22d0d0f1d7811870d39feaa7896319c7c20b849a4181c5a50609b', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 237 | 'all', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 238 | Dependency( |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 239 | 'buildtools/sqlite_src', |
| 240 | 'https://chromium.googlesource.com/external/github.com/sqlite/sqlite.git', |
Lalit Maganti | b706914 | 2022-09-02 15:43:20 +0100 | [diff] [blame] | 241 | '202b2a7b54ea2dd13a8a5adfd75523abe4dcf17f', # refs/tags/version-3.39.2. |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 242 | 'all', |
| 243 | 'all'), |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 244 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 245 | # JsonCpp for legacy json import. Used only by the trace processor in |
| 246 | # standalone builds. |
Ryan Savitski | 3175111 | 2022-04-02 00:49:07 +0100 | [diff] [blame] | 247 | # If updating the version, also update bazel/deps.bzl. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 248 | Dependency( |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 249 | 'buildtools/jsoncpp', |
| 250 | 'https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp.git', |
| 251 | '6aba23f4a8628d599a9ef7fa4811c4ff6e4070e2', # refs/tags/1.9.3. |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 252 | 'all', |
| 253 | 'all'), |
Florian Mayer | 475bd7e | 2018-08-07 20:04:03 +0100 | [diff] [blame] | 254 | |
Ryan Savitski | e65c405 | 2022-03-24 18:22:19 +0000 | [diff] [blame] | 255 | # Archive with only the demangling sources from llvm-project. |
| 256 | # See tools/repackage_llvm_demangler.sh on how to update this. |
| 257 | # File suffix is the git reference to the commit at which we rearchived the |
| 258 | # sources, as hosted on https://llvm.googlesource.com/llvm-project. |
| 259 | # If updating the version, also update bazel/deps.bzl. |
| 260 | Dependency( |
| 261 | 'buildtools/llvm-project.tgz', |
| 262 | 'https://storage.googleapis.com/perfetto/llvm-project-3b4c59c156919902c785ce3cbae0eee2ee53064d.tgz', |
| 263 | 'f4a52e7f36edd7cacc844d5ae0e5f60b6f57c5afc40683e99f295886c9ce8ff4', |
| 264 | 'all', 'all'), |
| 265 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 266 | # These dependencies are for libunwindstack, which is used by src/profiling. |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 267 | Dependency('buildtools/android-core', |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 268 | 'https://android.googlesource.com/platform/system/core.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 269 | '9e6cef7f07d8c11b3ea820938aeb7ff2e9dbaa52', 'all', 'all'), |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 270 | Dependency( |
| 271 | 'buildtools/android-unwinding', |
| 272 | 'https://android.googlesource.com/platform/system/unwinding.git', |
Daniele Di Proietto | f75abb0 | 2023-06-30 16:24:19 +0000 | [diff] [blame] | 273 | 'c0fa0c327e58eda604b2fd00b81f1c12817542d3', 'all', 'all'), |
Florian Mayer | e02b272 | 2020-11-12 10:50:43 +0000 | [diff] [blame] | 274 | Dependency('buildtools/android-logging', |
| 275 | 'https://android.googlesource.com/platform/system/logging.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 276 | '7b36b566c9113fc703d68f76e8f40c0c2432481c', 'all', 'all'), |
Florian Mayer | e02b272 | 2020-11-12 10:50:43 +0000 | [diff] [blame] | 277 | Dependency('buildtools/android-libbase', |
Florian Mayer | fd78c44 | 2020-08-14 12:48:29 +0100 | [diff] [blame] | 278 | 'https://android.googlesource.com/platform/system/libbase.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 279 | '78f1c2f83e625bdf66d55b48bdb3a301c20d2fb3', 'all', 'all'), |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 280 | Dependency( |
| 281 | 'buildtools/android-libprocinfo', |
| 282 | 'https://android.googlesource.com/platform/system/libprocinfo.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 283 | 'fd214c13ededecae97a3b15b5fccc8925a749a84', 'all', 'all'), |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 284 | Dependency('buildtools/lzma', |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 285 | 'https://android.googlesource.com/platform/external/lzma.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 286 | '7851dce6f4ca17f5caa1c93a4e0a45686b1d56c3', 'all', 'all'), |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 287 | Dependency('buildtools/bionic', |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 288 | 'https://android.googlesource.com/platform/bionic.git', |
Daniele Di Proietto | 62a22b6 | 2022-10-26 08:53:11 +0000 | [diff] [blame] | 289 | '4b0e16bc72a82a63c699977376a7d6eadca1b206', 'all', 'all'), |
Florian Mayer | 475bd7e | 2018-08-07 20:04:03 +0100 | [diff] [blame] | 290 | |
Ryan Savitski | 3175111 | 2022-04-02 00:49:07 +0100 | [diff] [blame] | 291 | # Zlib used both in the tracing binaries, as well as the trace processor and |
| 292 | # assorted tools. |
| 293 | # If updating the version, also update bazel/deps.bzl. |
| 294 | Dependency('buildtools/zlib', |
| 295 | 'https://android.googlesource.com/platform/external/zlib.git', |
Lalit Maganti | fa957e7 | 2023-03-16 18:22:23 +0000 | [diff] [blame] | 296 | '6d3f6aa0f87c9791ca7724c279ef61384f331dfd', 'all', 'all'), |
Ryan Savitski | 3175111 | 2022-04-02 00:49:07 +0100 | [diff] [blame] | 297 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 298 | # Linenoise, used only by trace_processor in standalone builds. |
Ryan Savitski | 3175111 | 2022-04-02 00:49:07 +0100 | [diff] [blame] | 299 | # If updating the version, also update bazel/deps.bzl. |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 300 | Dependency('buildtools/linenoise', |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 301 | 'https://fuchsia.googlesource.com/third_party/linenoise.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 302 | 'c894b9e59f02203dbe4e2be657572cf88c4230c3', 'all', 'all'), |
Hector Dearman | 74572bd | 2021-07-07 15:34:13 +0100 | [diff] [blame] | 303 | |
| 304 | # Bloaty, used to investigate binary size |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 305 | Dependency( |
| 306 | 'buildtools/bloaty.zip', |
| 307 | 'https://storage.googleapis.com/perfetto/bloaty-1.1-b3b829de35babc2fe831b9488ad2e50bca939412-mac.zip', |
| 308 | '2d301bd72a20e3f42888c9274ceb4dca76c103608053572322412c2c65ab8cb8', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 309 | 'darwin', 'all'), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 310 | ] |
| 311 | |
| 312 | # Dependencies required to build Android code. |
| 313 | # URLs and SHA1s taken from: |
| 314 | # - https://dl.google.com/android/repository/repository-11.xml |
| 315 | # - https://dl.google.com/android/repository/sys-img/android/sys-img.xml |
| 316 | BUILD_DEPS_ANDROID = [ |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 317 | # Android NDK |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 318 | Dependency( |
| 319 | 'buildtools/ndk.zip', |
Florian Mayer | 5592685 | 2021-02-17 14:42:32 +0000 | [diff] [blame] | 320 | 'https://dl.google.com/android/repository/android-ndk-r21e-darwin-x86_64.zip', |
| 321 | '437278103a3db12632c05b1be5c41bbb8522791a67e415cc54411a65366f499d', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 322 | 'darwin', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 323 | Dependency( |
| 324 | 'buildtools/ndk.zip', |
Florian Mayer | 5592685 | 2021-02-17 14:42:32 +0000 | [diff] [blame] | 325 | 'https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip', |
| 326 | 'ad7ce5467e18d40050dc51b8e7affc3e635c85bd8c59be62de32352328ed467e', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 327 | 'linux', 'x64'), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 328 | ] |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 329 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 330 | # Dependencies required to run Android tests. |
| 331 | TEST_DEPS_ANDROID = [ |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 332 | # Android emulator images. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 333 | Dependency( |
| 334 | 'buildtools/aosp-arm.zip', |
| 335 | 'https://storage.googleapis.com/perfetto/aosp-02022018-arm.zip', |
| 336 | 'f5c7a3a22ad7aa0bd14ba467e8697e1e917d306699bd25622aa4419a413b9b67', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 337 | 'all', 'all'), |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 338 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 339 | # platform-tools.zip contains adb binaries. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 340 | Dependency( |
| 341 | 'buildtools/android_sdk/platform-tools.zip', |
| 342 | 'https://dl.google.com/android/repository/platform-tools_r26.0.0-darwin.zip', |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 343 | '98d392cbd21ca20d643c7e1605760cc49075611e317c534096b5564053f4ac8e', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 344 | 'darwin', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 345 | Dependency( |
| 346 | 'buildtools/android_sdk/platform-tools.zip', |
| 347 | 'https://dl.google.com/android/repository/platform-tools_r26.0.0-linux.zip', |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 348 | '90208207521d85abf0d46e3374aa4e04b7aff74e4f355c792ac334de7a77e50b', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 349 | 'linux', 'x64'), |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 350 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 351 | # Android emulator binaries. |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 352 | Dependency( |
| 353 | 'buildtools/emulator', |
| 354 | 'https://android.googlesource.com/platform/prebuilts/android-emulator.git', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 355 | '4b260028dc27bc92c39bee9129cb2ba839970956', 'all', 'x64'), |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 356 | ] |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 357 | |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 358 | # This variable is updated by tools/roll-catapult-trace-viewer. |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 359 | CATAPULT_SHA256 = 'b30108e05268ce6c65bb4126b65f6bfac165d17f5c1fd285046e7e6fd76c209f' |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 360 | |
Hector Dearman | 69bcd1b | 2023-03-28 10:35:00 +0100 | [diff] [blame] | 361 | TYPEFACES_SHA256 = '1065172aaf0e9c22bc4f206ed9fdf5f1b4355d233fb21f9f26a89cd66c941940' |
Hector Dearman | 6177b75 | 2019-01-24 10:17:32 +0000 | [diff] [blame] | 362 | |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 363 | UI_DEPS = [ |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 364 | Dependency( |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 365 | 'buildtools/mac/nodejs.tgz', |
Hector Dearman | 0b600da | 2022-05-16 19:33:32 +0100 | [diff] [blame] | 366 | 'https://storage.googleapis.com/chromium-nodejs/16.13.0/31859fc1fa0994a95f44f09c367d6ff63607cfde', |
| 367 | 'd9cf1f36b16e08ce52cfbdef427c6596eed2bd2f3608a79112d25b4ec8f75753', |
| 368 | 'darwin', 'arm64'), |
| 369 | Dependency( |
| 370 | 'buildtools/mac/nodejs.tgz', |
| 371 | 'https://storage.googleapis.com/chromium-nodejs/16.13.0/16dfd094763b71988933a31735f9dea966f9abd6', |
| 372 | '065ced7e93f0e26276cb74d9688706674323865c4a8fc89e4adfa6868d4ebb4d', |
| 373 | 'darwin', 'x64'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 374 | Dependency( |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 375 | 'buildtools/linux64/nodejs.tgz', |
Hector Dearman | 0b600da | 2022-05-16 19:33:32 +0100 | [diff] [blame] | 376 | 'https://storage.googleapis.com/chromium-nodejs/16.13.0/ab9544e24e752d3d17f335fb7b2055062e582d11', |
| 377 | '3b5ca150a55f3aadfa18f3a10a4495aaf9653614ba3e460647170fef5287ec4f', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 378 | 'linux', 'x64'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 379 | Dependency( |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 380 | 'buildtools/mac/emsdk.tgz', |
| 381 | 'https://storage.googleapis.com/perfetto/emscripten-2.0.12-mac.tgz', |
| 382 | 'aa125f8c8ff8a386d43e18c8ea0c98c875cc19160a899403e8967a5478f96f31', |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 383 | 'darwin', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 384 | Dependency( |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 385 | 'buildtools/linux64/emsdk.tgz', |
| 386 | 'https://storage.googleapis.com/perfetto/emscripten-2.0.12-linux.tgz', |
| 387 | 'bfff9fb0326363c12e19b542f27a5f12cedbfc310f30621dc497c9af51d2d2e3', |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 388 | 'linux', 'x64'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 389 | Dependency( |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 390 | 'buildtools/catapult_trace_viewer.tgz', |
| 391 | 'https://storage.googleapis.com/perfetto/catapult_trace_viewer-%s.tar.gz' |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 392 | % CATAPULT_SHA256, CATAPULT_SHA256, 'all', 'all'), |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 393 | Dependency( |
| 394 | 'buildtools/typefaces.tgz', |
| 395 | 'https://storage.googleapis.com/perfetto/typefaces-%s.tar.gz' % |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 396 | TYPEFACES_SHA256, TYPEFACES_SHA256, 'all', 'all'), |
| 397 | |
| 398 | Dependency( |
| 399 | 'third_party/pnpm/pnpm', |
| 400 | 'https://storage.googleapis.com/perfetto/pnpm-linux-arm64-8.6.3', |
| 401 | 'ac76e9ab6a770479f93c1a2bf978d72636dbcb02608554378cf30075a78a22ac', |
| 402 | 'linux', 'arm64'), |
| 403 | Dependency( |
| 404 | 'third_party/pnpm/pnpm', |
| 405 | 'https://storage.googleapis.com/perfetto/pnpm-linux-x64-8.6.3', |
| 406 | '5a58ccd78d44faac138d901976a7a8917c0f2a2f83743cfdd895fcd0bb6aa135', |
| 407 | 'linux', 'x64'), |
| 408 | Dependency( |
| 409 | 'third_party/pnpm/pnpm', |
| 410 | 'https://storage.googleapis.com/perfetto/pnpm-macos-arm64-8.6.3', |
| 411 | 'f527713d3183e30cfbfd7fd6403ceed730831c53649e50c979961eab3b2cf866', |
| 412 | 'darwin', 'arm64'), |
| 413 | Dependency( |
| 414 | 'third_party/pnpm/pnpm', |
| 415 | 'https://storage.googleapis.com/perfetto/pnpm-macos-x64-8.6.3', |
| 416 | '6b425f7f0342341e9ee9427a9a2be2c89936c4a04efe6125f7af667eb02b10c1', |
| 417 | 'darwin', 'x64'), |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 418 | ] |
| 419 | |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 420 | # Dependencies to build gRPC. |
| 421 | GRPC_DEPS = [ |
| 422 | Dependency( |
| 423 | 'buildtools/grpc/src', |
| 424 | 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git', |
| 425 | '6943c1841f57cac4666b165aea4f618fe73b3ff1', 'all', 'all', True), |
| 426 | ] |
| 427 | |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 428 | # Sysroots required to cross-compile Linux targets (linux-arm{,64}). |
| 429 | # These are taken from Chromium's build/linux/sysroot_scripts/sysroots.json. |
| 430 | BUILD_DEPS_LINUX_CROSS_SYSROOTS = [ |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 431 | Dependency( |
| 432 | 'buildtools/debian_sid_arm-sysroot.tgz', |
| 433 | 'https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/11d6f690ca49e8ba01a1d8c5346cedad2cf308fd/debian_sid_arm_sysroot.tar.xz', |
| 434 | 'ff192fe073d140d836c9ca1e68f7200d558bb9aa6c5c8f4f76f794f82890f99a', |
| 435 | 'linux', 'all'), |
| 436 | Dependency( |
| 437 | 'buildtools/debian_sid_arm64-sysroot.tgz', |
| 438 | 'https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2befe8ce3e88be6080e4fb7e6d412278ea6a7625/debian_sid_arm64_sysroot.tar.xz', |
| 439 | 'e4389eab2fe363f3fbdfa4d3ce9d94457d78fd2c0e62171a7534867623eadc90', |
| 440 | 'linux', 'all'), |
| 441 | ] |
| 442 | |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 443 | ALL_DEPS = ( |
| 444 | BUILD_DEPS_HOST + BUILD_DEPS_ANDROID + BUILD_DEPS_LINUX_CROSS_SYSROOTS + |
| 445 | TEST_DEPS_ANDROID + UI_DEPS) |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 446 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 447 | ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 448 | UI_DIR = os.path.join(ROOT_DIR, 'ui') |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 449 | TOOLS_DIR = os.path.join(ROOT_DIR, 'tools') |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 450 | NODE_MODULES_STATUS_FILE = os.path.join(UI_DIR, 'node_modules', '.last_install') |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 451 | TEST_DATA_SCRIPT = os.path.join(TOOLS_DIR, 'test_data') |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 452 | |
| 453 | |
Primiano Tucci | 16fed02 | 2023-05-05 17:11:32 +0100 | [diff] [blame] | 454 | def CheckCallRetry(*args, **kwargs): |
| 455 | """ Like subprocess.check_call, with retries up to 5 times. """ |
| 456 | MAX_ATTEMPTS = 5 |
| 457 | for attempt in range(1, MAX_ATTEMPTS + 1): |
| 458 | try: |
| 459 | return subprocess.check_call(*args, **kwargs) |
| 460 | except subprocess.CalledProcessError as error: |
| 461 | if attempt == MAX_ATTEMPTS: |
| 462 | raise error |
| 463 | else: |
| 464 | logging.error(error) |
| 465 | time.sleep(attempt * 3) |
| 466 | |
| 467 | |
Primiano Tucci | 585b7e8 | 2020-05-14 11:19:10 +0100 | [diff] [blame] | 468 | def DownloadURL(url, out_file): |
Primiano Tucci | 16fed02 | 2023-05-05 17:11:32 +0100 | [diff] [blame] | 469 | CheckCallRetry(['curl', '-L', '-#', '-o', out_file, url]) |
Primiano Tucci | 585b7e8 | 2020-05-14 11:19:10 +0100 | [diff] [blame] | 470 | |
| 471 | |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 472 | def GetArch(): |
| 473 | arch = machine() |
Primiano Tucci | 0e7915d | 2022-02-08 15:25:49 +0000 | [diff] [blame] | 474 | if arch == 'arm64': |
| 475 | return 'arm64' |
Hector Dearman | d310930 | 2023-12-07 20:32:05 +0000 | [diff] [blame^] | 476 | elif arch == 'aarch64': |
| 477 | return 'arm64' |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 478 | else: |
| 479 | # Assume everything else is x64 matching previous behaviour. |
| 480 | return 'x64' |
| 481 | |
| 482 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 483 | def ReadFile(path): |
| 484 | if not os.path.exists(path): |
| 485 | return None |
| 486 | with open(path) as f: |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 487 | return f.read().strip() |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 488 | |
| 489 | |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 490 | def MkdirRecursive(path): |
| 491 | # Works with both relative and absolute paths |
| 492 | cwd = '/' if path.startswith('/') else ROOT_DIR |
| 493 | for part in path.split('/'): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 494 | cwd = os.path.join(cwd, part) |
| 495 | if not os.path.exists(cwd): |
| 496 | os.makedirs(cwd) |
| 497 | else: |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 498 | assert (os.path.isdir(cwd)) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 499 | |
| 500 | |
| 501 | def HashLocalFile(path): |
| 502 | if not os.path.exists(path): |
| 503 | return None |
| 504 | with open(path, 'rb') as f: |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 505 | return hashlib.sha256(f.read()).hexdigest() |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 506 | |
| 507 | |
| 508 | def ExtractZipfilePreservePermissions(zf, info, path): |
| 509 | zf.extract(info.filename, path=path) |
| 510 | target_path = os.path.join(path, info.filename) |
| 511 | min_acls = 0o755 if info.filename.endswith('/') else 0o644 |
Matthew Clarkson | 9a5dfa5 | 2019-10-03 09:54:04 +0100 | [diff] [blame] | 512 | os.chmod(target_path, (info.external_attr >> 16) | min_acls) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 513 | |
| 514 | |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 515 | def IsGitRepoCheckoutOutAtRevision(path, revision): |
| 516 | return ReadFile(os.path.join(path, '.git', 'HEAD')) == revision |
| 517 | |
| 518 | |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 519 | def RmtreeIfExists(path): |
Primiano Tucci | 857ed73 | 2020-12-19 18:11:42 +0100 | [diff] [blame] | 520 | # Git creates read-only files on windows, which cause failures with rmtree. |
| 521 | # This seems the socially accepted way to deal with it. |
| 522 | # See https://bugs.python.org/issue19643 . |
| 523 | def del_read_only_for_windows(_action, name, _exc): |
| 524 | os.chmod(name, stat.S_IWRITE) |
| 525 | os.remove(name) |
| 526 | |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 527 | if not os.path.exists(path): |
| 528 | return |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 529 | third_party_path = os.path.abspath(os.path.join(ROOT_DIR, 'third_party')) |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 530 | buildtools_path = os.path.abspath(os.path.join(ROOT_DIR, 'buildtools')) |
Florian Mayer | 83d683f | 2021-01-29 16:57:16 +0000 | [diff] [blame] | 531 | test_path = os.path.abspath(os.path.join(ROOT_DIR, 'test', 'data')) |
| 532 | if (not os.path.abspath(path).startswith(buildtools_path) and |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 533 | not os.path.abspath(path).startswith(test_path) and |
| 534 | not os.path.abspath(path).startswith(third_party_path)): |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 535 | # Safety check to prevent that some merge confilct ends up doing some |
| 536 | # rm -rf / or similar. |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 537 | logging.fatal( |
| 538 | 'Cannot remove %s: outside of {buildtools, test/data, third_party}', |
| 539 | path) |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 540 | sys.exit(1) |
| 541 | logging.info('Removing %s' % path) |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 542 | if os.path.isdir(path): |
| 543 | shutil.rmtree(path, onerror=del_read_only_for_windows) |
| 544 | else: |
| 545 | os.remove(path) |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 546 | |
| 547 | |
| 548 | def CheckoutGitRepo(path, git_url, revision, check_only): |
| 549 | if IsGitRepoCheckoutOutAtRevision(path, revision): |
| 550 | return False |
| 551 | if check_only: |
| 552 | return True |
| 553 | path = path.replace('/', os.sep) |
| 554 | RmtreeIfExists(path) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 555 | MkdirRecursive(path) |
| 556 | logging.info('Fetching %s @ %s into %s', git_url, revision, path) |
Lalit Maganti | 367fcd5 | 2018-02-05 16:06:13 +0000 | [diff] [blame] | 557 | subprocess.check_call(['git', 'init', path], cwd=path) |
Primiano Tucci | 16fed02 | 2023-05-05 17:11:32 +0100 | [diff] [blame] | 558 | CheckCallRetry(['git', 'fetch', '--quiet', '--depth', '1', git_url, revision], |
| 559 | cwd=path) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 560 | subprocess.check_call(['git', 'checkout', revision, '--quiet'], cwd=path) |
Primiano Tucci | 16fed02 | 2023-05-05 17:11:32 +0100 | [diff] [blame] | 561 | CheckCallRetry( |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 562 | ['git', 'submodule', 'update', '--init', '--recursive', '--quiet'], |
| 563 | cwd=path) |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 564 | assert (IsGitRepoCheckoutOutAtRevision(path, revision)) |
Eric Seckler | 676421f | 2019-02-12 14:43:31 +0000 | [diff] [blame] | 565 | return True |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 566 | |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 567 | |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 568 | def InstallNodeModules(force_clean=False): |
| 569 | if force_clean: |
| 570 | node_modules = os.path.join(UI_DIR, 'node_modules') |
| 571 | logging.info('Clearing %s', node_modules) |
| 572 | subprocess.check_call(['git', 'clean', '-qxffd', node_modules], |
| 573 | cwd=ROOT_DIR) |
Hector Dearman | 69c23df | 2023-06-27 12:51:04 +0100 | [diff] [blame] | 574 | logging.info("Running `pnpm install --shamefully-hoist --frozen-lockfile` in {0}".format(UI_DIR)) |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 575 | |
| 576 | # Some node modules have postinstall scripts (already bad) but worse |
| 577 | # sometimes they are in the form: "postinstall: 'node ./scripts/foo'" |
| 578 | # so here we need to ensure that our hermetic node is available in |
| 579 | # PATH. |
| 580 | env = os.environ.copy() |
| 581 | env['PATH'] = TOOLS_DIR + ':' + env['PATH'] |
| 582 | |
Hector Dearman | 69c23df | 2023-06-27 12:51:04 +0100 | [diff] [blame] | 583 | subprocess.check_call([ |
| 584 | os.path.join(TOOLS_DIR, 'pnpm'), |
| 585 | 'install', |
| 586 | '--shamefully-hoist', |
| 587 | '--frozen-lockfile'], |
| 588 | cwd=UI_DIR, |
| 589 | env=env) |
| 590 | # pbjs has the bad habit of installing extra packages on its first |
| 591 | # run. Run it here, so we avoid fetches while building. |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 592 | pbjs = ['node_modules/.bin/pbjs', '/dev/null', '-o', '/dev/null'] |
| 593 | subprocess.call(pbjs, cwd=UI_DIR, env=env) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 594 | with open(NODE_MODULES_STATUS_FILE, 'w') as f: |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 595 | f.write(HashLocalFile(os.path.join(UI_DIR, 'pnpm-lock.yaml'))) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 596 | |
| 597 | |
| 598 | def CheckNodeModules(): |
| 599 | """Returns True if the modules are up-to-date. |
| 600 | |
| 601 | There doesn't seem to be an easy way to check node modules versions. Instead |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 602 | just check if pnpm-lock.json changed since the last `pnpm install` call. |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 603 | """ |
| 604 | if not os.path.exists(NODE_MODULES_STATUS_FILE): |
| 605 | return False |
| 606 | with open(NODE_MODULES_STATUS_FILE, 'r') as f: |
| 607 | actual = f.read() |
Hector Dearman | 48d3408 | 2023-06-21 15:43:08 +0100 | [diff] [blame] | 608 | expected = HashLocalFile(os.path.join(UI_DIR, 'pnpm-lock.yaml')) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 609 | return expected == actual |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 610 | |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 611 | |
| 612 | def CheckHashes(): |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 613 | for dep in ALL_DEPS: |
| 614 | if dep.source_url.endswith('.git'): |
| 615 | continue |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 616 | logging.info('Downloading %s for %s-%s', dep.source_url, dep.target_os, |
| 617 | dep.target_arch) |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 618 | with tempfile.NamedTemporaryFile(delete=False) as f: |
| 619 | f.close() |
| 620 | DownloadURL(dep.source_url, f.name) |
| 621 | actual_checksum = HashLocalFile(f.name) |
| 622 | os.unlink(f.name) |
| 623 | if (actual_checksum != dep.checksum): |
| 624 | logging.fatal('SHA-256 mismatch for {} expected {} was {}'.format( |
| 625 | dep.source_url, dep.checksum, actual_checksum)) |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 626 | |
| 627 | |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 628 | def CheckDepotToolsIsRecent(): |
| 629 | gn_py_path = shutil.which('gn.py') |
| 630 | if gn_py_path is None: |
| 631 | return True # depot_tools doesn't seem to be installed in the PATH. |
| 632 | dt_dir = os.path.abspath(os.path.dirname(gn_py_path)) |
| 633 | cmd = ['git', '-C', dt_dir, 'merge-base', '--is-ancestor', 'a0cf4321', 'HEAD'] |
| 634 | git_ret = subprocess.call(cmd, stderr=subprocess.DEVNULL) |
| 635 | if git_ret == 0: |
| 636 | return True |
| 637 | print('\033[91mYour depot_tools revision is too old. Please run:\033[0m') |
| 638 | print('git -C %s fetch origin && git -C %s checkout -B main -t origin/main' % |
| 639 | (dt_dir, dt_dir)) |
| 640 | return False |
| 641 | |
| 642 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 643 | def Main(): |
| 644 | parser = argparse.ArgumentParser() |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 645 | parser.add_argument( |
| 646 | '--android', |
| 647 | action='store_true', |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 648 | help='NDK and emulator images target_os="android"') |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 649 | parser.add_argument( |
| 650 | '--linux-arm', |
| 651 | action='store_true', |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 652 | help='Debian sysroots for target_os="linux" target_cpu="arm|arm64"') |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 653 | parser.add_argument( |
| 654 | '--ui', |
| 655 | action='store_true', |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 656 | help='Node and NPM packages to Build the Web-based UI via ./ui/build') |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 657 | parser.add_argument( |
Lalit Maganti | 7d41871 | 2023-04-13 13:45:14 +0100 | [diff] [blame] | 658 | '--grpc', action='store_true', help='Packages to build gRPC') |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 659 | parser.add_argument('--check-only') |
Daniele Di Proietto | 99687bd | 2022-11-18 11:18:12 +0000 | [diff] [blame] | 660 | parser.add_argument('--filter', action='append') |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 661 | parser.add_argument('--verify', help='Check all URLs', action='store_true') |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 662 | parser.add_argument( |
| 663 | '--no-toolchain', help='Do not download toolchain', action='store_true') |
Chris Phlipot | 3d44ed9 | 2023-10-10 17:48:07 -0700 | [diff] [blame] | 664 | parser.add_argument( |
| 665 | '--build-os', |
| 666 | default=system().lower(), |
| 667 | choices=['windows', 'darwin', 'linux'], |
| 668 | help='Override the autodetected build operating system') |
| 669 | parser.add_argument( |
| 670 | '--build-arch', |
| 671 | default=GetArch(), |
| 672 | choices=['arm64', 'x64'], |
| 673 | help='Override the autodetected build CPU architecture') |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 674 | args = parser.parse_args() |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 675 | if args.verify: |
Sami Kyostila | c7ddac7 | 2019-06-05 21:43:40 +0100 | [diff] [blame] | 676 | CheckHashes() |
| 677 | return 0 |
Lalit Maganti | 0830b60 | 2021-06-11 15:11:42 +0100 | [diff] [blame] | 678 | |
Chris Phlipot | 3d44ed9 | 2023-10-10 17:48:07 -0700 | [diff] [blame] | 679 | target_os = args.build_os |
Lalit Maganti | 0830b60 | 2021-06-11 15:11:42 +0100 | [diff] [blame] | 680 | if args.ui and target_os == 'windows': |
| 681 | print('Building the UI on Windows is unsupported') |
| 682 | return 1 |
| 683 | |
Primiano Tucci | a0b1bc2 | 2023-05-04 15:06:58 +0100 | [diff] [blame] | 684 | if not CheckDepotToolsIsRecent(): |
| 685 | return 1 |
| 686 | |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 687 | deps = BUILD_DEPS_HOST |
Florian Mayer | 54c4e38 | 2021-04-20 15:51:23 +0100 | [diff] [blame] | 688 | if not args.no_toolchain: |
| 689 | deps += BUILD_DEPS_TOOLCHAIN_HOST |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 690 | if args.android: |
Primiano Tucci | d775045 | 2017-09-29 14:38:51 +0100 | [diff] [blame] | 691 | deps += BUILD_DEPS_ANDROID + TEST_DEPS_ANDROID |
Primiano Tucci | b428d49 | 2021-08-02 19:01:29 +0100 | [diff] [blame] | 692 | if args.linux_arm: |
| 693 | deps += BUILD_DEPS_LINUX_CROSS_SYSROOTS |
Primiano Tucci | 4bdc4c4 | 2018-05-10 15:52:33 +0100 | [diff] [blame] | 694 | if args.ui: |
| 695 | deps += UI_DEPS |
Lalit Maganti | bf99dd3 | 2023-02-07 23:50:48 +0000 | [diff] [blame] | 696 | if args.grpc: |
| 697 | deps += GRPC_DEPS |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 698 | deps_updated = False |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 699 | nodejs_updated = False |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 700 | |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 701 | for old_dir in CLEANUP_OLD_DIRS: |
| 702 | RmtreeIfExists(os.path.join(ROOT_DIR, old_dir)) |
| 703 | |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 704 | for dep in deps: |
Chris Phlipot | 3d44ed9 | 2023-10-10 17:48:07 -0700 | [diff] [blame] | 705 | target_arch = args.build_arch |
Hector Dearman | adf5117 | 2021-04-09 16:09:45 +0100 | [diff] [blame] | 706 | matches_os = dep.target_os == 'all' or target_os == dep.target_os |
| 707 | matches_arch = dep.target_arch == 'all' or target_arch == dep.target_arch |
| 708 | if not matches_os or not matches_arch: |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 709 | continue |
Daniele Di Proietto | 99687bd | 2022-11-18 11:18:12 +0000 | [diff] [blame] | 710 | if args.filter and not any(f in dep.target_folder for f in args.filter): |
Primiano Tucci | cde1a8c | 2021-02-15 19:18:10 +0100 | [diff] [blame] | 711 | continue |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 712 | local_path = os.path.join(ROOT_DIR, dep.target_folder) |
| 713 | if dep.source_url.endswith('.git'): |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 714 | deps_updated |= CheckoutGitRepo(local_path, dep.source_url, dep.checksum, |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 715 | args.check_only) |
Primiano Tucci | 0825bc8 | 2017-09-28 18:50:23 +0100 | [diff] [blame] | 716 | continue |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 717 | is_compressed = any([local_path.endswith(ext) for ext in ['.zip', '.tgz', '.tbz2']]) |
| 718 | compressed_target_dir = os.path.splitext(local_path)[0] if is_compressed else None |
| 719 | compressed_dir_stamp = os.path.join(compressed_target_dir, '.stamp') if is_compressed else None |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 720 | |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 721 | if ((not is_compressed and HashLocalFile(local_path) == dep.checksum) or |
| 722 | (is_compressed and ReadFile(compressed_dir_stamp) == dep.checksum)): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 723 | continue |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 724 | deps_updated = True |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 725 | if args.check_only: |
| 726 | continue |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 727 | MkdirRecursive(os.path.dirname(dep.target_folder)) |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 728 | if HashLocalFile(local_path) != dep.checksum: |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 729 | download_path = local_path + '.tmp' |
Jordan Bayles | 8c6a4bc | 2020-07-16 20:20:48 -0700 | [diff] [blame] | 730 | logging.info('Downloading %s from %s', local_path, dep.source_url) |
| 731 | DownloadURL(dep.source_url, download_path) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 732 | os.chmod(download_path, 0o755) |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 733 | actual_checksum = HashLocalFile(download_path) |
| 734 | if (actual_checksum != dep.checksum): |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 735 | os.remove(download_path) |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 736 | logging.fatal('SHA-256 mismatch for {} expected {} was {}'.format( |
| 737 | download_path, dep.checksum, actual_checksum)) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 738 | return 1 |
Primiano Tucci | e644010 | 2020-12-01 12:41:03 +0100 | [diff] [blame] | 739 | shutil.move(download_path, local_path) |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 740 | if 'nodejs' in dep.target_folder: |
| 741 | nodejs_updated = True |
| 742 | |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 743 | assert (HashLocalFile(local_path) == dep.checksum) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 744 | |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 745 | if is_compressed: |
| 746 | logging.info('Extracting %s into %s' % (local_path, compressed_target_dir)) |
| 747 | assert (os.path.commonprefix((ROOT_DIR, compressed_target_dir)) == ROOT_DIR) |
| 748 | RmtreeIfExists(compressed_target_dir) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 749 | |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 750 | # Decompress the archive. |
| 751 | if local_path.endswith('.tgz'): |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 752 | MkdirRecursive(compressed_target_dir) |
| 753 | subprocess.check_call(['tar', '-oxf', local_path], cwd=compressed_target_dir) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 754 | elif local_path.endswith('.zip'): |
| 755 | with zipfile.ZipFile(local_path, 'r') as zf: |
| 756 | for info in zf.infolist(): |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 757 | ExtractZipfilePreservePermissions(zf, info, compressed_target_dir) |
| 758 | elif local_path.endswith('.tbz2'): |
| 759 | tar_path = '{}.tar.tmp'.format(local_path) |
| 760 | with open(tar_path, 'w') as f: |
| 761 | with bz2.open(local_path, 'r') as bf: |
| 762 | f.write(bf.read()) |
| 763 | MkdirRecursive(compressed_target_dir) |
| 764 | subprocess.check_call(['tar', '-oxf', tar_path], cwd=compressed_target_dir) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 765 | |
| 766 | # If the zip contains one root folder, rebase one level up moving all |
| 767 | # its sub files and folders inside |target_dir|. |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 768 | subdir = os.listdir(compressed_target_dir) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 769 | if len(subdir) == 1: |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 770 | subdir = os.path.join(compressed_target_dir, subdir[0]) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 771 | if os.path.isdir(subdir): |
| 772 | for subf in os.listdir(subdir): |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 773 | shutil.move(os.path.join(subdir, subf), compressed_target_dir) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 774 | os.rmdir(subdir) |
| 775 | |
| 776 | # Create stamp and remove the archive. |
Hector Dearman | e198160 | 2023-06-16 10:28:12 +0100 | [diff] [blame] | 777 | with open(compressed_dir_stamp, 'w') as stamp_file: |
Primiano Tucci | 15968b5 | 2020-10-28 15:30:40 +0100 | [diff] [blame] | 778 | stamp_file.write(dep.checksum) |
Primiano Tucci | b60d4b0 | 2017-11-10 11:03:00 +0000 | [diff] [blame] | 779 | os.remove(local_path) |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 780 | |
Deepanjan Roy | acf8c07 | 2018-07-13 11:37:04 -0400 | [diff] [blame] | 781 | if args.ui: |
| 782 | # Needs to happen after nodejs is installed above. |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 783 | if args.check_only: |
Primiano Tucci | c1aecf4 | 2021-04-13 22:22:19 +0100 | [diff] [blame] | 784 | deps_updated |= not CheckNodeModules() |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 785 | else: |
Primiano Tucci | 43f111a | 2020-07-27 20:37:52 +0200 | [diff] [blame] | 786 | InstallNodeModules(force_clean=nodejs_updated) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 787 | |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 788 | cur_python_interpreter = sys.executable |
Primiano Tucci | 856f2be | 2022-03-17 17:25:12 +0000 | [diff] [blame] | 789 | test_data_synced = 0 == subprocess.call([ |
| 790 | cur_python_interpreter, TEST_DATA_SCRIPT, 'status', '--quiet', |
| 791 | '--ignore-new' |
| 792 | ]) |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 793 | if args.check_only: |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 794 | if not deps_updated and test_data_synced: |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 795 | with open(args.check_only, 'w') as f: |
| 796 | f.write('OK') # The content is irrelevant, just keep GN happy. |
| 797 | return 0 |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 798 | argz = ' '.join( |
| 799 | [x for x in sys.argv[1:] if not x.startswith('--check-only')]) |
Primiano Tucci | 7e9865c | 2021-01-10 23:55:15 +0100 | [diff] [blame] | 800 | print('\033[91mBuild deps are stale. ' + |
| 801 | 'Please run tools/install-build-deps %s\033[0m' % argz) |
Primiano Tucci | 856f2be | 2022-03-17 17:25:12 +0000 | [diff] [blame] | 802 | if not test_data_synced: |
| 803 | print('//test/data/ is out of sync. `tools/test_data status` for details') |
Primiano Tucci | 69132a1 | 2020-02-07 22:33:06 +0000 | [diff] [blame] | 804 | return 1 |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 805 | |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 806 | if not test_data_synced: |
Primiano Tucci | 5441890 | 2021-11-06 12:09:48 +0000 | [diff] [blame] | 807 | cmd = [cur_python_interpreter, TEST_DATA_SCRIPT, 'download', '--overwrite'] |
Primiano Tucci | 3d4217d | 2021-11-05 11:11:51 +0000 | [diff] [blame] | 808 | if not sys.stdout.isatty(): |
| 809 | cmd += ['--verbose'] # For CI bots |
| 810 | subprocess.check_call(cmd) |
| 811 | |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 812 | if deps_updated: |
| 813 | # Stale binary files may be compiled against old sysroot headers that aren't |
| 814 | # tracked by gn. |
Matthew Clarkson | 9a5dfa5 | 2019-10-03 09:54:04 +0100 | [diff] [blame] | 815 | logging.warning('Remember to run "gn clean <output_directory>" ' + |
| 816 | 'to avoid stale binary files.') |
Eric Seckler | 6e828f3 | 2019-01-02 11:10:56 +0000 | [diff] [blame] | 817 | |
Matthew Clarkson | 63028d6 | 2019-10-10 15:48:23 +0100 | [diff] [blame] | 818 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 819 | if __name__ == '__main__': |
| 820 | logging.basicConfig(level=logging.INFO) |
| 821 | sys.exit(Main()) |