forked from kotatogram/kotatogram-desktop
-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.py
59 lines (50 loc) · 1.97 KB
/
configure.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
'''
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
'''
import sys, os, re
sys.dont_write_bytecode = True
scriptPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(scriptPath + '/../cmake')
import run_cmake
executePath = os.getcwd()
def finish(code):
global executePath
os.chdir(executePath)
sys.exit(code)
def error(message):
print('[ERROR] ' + message)
finish(1)
if sys.platform == 'win32' and not 'COMSPEC' in os.environ:
error('COMSPEC environment variable is not set.')
executePath = os.getcwd()
scriptPath = os.path.dirname(os.path.realpath(__file__))
scriptName = os.path.basename(scriptPath)
arguments = sys.argv[1:]
officialTarget = ''
officialTargetFile = scriptPath + '/build/target'
if os.path.isfile(officialTargetFile):
with open(officialTargetFile, 'r') as f:
for line in f:
officialTarget = line.strip()
if officialTarget != '':
officialApiIdFile = scriptPath + '/../../DesktopPrivate/custom_api_id.h'
if not os.path.isfile(officialApiIdFile):
print("[ERROR] DesktopPrivate/custom_api_id.h not found.")
finish(1)
with open(officialApiIdFile, 'r') as f:
for line in f:
apiIdMatch = re.search(r'ApiId\s+=\s+(\d+)', line)
apiHashMatch = re.search(r'ApiHash\s+=\s+"([a-fA-F\d]+)"', line)
if apiIdMatch:
arguments.append('-DTDESKTOP_API_ID=' + apiIdMatch.group(1))
elif apiHashMatch:
arguments.append('-DTDESKTOP_API_HASH=' + apiHashMatch.group(1))
finish(run_cmake.run(scriptName, arguments))
elif 'linux' in sys.platform:
debugCode = run_cmake.run(scriptName, arguments, "Debug")
finish(debugCode if debugCode else run_cmake.run(scriptName, arguments, "Release"))
else:
finish(run_cmake.run(scriptName, arguments))