PageRenderTime 390ms CodeModel.GetById 171ms app.highlight 6ms RepoModel.GetById 145ms app.codeStats 0ms

/indra/newview/build_win32_appConfig.py

https://bitbucket.org/lindenlab/viewer-beta/
Python | 68 lines | 33 code | 12 blank | 23 comment | 2 complexity | bf96587b1707d19ed838a07113c82377 MD5 | raw file
 1# @file build_win32_appConfig.py
 2# @brief Create the windows app.config file to redirect crt linkage.
 3#
 4# $LicenseInfo:firstyear=2009&license=viewerlgpl$
 5# Second Life Viewer Source Code
 6# Copyright (C) 2010, Linden Research, Inc.
 7# 
 8# This library is free software; you can redistribute it and/or
 9# modify it under the terms of the GNU Lesser General Public
10# License as published by the Free Software Foundation;
11# version 2.1 of the License only.
12# 
13# This library is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# Lesser General Public License for more details.
17# 
18# You should have received a copy of the GNU Lesser General Public
19# License along with this library; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21# 
22# Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23# $/LicenseInfo$
24
25import sys, os, re
26from xml.dom.minidom import parse
27
28def munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name):
29    manifest_dom = parse(src_manifest_name)
30    node = manifest_dom.getElementsByTagName('assemblyIdentity')[0]
31    manifest_assm_ver = node.getAttribute('version')
32    
33    config_dom = parse(src_config_name)
34    node = config_dom.getElementsByTagName('bindingRedirect')[0]
35    node.setAttribute('newVersion', manifest_assm_ver)
36    src_old_ver = re.match('([^-]*-).*', node.getAttribute('oldVersion')).group(1)
37    node.setAttribute('oldVersion', src_old_ver + manifest_assm_ver)
38    comment = config_dom.createComment("This file is automatically generated by the build. see indra/newview/build_win32_appConfig.py")
39    config_dom.insertBefore(comment, config_dom.childNodes[0])
40
41    print "Writing: " + dst_config_name
42    f = open(dst_config_name, 'w')
43    config_dom.writexml(f)
44    f.close()
45    
46    
47
48def main():
49    config = sys.argv[1]
50    src_dir = sys.argv[2]
51    dst_dir = sys.argv[3]
52    dst_name = sys.argv[4]
53    
54    if config.lower() == 'debug':
55        src_manifest_name = dst_dir + '/Microsoft.VC80.DebugCRT.manifest'
56        src_config_name = src_dir + '/SecondLifeDebug.exe.config'
57    else:
58        src_manifest_name = dst_dir + '/Microsoft.VC80.CRT.manifest'
59        src_config_name = src_dir + '/SecondLife.exe.config'
60
61    dst_config_name = dst_dir + '/' + dst_name
62        
63    munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name)
64    
65    return 0
66
67if __name__ == "__main__":
68    main()