summaryrefslogtreecommitdiffstats
path: root/lib/libUPnP/Platinum/Build/Tools/Scripts/XCodeMake.py
blob: 15bce598e10e93ac98541cc0c58c4d89c66dfb1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /usr/bin/env python
"""

XCode Build Script

$Id: XCodeMake.py 655 2010-09-29 22:40:22Z soothe $

"""

import os
import sys
import getopt
import subprocess


# ------------------------------------------------------------
#       usage
# ------------------------------------------------------------
def usage(errMsg):
    try:
        print 'Error: %s' % (errMsg)
    except NameError:
        pass

    print 'Usage: '
    print '  %s -p <path to project> -b [Release|Debug|etc.] -t [All|Platinum|PlatinumFramework|etc.] -s [macosx|iphoneos]' % (sys.argv[0])
    print ''
    print '    REQUIRED OPTIONS'
    print '\t-p <project>'
    print '\t-b <configuration>'
    print '\t-t <target>'
    print '\t-s <sdk>'
    print ''
    print '    BUILD OPTIONS'
    print '\t-c\tMake clean'


# ------------------------------------------------------------
#       main
# ------------------------------------------------------------
try:
    opts, args = getopt.getopt(sys.argv[1:], "p:b:t:s:c")
except getopt.GetoptError, (msg, opt):
#    print 'Error: invalid argument, %s: %s' % (opt, msg)
    usage('invalid argument, %s: %s' % (opt, msg))
    sys.exit(2)

# Build options
doingBuild = False
rebuildAll = False
makeClean = False

for opt, arg in opts:
    if opt == '-p':
        projectFile = arg
        doingBuild = True
    elif opt == '-b':
        buildName = arg
        doingBuild = True
    elif opt == '-t':
        targetName = arg
    elif opt == '-s':
        sdk = arg
    elif opt == '-c':
        makeClean = True

try:
    buildSwitch = 'build'
    if makeClean: buildSwitch = 'clean'
        
    cmd_list = ['xcodebuild', '-project', '%s' % projectFile, '-target', '%s' % targetName, '-sdk', '%s' % sdk, '-configuration', '%s' % buildName, '%s' % buildSwitch]
    cmd = " ".join(cmd_list)
    print 'Executing:'
    print cmd
    retVal = subprocess.call(cmd_list)
    # only the least sig 8 bits are the real return value
    if retVal != 0:
        print cmd
        print '** BUILD FAILURE **'
        sys.exit(retVal)
except NameError, (name):
    usage('missing argument %s' % (name))
    sys.exit(2)