Skip to content

Commit

Permalink
libdeng2: Version info
Browse files Browse the repository at this point in the history
This commit makes a number of significant changes to how version
information is defined and handled in libdeng2.

1) The authoritative source for the info is libdeng2.pro. It is
   unacceptable to include headers from the libdeng1/engine side.

2) de::Version can be used to access version information at runtime.

3) On Windows, the .rc file is generated by qmake (Python script) out
   of the information defined in libdeng2.pro.
  • Loading branch information
skyjake committed Oct 30, 2012
1 parent a2dcdf9 commit 382219d
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 87 deletions.
2 changes: 2 additions & 0 deletions doomsday/config_win32.pri
Expand Up @@ -27,5 +27,7 @@ DENG_DOCS_DIR = $$DENG_BASE_DIR/doc
# Tell rc where to get the API headers.
QMAKE_RC = $$QMAKE_RC /I \"$$DENG_API_DIR\"

deng_debug: $$QMAKE_RC = $$QMAKE_RC /d _DEBUG

# Also build the OpenAL plugin.
CONFIG += deng_openal
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/Version
@@ -0,0 +1 @@
#include "version.h"
2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/core/app.h
Expand Up @@ -62,6 +62,8 @@ namespace de
public:
App(int& argc, char** argv, GUIMode guiMode);

~App();

/**
* Initializes all the application's subsystems. This includes Config
* and FS. Has to be called manually in the application's
Expand Down
105 changes: 66 additions & 39 deletions doomsday/libdeng2/include/de/version.h
@@ -1,6 +1,6 @@
/**
* @file version.h
* Version numbering, naming etc for libdeng 2.0
* Version numbering and labeling for libdeng2.
*
* @authors Copyright &copy; 2011-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2011-2012 Daniel Swanson <danij@dengine.net>
Expand All @@ -23,48 +23,75 @@
#ifndef LIBDENG2_VERSION_H
#define LIBDENG2_VERSION_H

// We'll take the values for most of these from deng 1.0 to avoid duplication
// (and hopefully avoid any oversights which might occur as a consequence).
#include "../../engine/portable/include/dd_version.h"
#ifdef __cplusplus

// Presented to the user in dialogs, messages etc.
#define LIBDENG2_NICENAME "deng2"
#define LIBDENG2_NICEAUTHOR DENGPROJECT_NICEAUTHOR
#define LIBDENG2_DETAILS "Doomsday 2.0 core engine library."
#include <de/String>
#include <de/Time>

#define LIBDENG2_HOMEURL DOOMSDAY_HOMEURL
#define LIBDENG2_MASTERURL DOOMSDAY_MASTERURL
#define LIBDENG2_DOCSURL DOOMSDAY_DOCSURL

#define LIBDENG2_VERSION_BASE DOOMSDAY_VERSION_BASE
#define LIBDENG2_VERSION_NUMBER DOOMSDAY_VERSION_NUMBER // For WIN32 version info.
#ifdef DOOMSDAY_RELEASE_FULL
# define LIBDENG2_RELEASE_FULL DOOMSDAY_RELEASE_FULL
#endif
#ifdef DOOMSDAY_RELEASE_NAME
# define LIBDENG2_RELEASE_NAME DOOMSDAY_RELEASE_NAME
#endif
namespace de {

/**
* LIBDENG2_RELEASE_TYPE determines the classification of the release.
* Possible values are "Unstable", "Candidate" and "Stable".
* Version information about libdeng2. The version numbers are defined in
* libdeng2.pro.
*
* @note For the time being, this is separate from the libdeng1/engine version
* number. libdeng2 versioning starts from 2.0.0. When the project as a whole
* switches to major version 2, libdeng2 version will be synced with the rest
* of the project. Also note that unlike libdeng1, there is only ever three
* components in the version.
*/
#define LIBDENG2_RELEASE_TYPE DOOMSDAY_RELEASE_TYPE

#define LIBDENG2_VERSION_TEXT DOOMSDAY_VERSION_TEXT
#if defined(WIN32) && defined(UNICODE)
# define LIBDENG2_VERSION_TEXT_WSTR DOOMSDAY_VERSION_TEXT_WSTR
#endif

// For WIN32 version info:
#if defined(WIN32)
# define LIBDENG2_FILENAME "deng2.dll"
# define LIBDENG2_COPYRIGHT DOOMSDAY_COPYRIGHT
# if defined(UNICODE)
# define LIBDENG2_DESC_WSTR TEXT(LIBDENG2_DETAILS)
# else
# define LIBDENG2_DESC LIBDENG2_DETAILS
# endif
#endif
class Version
{
public:
int major;
int minor;
int patch;
int build;
String label; ///< Informative label, only intended for humans.

/**
* Version information about this build.
*/
Version();

/**
* Version information.
*
* @param version Version number in the form "x.y.z".
* @param buildNumber Build number.
*/
Version(const String& version, int buildNumber);

/**
* Forms a version string in the form "x.y.z". If a release label is
* defined, it will be included, too: "x.y.z (label)".
*/
String base() const;

/**
* Forms a version string that includes the build number (unless it is
* zero).
*/
String asText() const;

/**
* Converts a textual version and updates the Version instance with the
* values. The version has the following format: (major).(minor).(patch).
* The release label is never part of the version string.
*
* @param version Version string. Cannot include a label.
*/
void parseVersionString(const String& version);

bool operator < (const Version& other) const;

bool operator == (const Version& other) const;

bool operator > (const Version& other) const;
};

} // namespace de

#endif // __cplusplus

#endif // LIBDENG2_VERSION_H
14 changes: 9 additions & 5 deletions doomsday/libdeng2/libdeng2.pro
Expand Up @@ -32,6 +32,12 @@ QT += core network gui opengl
win32 {
# Keep the version number out of the file name.
TARGET_EXT = .dll

# For Windows, an .rc file is generated for embedded version info in the binary.
system(python "$$PWD/res/win32/generate_rc.py" "$$PWD/res/win32/deng2.rc" \
$$LIBDENG2_MAJOR_VERSION $$LIBDENG2_MINOR_VERSION $$LIBDENG2_PATCHLEVEL \
$$LIBDENG2_RELEASE_LABEL $$DENG_BUILD)
RC_FILE = res/win32/deng2.rc
}

# Enable strict warnings for C++ code.
Expand Down Expand Up @@ -62,7 +68,8 @@ HEADERS += \
include/de/Log \
include/de/LogBuffer \
include/de/UnixInfo \
include/de/Vector
include/de/Vector \
include/de/Version

HEADERS += \
include/de/c_wrapper.h \
Expand All @@ -87,6 +94,7 @@ HEADERS += \
SOURCES += \
src/c_wrapper.cpp \
src/error.cpp \
src/version.cpp \
src/core/app.cpp \
src/core/commandline.cpp \
src/core/config.cpp \
Expand Down Expand Up @@ -122,7 +130,3 @@ macx {
INSTALLS += target
target.path = $$DENG_LIB_DIR
}

win32 {
RC_FILE = res/win32/deng2.rc
}
46 changes: 23 additions & 23 deletions doomsday/libdeng2/res/win32/deng2.rc
@@ -1,8 +1,10 @@
/**
* @file deng2.rc
* Win32 resource script.
* Win32 resource script. Not compatible with "apstudio", just plain RC
* invocation via qmake.
*
* @authors Copyright &copy; 2008-2012 Daniel Swanson <danij@dengine.net>
* @authors Copyright &copy; 2012 Jaakko Keranen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -24,7 +26,6 @@
#define APSTUDIO_READONLY_SYMBOLS

#include "windows.h"
#include "../../include/de/version.h"

#undef APSTUDIO_READONLY_SYMBOLS

Expand All @@ -45,7 +46,6 @@ END
2 TEXTINCLUDE
BEGIN
"#include ""windows.h""\r\n"
"#include ""../../include/de/version.h""\0"
END

3 TEXTINCLUDE
Expand All @@ -55,8 +55,8 @@ BEGIN
"#endif\r\n"
"\r\n"
"VS_VERSION_INFO VERSIONINFO\r\n"
"FILEVERSION LIBDENG2_VERSION_NUMBER\r\n"
"PRODUCTVERSION LIBDENG2_VERSION_NUMBER\r\n"
"FILEVERSION 2,0,0,669\r\n"
"PRODUCTVERSION 2,0,0,669\r\n"
"# if defined(_DEBUG)\r\n"
"FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE\r\n"
"# elif defined(LIBDENG2_RELEASE_FULL)\r\n"
Expand All @@ -74,16 +74,16 @@ BEGIN
" BEGIN\r\n"
" VALUE ""CompanyName"", ""\0""\r\n"
"#if defined(UNICODE)\r\n"
" VALUE ""FileDescription"", LIBDENG2_DESC_WSTR ""\0""\r\n"
" VALUE ""FileDescription"", ""Doomsday 2 core library"" ""\0""\r\n"
"#else\r\n"
" VALUE ""FileDescription"", LIBDENG2_DESC ""\0""\r\n"
" VALUE ""FileDescription"", ""Doomsday 2 core library"" ""\0""\r\n"
"#endif\r\n"
" VALUE ""FileVersion"", LIBDENG2_VERSION_TEXT ""\0""\r\n"
" VALUE ""InternalName"", LIBDENG2_NICENAME ""\0""\r\n"
" VALUE ""LegalCopyright"", ""Copyright "" LIBDENG2_COPYRIGHT ""\0""\r\n"
" VALUE ""OriginalFilename"", LIBDENG2_FILENAME ""\0""\r\n"
" VALUE ""ProductName"", LIBDENG2_NICENAME ""\0""\r\n"
" VALUE ""ProductVersion"", LIBDENG2_VERSION_TEXT ""\0""\r\n"
" VALUE ""FileVersion"", ""2.0.0"" ""\0""\r\n"
" VALUE ""InternalName"", ""deng2"" ""\0""\r\n"
" VALUE ""LegalCopyright"", ""Copyright (c) "" ""2004-2012 Deng Team"" ""\0""\r\n"
" VALUE ""OriginalFilename"", ""deng2.dll"" ""\0""\r\n"
" VALUE ""ProductName"", ""deng2"" ""\0""\r\n"
" VALUE ""ProductVersion"", ""2.0.0"" ""\0""\r\n"
"#if !defined(_DEBUG) && !defined(LIBDENG2_RELEASE_FULL) && defined(LIBDENG2_RELEASE_NAME)\r\n"
" VALUE ""SpecialBuild"", LIBDENG2_RELEASE_NAME ""\0""\r\n"
"#endif\r\n"
Expand All @@ -102,8 +102,8 @@ END

#ifndef APSTUDIO_INVOKED
VS_VERSION_INFO VERSIONINFO
FILEVERSION LIBDENG2_VERSION_NUMBER
PRODUCTVERSION LIBDENG2_VERSION_NUMBER
FILEVERSION 2,0,0,669
PRODUCTVERSION 2,0,0,669
# if defined(_DEBUG)
FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE
# elif !defined(LIBDENG2_RELEASE_FULL)
Expand All @@ -121,16 +121,16 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
#if defined(UNICODE)
VALUE "FileDescription", LIBDENG2_DESC_WSTR "\0"
VALUE "FileDescription", "Doomsday 2 core library" "\0"
#else
VALUE "FileDescription", LIBDENG2_DESC "\0"
VALUE "FileDescription", "Doomsday 2 core library" "\0"
#endif
VALUE "FileVersion", LIBDENG2_VERSION_TEXT "\0"
VALUE "InternalName", LIBDENG2_NICENAME "\0"
VALUE "LegalCopyright", "Copyright " LIBDENG2_COPYRIGHT "\0"
VALUE "OriginalFilename", LIBDENG2_FILENAME "\0"
VALUE "ProductName", LIBDENG2_NICENAME "\0"
VALUE "ProductVersion", LIBDENG2_VERSION_TEXT "\0"
VALUE "FileVersion", "2.0.0" "\0"
VALUE "InternalName", "deng2" "\0"
VALUE "LegalCopyright", "Copyright (c) " "2004-2012 Deng Team" "\0"
VALUE "OriginalFilename", "deng2.dll" "\0"
VALUE "ProductName", "deng2" "\0"
VALUE "ProductVersion", "2.0.0" "\0"
#if !defined(_DEBUG) && !defined(LIBDENG2_RELEASE_FULL) && defined(LIBDENG2_RELEASE_NAME)
VALUE "SpecialBuild", LIBDENG2_RELEASE_NAME "\0"
#endif
Expand Down

0 comments on commit 382219d

Please sign in to comment.