/usr/share/cmake/Modules/ManageChangeLogScript.cmake is in cmake-fedora 2.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | # - Manage ChangeLog
#
# Note that ChangeLog will be updated only when
#
# cmake -D cmd=update [Options] -P ManageChangeLogScript.cmake
#
# is run. This is triggered by:
# 1. Target changelog
# 2. Before source archive being built.
#
MACRO(MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE)
MESSAGE("Manage ChangeLog script: This script is not recommend for end users.
cmake -D cmd=make
-D changelog=<path/ChangeLog>
-D release=<path/RELEASE-NOTES.txt>
-D prj_info=<path/prj_info.cmake>
[-D \"<var>=<value>\"]
-P <CmakeModulePath>/ManageChangeLogScript.cmake
Always update ChangeLog.
cmake -D cmd=update
-D changelog=<path/ChangeLog>
-D release=<path/RELEASE-NOTES.txt>
-D prj_info=<path/prj_info.cmake>
-D cmakecache=<path/CMakeCache.txt>
[-D cmake_source_dir=<dir>]
[-D \"<var>=<value>\"]
-P <CmakeModulePath>/ManageChangeLogScript.cmake
This command updates ChangeLog only at one of following condition.
1) ChangeLog does not exist
2) RELEASE-NOTES.txt is newer than CMakeCache.txt
3) RELEASE-NOTES.txt is newer than ChangeLog
cmake -D cmd=extract_current
-D release=<path/RELEASE-NOTES.txt>
[-D \"<var>=<value>\"]
-P <CmakeModulePath>/ManageChangeLogScript.cmake
Extract current Changelog items from RELEASE-NOTES.txt
cmake -D cmd=extract_prev
-D ver=<ver>
-D changelog=<path/ChangeLog>
[-D \"<var>=<value>\"]
-P <CmakeModulePath>/ManageChangeLogScript.cmake
Extract prev Changelog items from ChangeLog.
"
)
ENDMACRO()
MACRO(EXTRACT_CURRENT_FROM_RELEASE strVar release)
IF("${release}" STREQUAL "")
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
M_MSG(${M_FATAL} "Requires \"-Drelease=RELEASE-NOTES.txt\"")
ENDIF()
IF(NOT EXISTS "${release}")
M_MSG(${M_FATAL} "File not found:${release}")
ENDIF()
RELEASE_NOTES_FILE_EXTRACT_CHANGELOG_CURRENT(${strVar} ${release})
ENDMACRO()
MACRO(EXTRACT_PREV_FROM_CHANGELOG strVar ver changeLogFile)
IF("${ver}" STREQUAL "")
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
M_MSG(${M_FATAL} "EXTRACT_PREV_FROM_CHANGELOG: Requires \"ver\"")
ENDIF()
IF("${changeLogFile}" STREQUAL "")
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
M_MSG(${M_FATAL} "Requires \"-Dchangelog=ChangeLog\"")
ENDIF()
IF(NOT EXISTS "${changeLogFile}")
M_MSG(${M_FATAL} "File not found:${changeLogFile}")
ENDIF()
SET(_this "")
SET(_prev "")
SET(_isThis 0)
SET(_isPrev 0)
EXECUTE_PROCESS(COMMAND cat "${changeLogFile}"
OUTPUT_VARIABLE _changeLogFileBuf
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING_SPLIT(_lines "\n" "${_changeLogFileBuf}" ALLOW_EMPTY)
## List should not ingore empty elements
CMAKE_POLICY(SET CMP0007 NEW)
LIST(LENGTH _lines _lineCount)
MATH(EXPR _lineCount ${_lineCount}-1)
FOREACH(_i RANGE ${_lineCount})
LIST(GET _lines ${_i} _line)
STRING(REGEX MATCH "^\\* [A-Za-z]+ [A-Za-z]+ [0-9]+ [0-9]+ .*<.+> - (.*)$" _match "${_line}")
IF("${_match}" STREQUAL "")
# Not a version line
IF(_isThis)
STRING_APPEND(_this "${_line}" "\n")
ELSEIF(_isPrev)
STRING_APPEND(_prev "${_line}" "\n")
ELSE(_isThis)
M_MSG(${M_ERROR} "ChangeLog: Cannot distinguish version for line :${_line}")
ENDIF(_isThis)
ELSE("${_match}" STREQUAL "")
# Is a version line
SET(_cV "${CMAKE_MATCH_1}")
IF("${_cV}" STREQUAL "${ver}")
SET(_isThis 1)
SET(_isPrev 0)
ELSE("${_cV}" STREQUAL "${ver}")
SET(_isThis 0)
SET(_isPrev 1)
STRING_APPEND(_prev "${_line}" "\n")
ENDIF("${_cV}" STREQUAL "${ver}")
ENDIF("${_match}" STREQUAL "")
ENDFOREACH(_i RANGE _lineCount)
SET(${strVar} "${_prev}")
ENDMACRO()
MACRO(CHANGELOG_MAKE prj_info release changelog)
PRJ_INFO_CMAKE_READ("${prj_info}")
EXTRACT_CURRENT_FROM_RELEASE(currentStr "${release}")
IF(EXISTS "${changelog}")
EXTRACT_PREV_FROM_CHANGELOG(prevStr "${PRJ_VER}" "${changelog}")
ENDIF()
FILE(WRITE "${changelog}" "* ${TODAY_CHANGELOG} ${MAINTAINER} - ${PRJ_VER}\n")
FILE(APPEND "${changelog}" "${currentStr}\n\n")
FILE(APPEND "${changelog}" "${prevStr}")
ENDMACRO()
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
#######################################
# Determine CMAKE_FEDORA_MODULE_DIR
#
## It is possible that current dir is in NO_PACK/FedPkg/<prj>
LIST(INSERT CMAKE_MODULE_PATH 0
${CMAKE_SOURCE_DIR}/Modules ${CMAKE_SOURCE_DIR}/cmake-fedora/Modules
${CMAKE_SOURCE_DIR}/../../../Modules
${CMAKE_SOURCE_DIR}/../../../cmake-fedora/Modules
${CMAKE_SOURCE_DIR}
)
IF(CMAKE_SCRIPT_MODE_FILE)
GET_FILENAME_COMPONENT(CMAKE_FEDORA_SCRIPT_DIR ${CMAKE_SCRIPT_MODE_FILE}
PATH
)
LIST(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_FEDORA_SCRIPT_DIR}")
ENDIF()
IF(cmake_fedora_module_dir)
LIST(INSERT CMAKE_MODULE_PATH 0 "${cmake_fedora_module_dir}")
ENDIF()
INCLUDE(ManageMessage RESULT_VARIABLE MANAGE_MODULE_PATH)
IF(NOT MANAGE_MODULE_PATH)
MESSAGE(FATAL_ERROR "ManageMessage.cmake cannot be found in ${CMAKE_MODULE_PATH}")
ENDIF()
GET_FILENAME_COMPONENT(CMAKE_FEDORA_MODULE_DIR
"${MANAGE_MODULE_PATH}" PATH)
INCLUDE(ManageEnvironmentCommon)
INCLUDE(DateTimeFormat)
INCLUDE(ManageVersion)
IF(NOT DEFINED cmd)
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
ELSE()
IF("${cmd}" STREQUAL "make")
CHANGELOG_MAKE(${prj_info} ${release} ${changelog})
ELSEIF("${cmd}" STREQUAL "update")
RELEASE_NOTES_READ_FILE(${release})
SET(updateRequired 0)
IF(cmake_source_dir STREQUAL "")
SET(cmake_source_dir ".")
ENDIF()
IF(EXISTS "${changelog}")
IF(${release} IS_NEWER_THAN ${changelog})
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} ${cmake_source_dir})
SET(updateRequired 1)
ELSEIF(NOT PRJ_VER EQUAL PRJ_VER_CACHED)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} ${cmake_source_dir})
SET(updateRequired 1)
ENDIF()
ELSE()
SET(updateRequired 1)
ENDIF()
IF(updateRequired)
CHANGELOG_MAKE(${prj_info} ${release} ${changelog})
ENDIF()
ELSEIF("${cmd}" STREQUAL "extract_current")
EXTRACT_CURRENT_FROM_RELEASE(outVar ${release})
M_OUT("${outVar}")
ELSEIF("${cmd}" STREQUAL "extract_prev")
IF("${ver}" STREQUAL "")
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
M_MSG(${M_FATAL} "Requires \"-Dver=ver\"")
ENDIF()
EXTRACT_PREV_FROM_CHANGELOG(outVar ${ver} ${changelog})
M_OUT("${outVar}")
ELSE()
MANAGE_CHANGELOG_SCRIPT_PRINT_USAGE()
M_MSG(${M_FATAL} "Invalid cmd ${cmd}")
ENDIF()
ENDIF()
|