Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Unified Diff: third_party/binutils/download.py

Issue 209853003: Adding binutils as a DEPS to allow DebugFission on Ubuntu Precise when compiling with clang. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using a minimal download script. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 ('k') | third_party/binutils/linux/.keepme » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/binutils/download.py
diff --git a/third_party/binutils/download.py b/third_party/binutils/download.py
new file mode 100755
index 0000000000000000000000000000000000000000..be819c21c75a1cc536b79c70e5fd62a6166af597
--- /dev/null
+++ b/third_party/binutils/download.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+# Copyright 2014 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.
+# vim: set ts=2 sw=2 et sts=2 ai:
+
+"""Minimal tool to download binutils from Google storage.
+
+TODO(mithro): Replace with generic download_and_extract tool.
+"""
+
+import os
+import platform
+import re
+import shutil
+import subprocess
+import sys
+
+
+BINUTILS_DIR = os.path.abspath(os.path.dirname(__file__))
+BINUTILS_FILE = 'binutils.tar.bz2'
+BINUTILS_OUT = os.path.join(BINUTILS_DIR, 'Release')
+BINUTILS_TOOLS = ['bin/ld.gold', 'bin/objcopy', 'bin/objdump']
+
+
+def ReadFile(filename):
+ with file(filename, 'r') as f:
+ return f.read().strip()
+
+
+def WriteFile(filename, content):
+ assert not os.path.exists(filename)
+ with file(filename, 'w') as f:
+ f.write(content)
+ f.write('\n')
+
+
+def main(args):
+ if not sys.platform.startswith('linux'):
+ return 0
+
+ if re.search('64', platform.processor(), re.I):
Lei Zhang 2014/04/02 21:30:13 This may not work right for 32-bit userland + 64-b
+ arch_dir = 'Linux_x64'
+ elif re.search('(i[3456]86)|(i86pc)', platform.processor(), re.I):
+ arch_dir = 'Linux_ia32'
+ else:
+ print "WARNING: No compatible binutils found for your system!"
+ return 0
+
+ tarball = os.path.join(BINUTILS_DIR, arch_dir, BINUTILS_FILE)
+ sha1file = tarball + '.sha1'
+ stampfile = tarball + '.stamp'
+ assert os.path.exists(sha1file)
+
+ checksum = ReadFile(sha1file)
+
+ if os.path.exists(stampfile):
+ if checksum == ReadFile(stampfile):
+ return 0
+ else:
+ os.unlink(stampfile)
+
+ print "Downloading", tarball
+ subprocess.check_call([
+ 'download_from_google_storage',
+ '--no_resume',
+ '--no_auth',
+ '--bucket', 'chromium-binutils',
+ '-s', sha1file])
+ assert os.path.exists(tarball)
+
+ if os.path.exists(BINUTILS_OUT):
+ shutil.rmtree(BINUTILS_OUT)
+ assert not os.path.exists(BINUTILS_OUT)
+ os.makedirs(BINUTILS_OUT)
+ assert os.path.exists(BINUTILS_OUT)
+
+ print "Extracting", tarball
+ subprocess.check_call(['tar', 'axf', tarball], cwd=BINUTILS_OUT)
+
+ for tool in BINUTILS_TOOLS:
+ assert os.path.exists(os.path.join(BINUTILS_OUT, tool))
+
+ WriteFile(stampfile, checksum)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
« no previous file with comments | « third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 ('k') | third_party/binutils/linux/.keepme » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698