From 67d89ff692a88ae42145043eac1a5c58413ae110 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 17 Aug 2018 12:44:55 +0900 Subject: [PATCH] chore: download clang-format from google storage --- tools/format.py | 6 +++--- tools/setup.py | 1 + tools/third_party.py | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tools/format.py b/tools/format.py index 51bf2c1fb06db3..85dbf2d4d764b6 100755 --- a/tools/format.py +++ b/tools/format.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import os -from third_party import third_party_path, fix_symlinks, google_env +from third_party import third_party_path, fix_symlinks, google_env, clang_format_path from util import root_path, run, find_exts fix_symlinks() @@ -12,8 +12,8 @@ os.chdir(root_path) -# TODO(ry) Use third_party/depot_tools/clang-format. -run(["clang-format", "-i", "-style", "Google"] + find_exts("src", ".cc", ".h")) +run([clang_format_path, "-i", "-style", "Google"] + + find_exts("src", ".cc", ".h")) for fn in ["BUILD.gn", ".gn"] + find_exts("build_extra", ".gn", ".gni"): run(["third_party/depot_tools/gn", "format", fn], env=google_env()) diff --git a/tools/setup.py b/tools/setup.py index 930f1b69048c93..883270ad171310 100755 --- a/tools/setup.py +++ b/tools/setup.py @@ -7,6 +7,7 @@ third_party.fix_symlinks() third_party.download_gn() +third_party.download_clang_format() third_party.download_clang() third_party.maybe_download_sysroot() diff --git a/tools/third_party.py b/tools/third_party.py index 1bc687b8574c8e..0a053fbcd1bd13 100644 --- a/tools/third_party.py +++ b/tools/third_party.py @@ -21,6 +21,7 @@ def tp(*subpath_parts): depot_tools_path = tp("depot_tools") rust_crates_path = tp("rust_crates") gn_path = tp(depot_tools_path, "gn") +clang_format_path = tp(depot_tools_path, "clang-format") ninja_path = tp(depot_tools_path, "ninja") @@ -141,27 +142,37 @@ def run_gclient_sync(): rmtree(depot_tools_temp_path) -# Download gn from Google storage. -def download_gn(): +# Download the given item from Google storage. +def download_from_google_storage(item, bucket): if sys.platform == 'win32': - sha1_file = "v8/buildtools/win/gn.exe.sha1" + sha1_file = "v8/buildtools/win/%s.exe.sha1" % item elif sys.platform == 'darwin': - sha1_file = "v8/buildtools/mac/gn.sha1" + sha1_file = "v8/buildtools/mac/%s.sha1" % item elif sys.platform.startswith('linux'): - sha1_file = "v8/buildtools/linux64/gn.sha1" + sha1_file = "v8/buildtools/linux64/%s.sha1" % item run([ "python", tp('depot_tools/download_from_google_storage.py'), '--platform=' + sys.platform, '--no_auth', - '--bucket=chromium-gn', + '--bucket=%s' % bucket, '--sha1_file', tp(sha1_file), ], env=google_env()) +# Download gn from Google storage. +def download_gn(): + download_from_google_storage('gn', 'chromium-gn') + + +# Download clang-format from Google storage. +def download_clang_format(): + download_from_google_storage('clang-format', 'chromium-clang-format') + + # Download clang by calling the clang update script. def download_clang(): run(['python',