|
@@ -0,0 +1,171 @@
|
|
1
|
+import sys, getopt, os
|
|
2
|
+import commands
|
|
3
|
+import subprocess
|
|
4
|
+
|
|
5
|
+BUILD_PATH = ""
|
|
6
|
+BUILD_MODE = ""
|
|
7
|
+BUILD_VERSION = ""
|
|
8
|
+
|
|
9
|
+class color:
|
|
10
|
+ PURPLE = '\033[95m'
|
|
11
|
+ CYAN = '\033[96m'
|
|
12
|
+ DARKCYAN = '\033[36m'
|
|
13
|
+ BLUE = '\033[94m'
|
|
14
|
+ GREEN = '\033[92m'
|
|
15
|
+ YELLOW = '\033[93m'
|
|
16
|
+ RED = '\033[91m'
|
|
17
|
+ BOLD = '\033[1m'
|
|
18
|
+ UNDERLINE = '\033[4m'
|
|
19
|
+ END = '\033[0m'
|
|
20
|
+
|
|
21
|
+def usage():
|
|
22
|
+ print color.BOLD + "Usage:" + color.END
|
|
23
|
+ print color.BOLD + "Build:" + color.END + "python %s [-p|--path] [-m|mode] [Debug|Release] [-v|--version]" % sys.argv[0]
|
|
24
|
+
|
|
25
|
+def parserCommand(argv):
|
|
26
|
+ try:
|
|
27
|
+ opts, args = getopt.getopt(argv, "p:m:v:", ["path=mode=version="])
|
|
28
|
+ return opts, args
|
|
29
|
+ except getopt.GetoptError:
|
|
30
|
+ usage()
|
|
31
|
+ sys.exit(1)
|
|
32
|
+
|
|
33
|
+def validParamaters():
|
|
34
|
+ cmd = 'svn ls %s --username wangyongbin --password aabb1234 --no-auth-cache' % BUILD_PATH;
|
|
35
|
+ status, output = commands.getstatusoutput(cmd)
|
|
36
|
+ if status != 0 :
|
|
37
|
+ print "svn '(%s)' path not exist" % BUILD_PATH
|
|
38
|
+ sys.exit(1)
|
|
39
|
+ if BUILD_MODE not in ("Debug", "Release"):
|
|
40
|
+ print "build mode must be Debug|Release"
|
|
41
|
+ sys.exit(1)
|
|
42
|
+
|
|
43
|
+def rmTmpDir() :
|
|
44
|
+ status, output = commands.getstatusoutput('rm -rf .tmp')
|
|
45
|
+ if status != 0 :
|
|
46
|
+ print output
|
|
47
|
+ sys.exit(1)
|
|
48
|
+
|
|
49
|
+def mkTmpDir() :
|
|
50
|
+ status, output = commands.getstatusoutput('mkdir .tmp')
|
|
51
|
+ if status != 0 :
|
|
52
|
+ print output
|
|
53
|
+ sys.exit(1)
|
|
54
|
+
|
|
55
|
+def svnCheckout() :
|
|
56
|
+ cmd = 'svn co %s .tmp --username wangyongbin --password aabb1234 --force --no-auth-cache' % (BUILD_PATH);
|
|
57
|
+ if BUILD_VERSION != "Latest":
|
|
58
|
+ cmd = 'svn co -r %s %s .tmp --username wangyongbin --password aabb1234 --force --no-auth-cache' % (BUILD_VERSION, BUILD_PATH);
|
|
59
|
+ status = subprocess.call(cmd, shell=True)
|
|
60
|
+ # if status != 0 :
|
|
61
|
+ # sys.exit(1)
|
|
62
|
+
|
|
63
|
+def unlockSign() :
|
|
64
|
+ status, output = commands.getstatusoutput('security unlock-keychain -p ascii');
|
|
65
|
+ status, output = commands.getstatusoutput('security unlock-keychain -p ascii /Users/ascii/Library/Keychains/login.keychain');
|
|
66
|
+ if status != 0 :
|
|
67
|
+ print output
|
|
68
|
+ sys.exit(1)
|
|
69
|
+
|
|
70
|
+def tmpDirPath() :
|
|
71
|
+ status, output = commands.getstatusoutput('pwd')
|
|
72
|
+ if status == 0 :
|
|
73
|
+ return output
|
|
74
|
+ else :
|
|
75
|
+ print output
|
|
76
|
+
|
|
77
|
+def buildDebug() :
|
|
78
|
+ status = subprocess.call('xcodebuild -workspace FirstLink.xcworkspace -scheme FirstLink -configuration Debug clean', shell=True)
|
|
79
|
+ # status = subprocess.call('xcodebuild -workspace FirstLink.xcworkspace -scheme FirstLink SYMROOT=%s' % tmpDirPath(), shell=True)
|
|
80
|
+ status = subprocess.call('xcodebuild -workspace FirstLink.xcworkspace -scheme FirstLink SYMROOT=%s -configuration Debug' % tmpDirPath(), shell=True)
|
|
81
|
+ if status != 0:
|
|
82
|
+ sys.exit(1)
|
|
83
|
+
|
|
84
|
+def buildArchive() :
|
|
85
|
+ status = subprocess.call('xcodebuild -workspace FirstLink.xcworkspace -scheme FirstLink -configuration Release clean', shell=True)
|
|
86
|
+ status = subprocess.call('xcodebuild -workspace FirstLink.xcworkspace -scheme FirstLink DSTROOT=%s archive' % tmpDirPath(), shell=True)
|
|
87
|
+ if status != 0:
|
|
88
|
+ sys.exit(1)
|
|
89
|
+
|
|
90
|
+def packageForDebug():
|
|
91
|
+ cmd = 'cp -R ./Debug-iphoneos/FirstLink.app ./FirstLink.app'
|
|
92
|
+ status = subprocess.call(cmd, shell=True)
|
|
93
|
+ status, output = commands.getstatusoutput('date +%m%d%H%M')
|
|
94
|
+ if status != 0:
|
|
95
|
+ print output
|
|
96
|
+ sys.exit(1)
|
|
97
|
+ else :
|
|
98
|
+ filename = 'Debug_%s.tar.gz' % (output)
|
|
99
|
+ cmd = 'tar zcvf %s ./FirstLink.app' % (filename)
|
|
100
|
+ print '** START TAR PACKAGE **'
|
|
101
|
+ status = subprocess.call(cmd, shell=True)
|
|
102
|
+ if status == 0 :
|
|
103
|
+ print '** PACKAGE SUCCEEDED **'
|
|
104
|
+ else:
|
|
105
|
+ print '** PACKAGE FAILED **'
|
|
106
|
+
|
|
107
|
+ cmd = 'cp %s ../ipa/%s' % (filename, filename)
|
|
108
|
+ status, output = commands.getstatusoutput(cmd)
|
|
109
|
+ if status != 0:
|
|
110
|
+ print output
|
|
111
|
+ sys.exit(1)
|
|
112
|
+
|
|
113
|
+def packageForArchive():
|
|
114
|
+ cmd = 'cp -R ./Applications/FirstLink.app ./FirstLink.app'
|
|
115
|
+ status = subprocess.call(cmd, shell=True)
|
|
116
|
+ status, output = commands.getstatusoutput('date +%m%d%H%M')
|
|
117
|
+ if status != 0:
|
|
118
|
+ print output
|
|
119
|
+ sys.exit(1)
|
|
120
|
+ else :
|
|
121
|
+ filename = 'Release_%s.tar.gz' % (output)
|
|
122
|
+ cmd = 'tar zcvf %s ./FirstLink.app' % (filename)
|
|
123
|
+ print '** START TAR PACKAGE **'
|
|
124
|
+ status = subprocess.call(cmd, shell=True)
|
|
125
|
+ if status == 0 :
|
|
126
|
+ print '** PACKAGE SUCCEEDED **'
|
|
127
|
+ else:
|
|
128
|
+ print '** PACKAGE FAILED **'
|
|
129
|
+
|
|
130
|
+ cmd = 'cp %s ../ipa/%s' % (filename, filename)
|
|
131
|
+ status, output = commands.getstatusoutput(cmd)
|
|
132
|
+ if status != 0:
|
|
133
|
+ print output
|
|
134
|
+ sys.exit(1)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+if __name__ == "__main__":
|
|
138
|
+ opts, args = parserCommand(sys.argv[1:])
|
|
139
|
+ for opt, arg in opts:
|
|
140
|
+ if opt in ("-p", "--path"):
|
|
141
|
+ BUILD_PATH = arg;
|
|
142
|
+ if opt in ("-v", "--version"):
|
|
143
|
+ BUILD_VERSION = arg;
|
|
144
|
+ if opt in ("-m", "--mode"):
|
|
145
|
+ BUILD_MODE = arg;
|
|
146
|
+
|
|
147
|
+ validParamaters()
|
|
148
|
+
|
|
149
|
+ rmTmpDir()
|
|
150
|
+ mkTmpDir()
|
|
151
|
+ svnCheckout()
|
|
152
|
+ # unlockSign()
|
|
153
|
+
|
|
154
|
+ os.chdir(".tmp")
|
|
155
|
+ if BUILD_MODE == "Debug" :
|
|
156
|
+ buildDebug()
|
|
157
|
+ packageForDebug()
|
|
158
|
+ sys.exit(1)
|
|
159
|
+ elif BUILD_MODE == "Release":
|
|
160
|
+ buildArchive()
|
|
161
|
+ packageForArchive()
|
|
162
|
+ sys.exit(1)
|
|
163
|
+
|
|
164
|
+ usage()
|
|
165
|
+ sys.exit(1)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|