/indra/newview/build_win32_appConfig.py

https://bitbucket.org/lindenlab/viewer-beta/ · Python · 68 lines · 33 code · 12 blank · 23 comment · 3 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. import sys, os, re
  25. from xml.dom.minidom import parse
  26. def munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name):
  27. manifest_dom = parse(src_manifest_name)
  28. node = manifest_dom.getElementsByTagName('assemblyIdentity')[0]
  29. manifest_assm_ver = node.getAttribute('version')
  30. config_dom = parse(src_config_name)
  31. node = config_dom.getElementsByTagName('bindingRedirect')[0]
  32. node.setAttribute('newVersion', manifest_assm_ver)
  33. src_old_ver = re.match('([^-]*-).*', node.getAttribute('oldVersion')).group(1)
  34. node.setAttribute('oldVersion', src_old_ver + manifest_assm_ver)
  35. comment = config_dom.createComment("This file is automatically generated by the build. see indra/newview/build_win32_appConfig.py")
  36. config_dom.insertBefore(comment, config_dom.childNodes[0])
  37. print "Writing: " + dst_config_name
  38. f = open(dst_config_name, 'w')
  39. config_dom.writexml(f)
  40. f.close()
  41. def main():
  42. config = sys.argv[1]
  43. src_dir = sys.argv[2]
  44. dst_dir = sys.argv[3]
  45. dst_name = sys.argv[4]
  46. if config.lower() == 'debug':
  47. src_manifest_name = dst_dir + '/Microsoft.VC80.DebugCRT.manifest'
  48. src_config_name = src_dir + '/SecondLifeDebug.exe.config'
  49. else:
  50. src_manifest_name = dst_dir + '/Microsoft.VC80.CRT.manifest'
  51. src_config_name = src_dir + '/SecondLife.exe.config'
  52. dst_config_name = dst_dir + '/' + dst_name
  53. munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name)
  54. return 0
  55. if __name__ == "__main__":
  56. main()