OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 | |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 # | |
7 # This script takes libcmt.lib for VS2005/08/10 and removes the allocation | |
M-A Ruel
2012/05/30 12:55:11
This should be a docstring.
| |
8 # related functions from it. | |
9 # | |
10 # Usage: prep_libc.py <VCInstallDir> <OutputDir> | |
11 # | |
12 # VCInstallDir is the path where VC is installed, something like: | |
13 # C:\Program Files\Microsoft Visual Studio 8\VC\ | |
14 # | |
15 # OutputDir is the directory where the modified libcmt file should be stored. | |
16 | |
17 import os | |
18 import shutil | |
19 import subprocess | |
20 import sys | |
21 | |
M-A Ruel
2012/05/30 12:55:11
The rest of the code base is formatted with 2 vert
| |
22 def run(command, filter=None): | |
23 """Run |command|, removing any lines that match |filter|. The filter is | |
24 to remove the echoing of input filename that 'lib' does.""" | |
25 popen = subprocess.Popen( | |
26 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
27 out, _ = popen.communicate() | |
28 for line in out.splitlines(): | |
29 if filter and line.strip() != filter: | |
30 print line | |
31 return popen.returncode | |
32 | |
33 def main(): | |
34 vs_install_dir = sys.argv[1] | |
35 outdir = sys.argv[2] | |
36 output_lib = os.path.join(outdir, 'libcmt.lib') | |
37 shutil.copyfile(os.path.join(vs_install_dir, 'libcmt.lib'), output_lib) | |
38 shutil.copyfile(os.path.join(vs_install_dir, 'libcmt.pdb'), | |
39 os.path.join(outdir, 'libcmt.pdb')) | |
40 vspaths = [ | |
41 'build\\intel\\mt_obj\\', | |
Evan Martin
2012/05/23 17:44:15
perhaps more readable as
r'build\intel\mt_obj' '
M-A Ruel
2012/05/30 12:55:11
I personally disagree, either a string all r'' or
| |
42 'f:\\dd\\vctools\\crt_bld\\SELF_X86\\crt\\src\\build\\INTEL\\mt_obj\\' | |
43 ] | |
44 objfiles = ['malloc', 'free', 'realloc', 'new', 'delete', 'new2', 'delete2', | |
45 'align', 'msize', 'heapinit', 'expand', 'heapchk', 'heapwalk', | |
46 'heapmin', 'sbheap', 'calloc', 'recalloc', 'calloc_impl', | |
47 'new_mode', 'newopnt'] | |
48 for obj in objfiles: | |
49 for vspath in vspaths: | |
50 cmd = ('lib /nologo /ignore:4006,4014,4221 /remove:%s%s.obj %s' % | |
M-A Ruel
2012/05/30 12:55:11
Please use a list, not a string.
| |
51 (vspath, obj, output_lib)) | |
52 run(cmd, obj + '.obj') | |
M-A Ruel
2012/05/30 12:55:11
you shouldn't discard the return code. If one of t
| |
53 | |
54 if __name__ == "__main__": | |
55 sys.exit(main()) | |
OLD | NEW |