Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
5bac9e28
Commit
5bac9e28
authored
Jun 28, 2017
by
Sebastian Eichelbaum
Browse files
[FIX] now using Git hash for automatic version header generation.
parent
524a611b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
24 deletions
+25
-24
VERSION
VERSION
+8
-8
tools/cmake/OpenWalnutUtils.cmake
tools/cmake/OpenWalnutUtils.cmake
+17
-16
No files found.
VERSION
View file @
5bac9e28
...
...
@@ -3,9 +3,9 @@
# set properly or CMake will fail.
#
# SYNTAX: * The version string always is 1.2.3
# * With an optional postfix of "+
h
g1234".
# * With an optional postfix of "+g
it
1234".
# This is useful if building is done by scripts. If you want to automatically
# add the correct
H
G revision, use only +
h
gX without number.
# add the correct G
it
revision, use only +g
it
X without number.
# * You can add beta or release candidate flags by appending b123 or rc123 directly
# after the version number.
#
...
...
@@ -15,12 +15,12 @@
#
# Examples:
# VERSION=1.2.0
# VERSION=1.2.0+
h
gX -> replaces the X with the current revision number
# VERSION=1.2.0+
h
g1234 -> here, revision number was set by the build scripts for example.
# VERSION=1.2.0b1+
h
gX -> first beta version
# VERSION=1.2.0rc1+
h
gX -> first release candidate version
# VERSION=1.2.0sometext1+
h
gX -> even arbitrary texts are allowd. Be careful as many packaging
# VERSION=1.2.0+g
it
X -> replaces the X with the current revision number
# VERSION=1.2.0+g
it
1234 -> here, revision number was set by the build scripts for example.
# VERSION=1.2.0b1+g
it
X -> first beta version
# VERSION=1.2.0rc1+g
it
X -> first release candidate version
# VERSION=1.2.0sometext1+g
it
X -> even arbitrary texts are allowd. Be careful as many packaging
# systems refuse to accept these arbitrary version strings.
# The current version string:
VERSION=1.5.0dev+
h
gX
VERSION=1.5.0dev+g
it
X
tools/cmake/OpenWalnutUtils.cmake
View file @
5bac9e28
...
...
@@ -536,7 +536,7 @@ ENDFUNCTION( SETUP_DEV_INSTALL )
# _default a default string you specify if all version check methods fail
FUNCTION
(
GET_VERSION_STRING _version _api_version
)
# Undef the OW_VERSION variable
UNSET
(
OW_VERSION_
H
G
)
UNSET
(
OW_VERSION_G
IT
)
UNSET
(
OW_VERSION_FILE
)
# Grab version file.
...
...
@@ -545,7 +545,7 @@ FUNCTION( GET_VERSION_STRING _version _api_version )
# Read the version file
FILE
(
READ
${
OW_VERSION_FILENAME
}
OW_VERSION_FILE_CONTENT
)
# The first regex will mathc
STRING
(
REGEX REPLACE
".*[^#]VERSION=([0-9]+
\\
.[0-9]+
\\
.[0-9]+[_~a-z,A-Z,0-9]*(
\\
+
h
gX?[0-9]*)?).*"
"
\\
1"
OW_VERSION_FILE
${
OW_VERSION_FILE_CONTENT
}
)
STRING
(
REGEX REPLACE
".*[^#]VERSION=([0-9]+
\\
.[0-9]+
\\
.[0-9]+[_~a-z,A-Z,0-9]*(
\\
+g
it
X?[0-9]*)?).*"
"
\\
1"
OW_VERSION_FILE
${
OW_VERSION_FILE_CONTENT
}
)
STRING
(
COMPARE EQUAL
${
OW_VERSION_FILE
}
${
OW_VERSION_FILE_CONTENT
}
OW_VERSION_FILE_INVALID
)
IF
(
OW_VERSION_FILE_INVALID
)
UNSET
(
OW_VERSION_FILE
)
...
...
@@ -562,24 +562,25 @@ FUNCTION( GET_VERSION_STRING _version _api_version )
MESSAGE
(
FATAL_ERROR
"Could not parse
\"
${
PROJECT_SOURCE_DIR
}
/../VERSION
\"
."
)
ENDIF
()
# Use
h
g to query version information.
# -> the nice thing is: if
h
g is not available, no compilation errors anymore
# Use g
it
to query version information.
# -> the nice thing is: if g
it
is not available, no compilation errors anymore
# NOTE: it is run insde the project source directory
EXECUTE_PROCESS
(
COMMAND
hg parents --template
"{node|short}"
OUTPUT_VARIABLE OW_VERSION_
H
G RESULT_VARIABLE
hgParents
RetVar
EXECUTE_PROCESS
(
COMMAND
git rev-parse --short HEAD
OUTPUT_VARIABLE OW_VERSION_G
IT
RESULT_VARIABLE
git
RetVar
WORKING_DIRECTORY
${
PROJECT_SOURCE_DIR
}
)
IF
(
NOT
${
hgParents
RetVar
}
STREQUAL 0
)
UNSET
(
OW_VERSION_
H
G
)
# be more nice if we do not find
mercruial
version. The simply strip the +
h
g tag.
STRING
(
REGEX REPLACE
"
\\
+
h
gX"
""
OW_VERSION
${
OW_VERSION_FILE
}
)
IF
(
NOT
${
git
RetVar
}
STREQUAL 0
)
UNSET
(
OW_VERSION_G
IT
)
# be more nice if we do not find
git
version. The simply strip the +g
it
tag.
STRING
(
REGEX REPLACE
"
\\
+g
it
X"
""
OW_VERSION
${
OW_VERSION_FILE
}
)
ELSE
()
# if we have the mercurial info -> complement the version string
STRING
(
REGEX REPLACE
"
h
gX"
"
h
g
${
OW_VERSION_
H
G
}
"
OW_VERSION
${
OW_VERSION_FILE
}
)
STRING
(
REGEX REPLACE
"g
it
X"
"g
it
${
OW_VERSION_G
IT
}
"
OW_VERSION
${
OW_VERSION_FILE
}
)
ENDIF
()
SET
(
${
_version
}
${
OW_VERSION
}
PARENT_SCOPE
)
# we need to separate the API version too. This basically is the same as the release version, but without the HG statement
# we need to separate the API version too. This basically is the same as the release version,
# but without the Git statement
STRING
(
REGEX REPLACE
"([0-9]+
\\
.[0-9]+
\\
.[0-9]).*"
"
\\
1"
OW_API_VERSION
${
OW_VERSION
}
)
SET
(
${
_api_version
}
${
OW_API_VERSION
}
PARENT_SCOPE
)
...
...
@@ -597,15 +598,15 @@ ENDFUNCTION( GET_VERSION_STRING )
# _OW_VERSION_HEADER the filename where to store the header. Should be absolute.
# _PREFIX the string used as prefix in the header. Useful if you have multiple version headers.
FUNCTION
(
SETUP_VERSION_HEADER _OW_VERSION_HEADER _PREFIX
)
# This ensures that an nonexisting .
hg/dirstate
file won't cause a compile error (do not know how to make target)
SET
(
H
G_DEP
""
)
IF
(
EXISTS
${
PROJECT_SOURCE_DIR
}
/../.
hg/dirstate
)
SET
(
H
G_DEP
${
PROJECT_SOURCE_DIR
}
/../.
hg/dirstate
)
# This ensures that an nonexisting .
git/index
file won't cause a compile error (do not know how to make target)
SET
(
G
IT
_DEP
""
)
IF
(
EXISTS
${
PROJECT_SOURCE_DIR
}
/../.
git/index
)
SET
(
G
IT
_DEP
${
PROJECT_SOURCE_DIR
}
/../.
git/index
)
ENDIF
()
# The file WVersion.* needs the version definition.
ADD_CUSTOM_COMMAND
(
OUTPUT
${
_OW_VERSION_HEADER
}
DEPENDS
${
PROJECT_SOURCE_DIR
}
/../VERSION
${
H
G_DEP
}
DEPENDS
${
PROJECT_SOURCE_DIR
}
/../VERSION
${
G
IT
_DEP
}
COMMAND
${
CMAKE_COMMAND
}
-D PROJECT_SOURCE_DIR:STRING=
${
PROJECT_SOURCE_DIR
}
-D HEADER_FILENAME:STRING=
${
_OW_VERSION_HEADER
}
-D PREFIX:STRING=
${
_PREFIX
}
-P OpenWalnutVersion.cmake
WORKING_DIRECTORY
${
PROJECT_SOURCE_DIR
}
/../tools/cmake/
COMMENT
"Creating Version Header
${
_OW_VERSION_HEADER
}
."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment