| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 # TODO(slightlyoff): move to using shared version of this script. | 5 # TODO(slightlyoff): move to using shared version of this script. |
| 6 | 6 |
| 7 '''This script makes it easy to combine libs and object files to a new lib, | 7 '''This script makes it easy to combine libs and object files to a new lib, |
| 8 optionally removing some of the object files in the input libs by regular | 8 optionally removing some of the object files in the input libs by regular |
| 9 expression matching. | 9 expression matching. |
| 10 For usage information, run the script with a --help argument. | 10 For usage information, run the script with a --help argument. |
| 11 ''' | 11 ''' |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return removals | 44 return removals |
| 45 | 45 |
| 46 | 46 |
| 47 def CombineLibraries(output, remove_re, inputs): | 47 def CombineLibraries(output, remove_re, inputs): |
| 48 '''Combines all the libraries and objects in inputs, while removing any | 48 '''Combines all the libraries and objects in inputs, while removing any |
| 49 object files that match remove_re. | 49 object files that match remove_re. |
| 50 ''' | 50 ''' |
| 51 removals = [] | 51 removals = [] |
| 52 if remove_re: | 52 if remove_re: |
| 53 removals = CollectRemovals(remove_re, inputs) | 53 removals = CollectRemovals(remove_re, inputs) |
| 54 | 54 |
| 55 print removals | 55 print removals |
| 56 | 56 |
| 57 args = ['lib.exe', '/out:%s' % output] | 57 args = ['lib.exe', '/out:%s' % output] |
| 58 args += ['/remove:%s' % obj for obj in removals] | 58 args += ['/remove:%s' % obj for obj in removals] |
| 59 args += inputs | 59 args += inputs |
| 60 Shell(*args) | 60 Shell(*args) |
| 61 | 61 |
| 62 | 62 |
| 63 USAGE = '''usage: %prog [options] <lib or obj>+ | 63 USAGE = '''usage: %prog [options] <lib or obj>+ |
| 64 | 64 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 93 remove = remove.strip() | 93 remove = remove.strip() |
| 94 | 94 |
| 95 if remove: | 95 if remove: |
| 96 try: | 96 try: |
| 97 remove_re = re.compile(opt.remove) | 97 remove_re = re.compile(opt.remove) |
| 98 except: | 98 except: |
| 99 parser.error('%s is not a valid regular expression' % opt.remove) | 99 parser.error('%s is not a valid regular expression' % opt.remove) |
| 100 else: | 100 else: |
| 101 remove_re = None | 101 remove_re = None |
| 102 | 102 |
| 103 if sys.platform != 'win32': | 103 if sys.platform != 'win32' and sys.platform != 'cygwin': |
| 104 parser.error('this script only works on Windows for now') | 104 parser.error('this script only works on Windows for now') |
| 105 | 105 |
| 106 # If this is set, we can't capture lib.exe's output. | 106 # If this is set, we can't capture lib.exe's output. |
| 107 if 'VS_UNICODE_OUTPUT' in os.environ: | 107 if 'VS_UNICODE_OUTPUT' in os.environ: |
| 108 del os.environ['VS_UNICODE_OUTPUT'] | 108 del os.environ['VS_UNICODE_OUTPUT'] |
| 109 | 109 |
| 110 CombineLibraries(output, remove_re, args) | 110 CombineLibraries(output, remove_re, args) |
| 111 | 111 |
| 112 | 112 |
| 113 if __name__ == '__main__': | 113 if __name__ == '__main__': |
| 114 Main() | 114 Main() |
| OLD | NEW |