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

Side by Side 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 seperate release dirs and same detect_host_arch as common.gypi Created 6 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 # vim: set ts=2 sw=2 et sts=2 ai:
6
7 """Minimal tool to download binutils from Google storage.
8
9 TODO(mithro): Replace with generic download_and_extract tool.
10 """
11
12 import os
13 import platform
14 import re
15 import shutil
16 import subprocess
17 import sys
18
19
20 BINUTILS_DIR = os.path.abspath(os.path.dirname(__file__))
21 BINUTILS_FILE = 'binutils.tar.bz2'
22 BINUTILS_TOOLS = ['bin/ld.gold', 'bin/objcopy', 'bin/objdump']
23 BINUTILS_OUT = 'Release'
24
25 DETECT_HOST_ARCH = os.path.abspath(os.path.join(
26 BINUTILS_DIR, '../../build/linux/detect_host_arch.py'))
27
28
29 def ReadFile(filename):
30 with file(filename, 'r') as f:
31 return f.read().strip()
32
33
34 def WriteFile(filename, content):
35 assert not os.path.exists(filename)
36 with file(filename, 'w') as f:
37 f.write(content)
38 f.write('\n')
39
40
41 def GetArch():
42 gyp_host_arch = re.search(
43 'host_arch=([^ ]*)', os.environ.get('GYP_DEFINES', ''))
44 if gyp_host_arch:
45 return gyp_host_arch.group(1)
46
47 return subprocess.check_output(['python', DETECT_HOST_ARCH]).strip()
48
49
50 def main(args):
51 if not sys.platform.startswith('linux'):
52 return 0
53
54 archdir = os.path.join(BINUTILS_DIR, 'Linux_' + GetArch())
55 tarball = os.path.join(archdir, BINUTILS_FILE)
56 outdir = os.path.join(archdir, BINUTILS_OUT)
57
58 sha1file = tarball + '.sha1'
59 if not os.path.exists(sha1file):
60 print "WARNING: No binutils found for your architecture (%s)!" % GetArch()
61 return 0
62
63 checksum = ReadFile(sha1file)
64
65 stampfile = tarball + '.stamp'
66 if os.path.exists(stampfile):
67 if checksum == ReadFile(stampfile):
68 return 0
69 else:
70 os.unlink(stampfile)
71
72 print "Downloading", tarball
73 subprocess.check_call([
74 'download_from_google_storage',
75 '--no_resume',
76 '--no_auth',
77 '--bucket', 'chromium-binutils',
78 '-s', sha1file])
79 assert os.path.exists(tarball)
80
81 if os.path.exists(outdir):
82 shutil.rmtree(outdir)
83 assert not os.path.exists(outdir)
84 os.makedirs(outdir)
85 assert os.path.exists(outdir)
86
87 print "Extracting", tarball
88 subprocess.check_call(['tar', 'axf', tarball], cwd=outdir)
89
90 for tool in BINUTILS_TOOLS:
91 assert os.path.exists(os.path.join(outdir, tool))
92
93 WriteFile(stampfile, checksum)
94 return 0
95
96
97 if __name__ == '__main__':
98 sys.exit(main(sys.argv))
OLDNEW
« 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