| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os |
| 5 import os.path | 6 import os.path |
| 6 import shutil | 7 import shutil |
| 7 import subprocess | 8 import subprocess |
| 8 import sys | 9 import sys |
| 9 | 10 |
| 10 # Usage: python copy_keystone_framework.py /path/to/input /path/to/output | 11 # Usage: python copy_keystone_framework.py /path/to/input /path/to/output |
| 12 # [DEVELOPER_DIR] |
| 11 # | 13 # |
| 12 # This script copies the KeystoneRegistration.framework, removing its | 14 # This script copies the KeystoneRegistration.framework, removing its |
| 13 # versioned directory structure, thinning it to just x86_64, and deleting | 15 # versioned directory structure, thinning it to just x86_64, and deleting |
| 14 # the Headers directory. | 16 # the Headers directory. |
| 15 | 17 |
| 16 def Main(args): | 18 def Main(args): |
| 17 if len(args) != 3: | 19 if len(args) != 3 and len(args) != 4: |
| 18 print >> sys.stderr, '%s: /path/to/input /path/to/output' % (args[0],) | 20 print >> sys.stderr, '%s: /path/to/input /path/to/output' % (args[0],) |
| 19 return 1 | 21 return 1 |
| 22 if len(args) == 4: |
| 23 os.environ['DEVELOPER_DIR'] = args[3] |
| 20 | 24 |
| 21 # Delete any old copies of the framework. | 25 # Delete any old copies of the framework. |
| 22 output_path = os.path.join(args[2], 'KeystoneRegistration.framework') | 26 output_path = os.path.join(args[2], 'KeystoneRegistration.framework') |
| 23 if os.path.exists(output_path): | 27 if os.path.exists(output_path): |
| 24 shutil.rmtree(output_path) | 28 shutil.rmtree(output_path) |
| 25 | 29 |
| 26 # Copy the framework out of its versioned directory. Use rsync to exclude | 30 # Copy the framework out of its versioned directory. Use rsync to exclude |
| 27 # dotfiles and the Headers directories. | 31 # dotfiles and the Headers directories. |
| 28 subprocess.check_call( | 32 subprocess.check_call( |
| 29 ['rsync', '-acC', '--delete', | 33 ['rsync', '-acC', '--delete', |
| 30 '--exclude', 'Headers', '--exclude', 'PrivateHeaders', | 34 '--exclude', 'Headers', '--exclude', 'PrivateHeaders', |
| 31 '--include', '*.so', | 35 '--include', '*.so', |
| 32 os.path.join(args[1], 'Versions/Current/'), | 36 os.path.join(args[1], 'Versions/Current/'), |
| 33 output_path]) | 37 output_path]) |
| 34 | 38 |
| 35 # Thin the library to just the required arch. | 39 # Thin the library to just the required arch. |
| 36 library_path = os.path.join(output_path, 'KeystoneRegistration') | 40 library_path = os.path.join(output_path, 'KeystoneRegistration') |
| 37 subprocess.check_call( | 41 subprocess.check_call( |
| 38 ['lipo', '-thin', 'x86_64', library_path, '-o', library_path]) | 42 ['lipo', '-thin', 'x86_64', library_path, '-o', library_path]) |
| 39 return 0 | 43 return 0 |
| 40 | 44 |
| 41 | 45 |
| 42 if __name__ == '__main__': | 46 if __name__ == '__main__': |
| 43 sys.exit(Main(sys.argv)) | 47 sys.exit(Main(sys.argv)) |
| OLD | NEW |