src/Version.cc

Sun, 23 Feb 2014 19:54:30 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 23 Feb 2014 19:54:30 +0200
changeset 634
5ef894f699d7
child 639
851634b85893
permissions
-rw-r--r--

- separated version stuff to new files to allow version changes be compiled near-instantly

634
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <stdio.h>
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <string.h>
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "Version.h"
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "Git.h"
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 char gVersionString[64] = {'\0'};
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 char gFullVersionString[256] = {'\0'};
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // -----------------------------------------------------------------------------
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 //
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 const char* versionString()
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 {
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 if (gVersionString[0] == '\0')
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 {
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #if VERSION_PATCH == 0
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 sprintf (gVersionString, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 #else
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 sprintf (gVersionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 #endif // VERSION_PATCH
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 }
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 return gVersionString;
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 }
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // -----------------------------------------------------------------------------
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 //
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 const char* fullVersionString()
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 {
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 if (gFullVersionString[0] == '\0')
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 {
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 #if BUILD_ID != BUILD_RELEASE
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 strcpy (gFullVersionString, GIT_DESCRIPTION);
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 #else
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 sprintf (gFullVersionString, "v%s", versionString());
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 #endif
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 }
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 return gFullVersionString;
5ef894f699d7 - separated version stuff to new files to allow version changes be compiled near-instantly
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 }

mercurial