/webkit/WebKitTools/wx/packaging/build-win-installer.py

https://github.com/blackberry/WebKit-Smartphone
Python | 97 lines | 50 code | 19 blank | 28 comment | 10 complexity | 0baba87b444b347d5dd5d740b044531d MD5 | raw file
  1. #!/usr/bin/env python
  2. # Copyright (C) 2008 Kevin Ollivier All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. # 1. Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # 2. Redistributions in binary form must reproduce the above copyright
  10. # notice, this list of conditions and the following disclaimer in the
  11. # documentation and/or other materials provided with the distribution.
  12. #
  13. # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. #
  25. # Create a Windows installer package for wxPython wxWebKit binaries
  26. import sys, os, string
  27. import commands
  28. import glob
  29. from subprocess import *
  30. script_dir = os.path.abspath(os.path.dirname(__file__))
  31. sys.path.append(os.path.abspath(os.path.join(script_dir, "..", "build")))
  32. from build_utils import *
  33. wxwk_root = os.path.abspath(os.path.join(script_dir, "..", "..", ".."))
  34. wxwebkit_dir = os.path.abspath(os.path.join(wxwk_root, "WebKitBuild", get_config(wxwk_root) + git_branch_name()))
  35. # Find InnoSetup executable
  36. def getInnoSetupPath():
  37. name = "ISCC.exe"
  38. retval = ""
  39. dirs = os.environ["PATH"].split(":")
  40. # Add the default file path
  41. dirs.append("C:\\Program Files\\Inno Setup 5")
  42. dirs.append("C:\\Program Files (x86)\\Inno Setup 5")
  43. if os.environ.has_key("INNO5"):
  44. retval = os.environ["INNO5"]
  45. if retval == "":
  46. for dir in dirs:
  47. filepath = os.path.join(dir, name)
  48. if os.path.isfile(filepath):
  49. retval = filepath
  50. return retval
  51. if __name__ == "__main__":
  52. innoSetup = getInnoSetupPath()
  53. os.chdir(sys.path[0])
  54. svnrevision = svn_revision()
  55. if not os.path.exists(innoSetup):
  56. print "ERROR: Cannot find InnoSetup."
  57. #sys.exit(1)
  58. if not os.path.exists(wxwebkit_dir):
  59. print "ERROR: Build dir %s doesn't exist." % wxwebkit_dir
  60. sys.exit(1)
  61. fileList = """
  62. CopyMode: alwaysoverwrite; Source: *.pyd; DestDir: "{app}"
  63. CopyMode: alwaysoverwrite; Source: *.py; DestDir: "{app}"
  64. """
  65. dlls = glob.glob(os.path.join(wxwebkit_dir, "*.dll"))
  66. for dll in dlls:
  67. if dll.find("wxbase") == -1 and dll.find("wxmsw") == -1:
  68. fileList += """CopyMode: alwaysoverwrite; Source: %s; DestDir: "{app}" \n""" % dll
  69. installerTemplate = open("wxWebKitInstaller.iss.in", "r").read()
  70. installerTemplate = installerTemplate.replace("<<VERSION>>", svnrevision)
  71. installerTemplate = installerTemplate.replace("<<ROOTDIR>>", wxwebkit_dir )
  72. installerTemplate = installerTemplate.replace("<<PYTHONVER>>", sys.version[0:3] )
  73. installerTemplate = installerTemplate.replace("<<FILES>>", fileList )
  74. outputFile = open("wxWebKitInstaller.iss", "w")
  75. outputFile.write(installerTemplate)
  76. outputFile.close()
  77. success = os.system('"%s" wxWebKitInstaller.iss' % innoSetup)
  78. sys.exit(success)