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

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
parent 633
34d18b9c2cab
child 635
d74279066305
child 685
2e74d99ee7ec

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

.gitignore file | annotate | diff | comparison | revisions
CMakeLists.txt file | annotate | diff | comparison | revisions
src/Dialogs.cc file | annotate | diff | comparison | revisions
src/Main.cc file | annotate | diff | comparison | revisions
src/Main.h file | annotate | diff | comparison | revisions
src/Version.cc file | annotate | diff | comparison | revisions
src/Version.h file | annotate | diff | comparison | revisions
--- a/.gitignore	Sat Feb 22 16:39:26 2014 +0200
+++ b/.gitignore	Sun Feb 23 19:54:30 2014 +0200
@@ -12,5 +12,5 @@
 debug_lastInput
 .kdev_include_paths
 *.cfg
-GitInformation.h
-.kdev4
\ No newline at end of file
+Git.h
+.kdev4
--- a/CMakeLists.txt	Sat Feb 22 16:39:26 2014 +0200
+++ b/CMakeLists.txt	Sun Feb 23 19:54:30 2014 +0200
@@ -12,7 +12,7 @@
 get_target_property (UPDATEREVISION_EXE updaterevision LOCATION)
 
 add_custom_target (revision_check ALL
-    COMMAND ${UPDATEREVISION_EXE} src/GitInformation.h
+    COMMAND ${UPDATEREVISION_EXE} src/Git.h
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     DEPENDS updaterevision)
 
@@ -30,6 +30,7 @@
 	src/Document.cc
 	src/EditHistory.cc
 	src/ExternalPrograms.cc
+	src/Git.cc
 	src/GLRenderer.cc
 	src/LDConfig.cc
 	src/LDObject.cc
--- a/src/Dialogs.cc	Sat Feb 22 16:39:26 2014 +0200
+++ b/src/Dialogs.cc	Sun Feb 23 19:54:30 2014 +0200
@@ -346,7 +346,7 @@
 {
 	Ui::AboutUI ui;
 	ui.setupUi (this);
-	ui.versionInfo->setText (APPNAME " " + fullVersionString());
+	ui.versionInfo->setText (APPNAME " " + QString (fullVersionString()));
 
 	QPushButton* mailButton = new QPushButton;
 	mailButton->setText (tr ("Contact"));
--- a/src/Main.cc	Sat Feb 22 16:39:26 2014 +0200
+++ b/src/Main.cc	Sun Feb 23 19:54:30 2014 +0200
@@ -33,7 +33,6 @@
 #include "ConfigurationDialog.h"
 #include "Dialogs.h"
 #include "CrashCatcher.h"
-#include "GitInformation.h"
 
 QList<LDDocument*> g_loadedFiles;
 MainWindow* g_win = null;
@@ -102,29 +101,3 @@
 	fflush (fp);
 }
 
-// =============================================================================
-// -----------------------------------------------------------------------------
-QString versionString()
-{
-	if (g_versionString.length() == 0)
-	{
-#if VERSION_PATCH == 0
-		g_versionString = fmt ("%1.%2", VERSION_MAJOR, VERSION_MINOR);
-#else
-		g_versionString = fmt ("%1.%2.%3", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
-#endif // VERSION_PATCH
-	}
-
-	return g_versionString;
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-QString fullVersionString()
-{
-#if BUILD_ID != BUILD_RELEASE
-	return GIT_DESCRIPTION;
-#else
-	return "v" + versionString();
-#endif
-}
\ No newline at end of file
--- a/src/Main.h	Sat Feb 22 16:39:26 2014 +0200
+++ b/src/Main.h	Sun Feb 23 19:54:30 2014 +0200
@@ -30,28 +30,10 @@
 #include <QString>
 #include <QTextFormat>
 
+#include "Version.h"
 #include "PropertyMacro.h"
 #include "Configuration.h"
 
-#define APPNAME			"LDForge"
-#define UNIXNAME		"ldforge"
-#define VERSION_MAJOR	0
-#define VERSION_MINOR	2
-#define VERSION_PATCH	999
-#define BUILD_ID		BUILD_INTERNAL
-
-#define BUILD_INTERNAL	0
-#define BUILD_RELEASE	1
-
-// =============================================
-#ifdef DEBUG
-# undef RELEASE
-#endif // DEBUG
-
-#ifdef RELEASE
-# undef DEBUG
-#endif // RELEASE
-
 // =============================================
 #define alias auto&
 #define elif(A) else if (A)
@@ -97,9 +79,9 @@
 # define assert(N) {}
 #endif // DEBUG
 
-// Version string identifier
-QString versionString();
-QString fullVersionString();
+// Version string identifier. These are defined in Version.cc.
+const char* versionString();
+const char* fullVersionString();
 
 #define properties private
 #define typedefs public
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Version.cc	Sun Feb 23 19:54:30 2014 +0200
@@ -0,0 +1,57 @@
+/*
+ *  LDForge: LDraw parts authoring CAD
+ *  Copyright (C) 2013, 2014 Santeri Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "Version.h"
+#include "Git.h"
+
+char gVersionString[64] = {'\0'};
+char gFullVersionString[256] = {'\0'};
+
+// -----------------------------------------------------------------------------
+//
+const char* versionString()
+{
+	if (gVersionString[0] == '\0')
+	{
+#if VERSION_PATCH == 0
+		sprintf (gVersionString, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
+#else
+		sprintf (gVersionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+#endif // VERSION_PATCH
+	}
+
+	return gVersionString;
+}
+
+// -----------------------------------------------------------------------------
+//
+const char* fullVersionString()
+{
+	if (gFullVersionString[0] == '\0')
+	{
+#if BUILD_ID != BUILD_RELEASE
+		strcpy (gFullVersionString, GIT_DESCRIPTION);
+#else
+		sprintf (gFullVersionString, "v%s", versionString());
+#endif
+	}
+
+	return gFullVersionString;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Version.h	Sun Feb 23 19:54:30 2014 +0200
@@ -0,0 +1,37 @@
+/*
+ *  LDForge: LDraw parts authoring CAD
+ *  Copyright (C) 2013, 2014 Santeri Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#define APPNAME			"LDForge"
+#define UNIXNAME		"ldforge"
+#define VERSION_MAJOR	0
+#define VERSION_MINOR	2
+#define VERSION_PATCH	999
+#define BUILD_ID		BUILD_INTERNAL
+
+#define BUILD_INTERNAL	0
+#define BUILD_RELEASE	1
+
+// =============================================
+#ifdef DEBUG
+# undef RELEASE
+#endif // DEBUG
+
+#ifdef RELEASE
+# undef DEBUG
+#endif // RELEASE
\ No newline at end of file

mercurial