Improve updates build script.

This commit is contained in:
John Preston 2023-08-18 23:03:05 +02:00
parent a2fe91af03
commit c765c4198f
2 changed files with 42 additions and 19 deletions

View File

@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_key.h"
#include "data/data_drafts.h"
#include "data/data_forum.h"
#include "data/data_forum_topic.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_changes.h"
@ -555,6 +557,7 @@ QString InterpretSendPath(
f.close();
const auto lines = content.split('\n');
auto toId = PeerId(0);
auto topicRootId = MsgId(0);
auto filePath = QString();
auto caption = QString();
for (const auto &line : lines) {
@ -570,6 +573,11 @@ QString InterpretSendPath(
line,
u"channel: "_q.size()).toULongLong();
toId = peerFromChannel(channelId);
} else if (line.startsWith(u"topic: "_q)) {
const auto topicId = base::StringViewMid(
line,
u"topic: "_q.size()).toULongLong();
topicRootId = MsgId(topicId);
} else if (line.startsWith(u"file: "_q)) {
const auto path = line.mid(u"file: "_q.size());
if (!QFile(path).exists()) {
@ -585,21 +593,33 @@ QString InterpretSendPath(
}
}
const auto history = window->session().data().historyLoaded(toId);
const auto sendTo = [=](not_null<Data::Thread*> thread) {
window->showThread(thread);
const auto premium = thread->session().user()->isPremium();
thread->session().api().sendFiles(
Storage::PrepareMediaList(
QStringList(filePath),
st::sendMediaPreviewSize,
premium),
SendMediaType::File,
{ caption },
nullptr,
Api::SendAction(thread));
};
if (!history) {
return "App Error: Could not find channel with id: "
+ QString::number(peerToChannel(toId).bare);
} else if (const auto forum = history->asForum()) {
forum->requestTopic(topicRootId, [=] {
if (const auto forum = history->asForum()) {
if (const auto topic = forum->topicFor(topicRootId)) {
sendTo(topic);
}
}
});
} else if (!topicRootId) {
sendTo(history);
}
window->showPeerHistory(history);
const auto premium = window->session().user()->isPremium();
history->session().api().sendFiles(
Storage::PrepareMediaList(
QStringList(filePath),
st::sendMediaPreviewSize,
premium),
SendMediaType::File,
{ caption },
nullptr,
Api::SendAction(history));
return QString();
}

View File

@ -11,6 +11,7 @@ nextDate = False
nextUuid = False
building = True
composing = False
conf = 'Release'
for arg in sys.argv:
if nextLast:
lastCommit = arg
@ -32,6 +33,8 @@ for arg in sys.argv:
nextDate = True
elif arg == 'request_uuid':
nextUuid = True
elif arg == 'debug':
conf = 'Debug'
def finish(code, error = ''):
if error != '':
@ -53,9 +56,9 @@ outputFolder = 'updates/' + today
archive = 'tdesktop_macOS_' + today + '.zip'
if building:
print('Building Release version for OS X 10.12+..')
print('Building ' + conf + ' version for OS X 10.12+..')
if os.path.exists('../out/Release/' + outputFolder):
if os.path.exists('../out/' + conf + '/' + outputFolder):
finish(1, 'Todays updates version exists.')
if uuid == '':
@ -65,11 +68,11 @@ if building:
os.chdir('../out')
if uuid == '':
result = subprocess.call('cmake --build . --config Release --target Telegram', shell=True)
result = subprocess.call('cmake --build . --config ' + conf + ' --target Telegram', shell=True)
if result != 0:
finish(1, 'While building Telegram.')
os.chdir('Release')
os.chdir(conf);
if uuid == '':
if not os.path.exists('Telegram.app'):
finish(1, 'Telegram.app not found.')
@ -193,7 +196,7 @@ if building:
print('NB! Notarization log not found.')
finish(0)
commandPath = scriptPath + '/../../out/Release/' + outputFolder + '/command.txt'
commandPath = scriptPath + '/../../out/' + conf + '/' + outputFolder + '/command.txt'
if composing:
templatePath = scriptPath + '/../../../DesktopPrivate/updates_template.txt'
@ -235,7 +238,7 @@ if composing:
for line in template:
if line.startswith('//'):
continue
line = line.replace('{path}', scriptPath + '/../../out/Release/' + outputFolder + '/' + archive)
line = line.replace('{path}', scriptPath + '/../../out/' + conf + '/' + outputFolder + '/' + archive)
line = line.replace('{caption}', 'TDesktop at ' + today.replace('_', '.') + ':\n\n' + changelog)
f.write(line)
print('\n\nEdit:\n')
@ -262,9 +265,9 @@ if len(caption) > 1024:
print('vi ' + commandPath)
finish(1, 'Too large.')
if not os.path.exists('../out/Release/' + outputFolder + '/' + archive):
if not os.path.exists('../out/' + conf + '/' + outputFolder + '/' + archive):
finish(1, 'Not built yet.')
subprocess.call(scriptPath + '/../../out/Release/Telegram.app/Contents/MacOS/Telegram -sendpath interpret://' + scriptPath + '/../../out/Release/' + outputFolder + '/command.txt', shell=True)
subprocess.call(scriptPath + '/../../out/' + conf + '/Telegram.app/Contents/MacOS/Telegram -sendpath interpret://' + scriptPath + '/../../out/' + conf + '/' + outputFolder + '/command.txt', shell=True)
finish(0)