Sun, 22 Jun 2014 17:17:32 +0300
- adapted the code to use hg-based updaterevision
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
19 | // Note: only using stock C stuff in this file, keeping the STL/Qt stuff out |
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
20 | // makes this simple file very fast to compile, which is nice since this file |
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
21 | // must be compiled every time I commit something. |
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
22 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <stdio.h> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <string.h> |
808
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
25 | #include <time.h> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "version.h" |
808
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
27 | #include "hginfo.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
29 | char g_versionString[64] = {'\0'}; |
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
30 | char g_fullVersionString[256] = {'\0'}; |
745
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
31 | char g_buildTime[256] = {'\0'}; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | const char* versionString() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | { |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
37 | if (g_versionString[0] == '\0') |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | #if VERSION_PATCH == 0 |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
40 | sprintf (g_versionString, "%d.%d", VERSION_MAJOR, VERSION_MINOR); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | #else |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
42 | sprintf (g_versionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | #endif // VERSION_PATCH |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
46 | return g_versionString; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | const char* fullVersionString() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | { |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
53 | if (g_fullVersionString[0] == '\0') |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { |
808
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
55 | #if BUILD_ID != BUILD_RELEASE && defined (SVN_REVISION_STRING) |
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
56 | strcpy (g_fullVersionString, SVN_REVISION_STRING); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | #else |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
58 | sprintf (g_fullVersionString, "v%s", versionString()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | #endif |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
658
2ca8316e0109
- some tweaks to version.cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
62 | return g_fullVersionString; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | } |
745
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
64 | |
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
65 | // ============================================================================= |
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
66 | // |
774
8bce7acd100c
- removed the build time in favor of commit time which I think is much more important
Santeri Piippo <crimsondusk64@gmail.com>
parents:
745
diff
changeset
|
67 | const char* commitTimeString() |
745
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
68 | { |
808
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
69 | #ifdef SVN_REVISION_NUMBER |
745
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
70 | if (g_buildTime[0] == '\0') |
808
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
71 | { |
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
72 | time_t timestamp = SVN_REVISION_NUMBER; |
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
73 | strftime (g_buildTime, sizeof g_buildTime, "%d %b %Y %T", localtime (×tamp)); |
a7d5a97839a0
- adapted the code to use hg-based updaterevision
Santeri Piippo <crimsondusk64@gmail.com>
parents:
774
diff
changeset
|
74 | } |
745
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
75 | #endif |
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
76 | |
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
77 | return g_buildTime; |
ab8adddc0f5c
- added build time to window title properly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
658
diff
changeset
|
78 | } |