Speculative fix for the white/stale tab issue on Windows.
[chromium-blink-merge.git] / base / allocator / prep_libc.py
blobbe7030f0f1de613a67d96409fbdfc6cd75eadd56
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 VS2005/08/10 and removes the allocation
8 # related functions from it.
10 # Usage: prep_libc.py <VCInstallDir> <OutputDir>
12 # VCInstallDir is the path where VC is installed, something like:
13 # C:\Program Files\Microsoft Visual Studio 8\VC\
15 # OutputDir is the directory where the modified libcmt file should be stored.
17 import os
18 import shutil
19 import subprocess
20 import sys
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
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\\',
42 'f:\\dd\\vctools\\crt_bld\\SELF_X86\\crt\\src\\build\\INTEL\\mt_obj\\',
43 'F:\\dd\\vctools\\crt_bld\\SELF_X86\\crt\\src\\build\\INTEL\\mt_obj\\nativec\\\\',
44 'F:\\dd\\vctools\\crt_bld\\SELF_X86\\crt\\src\\build\\INTEL\\mt_obj\\nativecpp\\\\',
46 objfiles = ['malloc', 'free', 'realloc', 'new', 'delete', 'new2', 'delete2',
47 'align', 'msize', 'heapinit', 'expand', 'heapchk', 'heapwalk',
48 'heapmin', 'sbheap', 'calloc', 'recalloc', 'calloc_impl',
49 'new_mode', 'newopnt']
50 for obj in objfiles:
51 for vspath in vspaths:
52 cmd = ('lib /nologo /ignore:4006,4014,4221 /remove:%s%s.obj %s' %
53 (vspath, obj, output_lib))
54 run(cmd, obj + '.obj')
56 if __name__ == "__main__":
57 sys.exit(main())