| 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'], |
| 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 'x86-64': ['mac_x86'], |
| 30 ], | 30 }, |
| 31 } | 31 } |
| 32 | 32 |
| 33 | |
| 34 def main(): | 33 def main(): |
| 35 parser = optparse.OptionParser() | 34 parser = optparse.OptionParser() |
| 36 parser.add_option( | 35 parser.add_option( |
| 37 '-b', '--base-url', dest='base_url', | 36 '-b', '--base-url', dest='base_url', |
| 38 default=('http://commondatastorage.googleapis.com/' | 37 default=('http://commondatastorage.googleapis.com/' |
| 39 'nativeclient-archive2/toolchain'), | 38 'nativeclient-archive2/toolchain'), |
| 40 help='base url to download from') | 39 help='base url to download from') |
| 41 parser.add_option( | 40 parser.add_option( |
| 42 '--x86-version', dest='x86_version', | 41 '--x86-version', dest='x86_version', |
| 43 default='latest', | 42 default='latest', |
| 44 help='which version of the toolchain to download for x86') | 43 help='which version of the toolchain to download for x86') |
| 45 parser.add_option( | 44 parser.add_option( |
| 46 '--arm-version', dest='arm_version', | 45 '--arm-version', dest='arm_version', |
| 47 default='latest', | 46 default='latest', |
| 48 help='which version of the toolchain to download for arm') | 47 help='which version of the toolchain to download for arm') |
| 49 options, args = parser.parse_args() | 48 options, args = parser.parse_args() |
| 50 if args: | 49 if args: |
| 51 parser.error('ERROR: invalid argument') | 50 parser.error('ERROR: invalid argument') |
| 52 | 51 |
| 53 platform_fixed = download_utils.PlatformName() | 52 platform_fixed = download_utils.PlatformName() |
| 54 for flavor in PLATFORM_MAPPING[platform_fixed]: | 53 arch_fixed = download_utils.ArchName() |
| 55 if 'arm' in flavor[0]: | 54 for flavor in PLATFORM_MAPPING[platform_fixed][arch_fixed]: |
| 55 if 'arm' in flavor or 'pnacl' in flavor: |
| 56 version = options.arm_version | 56 version = options.arm_version |
| 57 else: | 57 else: |
| 58 version = options.x86_version | 58 version = options.x86_version |
| 59 url = '%s/%s/naclsdk_%s.tgz' % (options.base_url, version, flavor[0]) | 59 url = '%s/%s/naclsdk_%s.tgz' % (options.base_url, version, flavor) |
| 60 parent_dir = os.path.dirname(os.path.dirname(__file__)) | 60 parent_dir = os.path.dirname(os.path.dirname(__file__)) |
| 61 dst = os.path.join(parent_dir, 'toolchain', flavor[1]) | 61 dst = os.path.join(parent_dir, 'toolchain', flavor) |
| 62 if version != 'latest' and download_utils.SourceIsCurrent(dst, url): | 62 if version != 'latest' and download_utils.SourceIsCurrent(dst, url): |
| 63 continue | 63 continue |
| 64 | 64 |
| 65 # TODO(bradnelson_): get rid of this when toolchain tarballs flattened. | 65 # TODO(bradnelson_): get rid of this when toolchain tarballs flattened. |
| 66 if 'arm' in flavor[0]: | 66 if 'arm' in flavor or 'pnacl' in flavor: |
| 67 # TODO(cbiffle): we really shouldn't do this until the unpack succeeds! | 67 # TODO(cbiffle): we really shouldn't do this until the unpack succeeds! |
| 68 # See: http://code.google.com/p/nativeclient/issues/detail?id=834 | 68 # See: http://code.google.com/p/nativeclient/issues/detail?id=834 |
| 69 download_utils.RemoveDir(dst) | 69 download_utils.RemoveDir(dst) |
| 70 sync_tgz.SyncTgz(url, dst) | 70 sync_tgz.SyncTgz(url, dst) |
| 71 else: | 71 else: |
| 72 dst_tmp = os.path.join(parent_dir, 'toolchain', '.tmp') | 72 dst_tmp = os.path.join(parent_dir, 'toolchain', '.tmp') |
| 73 sync_tgz.SyncTgz(url, dst_tmp) | 73 sync_tgz.SyncTgz(url, dst_tmp) |
| 74 subdir = os.path.join(dst_tmp, 'sdk', 'nacl-sdk') | 74 subdir = os.path.join(dst_tmp, 'sdk', 'nacl-sdk') |
| 75 download_utils.MoveDirCleanly(subdir, dst) | 75 download_utils.MoveDirCleanly(subdir, dst) |
| 76 download_utils.RemoveDir(dst_tmp) | 76 download_utils.RemoveDir(dst_tmp) |
| 77 | 77 |
| 78 # Write out source url stamp. | 78 # Write out source url stamp. |
| 79 download_utils.WriteSourceStamp(dst, url) | 79 download_utils.WriteSourceStamp(dst, url) |
| 80 | 80 |
| 81 | 81 |
| 82 if __name__ == '__main__': | 82 if __name__ == '__main__': |
| 83 main() | 83 main() |
| OLD | NEW |