michael@0: #!/usr/bin/env python michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: import shutil michael@0: import sys michael@0: import os michael@0: michael@0: def patch_msbuild(): michael@0: """VS2010 MSBuild has a ULDI bug that we patch here. See http://goo.gl/Pn8tj. michael@0: """ michael@0: source_path = os.path.join(os.environ['ProgramFiles(x86)'], michael@0: "MSBuild", michael@0: "Microsoft.Cpp", michael@0: "v4.0", michael@0: "Microsoft.CppBuild.targets") michael@0: backup_path = source_path + ".backup" michael@0: if not os.path.exists(backup_path): michael@0: try: michael@0: print "Backing up %s..." % source_path michael@0: shutil.copyfile(source_path, backup_path) michael@0: except IOError: michael@0: print "Could not back up %s to %s. Run as Administrator?" % ( michael@0: source_path, backup_path) michael@0: return 1 michael@0: michael@0: source = open(source_path).read() michael@0: base = ('''' michael@0: replace = base + ''' Condition="'$(ConfigurationType)'=='StaticLibrary'">''' michael@0: result = source.replace(find, replace) michael@0: michael@0: if result != source: michael@0: open(source_path, "w").write(result) michael@0: print "Patched %s." % source_path michael@0: return 0 michael@0: michael@0: michael@0: def main(): michael@0: return patch_msbuild() michael@0: michael@0: michael@0: if __name__ == "__main__": michael@0: sys.exit(main())