~ubuntu-branches/ubuntu/trusty/aegisub/trusty

« back to all changes in this revision

Viewing changes to src/version.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel
  • Date: 2012-03-16 22:58:00 UTC
  • Revision ID: package-import@ubuntu.com-20120316225800-yfb8h9e5n04rk46a
Tags: upstream-2.1.9
ImportĀ upstreamĀ versionĀ 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2005, Niels Martin Hansen
 
2
// All rights reserved.
 
3
//
 
4
// Redistribution and use in source and binary forms, with or without
 
5
// modification, are permitted provided that the following conditions are met:
 
6
//
 
7
//   * Redistributions of source code must retain the above copyright notice,
 
8
//     this list of conditions and the following disclaimer.
 
9
//   * Redistributions in binary form must reproduce the above copyright notice,
 
10
//     this list of conditions and the following disclaimer in the documentation
 
11
//     and/or other materials provided with the distribution.
 
12
//   * Neither the name of the Aegisub Group nor the names of its contributors
 
13
//     may be used to endorse or promote products derived from this software
 
14
//     without specific prior written permission.
 
15
//
 
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
21
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
26
// POSSIBILITY OF SUCH DAMAGE.
 
27
//
 
28
// -----------------------------------------------------------------------------
 
29
//
 
30
// AEGISUB
 
31
//
 
32
// Website: http://aegisub.cellosoft.com
 
33
// Contact: mailto:jiifurusu@gmail.com
 
34
//
 
35
 
 
36
#include "config.h"
 
37
 
 
38
#include <wx/string.h>
 
39
#include <wx/datetime.h>
 
40
#include "version.h"
 
41
 
 
42
#ifdef __WINDOWS__
 
43
#include "../build/svn-revision.h"
 
44
#else
 
45
 
 
46
#ifndef BUILD_SVN_REVISION
 
47
#define BUILD_SVN_REVISION 0
 
48
#endif
 
49
 
 
50
#endif
 
51
 
 
52
#define _T_rec(X) _T(X)
 
53
#define _T_stringize(X) _T(#X)
 
54
#define _T_int(X) _T_stringize(X)
 
55
 
 
56
#define BUILD_TIMESTAMP _T_rec(__DATE__) _T(" ") _T_rec(__TIME__)
 
57
 
 
58
// Define FINAL_RELEASE to mark a build as a "final" version, ie. not pre-release version
 
59
// In that case it won't include the SVN revision information
 
60
 
 
61
struct VersionInfoStruct {
 
62
        // Some raw data
 
63
        wxChar *VersionNumber;
 
64
        bool IsDebug;
 
65
        bool IsRelease;
 
66
        int SvnRev;
 
67
        wxChar *BuildTime;
 
68
        wxChar *BuildCredit;
 
69
 
 
70
        // Nice strings for display
 
71
        wxString LongVersionString;
 
72
        wxString ShortVersionString;
 
73
 
 
74
        // Generate the above data
 
75
        VersionInfoStruct() {
 
76
                wxString VersionStr;
 
77
 
 
78
                SvnRev = BUILD_SVN_REVISION;
 
79
 
 
80
#ifdef BUILD_SVN_DATE
 
81
                BuildTime = _T_rec(BUILD_SVN_DATE);
 
82
#else
 
83
                BuildTime = BUILD_TIMESTAMP;
 
84
#endif
 
85
 
 
86
#ifdef BUILD_CREDIT
 
87
                BuildCredit = _T(BUILD_CREDIT);
 
88
#else
 
89
                BuildCredit = _T("");
 
90
#endif
 
91
 
 
92
#ifdef _DEBUG
 
93
                IsDebug = true;
 
94
#else
 
95
                IsDebug = false;
 
96
#endif
 
97
 
 
98
#ifdef FINAL_RELEASE
 
99
                IsRelease = true;
 
100
                VersionNumber = _T("2.1.9");
 
101
#else
 
102
                IsRelease = false;
 
103
                VersionNumber = _T("r") _T_int(BUILD_SVN_REVISION)
 
104
# ifdef BUILD_SVN_LOCALMODS
 
105
                        _T("M")
 
106
# endif
 
107
                        ;
 
108
#endif
 
109
 
 
110
                if (IsRelease)
 
111
                {
 
112
                        // Short is used in about box
 
113
                        ShortVersionString = wxString::Format(_T("%s (built from SVN revision %d)"), VersionNumber, SvnRev);
 
114
                        // Long is used in title bar
 
115
                        LongVersionString = VersionNumber;
 
116
                }
 
117
                else
 
118
                {
 
119
                        wxString buildcred;
 
120
#ifdef BUILD_CREDIT
 
121
                        buildcred += _T(", "); buildcred += BuildCredit;
 
122
#endif
 
123
                        ShortVersionString = wxString::Format(_T("%s (development version%s)"), VersionNumber, buildcred.c_str());
 
124
                        LongVersionString = ShortVersionString;
 
125
                }
 
126
 
 
127
                if (IsDebug)
 
128
                {
 
129
                        ShortVersionString += _T(" [DEBUG VERSION]");
 
130
                        LongVersionString += _T(" [DEBUG VERSION]");
 
131
                }
 
132
        }
 
133
};
 
134
 
 
135
 
 
136
VersionInfoStruct versioninfo;
 
137
 
 
138
 
 
139
wxString GetAegisubLongVersionString() {
 
140
        return versioninfo.LongVersionString;
 
141
}
 
142
 
 
143
wxString GetAegisubShortVersionString() {
 
144
        return versioninfo.ShortVersionString;
 
145
}
 
146
 
 
147
wxString GetAegisubBuildTime() {
 
148
        return versioninfo.BuildTime;
 
149
}
 
150
 
 
151
wxString GetAegisubBuildCredit() {
 
152
        return versioninfo.BuildCredit;
 
153
}
 
154
 
 
155
bool GetIsOfficialRelease() {
 
156
        return versioninfo.IsRelease;
 
157
}
 
158
 
 
159
wxString GetVersionNumber() {
 
160
        return versioninfo.VersionNumber;
 
161
}
 
162
 
 
163
int GetSVNRevision() {
 
164
        return versioninfo.SvnRev;
 
165
}