diff options
Diffstat (limited to 'CMake/Modules')
| -rw-r--r-- | CMake/Modules/read_release_state.cmake | 32 | ||||
| -rw-r--r-- | CMake/Modules/read_release_tarballs.cmake | 37 | ||||
| -rw-r--r-- | CMake/Modules/set_build_type.cmake | 77 |
3 files changed, 108 insertions, 38 deletions
diff --git a/CMake/Modules/read_release_state.cmake b/CMake/Modules/read_release_state.cmake index 5084a0a8..0f258e2c 100644 --- a/CMake/Modules/read_release_state.cmake +++ b/CMake/Modules/read_release_state.cmake @@ -1,4 +1,4 @@ -function (wsjt_read_release_state state_file version_out channel_out rc_out revision_out) +function (wsjt_read_release_state state_file version_out channel_out prerelease_out revision_out) if (NOT EXISTS "${state_file}") message (FATAL_ERROR "Release state file not found: ${state_file}") endif () @@ -10,7 +10,7 @@ function (wsjt_read_release_state state_file version_out channel_out rc_out revi message (FATAL_ERROR "${state_file} must contain four or five metadata lines") endif () - set (_wsjt_release_state_keys version channel rc revision) + set (_wsjt_release_state_keys version channel prerelease revision) set (_wsjt_release_state_allowed_keys ${_wsjt_release_state_keys} windows_signing) foreach (_wsjt_release_state_line IN LISTS _wsjt_release_state_lines) if (NOT _wsjt_release_state_line MATCHES "^([a-z_]+)=(.*)$") @@ -42,15 +42,15 @@ function (wsjt_read_release_state state_file version_out channel_out rc_out revi if (NOT _wsjt_release_state_version MATCHES "^[0-9]+[.][0-9]+[.][0-9]+$") message (FATAL_ERROR "Release version must have the form X.Y.Z") endif () - if (NOT _wsjt_release_state_channel MATCHES "^(DEVEL|RC|GA)$") - message (FATAL_ERROR "Release channel must be DEVEL, RC, or GA") + if (NOT _wsjt_release_state_channel MATCHES "^(DEVEL|BETA|RC|GA)$") + message (FATAL_ERROR "Release channel must be DEVEL, BETA, RC, or GA") endif () - if (_wsjt_release_state_channel STREQUAL "RC") - if (NOT _wsjt_release_state_rc MATCHES "^[1-9][0-9]*$") - message (FATAL_ERROR "RC release state requires a positive rc number") + if (_wsjt_release_state_channel MATCHES "^(BETA|RC)$") + if (NOT _wsjt_release_state_prerelease MATCHES "^[1-9][0-9]*$") + message (FATAL_ERROR "BETA and RC release states require a positive prerelease number") endif () - elseif (NOT _wsjt_release_state_rc STREQUAL "") - message (FATAL_ERROR "The rc value must be empty for DEVEL and GA release states") + elseif (NOT _wsjt_release_state_prerelease STREQUAL "") + message (FATAL_ERROR "The prerelease value must be empty for DEVEL and GA release states") endif () if (NOT _wsjt_release_state_revision STREQUAL "$Format:%H$") @@ -64,7 +64,7 @@ function (wsjt_read_release_state state_file version_out channel_out rc_out revi set (${version_out} "${_wsjt_release_state_version}" PARENT_SCOPE) set (${channel_out} "${_wsjt_release_state_channel}" PARENT_SCOPE) - set (${rc_out} "${_wsjt_release_state_rc}" PARENT_SCOPE) + set (${prerelease_out} "${_wsjt_release_state_prerelease}" PARENT_SCOPE) if (_wsjt_release_state_revision STREQUAL "$Format:%H$") set (${revision_out} "" PARENT_SCOPE) else () @@ -83,3 +83,15 @@ function (wsjt_set_source_default_cache variable source_default description) endif () set (${_previous_default} "${source_default}" CACHE INTERNAL "Previous source default for ${variable}" FORCE) endfunction () + +# An empty WSJT_RELEASE_CHANNEL is no override; the number then follows release-state.txt too. +function (wsjt_set_release_channel_cache source_channel source_prerelease) + if (DEFINED WSJT_RELEASE_CHANNEL AND "${WSJT_RELEASE_CHANNEL}" STREQUAL "") + unset (WSJT_RELEASE_CHANNEL CACHE) + unset (WSJT_PRERELEASE_NUMBER CACHE) + endif () + wsjt_set_source_default_cache (WSJT_RELEASE_CHANNEL "${source_channel}" + "Build release channel: DEVEL, BETA, RC, or GA.") + wsjt_set_source_default_cache (WSJT_PRERELEASE_NUMBER "${source_prerelease}" + "Prerelease number used when WSJT_RELEASE_CHANNEL is BETA or RC.") +endfunction () diff --git a/CMake/Modules/read_release_tarballs.cmake b/CMake/Modules/read_release_tarballs.cmake new file mode 100644 index 00000000..e847e33b --- /dev/null +++ b/CMake/Modules/read_release_tarballs.cmake @@ -0,0 +1,37 @@ +# Reads CMake/release-tarballs.txt by the rules .github/scripts/release-policy.py +# and package-cli-tools.sh apply: fields split on blanks, a line whose first +# field starts with # is a comment, and each tarball is named once and names +# at least one program. +function (wsjt_read_release_tarballs tarball_file programs_out) + if (NOT EXISTS "${tarball_file}") + message (FATAL_ERROR "Release tarball list not found: ${tarball_file}") + endif () + + file (STRINGS "${tarball_file}" _wsjt_tarball_lines ENCODING UTF-8) + set (_wsjt_tarball_names) + set (_wsjt_tarball_programs) + foreach (_wsjt_tarball_line IN LISTS _wsjt_tarball_lines) + string (REGEX MATCHALL "[^ \t\r]+" _wsjt_tarball_fields "${_wsjt_tarball_line}") + list (LENGTH _wsjt_tarball_fields _wsjt_tarball_field_count) + if (_wsjt_tarball_field_count EQUAL 0) + continue () + endif () + list (GET _wsjt_tarball_fields 0 _wsjt_tarball_name) + if (_wsjt_tarball_name MATCHES "^#") + continue () + endif () + if (_wsjt_tarball_field_count LESS 2) + message (FATAL_ERROR "release tarball ${_wsjt_tarball_name} names no programs in ${tarball_file}") + endif () + if (_wsjt_tarball_name IN_LIST _wsjt_tarball_names) + message (FATAL_ERROR "release tarball ${_wsjt_tarball_name} is named twice in ${tarball_file}") + endif () + list (APPEND _wsjt_tarball_names "${_wsjt_tarball_name}") + list (REMOVE_AT _wsjt_tarball_fields 0) + list (APPEND _wsjt_tarball_programs ${_wsjt_tarball_fields}) + endforeach () + if (NOT _wsjt_tarball_names) + message (FATAL_ERROR "no release tarballs named in ${tarball_file}") + endif () + set (${programs_out} "${_wsjt_tarball_programs}" PARENT_SCOPE) +endfunction () diff --git a/CMake/Modules/set_build_type.cmake b/CMake/Modules/set_build_type.cmake index 69dd90b4..edb8dab2 100644 --- a/CMake/Modules/set_build_type.cmake +++ b/CMake/Modules/set_build_type.cmake @@ -3,26 +3,19 @@ include (CMakeParseArguments) # set_build_type() function # # Configure the output artefacts and their names for development, -# Release Candidate (RC), or General Availability (GA) build type. +# Beta (BETA), Release Candidate (RC), or General Availability (GA) build type. # # Usage: -# set_build_type () -# set_build_type (RC n) +# set_build_type () channel and number from WSJT_RELEASE_CHANNEL and WSJT_PRERELEASE_NUMBER +# set_build_type (RC n) RC n, or DEVEL when n is 0 # set_build_type (GA) # -# With no arguments or with RC 0 a development is specified. The -# variable BUILD_TYPE_REVISION is set to "-devel". -# -# With RC n with n>0 specifies a Release Candidate build. The -# variable BUIlD_TYPE_REVISION is set to "-rcn". -# -# With GA a General Availability release is specified and the -# variable BUIlD_TYPE_REVISION is unset. +# BUILD_TYPE_REVISION is "-devel", "-betaN", "-rcN", or empty for GA. # macro (set_build_type) - set (WSJT_RELEASE_CHANNEL "DEVEL" CACHE STRING "Build release channel: DEVEL, RC, or GA.") - set_property (CACHE WSJT_RELEASE_CHANNEL PROPERTY STRINGS DEVEL RC GA) - set (WSJT_RC_NUMBER "" CACHE STRING "Release candidate number used when WSJT_RELEASE_CHANNEL is RC.") + set (WSJT_RELEASE_CHANNEL "DEVEL" CACHE STRING "Build release channel: DEVEL, BETA, RC, or GA.") + set_property (CACHE WSJT_RELEASE_CHANNEL PROPERTY STRINGS DEVEL BETA RC GA) + set (WSJT_PRERELEASE_NUMBER "" CACHE STRING "Prerelease number used when WSJT_RELEASE_CHANNEL is BETA or RC.") set (options GA) set (oneValueArgs RC) @@ -45,31 +38,59 @@ macro (set_build_type) set (_WSJT_RELEASE_CHANNEL "DEVEL") else () set (_WSJT_RELEASE_CHANNEL "RC") - set (WSJT_RC_NUMBER "${BUILD_TYPE_RC}") + set (WSJT_PRERELEASE_NUMBER "${BUILD_TYPE_RC}") endif () else () set (_WSJT_RELEASE_CHANNEL "DEVEL") endif () endif () - if (NOT _WSJT_RELEASE_CHANNEL MATCHES "^(DEVEL|RC|GA)$") - message (FATAL_ERROR "WSJT_RELEASE_CHANNEL must be DEVEL, RC, or GA; got \"${WSJT_RELEASE_CHANNEL}\".") + if (NOT _WSJT_RELEASE_CHANNEL MATCHES "^(DEVEL|BETA|RC|GA)$") + message (FATAL_ERROR "WSJT_RELEASE_CHANNEL must be DEVEL, BETA, RC, or GA; got \"${WSJT_RELEASE_CHANNEL}\".") endif () set (BUILD_TYPE_REVISION "") - if (_WSJT_RELEASE_CHANNEL STREQUAL "DEVEL") - if (NOT WSJT_RC_NUMBER STREQUAL "") - message (FATAL_ERROR "WSJT_RC_NUMBER must be empty when WSJT_RELEASE_CHANNEL is DEVEL.") + set (BUILD_TYPE_PACKAGE_REVISION "") + if (_WSJT_RELEASE_CHANNEL MATCHES "^(BETA|RC)$") + if (NOT WSJT_PRERELEASE_NUMBER MATCHES "^[1-9][0-9]*$") + message (FATAL_ERROR "WSJT_PRERELEASE_NUMBER must be a positive integer when WSJT_RELEASE_CHANNEL is ${_WSJT_RELEASE_CHANNEL}.") endif () + string (TOLOWER "${_WSJT_RELEASE_CHANNEL}${WSJT_PRERELEASE_NUMBER}" _WSJT_PRERELEASE) + set (BUILD_TYPE_REVISION "-${_WSJT_PRERELEASE}") + # Debian and RPM order a "~" suffix below the release it precedes. + set (BUILD_TYPE_PACKAGE_REVISION "~${_WSJT_PRERELEASE}") + elseif (NOT WSJT_PRERELEASE_NUMBER STREQUAL "") + message (FATAL_ERROR "WSJT_PRERELEASE_NUMBER must be empty when WSJT_RELEASE_CHANNEL is ${_WSJT_RELEASE_CHANNEL}.") + elseif (_WSJT_RELEASE_CHANNEL STREQUAL "DEVEL") set (BUILD_TYPE_REVISION "-devel") - elseif (_WSJT_RELEASE_CHANNEL STREQUAL "RC") - if (NOT WSJT_RC_NUMBER MATCHES "^[1-9][0-9]*$") - message (FATAL_ERROR "WSJT_RC_NUMBER must be a positive integer when WSJT_RELEASE_CHANNEL is RC.") - endif () - set (BUILD_TYPE_REVISION "-rc${WSJT_RC_NUMBER}") - elseif (NOT WSJT_RC_NUMBER STREQUAL "") - message (FATAL_ERROR "WSJT_RC_NUMBER must be empty when WSJT_RELEASE_CHANNEL is GA.") + set (BUILD_TYPE_PACKAGE_REVISION "-devel") endif () - set (WSJT_RELEASE_CHANNEL "${_WSJT_RELEASE_CHANNEL}" CACHE STRING "Build release channel: DEVEL, RC, or GA." FORCE) + set (WSJT_RELEASE_CHANNEL "${_WSJT_RELEASE_CHANNEL}" CACHE STRING "Build release channel: DEVEL, BETA, RC, or GA." FORCE) message (STATUS "Building ${PROJECT_NAME} v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${BUILD_TYPE_REVISION}") endmacro () + +function (wsjt_prerelease_expiry channel source_dir expiry_out) + if (channel STREQUAL "GA") + set (${expiry_out} 0 PARENT_SCOPE) + return () + endif () + set (build_epoch "$ENV{SOURCE_DATE_EPOCH}") + if (NOT build_epoch MATCHES "^[0-9]*$") + message (FATAL_ERROR "SOURCE_DATE_EPOCH must be a Unix time; got \"${build_epoch}\".") + endif () + if (build_epoch STREQUAL "" AND GIT_EXECUTABLE AND EXISTS "${source_dir}/.git") + execute_process ( + COMMAND "${GIT_EXECUTABLE}" -c "safe.directory=${source_dir}" -C "${source_dir}" log -1 --format=%ct + OUTPUT_VARIABLE build_epoch + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + endif () + if (NOT build_epoch MATCHES "^[0-9]+$" AND ARGC GREATER 3) + set (build_epoch "${ARGV3}") + elseif (NOT build_epoch MATCHES "^[0-9]+$") + string (TIMESTAMP build_epoch "%s" UTC) + endif () + # The last second (UTC) of the 90th day after the build date. + math (EXPR expiry "(${build_epoch} / 86400 + 91) * 86400 - 1") + set (${expiry_out} "${expiry}" PARENT_SCOPE) +endfunction () |
