This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildPlayer.py
163 lines (147 loc) · 5.56 KB
/
buildPlayer.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import os
import shutil
import sys
import subprocess
import time
if (os.path.exists("/opt/flex")):
flex = "/opt/flex"
exe = ""
elif (os.path.exists(os.path.normpath("C:/flex_sdk_4.6"))):
flex = ("C:/flex_sdk_4.6")
exe = ".exe"
elif (os.path.exists(os.path.expanduser("~/SDKs/Flex/4.14"))):
flex = os.path.expanduser("~/SDKs/Flex/4.14")
exe = ""
SOURCE_PATH = "./src/as3/"
TRANSCODER_MAIN_CLASS = SOURCE_PATH + "com/streamroot/transcoder/TranscodeWorker.as"
TRANSCODER_OUTPUT = SOURCE_PATH + "com/streamroot/transcoder/TranscodeWorker.swf"
POLYFILL_MAIN_CLASS = SOURCE_PATH + "com/streamroot/Main.as"
POLYFILL_OUTPUT = "build/fMSE.swf"
debug = "false"
log_debug = "false"
log_error = "false"
verbose = False
swfversion = "17"
targetPlayer = "11.4.0"
color = True
startTime = time.time()
def helpParam():
print "\npython buildPlayer.py [options]"
print "options:"
print "\t--debug : set debug flag to true"
print "\t--log-debug : enables debug messages logging to browser console"
print "\t--log-error : enables error messages logging to browser console"
print "\t--no-color : disable color"
print "\t-v : verbose mode"
print "\t-h : display this menu"
print ""
sys.exit(0)
def printRed(text):
if color:
print "\033[31m" + text + "\033[0m"
else:
print text
def printPurple(text):
if color:
print "\033[35m" + text + "\033[0m"
else:
print text
def printGreen(text):
if color:
print "\033[32m" + text + "\033[0m"
else:
print text
def printYellow(text):
if color:
print "\033[33m" + text + "\033[0m"
else:
print text
if (len(sys.argv)>1):
for i in range(1, len(sys.argv)):
if sys.argv[i] == "--debug":
debug = "true"
elif sys.argv[i] == "--log-debug":
log_debug = "true"
elif sys.argv[i] == "--log-error":
log_error = "true"
elif sys.argv[i] == "-v":
verbose = True
elif sys.argv[i] in ["--help","-h"]:
helpParam()
elif sys.argv[i] == "--no-color":
color = False
else:
print "incorrect argument"
helpParam()
if verbose:
print "Debug flag = " + debug
print "-swf-version="+swfversion
print "-target-player="+targetPlayer
def popenPrint(result):
result.wait()
if verbose:
for line in result.stdout:
print(line)
for line in result.stderr:
while line.endswith("\n"):
line = line[:-1]
if not line == "":
if color:
line = line.replace("Error:", "\n\033[31mError\033[0m:");
line = line.replace("Erreur:", "\n\033[31mErreur\033[0m:");
line = line.replace("Warning:", "\n\033[33mWarning\033[0m:");
line = line.replace("Avertissement:", "\n\033[33mAvertissement\033[0m:");
else:
line = line.replace("Error:", "Error:");
line = line.replace("Erreur:", "Erreur:");
line = line.replace("Warning:", "Warning:");
line = line.replace("Avertissement:", "Avertissement:");
if line.startswith('\n'):
line = line[1:]
print(line)
#Compile worker
if os.path.exists(TRANSCODER_OUTPUT):
os.remove(os.path.normpath(TRANSCODER_OUTPUT))
workerResult = subprocess.Popen([os.path.normpath(flex + "/bin/mxmlc" + exe),
os.path.normpath(TRANSCODER_MAIN_CLASS),
os.path.normpath("-output=" + TRANSCODER_OUTPUT),
"-static-link-runtime-shared-libraries=true",
"-compiler.source-path=" + SOURCE_PATH,
"-target-player="+targetPlayer+"",
"-swf-version="+swfversion+"",
"-debug="+debug+"",
"-define+=CONFIG::LOG_DEBUG," + log_debug,
"-define+=CONFIG::LOG_ERROR," + log_error],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
popenPrint(workerResult)
if not os.path.exists(TRANSCODER_OUTPUT):
printRed("Transcoder build failed")
sys.exit(0)
else:
printPurple(">> " + TRANSCODER_OUTPUT + " has been generated, build successful")
#compiling polyfill
if os.path.exists(POLYFILL_OUTPUT):
os.remove(os.path.normpath(POLYFILL_OUTPUT))
polyfillResult = subprocess.Popen([os.path.normpath(flex +"/bin/mxmlc" + exe),
os.path.normpath(POLYFILL_MAIN_CLASS),
os.path.normpath("-output=" + POLYFILL_OUTPUT),
"-compiler.source-path=" + SOURCE_PATH,
"-target-player="+targetPlayer+"",
"-swf-version="+swfversion+"",
"-debug="+debug+"",
"-static-link-runtime-shared-libraries=true",
"-use-network=false",
"-compiler.optimize=true",
"-default-background-color=0x000000",
"-default-frame-rate=30",
"-define+=CONFIG::LOG_DEBUG," + log_debug,
"-define+=CONFIG::LOG_ERROR," + log_error], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
popenPrint(polyfillResult)
if not os.path.exists(POLYFILL_OUTPUT):
printRed("Polyfill build failed")
sys.exit(0)
else:
printPurple(">> " + POLYFILL_OUTPUT + " has been generated, build successful")
printGreen("Build successful")
time = time.time() - startTime
print "Time elapsed : " + str(time) + "s"