Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2010 The Native Client Authors. All rights reserved. | 2 # Copyright 2010 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can | 3 # Use of this source code is governed by a BSD-style license that can |
| 4 # be found in the LICENSE file. | 4 # be found in the LICENSE file. |
| 5 | 5 |
| 6 """Download all Native Client toolchains for this platform. | 6 """Download all Native Client toolchains for this platform. |
| 7 | 7 |
| 8 This module downloads multiple tgz's and expands them. | 8 This module downloads multiple tgz's and expands them. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import optparse | 11 import optparse |
| 12 import os.path | 12 import os.path |
| 13 | 13 |
| 14 import download_utils | 14 import download_utils |
| 15 import sync_tgz | 15 import sync_tgz |
| 16 | 16 |
| 17 | 17 |
| 18 PLATFORM_MAPPING = { | 18 PLATFORM_MAPPING = { |
| 19 'windows': [ | 19 'windows': { |
| 20 ['win_x86', 'win_x86'], # Multilib toolchain | 20 'x86-32': ['win_x86'], |
| 21 ], | 21 'x86-64': ['win_x86'], |
| 22 'linux': [ | 22 }, |
| 23 ['linux_x86', 'linux_x86'], # Multilib toolchain | 23 'linux': { |
| 24 ['linux_arm-trusted', 'linux_arm-trusted'], | 24 'x86-32': ['linux_x86','pnacl_linux_i686','linux_arm-trusted'], |
|
bradn
2011/04/12 00:47:41
why not drop the arm one?
| |
| 25 ['linux_arm-untrusted-hardy64-toolchain_arm-untrusted', | 25 'x86-64': ['linux_x86','pnacl_linux_x86_64','linux_arm-trusted'], |
| 26 'linux_arm-untrusted'], | 26 }, |
| 27 ], | 27 'mac': { |
| 28 'mac': [ | 28 'x86-32': ['mac_x86'], |
| 29 ['mac_x86', 'mac_x86'], # Multilib toolchain | 29 }, |
| 30 ], | |
| 31 } | 30 } |
| 32 | 31 |
| 33 | |
| 34 def main(): | 32 def main(): |
| 35 parser = optparse.OptionParser() | 33 parser = optparse.OptionParser() |
| 36 parser.add_option( | 34 parser.add_option( |
| 37 '-b', '--base-url', dest='base_url', | 35 '-b', '--base-url', dest='base_url', |
| 38 default=('http://commondatastorage.googleapis.com/' | 36 default=('http://commondatastorage.googleapis.com/' |
| 39 'nativeclient-archive2/toolchain'), | 37 'nativeclient-archive2/toolchain'), |
| 40 help='base url to download from') | 38 help='base url to download from') |
| 41 parser.add_option( | 39 parser.add_option( |
| 42 '--x86-version', dest='x86_version', | 40 '--x86-version', dest='x86_version', |
| 43 default='latest', | 41 default='latest', |
| 44 help='which version of the toolchain to download for x86') | 42 help='which version of the toolchain to download for x86') |
| 45 parser.add_option( | 43 parser.add_option( |
| 46 '--arm-version', dest='arm_version', | 44 '--arm-version', dest='arm_version', |
| 47 default='latest', | 45 default='latest', |
| 48 help='which version of the toolchain to download for arm') | 46 help='which version of the toolchain to download for arm') |
| 49 options, args = parser.parse_args() | 47 options, args = parser.parse_args() |
| 50 if args: | 48 if args: |
| 51 parser.error('ERROR: invalid argument') | 49 parser.error('ERROR: invalid argument') |
| 52 | 50 |
| 53 platform_fixed = download_utils.PlatformName() | 51 platform_fixed = download_utils.PlatformName() |
| 54 for flavor in PLATFORM_MAPPING[platform_fixed]: | 52 arch_fixed = download_utils.ArchName() |
| 55 if 'arm' in flavor[0]: | 53 for flavor in PLATFORM_MAPPING[platform_fixed][arch_fixed]: |
| 54 if 'arm' in flavor or 'pnacl' in flavor: | |
|
bradn
2011/04/12 00:47:41
Why not drop all the arm stuff?
pdox
2011/04/12 00:53:38
Because of linux_arm-trusted ?
| |
| 56 version = options.arm_version | 55 version = options.arm_version |
| 57 else: | 56 else: |
| 58 version = options.x86_version | 57 version = options.x86_version |
| 59 url = '%s/%s/naclsdk_%s.tgz' % (options.base_url, version, flavor[0]) | 58 url = '%s/%s/naclsdk_%s.tgz' % (options.base_url, version, flavor) |
| 60 parent_dir = os.path.dirname(os.path.dirname(__file__)) | 59 parent_dir = os.path.dirname(os.path.dirname(__file__)) |
| 61 dst = os.path.join(parent_dir, 'toolchain', flavor[1]) | 60 dst = os.path.join(parent_dir, 'toolchain', flavor) |
| 62 if version != 'latest' and download_utils.SourceIsCurrent(dst, url): | 61 if version != 'latest' and download_utils.SourceIsCurrent(dst, url): |
| 63 continue | 62 continue |
| 64 | 63 |
| 65 # TODO(bradnelson_): get rid of this when toolchain tarballs flattened. | 64 # TODO(bradnelson_): get rid of this when toolchain tarballs flattened. |
| 66 if 'arm' in flavor[0]: | 65 if 'arm' in flavor or 'pnacl' in flavor: |
| 67 # TODO(cbiffle): we really shouldn't do this until the unpack succeeds! | 66 # TODO(cbiffle): we really shouldn't do this until the unpack succeeds! |
| 68 # See: http://code.google.com/p/nativeclient/issues/detail?id=834 | 67 # See: http://code.google.com/p/nativeclient/issues/detail?id=834 |
| 69 download_utils.RemoveDir(dst) | 68 download_utils.RemoveDir(dst) |
| 70 sync_tgz.SyncTgz(url, dst) | 69 sync_tgz.SyncTgz(url, dst) |
| 71 else: | 70 else: |
| 72 dst_tmp = os.path.join(parent_dir, 'toolchain', '.tmp') | 71 dst_tmp = os.path.join(parent_dir, 'toolchain', '.tmp') |
| 73 sync_tgz.SyncTgz(url, dst_tmp) | 72 sync_tgz.SyncTgz(url, dst_tmp) |
| 74 subdir = os.path.join(dst_tmp, 'sdk', 'nacl-sdk') | 73 subdir = os.path.join(dst_tmp, 'sdk', 'nacl-sdk') |
| 75 download_utils.MoveDirCleanly(subdir, dst) | 74 download_utils.MoveDirCleanly(subdir, dst) |
| 76 download_utils.RemoveDir(dst_tmp) | 75 download_utils.RemoveDir(dst_tmp) |
| 77 | 76 |
| 78 # Write out source url stamp. | 77 # Write out source url stamp. |
| 79 download_utils.WriteSourceStamp(dst, url) | 78 download_utils.WriteSourceStamp(dst, url) |
| 80 | 79 |
| 81 | 80 |
| 82 if __name__ == '__main__': | 81 if __name__ == '__main__': |
| 83 main() | 82 main() |
| OLD | NEW |