OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 | 5 |
6 """Shim to run nacl toolchain download script only if there is a nacl dir.""" | 6 """Shim to run nacl toolchain download script only if there is a nacl dir.""" |
7 | 7 |
8 import os | 8 import os |
| 9 import shutil |
9 import sys | 10 import sys |
10 | 11 |
11 | 12 |
12 def Main(args): | 13 def Main(args): |
13 # Exit early if disable_nacl=1. | 14 # Exit early if disable_nacl=1. |
14 if 'disable_nacl=1' in os.environ.get('GYP_DEFINES', ''): | 15 if 'disable_nacl=1' in os.environ.get('GYP_DEFINES', ''): |
15 return 0 | 16 return 0 |
16 script_dir = os.path.dirname(os.path.abspath(__file__)) | 17 script_dir = os.path.dirname(os.path.abspath(__file__)) |
17 src_dir = os.path.dirname(script_dir) | 18 src_dir = os.path.dirname(script_dir) |
18 nacl_dir = os.path.join(src_dir, 'native_client') | 19 nacl_dir = os.path.join(src_dir, 'native_client') |
(...skipping 24 matching lines...) Expand all Loading... |
43 else: | 44 else: |
44 args.extend(['--exclude', 'pnacl_newlib']) | 45 args.extend(['--exclude', 'pnacl_newlib']) |
45 | 46 |
46 # Only download the ARM gcc toolchain if we are building for ARM | 47 # Only download the ARM gcc toolchain if we are building for ARM |
47 # TODO(olonho): we need to invent more reliable way to get build | 48 # TODO(olonho): we need to invent more reliable way to get build |
48 # configuration info, to know if we're building for ARM. | 49 # configuration info, to know if we're building for ARM. |
49 if 'target_arch=arm' not in os.environ.get('GYP_DEFINES', ''): | 50 if 'target_arch=arm' not in os.environ.get('GYP_DEFINES', ''): |
50 args.extend(['--exclude', 'nacl_arm_newlib']) | 51 args.extend(['--exclude', 'nacl_arm_newlib']) |
51 | 52 |
52 args.append('sync') | 53 args.append('sync') |
53 args.append('--extract') | |
54 package_version.main(args) | 54 package_version.main(args) |
| 55 |
| 56 # Because we are no longer extracting the toolchain, it is best to delete |
| 57 # the old extracted ones so that no stale toolchains are left behind. This |
| 58 # also would catch any stale code that happens to work because it is using |
| 59 # an old extracted toolchain that was left behind. |
| 60 toolchain_dir = os.path.join(nacl_dir, 'toolchain') |
| 61 for toolchain_item in os.listdir(toolchain_dir): |
| 62 toolchain_path = os.path.join(toolchain_dir, toolchain_item) |
| 63 if os.path.isdir(toolchain_path) and not toolchain_item.startswith('.'): |
| 64 shutil.rmtree(toolchain_path) |
| 65 |
55 return 0 | 66 return 0 |
56 | 67 |
57 | 68 |
58 if __name__ == '__main__': | 69 if __name__ == '__main__': |
59 sys.exit(Main(sys.argv[1:])) | 70 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |