From 6af255923a569733ef2cb8dd5f94fe999e865e01 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 25 Jan 2022 14:46:38 +0300 Subject: [PATCH] Use generate_target for timestamped changelog generator. --- Telegram/build/changelog2appdata.py | 4 ++-- Telegram/cmake/generate_appdata_changelog.cmake | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Telegram/build/changelog2appdata.py b/Telegram/build/changelog2appdata.py index 4ba34b677f..37beb5aee5 100755 --- a/Telegram/build/changelog2appdata.py +++ b/Telegram/build/changelog2appdata.py @@ -9,8 +9,8 @@ def parse_changelog(changelog_path): version_re = re.compile(r'([\d.-]+)\s+(\w+)?\s*\((\d{2}.\d{2}\.\d{2})\)') entry_re = re.compile(r'-\s(.*)') - with open(changelog_path, "r") as f: - changelog_lines = f.read().splitlines() + with open(changelog_path, "rb") as f: + changelog_lines = f.read().decode('utf-8').splitlines() releases = [] for l in changelog_lines: diff --git a/Telegram/cmake/generate_appdata_changelog.cmake b/Telegram/cmake/generate_appdata_changelog.cmake index 6cbdd64615..90be486038 100644 --- a/Telegram/cmake/generate_appdata_changelog.cmake +++ b/Telegram/cmake/generate_appdata_changelog.cmake @@ -7,18 +7,28 @@ function(generate_appdata_changelog target_name changelog_path appdata_path) find_package(Python3 REQUIRED) - add_custom_target(${target_name}_appdata_changelog + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_timestamp ${gen_dst}/${target_name}_changelog.timestamp) + set(gen_files ${appdata_path}) + + add_custom_command( + OUTPUT + ${gen_timestamp} + BYPRODUCTS + ${gen_files} + COMMAND ${Python3_EXECUTABLE} ${submodules_loc}/build/changelog2appdata.py -c "${changelog_path}" -a "${appdata_path}" -n 10 + COMMAND + echo 1> ${gen_timestamp} COMMENT "Generating AppData changelog (${target_name})" DEPENDS ${submodules_loc}/build/changelog2appdata.py ${changelog_path} ${appdata_path} - VERBATIM ) - add_dependencies(${target_name} ${target_name}_appdata_changelog) + generate_target(${target_name} changelog ${gen_timestamp} "${gen_files}" ${gen_dst}) endfunction()