OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # vim: set ts=2 sw=2 et sts=2 ai: | 5 # vim: set ts=2 sw=2 et sts=2 ai: |
6 | 6 |
7 """Minimal tool to download binutils from Google storage. | 7 """Minimal tool to download binutils from Google storage. |
8 | 8 |
9 TODO(mithro): Replace with generic download_and_extract tool. | 9 TODO(mithro): Replace with generic download_and_extract tool. |
10 """ | 10 """ |
(...skipping 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 def GetArch(): | 41 def GetArch(): |
42 gyp_host_arch = re.search( | 42 gyp_host_arch = re.search( |
43 'host_arch=([^ ]*)', os.environ.get('GYP_DEFINES', '')) | 43 'host_arch=([^ ]*)', os.environ.get('GYP_DEFINES', '')) |
44 if gyp_host_arch: | 44 if gyp_host_arch: |
45 return gyp_host_arch.group(1) | 45 return gyp_host_arch.group(1) |
46 | 46 |
47 return subprocess.check_output(['python', DETECT_HOST_ARCH]).strip() | 47 return subprocess.check_output(['python', DETECT_HOST_ARCH]).strip() |
48 | 48 |
49 | 49 |
50 def main(args): | 50 def FetchAndExtract(arch): |
51 if not sys.platform.startswith('linux'): | 51 archdir = os.path.join(BINUTILS_DIR, 'Linux_' + arch) |
52 return 0 | |
53 | |
54 archdir = os.path.join(BINUTILS_DIR, 'Linux_' + GetArch()) | |
55 tarball = os.path.join(archdir, BINUTILS_FILE) | 52 tarball = os.path.join(archdir, BINUTILS_FILE) |
56 outdir = os.path.join(archdir, BINUTILS_OUT) | 53 outdir = os.path.join(archdir, BINUTILS_OUT) |
57 | 54 |
58 sha1file = tarball + '.sha1' | 55 sha1file = tarball + '.sha1' |
59 if not os.path.exists(sha1file): | 56 if not os.path.exists(sha1file): |
60 print "WARNING: No binutils found for your architecture (%s)!" % GetArch() | 57 print "WARNING: No binutils found for your architecture (%s)!" % arch |
61 return 0 | 58 return 0 |
62 | 59 |
63 checksum = ReadFile(sha1file) | 60 checksum = ReadFile(sha1file) |
64 | 61 |
65 stampfile = tarball + '.stamp' | 62 stampfile = tarball + '.stamp' |
66 if os.path.exists(stampfile): | 63 if os.path.exists(stampfile): |
67 if (os.path.exists(tarball) and | 64 if (os.path.exists(tarball) and |
68 os.path.exists(outdir) and | 65 os.path.exists(outdir) and |
69 checksum == ReadFile(stampfile)): | 66 checksum == ReadFile(stampfile)): |
70 return 0 | 67 return 0 |
(...skipping 18 matching lines...) Expand all Loading... | |
89 print "Extracting", tarball | 86 print "Extracting", tarball |
90 subprocess.check_call(['tar', 'axf', tarball], cwd=outdir) | 87 subprocess.check_call(['tar', 'axf', tarball], cwd=outdir) |
91 | 88 |
92 for tool in BINUTILS_TOOLS: | 89 for tool in BINUTILS_TOOLS: |
93 assert os.path.exists(os.path.join(outdir, tool)) | 90 assert os.path.exists(os.path.join(outdir, tool)) |
94 | 91 |
95 WriteFile(stampfile, checksum) | 92 WriteFile(stampfile, checksum) |
96 return 0 | 93 return 0 |
97 | 94 |
98 | 95 |
96 def main(args): | |
97 if not sys.platform.startswith('linux'): | |
98 return 0 | |
99 | |
100 arch = GetArch() | |
mithro-old
2014/04/28 19:01:21
Maybe it should be;
-----------------------------
Lei Zhang
2014/04/28 19:13:22
GetArch() hasn't changed, for a machine with a 64-
| |
101 if arch == 'x64': | |
102 return FetchAndExtract(arch) | |
103 if arch == 'ia32': | |
104 ret = FetchAndExtract(arch) | |
105 if ret != 0: | |
106 return ret | |
107 # Fetch the x64 toolchain as well for official bots with 64-bit kernels. | |
108 return FetchAndExtract('x64') | |
mithro-old
2014/04/28 19:01:21
I think this script could detect the GYP_DEFINEs s
Lei Zhang
2014/04/28 19:13:22
It's simpler to just install both toolchains. Not
| |
109 print "Host architecture %s is not supported." % arch | |
110 return 1 | |
111 | |
112 | |
99 if __name__ == '__main__': | 113 if __name__ == '__main__': |
100 sys.exit(main(sys.argv)) | 114 sys.exit(main(sys.argv)) |
OLD | NEW |