Set Display size correctly on Android.
[chromium-blink-merge.git] / base / allocator / prep_libc.py
blob3238eec8c0fcf274fed05982b71c444f50432acc
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', 'align', 'msize', 'heapinit',
54 'expand', 'heapchk', 'heapwalk', 'heapmin', 'calloc', 'recalloc',
55 'calloc_impl']
56 cppobjfiles = ['new', 'new2', 'delete', 'delete2', 'new_mode', 'newopnt',
57 'newaopnt']
58 for obj in cobjfiles:
59 cmd = ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
60 (cvspath, obj, output_lib))
61 run(cmd)
62 for obj in cppobjfiles:
63 cmd = ('lib /nologo /ignore:4006,4221 /remove:%s%s.obj %s' %
64 (cppvspath, obj, output_lib))
65 run(cmd)
67 if __name__ == "__main__":
68 sys.exit(main())