File: ManageSourceVersionControl.cmake

package info (click to toggle)
ibus-table-chinese 1.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 29,812 kB
  • sloc: sh: 106; makefile: 11
file content (137 lines) | stat: -rw-r--r-- 4,613 bytes parent folder | download | duplicates (3)
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
# - Module for manipulate source version control systems.
# This module provides an universal interface for supported
# source version control systems, namely:
# Git, Mercurial and SVN.
#
# Following targets are defined for each source version control (in Git terminology):
#   - tag: Tag the working tree with PRJ_VER and CHANGE_SUMMARY.
#     This target also does:
#     1. Ensure there is nothing uncommitted.
#     2. Push the commits and tags to server
#   - tag_pre: Targets that 'tag' depends on.
#     So you can push some check before the tag.
#   - after_release_commit:
#     This target does some post release chores, such as
#     updating ChangeLog.prev and RPM-ChangeLog.prev, then push them to server.
#
# Following variables are defined for each source version control:
#   - MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE:
#     The file that would be touched after target tag is completed.
#
#

IF(NOT DEFINED _MANAGE_SOURCE_VERSION_CONTROL_CMAKE_)
    SET(_MANAGE_SOURCE_VERSION_CONTROL_CMAKE_ "DEFINED")
    SET(_after_release_message "After released ${PRJ_VER}")
    INCLUDE(ManageTarget)

    MACRO(MANAGE_SOURCE_VERSION_CONTROL_COMMON)
	ADD_CUSTOM_TARGET(tag_pre
	    COMMENT "Pre-tagging check"
	    )


	ADD_CUSTOM_TARGET(after_release_commit_pre
	    COMMENT "Before 'after_release_commit'"
	    )

	IF(TARGET changelog_prev_update)
	    ADD_DEPENDENCIES(after_release_commit_pre changelog_prev_update)
	ENDIF(TARGET changelog_prev_update)

	IF(TARGET rpm_changelog_prev_update)
	    ADD_DEPENDENCIES(after_release_commit_pre rpm_changelog_prev_update)
	ENDIF(TARGET rpm_changelog_prev_update)
    ENDMACRO(MANAGE_SOURCE_VERSION_CONTROL_COMMON)

    MACRO(MANAGE_SOURCE_VERSION_CONTROL_GIT)
	SET(MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE
	    ${CMAKE_SOURCE_DIR}/.git/refs/tags/${PRJ_VER}
	    CACHE PATH "Source Version Control Tag File" FORCE)

	ADD_CUSTOM_TARGET(after_release_commit
	    COMMAND make after_release_commit_pre
	    COMMAND git commit -a -m "${_after_release_message}"
	    COMMAND git push
	    COMMENT "After released ${PRJ_VER}"
	    VERBATIM
	    )

	# Can't use ADD_CUSTOM_TARGET here, as the COMMIT_SUMMARY may have semi-colon ':'
	ADD_CUSTOM_TARGET(tag
	    DEPENDS "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    )

	ADD_CUSTOM_TARGET(commit_clean
	    COMMAND git diff --exit-code
	    COMMENT "Is git commit clean?"
	    VERBATIM
	    )

	ADD_CUSTOM_COMMAND(OUTPUT ${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}
	    COMMAND make commit_clean
	    COMMAND make tag_pre
	    COMMAND git tag -a -m "${CHANGE_SUMMARY}" "${PRJ_VER}" HEAD
	    COMMENT "Tagging the source as ver ${PRJ_VER}"
	    VERBATIM
	    )
	MANAGE_SOURCE_VERSION_CONTROL_COMMON()
    ENDMACRO(MANAGE_SOURCE_VERSION_CONTROL_GIT)

    MACRO(MANAGE_SOURCE_VERSION_CONTROL_HG)
	SET(MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE
	    ${CMAKE_FEDORA_TEMP_DIR}/${PRJ_VER}
	    CACHE PATH "Source Version Control Tag File" FORCE)

	ADD_CUSTOM_TARGET(after_release_commit
	    COMMAND make after_release_commit_pre
    	    COMMAND hg commit -m "${_after_release_message}"
	    COMMAND hg push
	    COMMENT "After released ${PRJ_VER}"
	    VERBATIM
	    )

	ADD_CUSTOM_TARGET(tag
	    DEPENDS "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    )

	ADD_CUSTOM_COMMAND(OUTPUT "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    COMMAND make tag_pre
	    COMMAND hg tag -m "${CHANGE_SUMMARY}" "${PRJ_VER}"
	    COMMAND ${CMAKE_COMMAND} -E touch "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    COMMENT "Tagging the source as ver ${PRJ_VER}"
	    VERBATIM
	    )

	MANAGE_SOURCE_VERSION_CONTROL_COMMON()
    ENDMACRO(MANAGE_SOURCE_VERSION_CONTROL_HG)

    MACRO(MANAGE_SOURCE_VERSION_CONTROL_SVN)
	SET(MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE
	    ${CMAKE_FEDORA_TEMP_DIR}/${PRJ_VER}
	    CACHE PATH "Source Version Control Tag File" FORCE)

	ADD_CUSTOM_TARGET(after_release_commit
	    COMMAND make after_release_commit_pre
    	    COMMAND svn commit -m "${_after_release_message}"
	    COMMENT "After released ${PRJ_VER}"
	    VERBATIM
	    )

	ADD_CUSTOM_TARGET(tag
	    DEPENDS "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    )

	ADD_CUSTOM_TARGET(OUTPUT "${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}"
	    COMMAND make tag_pre
	    COMMAND svn copy "${SOURCE_BASE_URL}/trunk" "${SOURCE_BASE_URL}/tags/${PRJ_VER}" -m "${CHANGE_SUMMARY}"
	    COMMAND cmake -E touch ${MANAGE_SOURCE_VERSION_CONTROL_TAG_FILE}
	    COMMENT "Tagging the source as ver ${PRJ_VER}"
	    VERBATIM
	    )

	MANAGE_SOURCE_VERSION_CONTROL_COMMON()
    ENDMACRO(MANAGE_SOURCE_VERSION_CONTROL_SVN)

ENDIF(NOT DEFINED _MANAGE_SOURCE_VERSION_CONTROL_CMAKE_)