Skip to content

Commit

Permalink
chore: download clang-format from google storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored and ry committed Aug 17, 2018
1 parent 565a21e commit 67d89ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tools/format.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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())
Expand Down
1 change: 1 addition & 0 deletions tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
23 changes: 17 additions & 6 deletions tools/third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 67d89ff

Please sign in to comment.