mirror of
https://github.com/ares-emulator/ares.git
synced 2026-10-11 22:39:55 +00:00
build: Do not require tags, add unofficial versioning scheme
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
# When archiving, export a version file containing tag/commit information
|
||||
cmake/common/.archive-version export-subst
|
||||
cmake/common/.archive-version.json export-subst
|
||||
|
||||
@@ -7,6 +7,11 @@ on:
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
official:
|
||||
description: Use official version strings
|
||||
required: true
|
||||
default: true
|
||||
type: boolean
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
@@ -77,6 +82,7 @@ jobs:
|
||||
if: runner.os != 'macOS' && runner.os != 'Linux'
|
||||
run: .github/scripts/build_windows.sh
|
||||
env:
|
||||
ARES_BUILD_OFFICIAL: ${{ inputs.official }}
|
||||
ARES_PLATFORM_NAME: ${{ matrix.platform.name }}
|
||||
CROSS_COMPILE: ${{ matrix.platform.native-cmake-preset != '' }}
|
||||
NATIVE_PRESET: ${{ matrix.platform.native-cmake-preset }}
|
||||
@@ -95,6 +101,7 @@ jobs:
|
||||
if: runner.os == 'macOS'
|
||||
run: .github/scripts/build_macos.sh
|
||||
env:
|
||||
ARES_BUILD_OFFICIAL: ${{ inputs.official }}
|
||||
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
|
||||
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
|
||||
MACOS_NOTARIZATION_TEAMID: ${{ secrets.MACOS_NOTARIZATION_TEAMID }}
|
||||
|
||||
@@ -15,6 +15,8 @@ jobs:
|
||||
uses: ./.github/workflows/build.yml
|
||||
permissions:
|
||||
contents: read
|
||||
with:
|
||||
official: false
|
||||
build-aux:
|
||||
name: Build ares (auxiliary)
|
||||
uses: ./.github/workflows/build-aux.yml
|
||||
|
||||
@@ -13,6 +13,7 @@ jobs:
|
||||
secrets: inherit
|
||||
with:
|
||||
codesign: true
|
||||
official: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
|
||||
build-aux:
|
||||
name: Build ares (auxiliary)
|
||||
uses: ./.github/workflows/build-aux.yml
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@
|
||||
"cacheVariables": {
|
||||
"ARES_PROFILE_ACCURACY": false,
|
||||
"ARES_BUILD_LOCAL": true,
|
||||
"ENABLE_CCACHE": true
|
||||
"ENABLE_CCACHE": true,
|
||||
"ARES_BUILD_OFFICIAL": {"type": "BOOL", "value": "$penv{ARES_BUILD_OFFICIAL}"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
$Format:%(describe:tags,exclude=nightly)$
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"describe": "$Format:%(describe:tags,exclude=nightly)$",
|
||||
"hash": "$Format:%h$",
|
||||
"ref-name": "$Format:%D$",
|
||||
"commit-date": "$Format:%cs$"
|
||||
}
|
||||
@@ -33,8 +33,8 @@ function(message_configuration)
|
||||
" .. .:::. / __ `/ ___/ _ \\/ ___/\n"
|
||||
" .-:::::::: / /_/ / / / __(__ )\n"
|
||||
" .::::. \\__,_/_/ \\___/____/\n"
|
||||
"\n ares version: ${ARES_VERSION}\n"
|
||||
"==================================================================================\n\n"
|
||||
"\n ares version: ${ARES_VERSION} (${ARES_VERSION_CANONICAL})\n"
|
||||
"=================================================================================="
|
||||
)
|
||||
|
||||
get_property(ARES_FEATURES_ENABLED GLOBAL PROPERTY ARES_FEATURES_ENABLED)
|
||||
|
||||
@@ -1,55 +1,94 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
function(populate_ares_version_info)
|
||||
option(ARES_BUILD_OFFICIAL "Use official project versioning" OFF)
|
||||
|
||||
function(ares_populate_version_info)
|
||||
if(DEFINED ARES_VERSION_OVERRIDE)
|
||||
set(ARES_VERSION ${ARES_VERSION_OVERRIDE})
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
execute_process(
|
||||
COMMAND git describe --always --tags --exclude=nightly --dirty=-modified
|
||||
COMMAND git describe --always --tags --exclude=nightly --dirty=-modified --match "v[0-9]*"
|
||||
OUTPUT_VARIABLE ARES_VERSION
|
||||
ERROR_VARIABLE git_describe_err
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE ares_version_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(git_describe_err)
|
||||
message(FATAL_ERROR "Could not fetch ares version tag from git.\n" ${git_describe_err})
|
||||
if(ARES_VERSION MATCHES "^.*modified")
|
||||
set(modified YES)
|
||||
endif()
|
||||
else()
|
||||
file(READ cmake/common/.archive-version ares_tarball_version)
|
||||
string(STRIP "${ares_tarball_version}" ares_tarball_version)
|
||||
set(ARES_VERSION "${ares_tarball_version}")
|
||||
file(READ cmake/common/.archive-version.json archive_version_json)
|
||||
string(JSON archive_version_describe GET ${archive_version_json} describe)
|
||||
string(JSON ares_git_ref GET ${archive_version_json} ref-name)
|
||||
string(JSON ares_git_shorthash GET ${archive_version_json} hash)
|
||||
string(JSON ares_git_commit_date GET ${archive_version_json} commit-date)
|
||||
if(archive_version_describe)
|
||||
set(ARES_VERSION "${archive_version_describe}")
|
||||
else()
|
||||
set(ARES_VERSION "${ares_git_shorthash}")
|
||||
endif()
|
||||
string(STRIP "${ARES_VERSION}" ARES_VERSION)
|
||||
endif()
|
||||
|
||||
|
||||
string(REGEX REPLACE "^v([0-9]+(\\.[0-9]+)*)-.*" "\\1" ares_version_stripped "${ARES_VERSION}")
|
||||
string(REPLACE "." ";" ares_version_parts "${ares_version_stripped}")
|
||||
list(LENGTH ares_version_parts ares_version_parts_length)
|
||||
list(GET ares_version_parts 0 major)
|
||||
list(GET ares_version_parts 0 minor)
|
||||
if(ares_version_parts_length GREATER 1)
|
||||
list(GET ares_version_parts 1 minor)
|
||||
else()
|
||||
set(minor 0)
|
||||
endif()
|
||||
if(ares_version_parts_length GREATER 2)
|
||||
list(GET ares_version_parts 2 patch)
|
||||
list(GET ares_version_parts 1 patch)
|
||||
else()
|
||||
set(patch 0)
|
||||
endif()
|
||||
set(ARES_VERSION_CANONICAL "${major}.${minor}.${patch}")
|
||||
set(ARES_VERSION_CANONICAL "0.${minor}.${patch}")
|
||||
message(DEBUG "Canonical version set to ${ARES_VERSION_CANONICAL}")
|
||||
|
||||
set(
|
||||
ares_version_not_found_string
|
||||
"Could not derive a canonical version string from available version information ('${ARES_VERSION}')."
|
||||
)
|
||||
|
||||
if(NOT ARES_VERSION_CANONICAL MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
if(ARES_BUILD_OFFICIAL)
|
||||
message(FATAL_ERROR "${ares_version_not_found_string}")
|
||||
else()
|
||||
message(STATUS "${ares_version_not_found_string} - using fallback version 0.0.0")
|
||||
endif()
|
||||
set(ARES_VERSION_CANONICAL 0.0.0)
|
||||
endif()
|
||||
|
||||
if(NOT ARES_BUILD_OFFICIAL)
|
||||
# Disambiguate unofficial builds
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
OUTPUT_VARIABLE ares_git_shorthash
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git symbolic-ref -q --short HEAD
|
||||
OUTPUT_VARIABLE ares_git_ref
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git show -s --format=%cs
|
||||
OUTPUT_VARIABLE ares_git_commit_date
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
if(modified)
|
||||
set(ares_git_shorthash "${ares_git_shorthash}-modified")
|
||||
endif()
|
||||
if(NOT ares_git_ref)
|
||||
set(ARES_VERSION "${ares_git_shorthash} - ${ares_git_commit_date}")
|
||||
else()
|
||||
set(ARES_VERSION "${ares_git_ref} - (${ares_git_shorthash} - ${ares_git_commit_date})")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
return(PROPAGATE ARES_VERSION ARES_VERSION_CANONICAL)
|
||||
endfunction()
|
||||
|
||||
populate_ares_version_info()
|
||||
|
||||
if(NOT ARES_VERSION_CANONICAL MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Available ares version information ('${ARES_VERSION}') could not be converted to a valid CMake version string.\n"
|
||||
"Make sure the repository you have cloned or archived from contains ares version tags ('git fetch --tags').\n"
|
||||
"If tags are unavailable, you may specify a custom version with ARES_VERSION_OVERRIDE, using an ares-formatted "
|
||||
"version string, e.g. 'v123'.\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
ares_populate_version_info()
|
||||
|
||||
Reference in New Issue
Block a user