Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
5bac9e28
Commit
5bac9e28
authored
Jun 28, 2017
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[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 "+
hg
1234".
# * With an optional postfix of "+
git
1234".
# This is useful if building is done by scripts. If you want to automatically
# add the correct
HG revision, use only +hg
X without number.
# add the correct
Git revision, use only +git
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+
hg
X -> replaces the X with the current revision number
# VERSION=1.2.0+
hg
1234 -> here, revision number was set by the build scripts for example.
# VERSION=1.2.0b1+
hg
X -> first beta version
# VERSION=1.2.0rc1+
hg
X -> first release candidate version
# VERSION=1.2.0sometext1+
hg
X -> even arbitrary texts are allowd. Be careful as many packaging
# VERSION=1.2.0+
git
X -> replaces the X with the current revision number
# VERSION=1.2.0+
git
1234 -> here, revision number was set by the build scripts for example.
# VERSION=1.2.0b1+
git
X -> first beta version
# VERSION=1.2.0rc1+
git
X -> first release candidate version
# VERSION=1.2.0sometext1+
git
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+
hg
X
VERSION=1.5.0dev+
git
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_
HG
)
UNSET
(
OW_VERSION_
GIT
)
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]*(
\\
+
hg
X?[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]*(
\\
+
git
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
hg
to query version information.
# -> the nice thing is: if
hg
is not available, no compilation errors anymore
# Use
git
to query version information.
# -> the nice thing is: if
git
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_HG RESULT_VARIABLE hgParents
RetVar
EXECUTE_PROCESS
(
COMMAND
git rev-parse --short HEAD OUTPUT_VARIABLE OW_VERSION_GIT RESULT_VARIABLE git
RetVar
WORKING_DIRECTORY
${
PROJECT_SOURCE_DIR
}
)
IF
(
NOT
${
hgParents
RetVar
}
STREQUAL 0
)
UNSET
(
OW_VERSION_
HG
)
# be more nice if we do not find
mercruial version. The simply strip the +hg
tag.
STRING
(
REGEX REPLACE
"
\\
+
hg
X"
""
OW_VERSION
${
OW_VERSION_FILE
}
)
IF
(
NOT
${
git
RetVar
}
STREQUAL 0
)
UNSET
(
OW_VERSION_
GIT
)
# be more nice if we do not find
git version. The simply strip the +git
tag.
STRING
(
REGEX REPLACE
"
\\
+
git
X"
""
OW_VERSION
${
OW_VERSION_FILE
}
)
ELSE
()
# if we have the mercurial info -> complement the version string
STRING
(
REGEX REPLACE
"
hgX"
"hg
${
OW_VERSION_HG
}
"
OW_VERSION
${
OW_VERSION_FILE
}
)
STRING
(
REGEX REPLACE
"
gitX"
"git
${
OW_VERSION_GIT
}
"
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
(
HG
_DEP
""
)
IF
(
EXISTS
${
PROJECT_SOURCE_DIR
}
/../.
hg/dirstate
)
SET
(
HG_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
(
GIT
_DEP
""
)
IF
(
EXISTS
${
PROJECT_SOURCE_DIR
}
/../.
git/index
)
SET
(
GIT_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
${
HG
_DEP
}
DEPENDS
${
PROJECT_SOURCE_DIR
}
/../VERSION
${
GIT
_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