|
1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013 - 2015 Teemu Piippo |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 // Note: only using stock C stuff in this file, keeping the STL/Qt stuff out |
|
20 // makes this simple file very fast to compile, which is nice since this file |
|
21 // must be compiled every time I commit something. |
|
22 |
|
23 #include <stdio.h> |
|
24 #include <string.h> |
|
25 #include <time.h> |
|
26 #include "version.h" |
|
27 #include "hginfo.h" |
|
28 |
|
29 // ============================================================================= |
|
30 // |
|
31 const char* VersionString() |
|
32 { |
|
33 static char result[64] = {'\0'}; |
|
34 |
|
35 if (result[0] == '\0') |
|
36 { |
|
37 #if VERSION_PATCH == 0 |
|
38 sprintf (result, "%d.%d", VERSION_MAJOR, VERSION_MINOR); |
|
39 #else |
|
40 sprintf (g_versionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); |
|
41 #endif // VERSION_PATCH |
|
42 } |
|
43 |
|
44 return result; |
|
45 } |
|
46 |
|
47 // ============================================================================= |
|
48 // |
|
49 const char* FullVersionString() |
|
50 { |
|
51 static char result[256] = {'\0'}; |
|
52 |
|
53 if (result[0] == '\0') |
|
54 { |
|
55 #if BUILD_ID != BUILD_RELEASE and defined (HG_NODE) |
|
56 sprintf (result, "%s-" HG_NODE, VersionString()); |
|
57 #else |
|
58 sprintf (g_fullVersionString, "%s", VersionString()); |
|
59 #endif |
|
60 } |
|
61 |
|
62 return result; |
|
63 } |
|
64 |
|
65 // ============================================================================= |
|
66 // |
|
67 const char* CommitTimeString() |
|
68 { |
|
69 static char result[256] = {'\0'}; |
|
70 |
|
71 #ifdef HG_DATE_TIME |
|
72 if (result[0] == '\0') |
|
73 { |
|
74 time_t timestamp = HG_DATE_TIME; |
|
75 strftime (result, sizeof result, "%d %b %Y", localtime (×tamp)); |
|
76 } |
|
77 #endif |
|
78 |
|
79 return result; |
|
80 } |