-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathcompile_all.py
204 lines (174 loc) · 7.04 KB
/
compile_all.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# -*- coding: utf-8 -*-
'''
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
'''
import utils
import os
import shutil
import codecs
import detectinfo
import compile_lib_core
import compile_lib_gdi
import compile_lib_osutil
import compile_lib_screencapture
import compile_lib_screencapture_bitblt
import compile_lib_screencapture_xorg
import compile_lib_screencapture_quartzdisplay
import compile_lib_screencapture_desktopduplication
import compile_lib_soundcapture
import compile_os_win_launcher
import compile_os_win_service
import compile_os_win_updater
class CompileAll():
def __init__(self):
self._b32bit=False
def set_32bit(self):
self._b32bit=True
def get_path_tmp(self):
if self._b32bit:
return utils.PATHTMP+"32"
else:
return utils.PATHTMP
def get_path_native(self):
if self._b32bit:
return utils.PATHNATIVE+"32"
else:
return utils.PATHNATIVE
def run(self):
bok=True
arstatus=[]
utils.init_path(self.get_path_native())
utils.info("BEGIN DEPENDENCIES")
try:
if utils.is_windows():
self._dependency("lib_gcc", "8.1.0", arstatus)
self._dependency("lib_stdcpp", "8.1.0", arstatus)
self._dependency("lib_z", "1.2.11", arstatus)
self._dependency("lib_turbojpeg", "2.1.1", arstatus)
self._dependency("lib_opus", "21.3.1", arstatus)
self._dependency("lib_rtaudio", "5.1.0", arstatus)
utils.info("END DEPENDENCIES")
except:
bok=False
utils.info("ERROR DEPENDENCIES")
if bok:
utils.info("BEGIN COMPILE ALL")
try:
self._compile(compile_lib_core,arstatus)
self._compile(compile_lib_gdi,arstatus)
self._compile(compile_lib_osutil,arstatus)
if utils.is_windows():
self._compile(compile_os_win_launcher,arstatus)
self._compile(compile_os_win_service,arstatus)
self._compile(compile_os_win_updater,arstatus)
self._compile(compile_lib_screencapture,arstatus)
if utils.is_windows():
self._compile(compile_lib_screencapture_bitblt,arstatus)
self._compile(compile_lib_screencapture_desktopduplication,arstatus)
if utils.is_linux():
self._compile(compile_lib_screencapture_xorg,arstatus)
if utils.is_mac():
self._compile(compile_lib_screencapture_quartzdisplay,arstatus)
self._compile(compile_lib_soundcapture,arstatus)
utils.info("END COMPILE ALL")
except:
bok=False
utils.info("ERROR COMPILE ALL")
utils.info("")
utils.info("")
utils.info("STATUS:")
for n in arstatus:
utils.info(n)
utils.info("")
if bok:
utils.info("ALL COMPILED CORRECTLY.")
else:
utils.info("ERRORS OCCURRED.")
def _compile(self,md,ars):
mcp = md.Compile()
smsg=mcp.get_name()
try:
if self._b32bit:
mcp.set_32bit()
mcp.run()
smsg+=" - OK!"
ars.append(smsg)
except Exception as e:
smsg+=" - ERROR: " + utils.exception_to_string(e)
ars.append(smsg)
raise e
def _dependency_post_fix(self,snm,sver):
spth=self.get_path_tmp() + os.sep + snm;
if snm=="lib_z":
if utils.is_mac():
#CORREGGE zutil.h
apppth=spth + os.sep + "zutil.h"
f = codecs.open(apppth, encoding='utf-8')
appdata = f.read()
f.close()
appdata=appdata.replace('# define local static','//# define local static')
os.remove(apppth)
f = codecs.open(apppth, encoding='utf-8', mode='w+')
f.write(appdata)
f.close()
def _dependency(self,snm,sver,ars):
spth=self.get_path_tmp() + os.sep + snm;
smsg = snm + " " + sver
utils.info("BEGIN " + snm)
try:
conf = utils.read_json_file(spth + os.sep + snm + ".json")
bupd=True;
if conf is not None:
if "version" in conf:
if conf["version"]==sver:
bupd=False
else:
utils.info("incorrect version.")
else:
utils.info("version not found.")
else:
utils.info("version not found.")
if bupd:
sfx = detectinfo.get_native_suffix()
if sfx is None or "generic" in sfx:
utils.info("os not detected.")
raise Exception("You have to compile it manually.")
if self._b32bit:
sfx=sfx.replace("64","32")
utils.init_path(spth)
utils.info("download headers and library ...")
nurl = utils.get_node_url()
if snm!="lib_gcc" and snm!="lib_stdcpp":
appnm="headers_" + snm + ".zip"
utils.download_file(nurl + "getAgentFile.dw?name=" + appnm , spth + os.sep + appnm)
utils.unzip_file(spth + os.sep + appnm, spth + os.sep)
utils.remove_file(spth + os.sep + appnm)
appnm=snm + "_" + sfx + ".zip"
utils.download_file(nurl + "getAgentFile.dw?name=" + appnm , spth + os.sep + appnm)
utils.unzip_file(spth + os.sep + appnm, spth + os.sep, "native/")
utils.remove_file(spth + os.sep + appnm)
#FIX Version
conf = utils.read_json_file(spth + os.sep + snm + ".json")
if conf is not None:
if "version" not in conf:
conf["version"]=sver
utils.write_json_file(conf, spth + os.sep + snm + ".json")
#COPY LIB TO NATIVE
for f in os.listdir(spth):
if f.endswith('.dll') or f.endswith('.so') or f.endswith('.dylib'):
shutil.copy2(spth + os.sep + f, self.get_path_native() + os.sep + f)
#POST FIX
self._dependency_post_fix(snm,sver)
smsg+=" - OK!"
ars.append(smsg)
utils.info("END " + snm)
except Exception as e:
smsg+=" - ERROR: " + utils.exception_to_string(e)
ars.append(smsg)
raise e
if __name__ == "__main__":
m = CompileAll()
#m.set_32bit()
m.run()