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.
7 # This script takes libcmt.lib for VS2013 and removes the allocation related
10 # Usage: prep_libc.py <VCLibDir> <OutputDir> <arch>
12 # VCLibDir is the path where VC is installed, something like:
13 # C:\Program Files\Microsoft Visual Studio 8\VC\lib
14 # OutputDir is the directory where the modified libcmt file should be stored.
15 # arch is one of: 'ia32', 'x86' or 'x64'. ia32 and x86 are synonyms.
23 """Run |command|. If any lines that match an error condition then
25 error
= 'cannot find member object'
26 popen
= subprocess
.Popen(
27 command
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
28 out
, _
= popen
.communicate()
29 for line
in out
.splitlines():
31 if error
and line
.find(error
) != -1:
32 print 'prep_libc.py: Error stripping object from C runtime.'
38 vs_install_dir
= sys
.argv
[1]
40 if "x64" in sys
.argv
[3]:
41 bindir
= 'SELF_64_amd64'
43 vs_install_dir
= os
.path
.join(vs_install_dir
, 'amd64')
44 output_lib
= os
.path
.join(outdir
, 'libcmt.lib')
45 shutil
.copyfile(os
.path
.join(vs_install_dir
, 'libcmt.lib'), output_lib
)
46 shutil
.copyfile(os
.path
.join(vs_install_dir
, 'libcmt.pdb'),
47 os
.path
.join(outdir
, 'libcmt.pdb'))
48 cvspath
= 'f:\\binaries\\Intermediate\\vctools\\crt_bld\\' + bindir
+ \
49 '\\crt\\prebuild\\build\\' + objdir
+ '\\mt_obj\\nativec\\\\';
50 cppvspath
= 'f:\\binaries\\Intermediate\\vctools\\crt_bld\\' + bindir
+ \
51 '\\crt\\prebuild\\build\\' + objdir
+ '\\mt_obj\\nativecpp\\\\';
53 cobjfiles
= ['malloc', 'free', 'realloc', 'align', 'msize', 'heapinit',
54 'expand', 'heapchk', 'heapwalk', 'heapmin', 'calloc', 'recalloc',
56 cppobjfiles
= ['new', 'new2', 'delete', 'delete2', 'new_mode', 'newopnt',
59 cmd
= ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
60 (cvspath
, obj
, output_lib
))
62 for obj
in cppobjfiles
:
63 cmd
= ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
64 (cppvspath
, obj
, output_lib
))
67 if __name__
== "__main__":