mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 11:40:42 +00:00
Move version and git constants into #defines and update bash script.
The bash script now adds a #define if the current checkout is exactly on a tag, and it leaves all #defines empty if building from a tarball. The batch file still needs to be updated.
This commit is contained in:
parent
6d53fc5ebf
commit
083fa3debd
4
oscar/VERSION
Normal file
4
oscar/VERSION
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// Update the string below to set OSCAR's version and release status.
|
||||||
|
// See https://semver.org/spec/v2.0.0.html for details on format.
|
||||||
|
|
||||||
|
#define VERSION "1.1.0-beta-1"
|
@ -327,6 +327,7 @@ HEADERS += \
|
|||||||
updateparser.h \
|
updateparser.h \
|
||||||
UpdaterWindow.h \
|
UpdaterWindow.h \
|
||||||
version.h \
|
version.h \
|
||||||
|
VERSION \
|
||||||
Graphs/gFlagsLine.h \
|
Graphs/gFlagsLine.h \
|
||||||
Graphs/gFooBar.h \
|
Graphs/gFooBar.h \
|
||||||
Graphs/gGraph.h \
|
Graphs/gGraph.h \
|
||||||
|
@ -3,19 +3,23 @@
|
|||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
cd $DIR
|
cd $DIR
|
||||||
|
|
||||||
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
git rev-parse --git-dir &>/dev/null
|
||||||
GIT_REVISION=`git rev-parse --short HEAD`
|
if [ $? -eq 0 ]; then
|
||||||
$(git diff-index --quiet HEAD --)
|
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
if [ $? -ne 0 ]; then
|
GIT_REVISION=`git rev-parse --short HEAD`
|
||||||
GIT_REVISION="${GIT_REVISION}-plus" # uncommitted changes
|
$(git diff-index --quiet HEAD --)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
GIT_REVISION="${GIT_REVISION}-plus" # uncommitted changes
|
||||||
|
else
|
||||||
|
# only use the tag if clean
|
||||||
|
GIT_TAG=`git describe --exact-match --tags 2>/dev/null`
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$GIT_BRANCH" ] && GIT_BRANCH="Unknown";
|
|
||||||
[ -z "$GIT_REVISION" ] && GIT_REVISION="Unknown";
|
|
||||||
|
|
||||||
echo // This is an auto generated file > $DIR/git_info.h.new
|
echo // This is an auto generated file > $DIR/git_info.h.new
|
||||||
echo const QString GIT_BRANCH=\"$GIT_BRANCH\"\; >> $DIR/git_info.h.new
|
[ -n "$GIT_BRANCH" ] && echo "#define GIT_BRANCH \"$GIT_BRANCH\"" >> $DIR/git_info.h.new
|
||||||
echo const QString GIT_REVISION=\"$GIT_REVISION\"\; >> $DIR/git_info.h.new
|
[ -n "$GIT_REVISION" ] && echo "#define GIT_REVISION \"$GIT_REVISION\"" >> $DIR/git_info.h.new
|
||||||
|
[ -n "$GIT_TAG" ] && echo "#define GIT_TAG \"$GIT_TAG\"" >> $DIR/git_info.h.new
|
||||||
|
|
||||||
if diff $DIR/git_info.h $DIR/git_info.h.new &> /dev/null; then
|
if diff $DIR/git_info.h $DIR/git_info.h.new &> /dev/null; then
|
||||||
rm $DIR/git_info.h.new
|
rm $DIR/git_info.h.new
|
||||||
|
@ -7,13 +7,22 @@
|
|||||||
* for more details. */
|
* for more details. */
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "VERSION"
|
||||||
#include "git_info.h"
|
#include "git_info.h"
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#define VERSION "1.1.0-beta-1"
|
|
||||||
|
|
||||||
// TODO: add preprocessor macros to build full version number including build metadata, accounting for tarball/non-git builds.
|
// Initialize the Version instance with build metadata, if any.
|
||||||
static const Version s_Version(VERSION "+" + GIT_BRANCH + "-" + GIT_REVISION);
|
#ifdef GIT_REVISION
|
||||||
|
#ifdef GIT_BRANCH
|
||||||
|
#define BUILD_METADATA "+" GIT_BRANCH "-" GIT_REVISION
|
||||||
|
#else
|
||||||
|
#define BUILD_METADATA "+" GIT_REVISION
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define BUILD_METADATA ""
|
||||||
|
#endif
|
||||||
|
static const Version s_Version(VERSION BUILD_METADATA);
|
||||||
|
|
||||||
// Technically this is the date and time that version.cpp was compiled, but since
|
// Technically this is the date and time that version.cpp was compiled, but since
|
||||||
// it gets recompiled whenever git_info.h changes, it's about as close as we can
|
// it gets recompiled whenever git_info.h changes, it's about as close as we can
|
||||||
@ -27,7 +36,7 @@ QString getPrereleaseSuffix()
|
|||||||
|
|
||||||
// Append branch if there is a branch specified
|
// Append branch if there is a branch specified
|
||||||
if (GIT_BRANCH != "master") {
|
if (GIT_BRANCH != "master") {
|
||||||
suffix += "-"+GIT_BRANCH;
|
suffix += "-" GIT_BRANCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append "-test" if not release or release candidate
|
// Append "-test" if not release or release candidate
|
||||||
|
Loading…
Reference in New Issue
Block a user