aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-03-08 10:54:09 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-08 16:43:49 +0000
commitb357dea546f058a8bf2a293c1f8d2f673c29550b (patch)
treeedffce91e3c3146dda100be1024af65101031191 /bin
parentb69c4b8bdeb30e74c88b6ce3f3792d825992b03d (diff)
bin/fetch-clang-format
Change-Id: I7deb9b49b4a3a361888a6afc07b4c6341a4b16cf Reviewed-on: https://skia-review.googlesource.com/9410 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fetch-clang-format44
1 files changed, 44 insertions, 0 deletions
diff --git a/bin/fetch-clang-format b/bin/fetch-clang-format
new file mode 100755
index 0000000000..78b5c05221
--- /dev/null
+++ b/bin/fetch-clang-format
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import hashlib
+import os
+import shutil
+import stat
+import sys
+import urllib2
+
+os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
+
+def fetch(target):
+ target_path = 'buildtools/linux64/' + target if 'linux' in sys.platform else \
+ 'buildtools/mac/' + target if 'darwin' in sys.platform else \
+ 'buildtools/win/'+ target + '.exe'
+
+ sha1 = open(target_path + '.sha1').read().strip()
+
+ def sha1_of_file(path):
+ h = hashlib.sha1()
+ if os.path.isfile(path):
+ with open(path, 'rb') as f:
+ h.update(f.read())
+ return h.hexdigest()
+
+ if sha1_of_file(target_path) != sha1:
+ with open(target_path, 'wb') as f:
+ url = 'https://chromium-%s.storage-download.googleapis.com/%s' % (target, sha1)
+ f.write(urllib2.urlopen(url).read())
+
+ os.chmod(target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
+ stat.S_IRGRP | stat.S_IXGRP |
+ stat.S_IROTH | stat.S_IXOTH )
+
+ target_copy_path = os.path.join('bin', os.path.basename(target_path))
+ if sha1_of_file(target_copy_path) != sha1:
+ shutil.copy(target_path, target_copy_path)
+
+fetch('clang-format')