summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.src.in5
-rwxr-xr-xfindversion.sh15
-rwxr-xr-xprojects/determineversion.vbs31
-rw-r--r--src/rev.cpp.in5
-rw-r--r--src/rev.h1
5 files changed, 37 insertions, 20 deletions
diff --git a/Makefile.src.in b/Makefile.src.in
index e5a032d96..9cf3557c5 100644
--- a/Makefile.src.in
+++ b/Makefile.src.in
@@ -90,6 +90,7 @@ MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
# Use autodetected revisions
VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
ISODATE := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
+GITHASH := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
# Make sure we have something in VERSION and ISODATE
ifeq ($(VERSION),)
@@ -275,10 +276,10 @@ endif
# Revision files
$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in
- $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/rev.cpp
+ $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g" > $(SRC_DIR)/rev.cpp
$(SRC_DIR)/os/windows/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/os/windows/ottdres.rc.in
- $(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/os/windows/ottdres.rc
+ $(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g" > $(SRC_DIR)/os/windows/ottdres.rc
FORCE:
diff --git a/findversion.sh b/findversion.sh
index ead908167..5d2322adb 100755
--- a/findversion.sh
+++ b/findversion.sh
@@ -67,20 +67,25 @@ if [ -d "$ROOT_DIR/.git" ]; then
MODIFIED="2"
fi
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
- SHORTHASH=`echo ${HASH} | cut -c1-8`
+ SHORTHASH=`echo ${HASH} | cut -c1-10`
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"
+ if [ "$MODIFIED" -eq "0" ]; then
+ hashprefix="-g"
+ elif [ "$MODIFIED" -eq "2" ]; then
+ hashprefix="-m"
+ else
+ hashprefix="-u"
+ fi
+
if [ -n "$TAG" ]; then
VERSION="${TAG}"
else
- VERSION="${ISODATE}-${BRANCH}-g${SHORTHASH}"
+ VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
fi
- if [ "$MODIFIED" -eq "2" ]; then
- VERSION="${VERSION}M"
- fi
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
# We are an exported source bundle
cat $ROOT_DIR/.ottdrev
diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs
index b1f7886a4..1446b6e43 100755
--- a/projects/determineversion.vbs
+++ b/projects/determineversion.vbs
@@ -21,31 +21,34 @@ Sub FindReplaceInFile(filename, to_find, replacement)
file.Close
End Sub
-Sub UpdateFile(modified, isodate, version, cur_date, filename)
+Sub UpdateFile(modified, isodate, version, cur_date, githash, filename)
FSO.CopyFile filename & ".in", filename
FindReplaceInFile filename, "!!MODIFIED!!", modified
FindReplaceInFile filename, "!!ISODATE!!", isodate
FindReplaceInFile filename, "!!VERSION!!", version
FindReplaceInFile filename, "!!DATE!!", cur_date
+ FindReplaceInFile filename, "!!GITHASH!!", githash
End Sub
Sub UpdateFiles(version)
- Dim modified, isodate, cur_date
+ Dim modified, isodate, cur_date, githash
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
If InStr(version, Chr(9)) Then
isodate = Mid(version, InStr(version, Chr(9)) + 1)
modified = Mid(isodate, InStr(isodate, Chr(9)) + 1)
+ githash = Mid(modified, InStr(modified, Chr(9)) + 1)
isodate = Mid(isodate, 1, InStr(isodate, Chr(9)) - 1)
modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1)
version = Mid(version, 1, InStr(version, Chr(9)) - 1)
Else
isodate = 0
modified = 1
+ githash = ""
End If
- UpdateFile modified, isodate, version, cur_date, "../src/rev.cpp"
- UpdateFile modified, isodate, version, cur_date, "../src/os/windows/ottdres.rc"
+ UpdateFile modified, isodate, version, cur_date, githash, "../src/rev.cpp"
+ UpdateFile modified, isodate, version, cur_date, githash, "../src/os/windows/ottdres.rc"
End Sub
Function DetermineVersion()
@@ -71,7 +74,7 @@ Function DetermineVersion()
If oExec.ExitCode = 0 Then
hash = oExec.StdOut.ReadLine()
- shorthash = Mid(hash, 1, 8)
+ shorthash = Mid(hash, 1, 10)
' Make sure index is in sync with disk
Set oExec = WshShell.Exec("git update-index --refresh")
If Err.Number = 0 Then
@@ -133,17 +136,19 @@ Function DetermineVersion()
ElseIf hash = "" Then
DetermineVersion = "norev000"
Else
- Dim version
- If tag <> "" Then
- version = tag
- ElseIf branch = "master" Then
- version = isodate & "-g" & shorthash
+ Dim version, hashprefix
+ If modified = 0 Then
+ hashprefix = "-g"
+ ElseIf modified = 2 Then
+ hashprefix = "-m"
Else
- version = isodate & "-" & branch & "-g" & shorthash
+ hashprefix = "-u"
End If
- If modified = 2 Then
- version = version & "M"
+ If tag <> "" Then
+ version = tag
+ Else
+ version = isodate & "-" & branch & hashprefix & shorthash
End If
DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash
diff --git a/src/rev.cpp.in b/src/rev.cpp.in
index 0f4b2a6b5..3c68e18eb 100644
--- a/src/rev.cpp.in
+++ b/src/rev.cpp.in
@@ -48,6 +48,11 @@ const char _openttd_revision[] = "!!VERSION!!";
const char _openttd_build_date[] = __DATE__ " " __TIME__;
/**
+ * The git revision hash of this version.
+ */
+const char _openttd_revision_hash[] = "!!GITHASH!!";
+
+/**
* Let us know if current build was modified. This detection
* works even in the case when revision string is overridden by
* --revision argument.
diff --git a/src/rev.h b/src/rev.h
index d31dbb51c..55fc08699 100644
--- a/src/rev.h
+++ b/src/rev.h
@@ -14,6 +14,7 @@
extern const char _openttd_revision[];
extern const char _openttd_build_date[];
+extern const char _openttd_revision_hash[];
extern const byte _openttd_revision_modified;
extern const uint32 _openttd_newgrf_version;