2019-12-06 10:17:40 +00:00
|
|
|
'''
|
|
|
|
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)
|
|
|
|
|
2021-06-28 11:02:21 +00:00
|
|
|
if sys.platform == 'win32' and 'COMSPEC' not in os.environ:
|
2019-12-06 10:17:40 +00:00
|
|
|
error('COMSPEC environment variable is not set.')
|
|
|
|
|
|
|
|
executePath = os.getcwd()
|
|
|
|
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
2019-12-15 00:42:02 +00:00
|
|
|
scriptName = os.path.basename(scriptPath)
|
2019-12-06 10:17:40 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-11-06 17:22:02 +00:00
|
|
|
arch = ''
|
2021-06-28 11:02:21 +00:00
|
|
|
if officialTarget in ['win', 'uwp']:
|
2020-11-06 17:22:02 +00:00
|
|
|
arch = 'x86'
|
2021-06-28 11:02:21 +00:00
|
|
|
elif officialTarget in ['win64', 'uwp64']:
|
2020-11-06 17:22:02 +00:00
|
|
|
arch = 'x64'
|
|
|
|
|
2019-12-06 10:17:40 +00:00
|
|
|
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))
|
2020-11-06 17:22:02 +00:00
|
|
|
if arch != '':
|
|
|
|
arguments.append(arch)
|
2021-11-14 07:31:54 +00:00
|
|
|
finish(run_cmake.run(scriptName, arguments))
|