Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / base / allocator / prep_libc.py
blob079297b4629346601a1401e59f98f47e09578033
1 #!/usr/bin/env python
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
8 # functions from it.
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.
17 import os
18 import shutil
19 import subprocess
20 import sys
22 def run(command):
23 """Run |command|. If any lines that match an error condition then
24 terminate."""
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():
30 print line
31 if error and line.find(error) != -1:
32 print 'prep_libc.py: Error stripping object from C runtime.'
33 sys.exit(1)
35 def main():
36 bindir = 'SELF_X86'
37 objdir = 'INTEL'
38 vs_install_dir = sys.argv[1]
39 outdir = sys.argv[2]
40 if "x64" in sys.argv[3]:
41 bindir = 'SELF_64_amd64'
42 objdir = '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', 'heapinit', 'calloc', 'recalloc',
54 'calloc_impl']
55 cppobjfiles = ['new', 'new2', 'delete', 'delete2', 'new_mode', 'newopnt',
56 'newaopnt']
57 for obj in cobjfiles:
58 cmd = ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
59 (cvspath, obj, output_lib))
60 run(cmd)
61 for obj in cppobjfiles:
62 cmd = ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
63 (cppvspath, obj, output_lib))
64 run(cmd)
66 if __name__ == "__main__":
67 sys.exit(main())