Don't add -fuse-ld=gold to cflags
[chromium-blink-merge.git] / base / allocator / prep_libc.py
blobba25cea092f8a3dae2abc0c35af8da577d5efb33
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/12/13 and removes the allocation
8 # related 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 either 'ia32' or 'x64'
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 bindir = 'SELF_X86'
35 objdir = 'INTEL'
36 vs_install_dir = sys.argv[1]
37 outdir = sys.argv[2]
38 if "x64" in sys.argv[3]:
39 bindir = 'SELF_64_amd64'
40 objdir = 'amd64'
41 vs_install_dir = os.path.join(vs_install_dir, 'amd64')
42 output_lib = os.path.join(outdir, 'libcmt.lib')
43 shutil.copyfile(os.path.join(vs_install_dir, 'libcmt.lib'), output_lib)
44 shutil.copyfile(os.path.join(vs_install_dir, 'libcmt.pdb'),
45 os.path.join(outdir, 'libcmt.pdb'))
47 vspaths = [
48 'build\\intel\\mt_obj\\',
49 'f:\\dd\\vctools\\crt_bld\\' + bindir + \
50 '\\crt\\src\\build\\' + objdir + '\\mt_obj\\',
51 'F:\\dd\\vctools\\crt_bld\\' + bindir + \
52 '\\crt\\src\\build\\' + objdir + '\\mt_obj\\nativec\\\\',
53 'F:\\dd\\vctools\\crt_bld\\' + bindir + \
54 '\\crt\\src\\build\\' + objdir + '\\mt_obj\\nativecpp\\\\',
55 'f:\\binaries\\Intermediate\\vctools\\crt_bld\\' + bindir + \
56 '\\crt\\prebuild\\build\\INTEL\\mt_obj\\cpp_obj\\\\',
59 objfiles = ['malloc', 'free', 'realloc', 'new', 'delete', 'new2', 'delete2',
60 'align', 'msize', 'heapinit', 'expand', 'heapchk', 'heapwalk',
61 'heapmin', 'sbheap', 'calloc', 'recalloc', 'calloc_impl',
62 'new_mode', 'newopnt', 'newaopnt']
63 for obj in objfiles:
64 for vspath in vspaths:
65 cmd = ('lib /nologo /ignore:4006,4014,4221 /remove:%s%s.obj %s' %
66 (vspath, obj, output_lib))
67 run(cmd, obj + '.obj')
69 if __name__ == "__main__":
70 sys.exit(main())