aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Wiitala <miu@chromium.org>2020-01-09 18:36:09 -0800
committerYuri Wiitala <miu@chromium.org>2020-01-10 22:08:19 +0000
commit50d8abc87806ee09096318c51b07fefb7cad1f5f (patch)
tree875a68e4850e9aa8665a922912098b42950dc89c
parent80fd1cdeb5b6928084532164065d3cb0cbb8ff2f (diff)
downloadopenscreen-50d8abc87806ee09096318c51b07fefb7cad1f5f.tar.gz
Update buildtools DEPS revision, add hooks; and fix GN libs prefix.
Moves the buildtools dependency to the latest commit (8d2132841536523249669813b928e29144d487f9), and adds hooks for auto-downloading clang-format. Then, fixes a GN-internal change that broke the linker command line for specifying external libraries. Also, shucked the tools/install-build-tools.sh script, removing the unnecessary ninja download (it's in depot_tools now), and the clang-format download. The result of all this is that all developers will be using the correct versions of all development and build tools, and upgrades can easily be managed via changes to the DEPS file from here onwards. NOTE: Developers will want to run `rm -rf buildtools/ && gclient sync` to ensure they have a clean/consistent checkout with the correct tools/revisions. Bug: openscreen:95 Change-Id: I5028d9f97f11a62f0a10d3edf8f46631e72a6ae6 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1988936 Reviewed-by: mark a. foltz <mfoltz@chromium.org> Reviewed-by: Jordan Bayles <jophba@chromium.org> Reviewed-by: Yuri Wiitala <miu@chromium.org>
-rw-r--r--.gitignore1
-rw-r--r--DEPS281
-rw-r--r--README.md48
-rw-r--r--build/config/BUILDCONFIG.gn6
-rw-r--r--build/toolchain/linux/BUILD.gn3
-rw-r--r--build/toolchain/mac/BUILD.gn3
-rw-r--r--cast/standalone_receiver/BUILD.gn6
-rw-r--r--cast/standalone_receiver/dummy_player.h2
-rw-r--r--third_party/boringssl/BUILD.gn12
-rw-r--r--third_party/chromium_quic/BUILD.gn32
-rw-r--r--third_party/mDNSResponder/BUILD.gn15
-rw-r--r--third_party/tinycbor/BUILD.gn7
-rw-r--r--third_party/zlib/BUILD.gn8
-rwxr-xr-xtools/cl-format.sh32
-rwxr-xr-xtools/clang/scripts/update.py1025
-rwxr-xr-xtools/download-clang-update-script.py66
-rwxr-xr-xtools/install-build-tools.sh33
17 files changed, 275 insertions, 1305 deletions
diff --git a/.gitignore b/.gitignore
index a0f15f28..30459376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@
buildtools/
clang-format
third_party/llvm-build
+tools/clang/scripts/update.py
*sysroot
diff --git a/DEPS b/DEPS
index 37f4c3b8..82eca9ee 100644
--- a/DEPS
+++ b/DEPS
@@ -8,147 +8,176 @@
# to list the dependency's destination directory.
use_relative_paths = True
+use_relative_hooks = True
vars = {
- 'boringssl_git': 'https://boringssl.googlesource.com',
- 'chromium_git': 'https://chromium.googlesource.com',
+ 'boringssl_git': 'https://boringssl.googlesource.com',
+ 'chromium_git': 'https://chromium.googlesource.com',
- # TODO(jophba): move to googlesource external for github repos.
- 'github': 'https://github.com',
+ # TODO(jophba): move to googlesource external for github repos.
+ 'github': 'https://github.com',
- # NOTE: Strangely enough, this will be overridden by any _parent_ DEPS, so
- # in Chromium it will correctly be True.
- 'build_with_chromium': False,
+ # NOTE: Strangely enough, this will be overridden by any _parent_ DEPS, so
+ # in Chromium it will correctly be True.
+ 'build_with_chromium': False,
- 'gn_version': 'git_revision:0790d3043387c762a6bacb1ae0a9ebe883188ab2',
- 'checkout_chromium_quic_boringssl': False,
-
- # By default, do not check out openscreen/cast. This can be overridden
- # by custom_vars in .gclient.
- 'checkout_openscreen_cast_internal': False
+ 'checkout_chromium_quic_boringssl': False,
}
deps = {
- 'cast/internal': {
- 'url': 'https://chrome-internal.googlesource.com/openscreen/cast.git' +
- '@' + '703984f9d1674c2cfc259904a5a7fba4990cca4b',
- 'condition': 'checkout_openscreen_cast_internal',
- },
-
- 'buildtools': {
- 'url': Var('chromium_git')+ '/chromium/src/buildtools' +
- '@' + '140e4d7c45ffb55ce5dc4d11a0c3938363cd8257',
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/protobuf/src': {
- 'url': Var('chromium_git') +
- '/external/github.com/protocolbuffers/protobuf.git' +
- '@' + 'd09d649aea36f02c03f8396ba39a8d4db8a607e4', # version 3.10.1
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/zlib/src': {
- 'url': Var('github') +
- '/madler/zlib.git' +
- '@' + 'cacf7f1d4e3d44d871b605da3b647f07d718623f', # version 1.2.11
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/jsoncpp/src': {
- 'url': Var('chromium_git') +
- '/external/github.com/open-source-parsers/jsoncpp.git' +
- '@' + '2eb20a938c454411c1d416caeeb2a6511daab5cb', # version 1.9.0
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/googletest/src': {
- 'url': Var('chromium_git') +
- '/external/github.com/google/googletest.git' +
- '@' + '8697709e0308af4cd5b09dc108480804e5447cf0',
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/mDNSResponder/src': {
- 'url': Var('github') + '/jevinskie/mDNSResponder.git' +
- '@' + '2942dde61f920fbbf96ff9a3840567ebbe7cb1b6',
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/boringssl/src': {
- 'url' : Var('boringssl_git') + '/boringssl.git' +
- '@' + '6410e18e9190b6b0c71955119fbf3cae1b9eedb7',
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/chromium_quic/src': {
- 'url': Var('chromium_git') + '/openscreen/quic.git' +
- '@' + '952c77df033dcbfa1972bcedbd125aea34f2790a',
- 'condition': 'not build_with_chromium',
- },
-
- 'third_party/tinycbor/src':
- Var('chromium_git') + '/external/github.com/intel/tinycbor.git' +
- '@' + '755f9ef932f9830a63a712fd2ac971d838b131f1',
-
- 'third_party/abseil/src': {
- 'url': Var('chromium_git') +
- '/external/github.com/abseil/abseil-cpp.git' +
- '@' + '20de2db748ca0471cfb61cb53e813dd12938c12b',
- 'condition': 'not build_with_chromium',
- },
- 'third_party/libfuzzer/src': {
- 'url': Var('chromium_git') +
- '/chromium/llvm-project/compiler-rt/lib/fuzzer.git' +
- '@' + 'debe7d2d1982e540fbd6bd78604bf001753f9e74',
- 'condition': 'not build_with_chromium',
- },
+ # NOTE: This commit hash here references a repository/branch that is a mirror
+ # of the commits to the buildtools directory in the Chromium repository. This
+ # should be regularly updated with the tip of the MIRRORED master branch,
+ # found here:
+ # https://chromium.googlesource.com/chromium/src/buildtools/+/refs/heads/master.
+ 'buildtools': {
+ 'url': Var('chromium_git')+ '/chromium/src/buildtools' +
+ '@' + '8d2132841536523249669813b928e29144d487f9',
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/protobuf/src': {
+ 'url': Var('chromium_git') +
+ '/external/github.com/protocolbuffers/protobuf.git' +
+ '@' + 'd09d649aea36f02c03f8396ba39a8d4db8a607e4', # version 3.10.1
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/zlib/src': {
+ 'url': Var('github') +
+ '/madler/zlib.git' +
+ '@' + 'cacf7f1d4e3d44d871b605da3b647f07d718623f', # version 1.2.11
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/jsoncpp/src': {
+ 'url': Var('chromium_git') +
+ '/external/github.com/open-source-parsers/jsoncpp.git' +
+ '@' + '2eb20a938c454411c1d416caeeb2a6511daab5cb', # version 1.9.0
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/googletest/src': {
+ 'url': Var('chromium_git') +
+ '/external/github.com/google/googletest.git' +
+ '@' + '8697709e0308af4cd5b09dc108480804e5447cf0',
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/mDNSResponder/src': {
+ 'url': Var('github') + '/jevinskie/mDNSResponder.git' +
+ '@' + '2942dde61f920fbbf96ff9a3840567ebbe7cb1b6',
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/boringssl/src': {
+ 'url' : Var('boringssl_git') + '/boringssl.git' +
+ '@' + '6410e18e9190b6b0c71955119fbf3cae1b9eedb7',
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/chromium_quic/src': {
+ 'url': Var('chromium_git') + '/openscreen/quic.git' +
+ '@' + 'd2363edc9f2a8561c9d02e836262f2d03de2d6e1',
+ 'condition': 'not build_with_chromium',
+ },
+
+ 'third_party/tinycbor/src':
+ Var('chromium_git') + '/external/github.com/intel/tinycbor.git' +
+ '@' + '755f9ef932f9830a63a712fd2ac971d838b131f1',
+
+ 'third_party/abseil/src': {
+ 'url': Var('chromium_git') +
+ '/external/github.com/abseil/abseil-cpp.git' +
+ '@' + '20de2db748ca0471cfb61cb53e813dd12938c12b',
+ 'condition': 'not build_with_chromium',
+ },
+ 'third_party/libfuzzer/src': {
+ 'url': Var('chromium_git') +
+ '/chromium/llvm-project/compiler-rt/lib/fuzzer.git' +
+ '@' + 'debe7d2d1982e540fbd6bd78604bf001753f9e74',
+ 'condition': 'not build_with_chromium',
+ },
}
+hooks = [
+ {
+ 'name': 'clang_update_script',
+ 'pattern': '.',
+ 'condition': 'not build_with_chromium',
+ 'action': [ 'python', 'tools/download-clang-update-script.py',
+ '--output', 'tools/clang/scripts/update.py' ],
+ # NOTE: This file appears in .gitignore, as it is not a part of the
+ # openscreen repo.
+ },
+ {
+ 'name': 'update_clang',
+ 'pattern': '.',
+ 'condition': 'not build_with_chromium',
+ 'action': [ 'python', 'tools/clang/scripts/update.py' ],
+ },
+ {
+ 'name': 'clang_format_linux64',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage.py', '--no_resume', '--no_auth',
+ '--bucket', 'chromium-clang-format',
+ '-s', 'buildtools/linux64/clang-format.sha1' ],
+ 'condition': 'host_os == "linux" and not build_with_chromium',
+ },
+ {
+ 'name': 'clang_format_mac',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage.py', '--no_resume', '--no_auth',
+ '--bucket', 'chromium-clang-format',
+ '-s', 'buildtools/mac/clang-format.sha1' ],
+ 'condition': 'host_os == "mac" and not build_with_chromium',
+ },
+]
+
recursedeps = [
- 'third_party/chromium_quic/src',
- 'buildtools',
+ 'third_party/chromium_quic/src',
+ 'buildtools',
]
include_rules = [
- '+build/config/features.h',
- '+util',
- '+platform/api',
- '+platform/base',
- '+platform/test',
- '+testing/util',
- '+third_party',
-
- # Don't include abseil from the root so the path can change via include_dirs
- # rules when in Chromium.
- '-third_party/abseil',
-
- # Abseil whitelist.
- '+absl/algorithm/container.h',
- '+absl/base/thread_annotations.h',
- '+absl/hash/hash.h',
- '+absl/strings/ascii.h',
- '+absl/strings/match.h',
- '+absl/strings/numbers.h',
- '+absl/strings/str_cat.h',
- '+absl/strings/str_join.h',
- '+absl/strings/str_split.h',
- '+absl/strings/string_view.h',
- '+absl/strings/substitute.h',
- '+absl/types/optional.h',
- '+absl/types/span.h',
- '+absl/types/variant.h',
-
- # Similar to abseil, don't include boringssl using root path. Instead,
- # explicitly allow 'openssl' where needed.
- '-third_party/boringssl',
-
- # Test framework includes.
- "-third_party/googletest",
- "+gtest",
- "+gmock",
+ '+build/config/features.h',
+ '+util',
+ '+platform/api',
+ '+platform/base',
+ '+platform/test',
+ '+testing/util',
+ '+third_party',
+
+ # Don't include abseil from the root so the path can change via include_dirs
+ # rules when in Chromium.
+ '-third_party/abseil',
+
+ # Abseil whitelist.
+ '+absl/algorithm/container.h',
+ '+absl/base/thread_annotations.h',
+ '+absl/hash/hash.h',
+ '+absl/strings/ascii.h',
+ '+absl/strings/match.h',
+ '+absl/strings/numbers.h',
+ '+absl/strings/str_cat.h',
+ '+absl/strings/str_join.h',
+ '+absl/strings/str_split.h',
+ '+absl/strings/string_view.h',
+ '+absl/strings/substitute.h',
+ '+absl/types/optional.h',
+ '+absl/types/span.h',
+ '+absl/types/variant.h',
+
+ # Similar to abseil, don't include boringssl using root path. Instead,
+ # explicitly allow 'openssl' where needed.
+ '-third_party/boringssl',
+
+ # Test framework includes.
+ "-third_party/googletest",
+ "+gtest",
+ "+gmock",
]
skip_child_includes = [
- 'third_party/chromium_quic',
+ 'third_party/chromium_quic',
]
diff --git a/README.md b/README.md
index 0d9fd115..aa77b33e 100644
--- a/README.md
+++ b/README.md
@@ -26,22 +26,28 @@ lint` and `git cl upload.`
## Checking out code
-From the parent directory of where you want the openscreen checkout, configure
-`gclient` and check out openscreen with the following commands:
+From the parent directory of where you want the openscreen checkout (e.g.,
+`~/my_project_dir`), configure `gclient` and check out openscreen with the
+following commands:
```bash
+ cd ~/my_project_dir
gclient config https://chromium.googlesource.com/openscreen
gclient sync
```
-Now, you should have `openscreen/` repository checked out, with all dependencies
-checked out to their appropriate revisions.
+The first `gclient` command will create a default .gclient file in
+`~/my_project_dir` that describes how to pull down the `openscreen` repository.
+The second command creates an `openscreen/` subdirectory, downloads the source
+code, all third-party dependencies, and the toolchain needed to build things;
+and at their appropriate revisions.
## Syncing your local checkout
To update your local checkout from the openscreen master repository, just run
```bash
+ cd ~/my_project_dir/openscreen
git pull
gclient sync
```
@@ -51,24 +57,23 @@ dependencies that have changed.
# Build setup
-## Installing build dependencies
-
-The following tools are required for building:
+The following are the main tools are required for development/builds:
- Build file generator: `gn`
- - Code formatter (optional): `clang-format`
+ - Code formatter: `clang-format`
- Builder: `ninja` ([GitHub releases](https://github.com/ninja-build/ninja/releases))
+ - Compiler/Linker: `clang` (installed by default) or `gcc` (installed by you)
-`clang-format` and `ninja` can be downloaded to `buildtools/<platform>` root by
-running `./tools/install-build-tools.sh`.
-
-`clang-format` is only used for presubmit checks and optionally used on
-generated code from the CDDL tool.
+All of these--except `gcc` as noted above--are automatically downloaded/updated
+for the Linux and Mac environments via `gclient sync` as described above. The
+first two are installed into `buildtools/<platform>/`.
-`gn` will be installed in `buildtools/<platform>/` automatically by `gclient sync`.
+Mac only: XCode must be installed on the system, to link against its frameworks.
-You also need to ensure that you have the compiler and its toolchain dependencies.
-Currently, both Linux and Mac OS X build configurations use clang by default.
+`clang-format` is used for maintaining consistent coding style, but it is not a
+complete replacement for adhering to Chromium/Google C++ style (that's on you!).
+The presubmit script will sanity-check that it has been run on all new/changed
+code.
## Linux clang
@@ -153,6 +158,11 @@ the working directory for the build. So the same could be done as follows:
After editing a file, only `ninja` needs to be rerun, not `gn`. If you have
edited a `BUILD.gn` file, `ninja` will re-run `gn` for you.
+Unless you like to wait longer than necessary for builds to complete, run
+`autoninja` instead of `ninja`, which takes the same command-line arguments.
+This will automatically parallelize the build for your system, depending on
+number of processor cores, RAM, etc.
+
For details on running `demo`, see its [README.md](demo/README.md).
## Building other targets
@@ -214,11 +224,13 @@ review tool) and is recommended for pushing patches for review. Once you have
committed changes locally, simply run:
```bash
+ git cl format
git cl upload
```
-This will run our `PRESUBMIT.sh` script to check style, and if it passes, a new
-code review will be posted on `chromium-review.googlesource.com`.
+The first command will will auto-format the code changes. Then, the second
+command runs the `PRESUBMIT.sh` script to check style and, if it passes, a
+newcode review will be posted on `chromium-review.googlesource.com`.
If you make additional commits to your local branch, then running `git cl
upload` again in the same branch will merge those commits into the ongoing
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index b37fb5c2..f10a4b98 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -74,12 +74,6 @@ declare_args() {
is_clang = !is_gcc
}
-# We need to ensure that clang is pulled down using the update script. In
-# Chromium, this is done with a gclient hook, but we can just call
-if (is_clang) {
- exec_script("//tools/clang/scripts/update.py")
-}
-
# ==============================================================================
# TOOLCHAIN SETUP
# ==============================================================================
diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn
index e2205142..f509e848 100644
--- a/build/toolchain/linux/BUILD.gn
+++ b/build/toolchain/linux/BUILD.gn
@@ -13,6 +13,9 @@ toolchain("linux") {
cpp_command = "g++"
}
+ lib_switch = "-l"
+ lib_dir_switch = "-L"
+
tool("cc") {
depfile = "{{output}}.d"
command = "$c_command -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
index f56dd499..341d6a63 100644
--- a/build/toolchain/mac/BUILD.gn
+++ b/build/toolchain/mac/BUILD.gn
@@ -6,6 +6,9 @@ toolchain("clang") {
c_command = "clang"
cpp_command = "clang++"
+ lib_switch = "-l"
+ lib_dir_switch = "-L"
+
tool("cc") {
depfile = "{{output}}.d"
command = "$c_command -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
diff --git a/cast/standalone_receiver/BUILD.gn b/cast/standalone_receiver/BUILD.gn
index 696f732b..0de68ee4 100644
--- a/cast/standalone_receiver/BUILD.gn
+++ b/cast/standalone_receiver/BUILD.gn
@@ -49,9 +49,9 @@ if (!build_with_chromium) {
"sdl_video_player.h",
]
libs += [
- "-lSDL2",
- "-lavcodec",
- "-lavutil",
+ "SDL2",
+ "avcodec",
+ "avutil",
]
} else {
sources += [
diff --git a/cast/standalone_receiver/dummy_player.h b/cast/standalone_receiver/dummy_player.h
index a75aa61e..e8db1bf7 100644
--- a/cast/standalone_receiver/dummy_player.h
+++ b/cast/standalone_receiver/dummy_player.h
@@ -20,7 +20,7 @@ namespace cast {
// each one's FrameId, timestamp and size. This is only useful for confirming a
// Receiver is successfully receiving a stream, for platforms where
// SDLVideoPlayer cannot be built.
-class DummyPlayer : public Receiver::Consumer {
+class DummyPlayer final : public Receiver::Consumer {
public:
explicit DummyPlayer(Receiver* receiver);
diff --git a/third_party/boringssl/BUILD.gn b/third_party/boringssl/BUILD.gn
index 6bfebca5..22e504fe 100644
--- a/third_party/boringssl/BUILD.gn
+++ b/third_party/boringssl/BUILD.gn
@@ -32,18 +32,8 @@ if (build_with_chromium) {
"BORINGSSL_NO_STATIC_INITIALIZER",
"OPENSSL_SMALL",
]
- cflags = []
+ cflags = [ "-w" ] # Disable all warnings.
cflags_c = [ "-std=c99" ]
- cflags_cc = []
- if (is_clang) {
- cflags += [ "-Wno-extra-semi" ]
- cflags_cc += [ "-Wno-c++98-compat-extra-semi" ]
- }
-
- if (is_mac) {
- # Necessary since trybots have an old version of clang.
- cflags += [ "-Wno-unknown-warning-option" ]
- }
defines += [ "_XOPEN_SOURCE=700" ]
}
diff --git a/third_party/chromium_quic/BUILD.gn b/third_party/chromium_quic/BUILD.gn
index 2cf14c00..4644bd5e 100644
--- a/third_party/chromium_quic/BUILD.gn
+++ b/third_party/chromium_quic/BUILD.gn
@@ -5,37 +5,7 @@
import("//third_party/protobuf/proto_library.gni")
config("chromium_quic_config") {
- cflags_cc = [
- "-Wno-error=attributes",
- "-Wno-unused-const-variable",
- ]
-
- if (is_clang) {
- cflags_cc += [
- "-Wno-defaulted-function-deleted",
- "-Wno-c++98-compat-extra-semi",
- "-Wno-extra-semi",
- ]
-
- # The clang version on the Mac OS X build bots is old, causing them to
- # not recognize the defaulted-function-deleted warning. This flag allows
- # us to build on both older and newer Mac OS X Clang toolchains.
- if (is_mac) {
- cflags_cc += [ "-Wno-unknown-warning-option" ]
- }
- }
-
- if (is_gcc) {
- cflags_cc += [
- "-Wno-dangling-else",
- "-Wno-return-type",
- "-Wno-unused-but-set-variable",
-
- # Don't warn about "maybe" uninitialized. Clang doesn't include this
- # in -Wall but gcc does, and it gives false positives.
- "-Wno-maybe-uninitialized",
- ]
- }
+ cflags = [ "-w" ] # Disable all warnings.
configs = [ "//third_party/protobuf:protobuf_config" ]
diff --git a/third_party/mDNSResponder/BUILD.gn b/third_party/mDNSResponder/BUILD.gn
index 2927e84f..4e2fb8d4 100644
--- a/third_party/mDNSResponder/BUILD.gn
+++ b/third_party/mDNSResponder/BUILD.gn
@@ -3,20 +3,9 @@
# found in the LICENSE file.
config("mdnsresponder_config") {
- cflags_c = [ "-Wno-array-bounds" ]
+ cflags = [ "-w" ] # Disable all warnings.
- if (is_gcc) {
- cflags_c += [
- "-Wno-unused-but-set-variable",
- "-Wno-unused-value",
- ]
- }
-
- if (is_clang) {
- cflags_c += [ "-Wno-address-of-packed-member" ]
- }
-
- cflags_c += [
+ cflags_c = [
# We need to rename some linked symbols in order to avoid multiple
# definitions.
"-DMD5_Update=MD5_Update_mDNS",
diff --git a/third_party/tinycbor/BUILD.gn b/third_party/tinycbor/BUILD.gn
index ff8480fc..45215805 100644
--- a/third_party/tinycbor/BUILD.gn
+++ b/third_party/tinycbor/BUILD.gn
@@ -4,6 +4,11 @@
import("//build_overrides/build.gni")
+config("tinycbor_internal_config") {
+ defines = [ "WITHOUT_OPEN_MEMSTREAM" ]
+ cflags = [ "-w" ] # Disable all warnings.
+}
+
source_set("tinycbor") {
sources = [
"src/src/cbor.h",
@@ -16,5 +21,5 @@ source_set("tinycbor") {
"src/src/utf8_p.h",
]
- defines = [ "WITHOUT_OPEN_MEMSTREAM" ]
+ configs += [ ":tinycbor_internal_config" ]
}
diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn
index 3223c28f..457fc9a8 100644
--- a/third_party/zlib/BUILD.gn
+++ b/third_party/zlib/BUILD.gn
@@ -8,13 +8,7 @@ config("zlib_config") {
config("zlib_internal_config") {
defines = [ "ZLIB_IMPLEMENTATION" ]
- cflags = [ "-Wno-implicit-function-declaration" ]
- if (is_clang) {
- cflags += [
- "-Wno-incompatible-pointer-types",
- "-Wno-unused-variable",
- ]
- }
+ cflags = [ "-w" ] # Disable all warnings.
}
static_library("zlib") {
diff --git a/tools/cl-format.sh b/tools/cl-format.sh
deleted file mode 100755
index 6bc159e6..00000000
--- a/tools/cl-format.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-for f in $(git diff --name-only @{u}); do
- # Skip third party files, except our custom BUILD.gns
- if [[ $f =~ third_party/[^\/]*/src ]]; then
- continue;
- fi
-
- # Skip statically copied Chromium QUIC build files.
- if [[ $f =~ third_party/chromium_quic/build ]]; then
- continue;
- fi
-
- # Skip files deleted in this patch
- if ! [[ -f $f ]]; then
- continue;
- fi
-
- # Format cpp files
- if [[ $f =~ \.(cc|h)$ ]]; then
- clang-format -style=file -i "$f"
- fi
-
- # Format gn files
- if [[ $f =~ \.gn$ ]]; then
- gn format $f
- fi
-
-done
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
deleted file mode 100755
index 3774d78d..00000000
--- a/tools/clang/scripts/update.py
+++ /dev/null
@@ -1,1025 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# NOTE: this file is taken from the chromium repo, viewable here:
-# https://cs.chromium.org/codesearch/f/chromium/src/tools/clang/scripts/update.py?cl=e485df98abd46b3f774377624ae7850e795fd4d8
-
-# Some minor alterations have been made to suit our use case here.
-
-"""This script is used to download prebuilt clang binaries.
-
-It is also used by package.py to build the prebuilt clang binaries."""
-
-import argparse
-import distutils.spawn
-import glob
-import os
-import pipes
-import re
-import shutil
-import subprocess
-import stat
-import sys
-import tarfile
-import tempfile
-import time
-import urllib2
-import zipfile
-
-
-# Do NOT CHANGE this if you don't know what you're doing -- see
-# https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang.md
-# Reverting problematic clang rolls is safe, though.
-CLANG_REVISION = '352138'
-
-use_head_revision = bool(os.environ.get('LLVM_FORCE_HEAD_REVISION', '0')
- in ('1', 'YES'))
-if use_head_revision:
- CLANG_REVISION = 'HEAD'
-
-# This is incremented when pushing a new build of Clang at the same revision.
-CLANG_SUB_REVISION=2
-
-PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION)
-
-# Path constants. (All of these should be absolute paths.)
-THIS_DIR = os.path.abspath(os.path.dirname(__file__))
-CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..'))
-GCLIENT_CONFIG = os.path.join(os.path.dirname(CHROMIUM_DIR), '.gclient')
-THIRD_PARTY_DIR = os.path.join(CHROMIUM_DIR, 'third_party')
-LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm')
-LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap')
-LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR,
- 'llvm-bootstrap-install')
-CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools')
-LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build',
- 'Release+Asserts')
-THREADS_ENABLED_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, 'threads_enabled')
-COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, 'compiler-rt')
-CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang')
-LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld')
-# compiler-rt is built as part of the regular LLVM build on Windows to get
-# the 64-bit runtime, and out-of-tree elsewhere.
-# TODO(thakis): Try to unify this.
-if sys.platform == 'win32':
- COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt')
-else:
- COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'compiler-rt')
-LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx')
-LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi')
-LLVM_BUILD_TOOLS_DIR = os.path.abspath(
- os.path.join(LLVM_DIR, '..', 'llvm-build-tools'))
-STAMP_FILE = os.path.normpath(
- os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision'))
-VERSION = '9.0.0'
-ANDROID_NDK_DIR = os.path.join(
- CHROMIUM_DIR, 'third_party', 'android_ndk')
-FUCHSIA_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'fuchsia-sdk',
- 'sdk')
-
-# URL for pre-built binaries.
-CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE',
- 'https://commondatastorage.googleapis.com/chromium-browser-clang')
-
-LLVM_REPO_URL='https://llvm.org/svn/llvm-project'
-if 'LLVM_REPO_URL' in os.environ:
- LLVM_REPO_URL = os.environ['LLVM_REPO_URL']
-
-
-
-def DownloadUrl(url, output_file):
- """Download url into output_file."""
- CHUNK_SIZE = 4096
- TOTAL_DOTS = 10
- num_retries = 3
- retry_wait_s = 5 # Doubled at each retry.
-
- while True:
- try:
- sys.stdout.write('Downloading %s ' % url)
- sys.stdout.write('to %s' % output_file)
- sys.stdout.flush()
- response = urllib2.urlopen(url)
- total_size = int(response.info().getheader('Content-Length').strip())
- bytes_done = 0
- dots_printed = 0
- while True:
- chunk = response.read(CHUNK_SIZE)
- if not chunk:
- break
- output_file.write(chunk)
- bytes_done += len(chunk)
- num_dots = TOTAL_DOTS * bytes_done / total_size
- sys.stdout.write('.' * (num_dots - dots_printed))
- sys.stdout.flush()
- dots_printed = num_dots
- if bytes_done != total_size:
- raise urllib2.URLError("only got %d of %d bytes" %
- (bytes_done, total_size))
- print ' Done.'
- return
- except urllib2.URLError as e:
- sys.stdout.write('\n')
- print e
- if num_retries == 0 or isinstance(e, urllib2.HTTPError) and e.code == 404:
- raise e
- num_retries -= 1
- print 'Retrying in %d s ...' % retry_wait_s
- time.sleep(retry_wait_s)
- retry_wait_s *= 2
-
-
-def EnsureDirExists(path):
- if not os.path.exists(path):
- os.makedirs(path)
-
-
-def DownloadAndUnpack(url, output_dir, path_prefix=None):
- """Download an archive from url and extract into output_dir. If path_prefix is
- not None, only extract files whose paths within the archive start with
- path_prefix."""
- with tempfile.TemporaryFile() as f:
- DownloadUrl(url, f)
- f.seek(0)
- EnsureDirExists(output_dir)
- if url.endswith('.zip'):
- assert path_prefix is None
- zipfile.ZipFile(f).extractall(path=output_dir)
- else:
- t = tarfile.open(mode='r:gz', fileobj=f)
- members = None
- if path_prefix is not None:
- members = [m for m in t.getmembers() if m.name.startswith(path_prefix)]
- print("Extracting to output_dir: {}".format(output_dir))
- t.extractall(path=output_dir, members=members)
-
-
-def ReadStampFile(path=STAMP_FILE):
- """Return the contents of the stamp file, or '' if it doesn't exist."""
- try:
- with open(path, 'r') as f:
- return f.read().rstrip()
- except IOError:
- return ''
-
-
-def WriteStampFile(s, path=STAMP_FILE):
- """Write s to the stamp file."""
- EnsureDirExists(os.path.dirname(path))
- with open(path, 'w') as f:
- f.write(s)
- f.write('\n')
-
-
-def GetSvnRevision(svn_repo):
- """Returns current revision of the svn repo at svn_repo."""
- svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True)
- m = re.search(r'Revision: (\d+)', svn_info)
- return m.group(1)
-
-
-def RmTree(dir):
- """Delete dir."""
- def ChmodAndRetry(func, path, _):
- # Subversion can leave read-only files around.
- if not os.access(path, os.W_OK):
- os.chmod(path, stat.S_IWUSR)
- return func(path)
- raise
-
- shutil.rmtree(dir, onerror=ChmodAndRetry)
-
-
-def RmCmakeCache(dir):
- """Delete CMake cache related files from dir."""
- for dirpath, dirs, files in os.walk(dir):
- if 'CMakeCache.txt' in files:
- os.remove(os.path.join(dirpath, 'CMakeCache.txt'))
- if 'CMakeFiles' in dirs:
- RmTree(os.path.join(dirpath, 'CMakeFiles'))
-
-
-def RunCommand(command, msvc_arch=None, env=None, fail_hard=True):
- """Run command and return success (True) or failure; or if fail_hard is
- True, exit on failure. If msvc_arch is set, runs the command in a
- shell with the msvc tools for that architecture."""
-
- if msvc_arch and sys.platform == 'win32':
- command = [os.path.join(GetWinSDKDir(), 'bin', 'SetEnv.cmd'),
- "/" + msvc_arch, '&&'] + command
-
- # https://docs.python.org/2/library/subprocess.html:
- # "On Unix with shell=True [...] if args is a sequence, the first item
- # specifies the command string, and any additional items will be treated as
- # additional arguments to the shell itself. That is to say, Popen does the
- # equivalent of:
- # Popen(['/bin/sh', '-c', args[0], args[1], ...])"
- #
- # We want to pass additional arguments to command[0], not to the shell,
- # so manually join everything into a single string.
- # Annoyingly, for "svn co url c:\path", pipes.quote() thinks that it should
- # quote c:\path but svn can't handle quoted paths on Windows. Since on
- # Windows follow-on args are passed to args[0] instead of the shell, don't
- # do the single-string transformation there.
- if sys.platform != 'win32':
- command = ' '.join([pipes.quote(c) for c in command])
- print 'Running', command
- if subprocess.call(command, env=env, shell=True) == 0:
- return True
- print 'Failed.'
- if fail_hard:
- sys.exit(1)
- return False
-
-
-def CopyFile(src, dst):
- """Copy a file from src to dst."""
- print "Copying %s to %s" % (src, dst)
- shutil.copy(src, dst)
-
-
-def CopyDirectoryContents(src, dst):
- """Copy the files from directory src to dst."""
- dst = os.path.realpath(dst) # realpath() in case dst ends in /..
- EnsureDirExists(dst)
- for f in os.listdir(src):
- CopyFile(os.path.join(src, f), dst)
-
-
-def Checkout(name, url, dir):
- """Checkout the SVN module at url into dir. Use name for the log message."""
- print "Checking out %s r%s into '%s'" % (name, CLANG_REVISION, dir)
-
- command = ['svn', 'checkout', '--force', url + '@' + CLANG_REVISION, dir]
- if RunCommand(command, fail_hard=False):
- return
-
- if os.path.isdir(dir):
- print "Removing %s." % (dir)
- RmTree(dir)
-
- print "Retrying."
- RunCommand(command)
-
-
-def CheckoutRepos(args):
- if args.skip_checkout:
- return
-
- Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR)
- Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR)
- if True:
- Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR)
- elif os.path.exists(LLD_DIR):
- # In case someone sends a tryjob that temporary adds lld to the checkout,
- # make sure it's not around on future builds.
- RmTree(LLD_DIR)
- Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR)
- if sys.platform == 'darwin':
- # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
- # (i.e. this is needed for bootstrap builds).
- Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR)
- # We used to check out libcxxabi on OS X; we no longer need that.
- if os.path.exists(LIBCXXABI_DIR):
- RmTree(LIBCXXABI_DIR)
-
-
-def DeleteChromeToolsShim():
- OLD_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'zzz-chrometools')
- shutil.rmtree(OLD_SHIM_DIR, ignore_errors=True)
- shutil.rmtree(CHROME_TOOLS_SHIM_DIR, ignore_errors=True)
-
-
-def CreateChromeToolsShim():
- """Hooks the Chrome tools into the LLVM build.
-
- Several Chrome tools have dependencies on LLVM/Clang libraries. The LLVM build
- detects implicit tools in the tools subdirectory, so this helper install a
- shim CMakeLists.txt that forwards to the real directory for the Chrome tools.
-
- Note that the shim directory name intentionally has no - or _. The implicit
- tool detection logic munges them in a weird way."""
- assert not any(i in os.path.basename(CHROME_TOOLS_SHIM_DIR) for i in '-_')
- os.mkdir(CHROME_TOOLS_SHIM_DIR)
- with file(os.path.join(CHROME_TOOLS_SHIM_DIR, 'CMakeLists.txt'), 'w') as f:
- f.write('# Automatically generated by tools/clang/scripts/update.py. ' +
- 'Do not edit.\n')
- f.write('# Since tools/clang is located in another directory, use the \n')
- f.write('# two arg version to specify where build artifacts go. CMake\n')
- f.write('# disallows reuse of the same binary dir for multiple source\n')
- f.write('# dirs, so the build artifacts need to go into a subdirectory.\n')
- f.write('if (CHROMIUM_TOOLS_SRC)\n')
- f.write(' add_subdirectory(${CHROMIUM_TOOLS_SRC} ' +
- '${CMAKE_CURRENT_BINARY_DIR}/a)\n')
- f.write('endif (CHROMIUM_TOOLS_SRC)\n')
-
-
-def AddSvnToPathOnWin():
- """Download svn.exe and add it to PATH."""
- if sys.platform != 'win32':
- return
- svn_ver = 'svn-1.6.6-win'
- svn_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, svn_ver)
- if not os.path.exists(svn_dir):
- DownloadAndUnpack(CDS_URL + '/tools/%s.zip' % svn_ver, LLVM_BUILD_TOOLS_DIR)
- os.environ['PATH'] = svn_dir + os.pathsep + os.environ.get('PATH', '')
-
-
-def AddCMakeToPath(args):
- """Download CMake and add it to PATH."""
- if args.use_system_cmake:
- return
-
- if sys.platform == 'win32':
- zip_name = 'cmake-3.12.1-win32-x86.zip'
- dir_name = ['cmake-3.12.1-win32-x86', 'bin']
- elif sys.platform == 'darwin':
- zip_name = 'cmake-3.12.1-Darwin-x86_64.tar.gz'
- dir_name = ['cmake-3.12.1-Darwin-x86_64', 'CMake.app', 'Contents', 'bin']
- else:
- zip_name = 'cmake-3.12.1-Linux-x86_64.tar.gz'
- dir_name = ['cmake-3.12.1-Linux-x86_64', 'bin']
-
- cmake_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, *dir_name)
- if not os.path.exists(cmake_dir):
- DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
- os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
-
-
-def AddGnuWinToPath():
- """Download some GNU win tools and add them to PATH."""
- if sys.platform != 'win32':
- return
-
- gnuwin_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gnuwin')
- GNUWIN_VERSION = '9'
- GNUWIN_STAMP = os.path.join(gnuwin_dir, 'stamp')
- if ReadStampFile(GNUWIN_STAMP) == GNUWIN_VERSION:
- print 'GNU Win tools already up to date.'
- else:
- zip_name = 'gnuwin-%s.zip' % GNUWIN_VERSION
- DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
- WriteStampFile(GNUWIN_VERSION, GNUWIN_STAMP)
-
- os.environ['PATH'] = gnuwin_dir + os.pathsep + os.environ.get('PATH', '')
-
- # find.exe, mv.exe and rm.exe are from MSYS (see crrev.com/389632). MSYS uses
- # Cygwin under the hood, and initializing Cygwin has a race-condition when
- # getting group and user data from the Active Directory is slow. To work
- # around this, use a horrible hack telling it not to do that.
- # See https://crbug.com/905289
- etc = os.path.join(gnuwin_dir, '..', '..', 'etc')
- EnsureDirExists(etc)
- with open(os.path.join(etc, 'nsswitch.conf'), 'w') as f:
- f.write('passwd: files\n')
- f.write('group: files\n')
-
-
-win_sdk_dir = None
-dia_dll = None
-def GetWinSDKDir():
- """Get the location of the current SDK. Sets dia_dll as a side-effect."""
- global win_sdk_dir
- global dia_dll
- if win_sdk_dir:
- return win_sdk_dir
-
- # Bump after VC updates.
- DIA_DLL = {
- '2013': 'msdia120.dll',
- '2015': 'msdia140.dll',
- '2017': 'msdia140.dll',
- '2019': 'msdia140.dll',
- }
-
- # Don't let vs_toolchain overwrite our environment.
- environ_bak = os.environ
-
- sys.path.append(os.path.join(CHROMIUM_DIR, 'build'))
- import vs_toolchain
- win_sdk_dir = vs_toolchain.SetEnvironmentAndGetSDKDir()
- msvs_version = vs_toolchain.GetVisualStudioVersion()
-
- if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))):
- dia_path = os.path.join(win_sdk_dir, '..', 'DIA SDK', 'bin', 'amd64')
- else:
- if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ:
- vs_path = vs_toolchain.DetectVisualStudioPath()
- else:
- vs_path = os.environ['GYP_MSVS_OVERRIDE_PATH']
- dia_path = os.path.join(vs_path, 'DIA SDK', 'bin', 'amd64')
-
- dia_dll = os.path.join(dia_path, DIA_DLL[msvs_version])
-
- os.environ = environ_bak
- return win_sdk_dir
-
-
-def CopyDiaDllTo(target_dir):
- # This script always wants to use the 64-bit msdia*.dll.
- GetWinSDKDir()
- CopyFile(dia_dll, target_dir)
-
-
-def VeryifyVersionOfBuiltClangMatchesVERSION():
- """Checks that `clang --version` outputs VERSION. If this fails, VERSION
- in this file is out-of-date and needs to be updated (possibly in an
- `if use_head_revision:` block in main() first)."""
- clang = os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')
- if sys.platform == 'win32':
- clang += '.exe'
- version_out = subprocess.check_output([clang, '--version'])
- version_out = re.match(r'clang version ([0-9.]+)', version_out).group(1)
- if version_out != VERSION:
- print ('unexpected clang version %s (not %s), update VERSION in update.py'
- % (version_out, VERSION))
- sys.exit(1)
-
-
-def GetPlatformUrlPrefix(platform):
- if platform == 'win32' or platform == 'cygwin':
- return CDS_URL + '/Win/'
- if platform == 'darwin':
- return CDS_URL + '/Mac/'
- assert platform.startswith('linux')
- return CDS_URL + '/Linux_x64/'
-
-
-def DownloadAndUnpackClangPackage(platform, runtimes_only=False):
- cds_file = "clang-%s.tgz" % PACKAGE_VERSION
- cds_full_url = GetPlatformUrlPrefix(platform) + cds_file
- try:
- path_prefix = None
- if runtimes_only:
- path_prefix = 'lib/clang/' + VERSION + '/lib/'
- DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR, path_prefix)
- except urllib2.URLError:
- print 'Failed to download prebuilt clang %s' % cds_file
- print 'Use --force-local-build if you want to build locally.'
- print 'Exiting.'
- sys.exit(1)
-
-
-def UpdateClang(args):
- # Read target_os from .gclient so we know which non-native runtimes we need.
- # TODO(pcc): See if we can download just the runtimes instead of the entire
- # clang package, and do that from DEPS instead of here.
- target_os = []
- try:
- env = {}
- execfile(GCLIENT_CONFIG, env, env)
- target_os = env.get('target_os', target_os)
- except:
- pass
-
- expected_stamp = ','.join([PACKAGE_VERSION] + target_os)
- if ReadStampFile() == expected_stamp and not args.force_local_build:
- return 0
-
- # Reset the stamp file in case the build is unsuccessful.
- WriteStampFile('')
-
- if not args.force_local_build:
- if os.path.exists(LLVM_BUILD_DIR):
- RmTree(LLVM_BUILD_DIR)
-
- DownloadAndUnpackClangPackage(sys.platform)
- if 'win' in target_os:
- DownloadAndUnpackClangPackage('win32', runtimes_only=True)
- if sys.platform == 'win32':
- CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin'))
- WriteStampFile(expected_stamp)
- return 0
-
- if args.with_android and not os.path.exists(ANDROID_NDK_DIR):
- print 'Android NDK not found at ' + ANDROID_NDK_DIR
- print 'The Android NDK is needed to build a Clang whose -fsanitize=address'
- print 'works on Android. See '
- print 'https://www.chromium.org/developers/how-tos/android-build-instructions'
- print 'for how to install the NDK, or pass --without-android.'
- return 1
-
- if args.with_fuchsia and not os.path.exists(FUCHSIA_SDK_DIR):
- print 'Fuchsia SDK not found at ' + FUCHSIA_SDK_DIR
- print 'The Fuchsia SDK is needed to build libclang_rt for Fuchsia.'
- print 'Install the Fuchsia SDK by adding fuchsia to the '
- print 'target_os section in your .gclient and running hooks, '
- print 'or pass --without-fuchsia.'
- print 'https://chromium.googlesource.com/chromium/src/+/master/docs/fuchsia_build_instructions.md'
- print 'for general Fuchsia build instructions.'
- return 1
-
- print 'Locally building Clang %s...' % PACKAGE_VERSION
-
- AddCMakeToPath(args)
- AddGnuWinToPath()
-
- DeleteChromeToolsShim()
-
- CheckoutRepos(args)
-
- if args.skip_build:
- return
-
- cc, cxx = None, None
- libstdcpp = None
-
- cflags = []
- cxxflags = []
- ldflags = []
-
- targets = 'AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86'
- base_cmake_args = ['-GNinja',
- '-DCMAKE_BUILD_TYPE=Release',
- '-DLLVM_ENABLE_ASSERTIONS=ON',
- '-DLLVM_ENABLE_TERMINFO=OFF',
- '-DLLVM_TARGETS_TO_BUILD=' + targets,
- # Statically link MSVCRT to avoid DLL dependencies.
- '-DLLVM_USE_CRT_RELEASE=MT',
- '-DCLANG_PLUGIN_SUPPORT=OFF',
- '-DCLANG_ENABLE_STATIC_ANALYZER=OFF',
- '-DCLANG_ENABLE_ARCMT=OFF',
- ]
-
- if sys.platform != 'win32':
- # libxml2 is required by the Win manifest merging tool used in cross-builds.
- base_cmake_args.append('-DLLVM_ENABLE_LIBXML2=FORCE_ON')
-
- if args.bootstrap:
- print 'Building bootstrap compiler'
- EnsureDirExists(LLVM_BOOTSTRAP_DIR)
- os.chdir(LLVM_BOOTSTRAP_DIR)
- bootstrap_args = base_cmake_args + [
- '-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64',
- '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR,
- '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
- ]
- if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc)
- if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
- RmCmakeCache('.')
- RunCommand(['cmake'] + bootstrap_args + [LLVM_DIR], msvc_arch='x64')
- RunCommand(['ninja'], msvc_arch='x64')
- if args.run_tests:
- if sys.platform == 'win32':
- CopyDiaDllTo(os.path.join(LLVM_BOOTSTRAP_DIR, 'bin'))
- RunCommand(['ninja', 'check-all'], msvc_arch='x64')
- RunCommand(['ninja', 'install'], msvc_arch='x64')
-
- if sys.platform == 'win32':
- cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe')
- cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe')
- # CMake has a hard time with backslashes in compiler paths:
- # https://stackoverflow.com/questions/13050827
- cc = cc.replace('\\', '/')
- cxx = cxx.replace('\\', '/')
- else:
- cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang')
- cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang++')
-
- print 'Building final compiler'
-
- # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
- # needed, on OS X it requires libc++. clang only automatically links to libc++
- # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run
- # on OS X versions as old as 10.7.
- deployment_target = ''
-
- if sys.platform == 'darwin' and args.bootstrap:
- # When building on 10.9, /usr/include usually doesn't exist, and while
- # Xcode's clang automatically sets a sysroot, self-built clangs don't.
- cflags = ['-isysroot', subprocess.check_output(
- ['xcrun', '--show-sdk-path']).rstrip()]
- cxxflags = ['-stdlib=libc++'] + cflags
- ldflags += ['-stdlib=libc++']
- deployment_target = '10.7'
- # Running libc++ tests takes a long time. Since it was only needed for
- # the install step above, don't build it as part of the main build.
- # This makes running package.py over 10% faster (30 min instead of 34 min)
- RmTree(LIBCXX_DIR)
-
-
- # If building at head, define a macro that plugins can use for #ifdefing
- # out code that builds at head, but not at CLANG_REVISION or vice versa.
- if use_head_revision:
- cflags += ['-DLLVM_FORCE_HEAD_REVISION']
- cxxflags += ['-DLLVM_FORCE_HEAD_REVISION']
-
- # Build PDBs for archival on Windows. Don't use RelWithDebInfo since it
- # has different optimization defaults than Release.
- # Also disable stack cookies (/GS-) for performance.
- if sys.platform == 'win32':
- cflags += ['/Zi', '/GS-']
- cxxflags += ['/Zi', '/GS-']
- ldflags += ['/DEBUG', '/OPT:REF', '/OPT:ICF']
-
- deployment_env = None
- if deployment_target:
- deployment_env = os.environ.copy()
- deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
-
- # Build lld and code coverage tools. This is done separately from the rest of
- # the build because these tools require threading support.
- tools_with_threading = [ 'lld', 'llvm-cov', 'llvm-profdata' ]
- print 'Building the following tools with threading support: %s' % (
- str(tools_with_threading))
-
- if os.path.exists(THREADS_ENABLED_BUILD_DIR):
- RmTree(THREADS_ENABLED_BUILD_DIR)
- EnsureDirExists(THREADS_ENABLED_BUILD_DIR)
- os.chdir(THREADS_ENABLED_BUILD_DIR)
-
- threads_enabled_cmake_args = base_cmake_args + [
- '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
- '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags),
- '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags),
- '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags)]
- if cc is not None:
- threads_enabled_cmake_args.append('-DCMAKE_C_COMPILER=' + cc)
- if cxx is not None:
- threads_enabled_cmake_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
-
- if args.lto_lld:
- # Build lld with LTO. That speeds up the linker by ~10%.
- # We only use LTO for Linux now.
- #
- # The linker expects all archive members to have symbol tables, so the
- # archiver needs to be able to create symbol tables for bitcode files.
- # GNU ar and ranlib don't understand bitcode files, but llvm-ar and
- # llvm-ranlib do, so use them.
- ar = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'llvm-ar')
- ranlib = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'llvm-ranlib')
- threads_enabled_cmake_args += [
- '-DCMAKE_AR=' + ar,
- '-DCMAKE_RANLIB=' + ranlib,
- '-DLLVM_ENABLE_LTO=thin',
- '-DLLVM_USE_LINKER=lld']
-
- RmCmakeCache('.')
- RunCommand(['cmake'] + threads_enabled_cmake_args + [LLVM_DIR],
- msvc_arch='x64', env=deployment_env)
- RunCommand(['ninja'] + tools_with_threading, msvc_arch='x64')
-
- # Build clang and other tools.
- CreateChromeToolsShim()
-
- cmake_args = []
- # TODO(thakis): Unconditionally append this to base_cmake_args instead once
- # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698)
- cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args
- if cc is not None: cc_args.append('-DCMAKE_C_COMPILER=' + cc)
- if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
- default_tools = ['plugins', 'blink_gc_plugin', 'translation_unit']
- chrome_tools = list(set(default_tools + args.extra_tools))
- cmake_args += base_cmake_args + [
- '-DLLVM_ENABLE_THREADS=OFF',
- '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
- '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags),
- '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags),
- '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags),
- '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR,
- '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'),
- '-DCHROMIUM_TOOLS=%s' % ';'.join(chrome_tools)]
-
- EnsureDirExists(LLVM_BUILD_DIR)
- os.chdir(LLVM_BUILD_DIR)
- RmCmakeCache('.')
- RunCommand(['cmake'] + cmake_args + [LLVM_DIR],
- msvc_arch='x64', env=deployment_env)
- RunCommand(['ninja'], msvc_arch='x64')
-
- # Copy in the threaded versions of lld and other tools.
- if sys.platform == 'win32':
- CopyFile(os.path.join(THREADS_ENABLED_BUILD_DIR, 'bin', 'lld-link.exe'),
- os.path.join(LLVM_BUILD_DIR, 'bin'))
- CopyFile(os.path.join(THREADS_ENABLED_BUILD_DIR, 'bin', 'lld.pdb'),
- os.path.join(LLVM_BUILD_DIR, 'bin'))
- else:
- for tool in tools_with_threading:
- CopyFile(os.path.join(THREADS_ENABLED_BUILD_DIR, 'bin', tool),
- os.path.join(LLVM_BUILD_DIR, 'bin'))
-
- if chrome_tools:
- # If any Chromium tools were built, install those now.
- RunCommand(['ninja', 'cr-install'], msvc_arch='x64')
-
- VeryifyVersionOfBuiltClangMatchesVERSION()
-
- # Do an out-of-tree build of compiler-rt.
- # On Windows, this is used to get the 32-bit ASan run-time.
- # TODO(hans): Remove once the regular build above produces this.
- # On Mac and Linux, this is used to get the regular 64-bit run-time.
- # Do a clobbered build due to cmake changes.
- if os.path.isdir(COMPILER_RT_BUILD_DIR):
- RmTree(COMPILER_RT_BUILD_DIR)
- os.makedirs(COMPILER_RT_BUILD_DIR)
- os.chdir(COMPILER_RT_BUILD_DIR)
- # TODO(thakis): Add this once compiler-rt can build with clang-cl (see
- # above).
- #if args.bootstrap and sys.platform == 'win32':
- # The bootstrap compiler produces 64-bit binaries by default.
- #cflags += ['-m32']
- #cxxflags += ['-m32']
- compiler_rt_args = base_cmake_args + [
- '-DLLVM_ENABLE_THREADS=OFF',
- '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)]
- if sys.platform == 'darwin':
- compiler_rt_args += ['-DCOMPILER_RT_ENABLE_IOS=ON']
- if sys.platform != 'win32':
- compiler_rt_args += ['-DLLVM_CONFIG_PATH=' +
- os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-config'),
- '-DSANITIZER_MIN_OSX_VERSION="10.7"']
- # compiler-rt is part of the llvm checkout on Windows but a stand-alone
- # directory elsewhere, see the TODO above COMPILER_RT_DIR.
- RmCmakeCache('.')
- RunCommand(['cmake'] + compiler_rt_args +
- [LLVM_DIR if sys.platform == 'win32' else COMPILER_RT_DIR],
- msvc_arch='x86', env=deployment_env)
- RunCommand(['ninja', 'compiler-rt'], msvc_arch='x86')
- if sys.platform != 'win32':
- RunCommand(['ninja', 'fuzzer'])
-
- # Copy select output to the main tree.
- # TODO(hans): Make this (and the .gypi and .isolate files) version number
- # independent.
- if sys.platform == 'win32':
- platform = 'windows'
- elif sys.platform == 'darwin':
- platform = 'darwin'
- else:
- assert sys.platform.startswith('linux')
- platform = 'linux'
- rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', platform)
- if sys.platform == 'win32':
- # TODO(thakis): This too is due to compiler-rt being part of the checkout
- # on Windows, see TODO above COMPILER_RT_DIR.
- rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
- VERSION, 'lib', platform)
- rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', VERSION, 'lib',
- platform)
- # Blacklists:
- CopyDirectoryContents(os.path.join(rt_lib_src_dir, '..', '..', 'share'),
- os.path.join(rt_lib_dst_dir, '..', '..', 'share'))
- # Headers:
- if sys.platform != 'win32':
- CopyDirectoryContents(
- os.path.join(COMPILER_RT_BUILD_DIR, 'include/sanitizer'),
- os.path.join(LLVM_BUILD_DIR, 'lib/clang', VERSION, 'include/sanitizer'))
- # Static and dynamic libraries:
- CopyDirectoryContents(rt_lib_src_dir, rt_lib_dst_dir)
- if sys.platform == 'darwin':
- for dylib in glob.glob(os.path.join(rt_lib_dst_dir, '*.dylib')):
- # Fix LC_ID_DYLIB for the ASan dynamic libraries to be relative to
- # @executable_path.
- # TODO(glider): this is transitional. We'll need to fix the dylib
- # name either in our build system, or in Clang. See also
- # http://crbug.com/344836.
- subprocess.call(['install_name_tool', '-id',
- '@executable_path/' + os.path.basename(dylib), dylib])
-
- if args.with_android:
- make_toolchain = os.path.join(
- ANDROID_NDK_DIR, 'build', 'tools', 'make_standalone_toolchain.py')
- for target_arch in ['aarch64', 'arm', 'i686']:
- # Make standalone Android toolchain for target_arch.
- toolchain_dir = os.path.join(
- LLVM_BUILD_DIR, 'android-toolchain-' + target_arch)
- api_level = '21' if target_arch == 'aarch64' else '19'
- RunCommand([
- make_toolchain,
- '--api=' + api_level,
- '--force',
- '--install-dir=%s' % toolchain_dir,
- '--stl=libc++',
- '--arch=' + {
- 'aarch64': 'arm64',
- 'arm': 'arm',
- 'i686': 'x86',
- }[target_arch]])
-
- # NDK r16 "helpfully" installs libc++ as libstdc++ "so the compiler will
- # pick it up by default". Only these days, the compiler tries to find
- # libc++ instead. See https://crbug.com/902270.
- shutil.copy(os.path.join(toolchain_dir, 'sysroot/usr/lib/libstdc++.a'),
- os.path.join(toolchain_dir, 'sysroot/usr/lib/libc++.a'))
- shutil.copy(os.path.join(toolchain_dir, 'sysroot/usr/lib/libstdc++.so'),
- os.path.join(toolchain_dir, 'sysroot/usr/lib/libc++.so'))
-
- # Build compiler-rt runtimes needed for Android in a separate build tree.
- build_dir = os.path.join(LLVM_BUILD_DIR, 'android-' + target_arch)
- if not os.path.exists(build_dir):
- os.mkdir(os.path.join(build_dir))
- os.chdir(build_dir)
- target_triple = target_arch
- abi_libs = 'c++abi'
- if target_arch == 'arm':
- target_triple = 'armv7'
- abi_libs += ';unwind'
- target_triple += '-linux-android' + api_level
- cflags = ['--target=%s' % target_triple,
- '--sysroot=%s/sysroot' % toolchain_dir,
- '-B%s' % toolchain_dir]
- android_args = base_cmake_args + [
- '-DLLVM_ENABLE_THREADS=OFF',
- '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
- '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'),
- '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'),
- '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_CXX_FLAGS=' + ' '.join(cflags),
- '-DCMAKE_ASM_FLAGS=' + ' '.join(cflags),
- '-DSANITIZER_CXX_ABI=none',
- '-DSANITIZER_CXX_ABI_LIBRARY=' + abi_libs,
- '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-u__cxa_demangle',
- '-DANDROID=1']
- RmCmakeCache('.')
- RunCommand(['cmake'] + android_args + [COMPILER_RT_DIR])
-
- # We use ASan i686 build for fuzzing.
- libs_want = ['lib/linux/libclang_rt.asan-{0}-android.so']
- if target_arch in ['aarch64', 'arm']:
- libs_want += [
- 'lib/linux/libclang_rt.ubsan_standalone-{0}-android.so',
- 'lib/linux/libclang_rt.profile-{0}-android.a',
- ]
- if target_arch == 'aarch64':
- libs_want += ['lib/linux/libclang_rt.hwasan-{0}-android.so']
- libs_want = [lib.format(target_arch) for lib in libs_want]
- RunCommand(['ninja'] + libs_want)
-
- # And copy them into the main build tree.
- for p in libs_want:
- shutil.copy(p, rt_lib_dst_dir)
-
- if args.with_fuchsia:
- # Fuchsia links against libclang_rt.builtins-<arch>.a instead of libgcc.a.
- for target_arch in ['aarch64', 'x86_64']:
- fuchsia_arch_name = {'aarch64': 'arm64', 'x86_64': 'x64'}[target_arch]
- toolchain_dir = os.path.join(
- FUCHSIA_SDK_DIR, 'arch', fuchsia_arch_name, 'sysroot')
- # Build clang_rt runtime for Fuchsia in a separate build tree.
- build_dir = os.path.join(LLVM_BUILD_DIR, 'fuchsia-' + target_arch)
- if not os.path.exists(build_dir):
- os.mkdir(os.path.join(build_dir))
- os.chdir(build_dir)
- target_spec = target_arch + '-fuchsia'
- # TODO(thakis): Might have to pass -B here once sysroot contains
- # binaries (e.g. gas for arm64?)
- fuchsia_args = base_cmake_args + [
- '-DLLVM_ENABLE_THREADS=OFF',
- '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
- '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'),
- '-DCMAKE_LINKER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
- '-DCMAKE_AR=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-ar'),
- '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'),
- '-DCMAKE_SYSTEM_NAME=Fuchsia',
- '-DCMAKE_C_COMPILER_TARGET=%s-fuchsia' % target_arch,
- '-DCMAKE_ASM_COMPILER_TARGET=%s-fuchsia' % target_arch,
- '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON',
- '-DCMAKE_SYSROOT=%s' % toolchain_dir,
- # TODO(thakis|scottmg): Use PER_TARGET_RUNTIME_DIR for all platforms.
- # https://crbug.com/882485.
- '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON',
-
- # These are necessary because otherwise CMake tries to build an
- # executable to test to see if the compiler is working, but in doing so,
- # it links against the builtins.a that we're about to build.
- '-DCMAKE_C_COMPILER_WORKS=ON',
- '-DCMAKE_ASM_COMPILER_WORKS=ON',
- ]
- RmCmakeCache('.')
- RunCommand(['cmake'] +
- fuchsia_args +
- [os.path.join(COMPILER_RT_DIR, 'lib', 'builtins')])
- builtins_a = 'libclang_rt.builtins.a'
- RunCommand(['ninja', builtins_a])
-
- # And copy it into the main build tree.
- fuchsia_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
- VERSION, target_spec, 'lib')
- if not os.path.exists(fuchsia_lib_dst_dir):
- os.makedirs(fuchsia_lib_dst_dir)
- CopyFile(os.path.join(build_dir, target_spec, 'lib', builtins_a),
- fuchsia_lib_dst_dir)
-
- # Run tests.
- if args.run_tests or use_head_revision:
- os.chdir(LLVM_BUILD_DIR)
- RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64')
- if args.run_tests:
- if sys.platform == 'win32':
- CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin'))
- os.chdir(LLVM_BUILD_DIR)
- RunCommand(['ninja', 'check-all'], msvc_arch='x64')
-
- WriteStampFile(PACKAGE_VERSION)
- print 'Clang update was successful.'
- return 0
-
-
-def gn_arg(v):
- if v == 'True':
- return True
- if v == 'False':
- return False
- raise argparse.ArgumentTypeError('Expected one of %r or %r' % (
- 'True', 'False'))
-
-
-def main():
- parser = argparse.ArgumentParser(description='Build Clang.')
- parser.add_argument('--bootstrap', action='store_true',
- help='first build clang with CC, then with itself.')
- parser.add_argument('--force-local-build', action='store_true',
- help="don't try to download prebuild binaries")
- parser.add_argument('--gcc-toolchain', help='set the version for which gcc '
- 'version be used for building; --gcc-toolchain=/opt/foo '
- 'picks /opt/foo/bin/gcc')
- parser.add_argument('--lto-lld', action='store_true',
- help='build lld with LTO')
- parser.add_argument('--llvm-force-head-revision', action='store_true',
- help=('use the revision in the repo when printing '
- 'the revision'))
- parser.add_argument('--print-revision', action='store_true',
- help='print current clang revision and exit.')
- parser.add_argument('--print-clang-version', action='store_true',
- help='print current clang version (e.g. x.y.z) and exit.')
- parser.add_argument('--run-tests', action='store_true',
- help='run tests after building; only for local builds')
- parser.add_argument('--skip-build', action='store_true',
- help='do not build anything')
- parser.add_argument('--skip-checkout', action='store_true',
- help='do not create or update any checkouts')
- parser.add_argument('--extra-tools', nargs='*', default=[],
- help='select additional chrome tools to build')
- parser.add_argument('--use-system-cmake', action='store_true',
- help='use the cmake from PATH instead of downloading '
- 'and using prebuilt cmake binaries')
- parser.add_argument('--verify-version',
- help='verify that clang has the passed-in version')
- parser.add_argument('--with-android', type=gn_arg, nargs='?', const=True,
- help='build the Android ASan runtime (linux only)',
- default=sys.platform.startswith('linux'))
- parser.add_argument('--without-android', action='store_false',
- help='don\'t build Android ASan runtime (linux only)',
- dest='with_android')
- parser.add_argument('--without-fuchsia', action='store_false',
- help='don\'t build Fuchsia clang_rt runtime (linux/mac)',
- dest='with_fuchsia',
- default=sys.platform in ('linux2', 'darwin'))
- args = parser.parse_args()
-
- if args.lto_lld and not args.bootstrap:
- print '--lto-lld requires --bootstrap'
- return 1
- if args.lto_lld and not sys.platform.startswith('linux'):
- print '--lto-lld is only effective on Linux. Ignoring the option.'
- args.lto_lld = False
-
- # Get svn if we're going to use it to check the revision or do a local build.
- if (use_head_revision or args.llvm_force_head_revision or
- args.force_local_build):
- AddSvnToPathOnWin()
-
- if args.verify_version and args.verify_version != VERSION:
- print 'VERSION is %s but --verify-version argument was %s, exiting.' % (
- VERSION, args.verify_version)
- print 'clang_version in build/toolchain/toolchain.gni is likely outdated.'
- return 1
-
- global CLANG_REVISION, PACKAGE_VERSION
- if args.print_revision:
- if use_head_revision or args.llvm_force_head_revision:
- print GetSvnRevision(LLVM_DIR)
- else:
- print PACKAGE_VERSION
- return 0
-
- if args.print_clang_version:
- sys.stdout.write(VERSION)
- return 0
-
- # Don't buffer stdout, so that print statements are immediately flushed.
- # Do this only after --print-revision has been handled, else we'll get
- # an error message when this script is run from gn for some reason.
- sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
-
- if use_head_revision:
- # Use a real revision number rather than HEAD to make sure that the stamp
- # file logic works.
- CLANG_REVISION = GetSvnRevision(LLVM_REPO_URL)
- PACKAGE_VERSION = CLANG_REVISION + '-0'
-
- args.force_local_build = True
- # Don't build fuchsia runtime on ToT bots at all.
- args.with_fuchsia = False
-
- return UpdateClang(args)
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/tools/download-clang-update-script.py b/tools/download-clang-update-script.py
new file mode 100755
index 00000000..0d707060
--- /dev/null
+++ b/tools/download-clang-update-script.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# Copyright 2020 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""This script is used to download the clang update script. It runs as a
+gclient hook.
+
+It's equivalent to using curl to download the latest update script:
+
+ $ curl --silent --create-dirs -o tools/clang/scripts/update.py \
+ https://raw.githubusercontent.com/chromium/chromium/master/tools/clang/scripts/update.py
+
+The purpose of "reinventing the wheel" with this script is just so developers
+aren't required to have curl installed.
+"""
+
+import argparse
+import os
+import sys
+
+try:
+ from urllib2 import HTTPError, URLError, urlopen
+except ImportError: # For Py3 compatibility
+ from urllib.error import HTTPError, URLError
+ from urllib.request import urlopen
+
+SCRIPT_DOWNLOAD_URL = ('https://raw.githubusercontent.com/' +
+ 'chromium/chromium/master/tools/clang/scripts/update.py')
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Download clang update script from chromium master.')
+ parser.add_argument('--output',
+ help='Path to script file to create/overwrite.')
+ args = parser.parse_args()
+
+ if not args.output:
+ print('usage: download-clang-update-script.py ' +
+ '--output=tools/clang/scripts/update.py');
+ return 1
+
+ script_contents = ''
+ try:
+ response = urlopen(SCRIPT_DOWNLOAD_URL)
+ script_contents = response.read()
+ except HTTPError as e:
+ print e.code
+ print e.read()
+ return 1
+ except URLError as e:
+ print 'Download failed. Reason: ', e.reason
+ return 1
+
+ directory = os.path.dirname(args.output)
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+ script_file = open(args.output, 'w')
+ script_file.write(script_contents)
+ script_file.close()
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/tools/install-build-tools.sh b/tools/install-build-tools.sh
index 65fb4643..d4f75fe2 100755
--- a/tools/install-build-tools.sh
+++ b/tools/install-build-tools.sh
@@ -3,34 +3,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-uname="$(uname -s)"
-case "${uname}" in
- Linux*) env="linux64";;
- Darwin*) env="mac";;
-esac
-
-echo "Assuming we are running in $env..."
-
-ninja_version="v1.9.0"
-ninja_zipfile=""
-case "$env" in
- linux64) ninja_zipfile="ninja-linux.zip";;
- mac) ninja_zipfile="ninja-mac.zip";;
-esac
-
-GOOGLE_STORAGE_URL="https://storage.googleapis.com"
-BUILDTOOLS_ROOT=$(git rev-parse --show-toplevel)/buildtools/$env
-if [ ! -d $BUILDTOOLS_ROOT ]; then
- mkdir -p $BUILDTOOLS_ROOT
-fi
-
-pushd $BUILDTOOLS_ROOT
-set -x # echo on
-sha1=$(tail -c+1 $BUILDTOOLS_ROOT/clang-format.sha1)
-curl -Lo clang-format "$GOOGLE_STORAGE_URL/chromium-clang-format/$sha1"
-chmod +x clang-format
-curl -L "https://github.com/ninja-build/ninja/releases/download/${ninja_version}/${ninja_zipfile}" | funzip > ninja
-chmod +x ninja
-set +x # echo off
-popd
-
+# TODO(crbug.com/openscreen/96): Remove bot config that runs this file.
+echo "You don't need to run this anymore. Just gclient sync!"