Codechange: Use a dynamic copyright year

desync-debugging
glx 4 years ago committed by Charles Pigott
parent e1c85e67a7
commit e0d20a44d2

@ -91,6 +91,7 @@ ISODATE := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
GITHASH := $(shell echo "$(VERSIONS)" | cut -f 4 -d' ')
ISTAG := $(shell echo "$(VERSIONS)" | cut -f 5 -d' ')
ISSTABLETAG := $(shell echo "$(VERSIONS)" | cut -f 6 -d' ')
YEAR := $(shell echo "$(VERSIONS)" | cut -f 7 -d' ')
# Make sure we have something in VERSION and ISODATE
ifeq ($(VERSION),)
@ -272,10 +273,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;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@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;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g;s@!!YEAR!!@$(YEAR)@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;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@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;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g;s@!!YEAR!!@$(YEAR)@g" > $(SRC_DIR)/os/windows/ottdres.rc
FORCE:

@ -67,6 +67,7 @@ if [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; then
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
SHORTHASH=`echo ${HASH} | cut -c1-10`
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
YEAR=`echo ${ISODATE} | cut -c1-4`
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$@@'`"
@ -103,10 +104,11 @@ else
SHORTHASH=""
BRANCH=""
ISODATE=""
YEAR=""
TAG=""
VERSION=""
ISTAG="0"
ISSTABLETAG="0"
fi
echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG"
echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG $YEAR"

@ -19,7 +19,7 @@ Sub FindReplaceInFile(filename, to_find, replacement)
file.Close
End Sub
Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, isstabletag, filename)
Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, isstabletag, year, filename)
FSO.CopyFile filename & ".in", filename
FindReplaceInFile filename, "!!MODIFIED!!", modified
FindReplaceInFile filename, "!!ISODATE!!", isodate
@ -28,10 +28,11 @@ Sub UpdateFile(modified, isodate, version, cur_date, githash, istag, isstabletag
FindReplaceInFile filename, "!!GITHASH!!", githash
FindReplaceInFile filename, "!!ISTAG!!", istag
FindReplaceInFile filename, "!!ISSTABLETAG!!", isstabletag
FindReplaceInFile filename, "!!YEAR!!", year
End Sub
Sub UpdateFiles(version)
Dim modified, isodate, cur_date, githash, istag, isstabletag
Dim modified, isodate, cur_date, githash, istag, isstabletag, year
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
If InStr(version, Chr(9)) Then
@ -41,26 +42,29 @@ Sub UpdateFiles(version)
githash = Mid(modified, InStr(modified, Chr(9)) + 1)
istag = Mid(githash, InStr(githash, Chr(9)) + 1)
isstabletag = Mid(istag, InStr(istag, Chr(9)) + 1)
year = Mid(isstabletag, InStr(isstabletag, Chr(9)) + 1)
' Remove tails from fields
version = Mid(version, 1, InStr(version, Chr(9)) - 1)
isodate = Mid(isodate, 1, InStr(isodate, Chr(9)) - 1)
modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1)
githash = Mid(githash, 1, InStr(githash, Chr(9)) - 1)
istag = Mid(istag, 1, InStr(istag, Chr(9)) - 1)
isstabletag = Mid(isstabletag, 1, InStr(isstabletag, Chr(9)) - 1)
Else
isodate = 0
modified = 1
githash = ""
istag = 0
isstabletag = 0
year = ""
End If
UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, "../src/rev.cpp"
UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, "../src/os/windows/ottdres.rc"
UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, year, "../src/rev.cpp"
UpdateFile modified, isodate, version, cur_date, githash, istag, isstabletag, year, "../src/os/windows/ottdres.rc"
End Sub
Function DetermineVersion()
Dim WshShell, branch, tag, modified, isodate, oExec, line, hash, shorthash
Dim WshShell, branch, tag, modified, isodate, oExec, line, hash, shorthash, year
Set WshShell = CreateObject("WScript.Shell")
On Error Resume Next
@ -70,6 +74,7 @@ Function DetermineVersion()
branch = ""
isodate = ""
tag = ""
year = ""
' Set the environment to english
WshShell.Environment("PROCESS")("LANG") = "en"
@ -108,6 +113,7 @@ Function DetermineVersion()
if Err.Number = 0 Then
isodate = Mid(oExec.StdOut.ReadLine(), 1, 10)
isodate = Replace(isodate, "-", "")
year = Mid(isodate, 1, 4)
End If ' Err.Number = 0
' Check branch
@ -171,7 +177,7 @@ Function DetermineVersion()
isstabletag = 0
End If
DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash & Chr(9) & istag & Chr(9) & isstabletag
DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash & Chr(9) & istag & Chr(9) & isstabletag & Chr(9) & year
End If
End Function

@ -2736,7 +2736,7 @@ STR_LAI_OBJECT_DESCRIPTION_COMPANY_OWNED_LAND :Company-owned l
STR_ABOUT_OPENTTD :{WHITE}About OpenTTD
STR_ABOUT_ORIGINAL_COPYRIGHT :{BLACK}Original copyright {COPYRIGHT} 1995 Chris Sawyer, All rights reserved
STR_ABOUT_VERSION :{BLACK}OpenTTD version {REV}
STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-2019 The OpenTTD team
STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-{RAW_STRING} The OpenTTD team
# Framerate display window
STR_FRAMERATE_CAPTION :{WHITE}Frame rate

@ -25,6 +25,7 @@
#include "newgrf_debug.h"
#include "zoom_func.h"
#include "guitimer_func.h"
#include "rev.h"
#include "widgets/misc_widget.h"
@ -399,7 +400,7 @@ static const NWidgetPart _nested_about_widgets[] = {
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_A_SCROLLING_TEXT),
EndContainer(),
NWidget(WWT_LABEL, COLOUR_GREY, WID_A_WEBSITE), SetDataTip(STR_BLACK_RAW_STRING, STR_NULL),
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL),
NWidget(WWT_LABEL, COLOUR_GREY, WID_A_COPYRIGHT), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL),
EndContainer(),
};
@ -495,6 +496,7 @@ struct AboutWindow : public Window {
void SetStringParameters(int widget) const override
{
if (widget == WID_A_WEBSITE) SetDParamStr(0, "Website: http://www.openttd.org");
if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year);
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override

@ -98,7 +98,7 @@ BEGIN
VALUE "FileDescription", "OpenTTD\0"
VALUE "FileVersion", "!!VERSION!!\0"
VALUE "InternalName", "openttd\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-2019. All Rights Reserved.\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-!!YEAR!!. All Rights Reserved.\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "openttd.exe\0"
VALUE "PrivateBuild", "\0"

@ -50,6 +50,11 @@ const char _openttd_build_date[] = __DATE__ " " __TIME__;
*/
const char _openttd_revision_hash[] = "!!GITHASH!!";
/**
* The year of this version.
*/
const char _openttd_revision_year[] = "!!YEAR!!";
/**
* Let us know if current build was modified. This detection
* works even in the case when revision string is overridden by

@ -13,6 +13,7 @@
extern const char _openttd_revision[];
extern const char _openttd_build_date[];
extern const char _openttd_revision_hash[];
extern const char _openttd_revision_year[];
extern const byte _openttd_revision_modified;
extern const byte _openttd_revision_tagged;
extern const uint32 _openttd_newgrf_version;

@ -639,6 +639,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TT_BACKGROUND, "WID_TT_BACKGROUND");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_SCROLLING_TEXT, "WID_A_SCROLLING_TEXT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_WEBSITE, "WID_A_WEBSITE");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_COPYRIGHT, "WID_A_COPYRIGHT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION, "WID_QS_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT, "WID_QS_TEXT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING, "WID_QS_WARNING");

@ -1605,6 +1605,7 @@ public:
enum AboutWidgets {
WID_A_SCROLLING_TEXT = ::WID_A_SCROLLING_TEXT, ///< The actually scrolling text.
WID_A_WEBSITE = ::WID_A_WEBSITE, ///< URL of OpenTTD website.
WID_A_COPYRIGHT = ::WID_A_COPYRIGHT, ///< Copyright string
};
/** Widgets of the #QueryStringWindow class. */

@ -24,6 +24,7 @@ enum ToolTipsWidgets {
enum AboutWidgets {
WID_A_SCROLLING_TEXT, ///< The actually scrolling text.
WID_A_WEBSITE, ///< URL of OpenTTD website.
WID_A_COPYRIGHT, ///< Copyright string
};
/** Widgets of the #QueryStringWindow class. */

Loading…
Cancel
Save