feat(updater): Improved Updater System w/ Automation & SCM Logic Changes

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2025-12-26 02:23:43 +00:00
parent 416bcde3dc
commit 1f831b1e88

View File

@@ -1,13 +1,11 @@
# SPDX-FileCopyrightText: 2019 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# Gets a UTC timestamp and sets the provided variable to it
function(get_timestamp _var)
string(TIMESTAMP timestamp UTC)
set(${_var} "${timestamp}" PARENT_SCOPE)
endfunction()
# generate git/build information
include(GetGitRevisionDescription)
if(NOT GIT_REF_SPEC)
get_git_head_revision(GIT_REF_SPEC GIT_REV)
@@ -20,30 +18,37 @@ if (NOT GIT_BRANCH)
endif()
get_timestamp(BUILD_DATE)
#
# Generate build information based on the CITRON_BUILD_TYPE variable.
#
if(CITRON_BUILD_TYPE STREQUAL "Stable")
# For Stable builds, use a clean version string and an empty build name for the title bar.
set(BUILD_FULLNAME "")
# These variables are set in the root CMakeLists.txt, but we provide a fallback.
if(DEFINED CITRON_VERSION_MAJOR)
set(BUILD_VERSION "${CITRON_VERSION_MAJOR}.${CITRON_VERSION_MINOR}.${CITRON_VERSION_PATCH}")
else()
set(BUILD_VERSION "0.11.0") # Fallback stable version
endif()
set(BUILD_ID ${DISPLAY_VERSION})
# Handle the Variant variable from the build script.
if (NOT CITRON_VARIANT)
set(CITRON_VARIANT "Generic")
endif()
# Clean up the Git Description (strip -dirty and tags for a clean hash)
string(REGEX REPLACE "-dirty$" "" GIT_HASH_CLEAN "${GIT_DESC}")
string(REGEX MATCH "[0-9a-fA-F]{7,40}" GIT_HASH_FINAL "${GIT_HASH_CLEAN}")
if (NOT GIT_HASH_FINAL)
set(GIT_HASH_FINAL "${GIT_HASH_CLEAN}")
endif()
# Always compute the version number string (e.g. 0.11.0)
if(DEFINED CITRON_VERSION_MAJOR)
set(CITRON_VERSION_STR "${CITRON_VERSION_MAJOR}.${CITRON_VERSION_MINOR}.${CITRON_VERSION_PATCH}")
else()
# For Nightly or local developer builds, use the existing logic to generate a name and use the git hash.
set(CITRON_VERSION_STR "0.11.0")
endif()
if(CITRON_BUILD_TYPE STREQUAL "Stable")
set(BUILD_TYPE_NAME "Stable")
set(BUILD_VERSION "${CITRON_VERSION_STR}")
set(BUILD_ID ${DISPLAY_VERSION})
else()
set(BUILD_TYPE_NAME "Nightly")
set(REPO_NAME "")
set(BUILD_VERSION "0")
set(BUILD_ID ${DISPLAY_VERSION})
if (BUILD_REPOSITORY)
# regex capture the string nightly or canary into CMAKE_MATCH_1
string(REGEX MATCH "citron-emu/citron-?(.*)" OUTVAR ${BUILD_REPOSITORY})
if ("${CMAKE_MATCH_COUNT}" GREATER 0)
# capitalize the first letter of each word in the repo name.
string(REPLACE "-" ";" REPO_NAME_LIST ${CMAKE_MATCH_1})
foreach(WORD ${REPO_NAME_LIST})
string(SUBSTRING ${WORD} 0 1 FIRST_LETTER)
@@ -56,24 +61,20 @@ else()
if (${CMAKE_MATCH_COUNT} GREATER 0)
set(BUILD_VERSION ${CMAKE_MATCH_1})
endif()
if (BUILD_VERSION)
# This leaves a trailing space on the last word, but we actually want that
# because of how it's styled in the title bar.
set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ")
else()
set(BUILD_FULLNAME "")
endif()
endif()
endif()
endif()
# Add a fallback for local builds
# If BUILD_VERSION is still "0", it means the CI-specific logic was not executed.
# In that case, we should use the git description which contains the commit hash.
if (BUILD_VERSION STREQUAL "0")
set(BUILD_FULLNAME "Nightly ") # Ensure local builds are also identified as Nightly
set(BUILD_VERSION ${GIT_DESC})
set(BUILD_VERSION ${GIT_HASH_FINAL})
endif()
endif()
# Final SCM Fullname: e.g. "Nightly | Linux x86_64 v3"
set(BUILD_FULLNAME "${BUILD_TYPE_NAME} | ${CITRON_VARIANT} ")
set(CITRON_VARIANT_BAKED ${CITRON_VARIANT})
set(CITRON_VERSION_BAKED ${CITRON_VERSION_STR})
set(CITRON_HASH_BAKED ${GIT_HASH_FINAL})
configure_file(scm_rev.cpp.in scm_rev.cpp @ONLY)