Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / Neptune / Build / Targets / x86-microsoft-win32-vs2010 / Build.py
blobab9b164d22facc4ddcf4c3c3946f9c7c94b4a8b2
1 #! /usr/bin/env python
2 """
4 Visual Studio 2010 Build Script
6 $Id: Build.py 87 2008-08-15 19:03:36Z bok $
8 """
10 import os
11 import sys
12 import getopt
13 import subprocess
15 # Setup some path stuff
16 try:
17 if environ['VISUALSTUDIO_BIN']:
18 VSBINDIR = environ['VISUALSTUDIO_BIN']
19 except NameError:
20 # Use default value for visual studio.
21 VSBINDIR = 'C:/Program Files/Microsoft Visual Studio 10.0/Common7/IDE'
22 print 'VISUALSTUDIO_BIN not set. Trying default value:'
23 print ' ' + VSBINDIR
24 print ''
27 # ------------------------------------------------------------
28 # usage
29 # ------------------------------------------------------------
30 def usage(errMsg):
31 try:
32 print 'Error: %s' % (errMsg)
33 except NameError:
34 pass
36 print 'Usage: '
37 print ' %s -s <path to solution> -b [Release|Debug|etc.]' % (sys.argv[0])
38 print ''
39 print ' REQUIRED OPTIONS'
40 print '\t-s <solution>'
41 print '\t-b <configuration>'
42 print ''
43 print ' BUILD OPTIONS'
44 print '\t-c\tMake clean'
45 print '\t-r\tRe-build all'
48 # ------------------------------------------------------------
49 # main
50 # ------------------------------------------------------------
51 try:
52 opts, args = getopt.getopt(sys.argv[1:], "s:b:rc")
53 except getopt.GetoptError, (msg, opt):
54 # print 'Error: invalid argument, %s: %s' % (opt, msg)
55 usage('invalid argument, %s: %s' % (opt, msg))
56 sys.exit(2)
58 # Build options
59 doingBuild = False
60 rebuildAll = False
61 makeClean = False
63 for opt, arg in opts:
64 if opt == '-s':
65 solutionFile = arg
66 doingBuild = True
67 elif opt == '-b':
68 buildName = arg
69 doingBuild = True
70 elif opt == '-r':
71 rebuildAll = True
72 doingBuild = True
73 elif opt == '-c':
74 makeClean = True
76 if rebuildAll and makeClean:
77 usage('Error cannot specify -c and -r together')
78 sys.exit(2)
80 try:
81 buildSwitch = 'build'
82 if rebuildAll: buildSwitch = 'rebuild'
83 elif makeClean: buildSwitch = 'clean'
85 cmd_list = ['%s/devenv.com' % VSBINDIR, '/%s' % buildSwitch, buildName, solutionFile]
86 cmd = " ".join(cmd_list)
87 print 'Executing:'
88 print cmd
89 retVal = subprocess.call(cmd_list)
90 # only the least sig 8 bits are the real return value
91 if retVal != 0:
92 print cmd
93 print '** BUILD FAILURE **'
94 sys.exit(retVal)
95 except NameError, (name):
96 usage('missing argument %s' % (name))
97 sys.exit(2)