# HG changeset patch # User Santeri Piippo # Date 1391712202 -7200 # Node ID 63e6243b880cd776c7e9fd98e0b4cb44a0357af4 # Parent 93272c0f9a8039d6a8b5480d3c4c77a74ee8739f - migrated to CMake again - added public domain updaterevision for git information diff -r 93272c0f9a80 -r 63e6243b880c .gitignore --- a/.gitignore Wed Feb 05 06:06:23 2014 +0200 +++ b/.gitignore Thu Feb 06 20:43:22 2014 +0200 @@ -2,7 +2,7 @@ build_shared build_debug build_release -ldforge.kdev4 +*.kdev4 Makefile Makefile.* ldforge @@ -12,3 +12,5 @@ debug_lastInput .kdev_include_paths *.cfg +GitInformation.h +.kdev4 \ No newline at end of file diff -r 93272c0f9a80 -r 63e6243b880c CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Thu Feb 06 20:43:22 2014 +0200 @@ -0,0 +1,130 @@ +###################################################################### +# CMake file for LDForge. +# The original QMake file was created on Sat Sep 22 17:29:49 2012 +###################################################################### + +project (ldforge) +add_subdirectory (updaterevision) +cmake_minimum_required (VERSION 2.6) +find_package (Qt4 REQUIRED) +find_package (OpenGL REQUIRED) + +get_target_property (UPDATEREVISION_EXE updaterevision LOCATION) + +add_custom_target (revision_check ALL + COMMAND ${UPDATEREVISION_EXE} src/GitInformation.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS updaterevision) + +include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) + +set (LDForgeSources + src/AddObjectDialog.cc + src/Colors.cc + src/ColorSelector.cc + src/Configuration.cc + src/ConfigurationDialog.cc + src/CrashCatcher.cc + src/Dialogs.cc + src/Documentation.cc + src/Document.cc + src/EditHistory.cc + src/ExternalPrograms.cc + src/GLRenderer.cc + src/LDConfig.cc + src/LDObject.cc + src/Main.cc + src/MainWindow.cc + src/MessageLog.cc + src/Misc.cc + src/PartDownloader.cc + src/Primitives.cc + src/Types.cc + src/Widgets.cc + src/actions/MainActions.cc + src/actions/EditActions.cc +) + +set (LDForgeHeaders + src/PropertyMacro.h + src/CrashCatcher.h + src/Colors.h + src/misc/DocumentPointer.h + src/misc/InvokationDeferer.h + src/misc/RingFinder.h + src/Document.h + src/AddObjectDialog.h + src/LDConfig.h + src/PartDownloader.h + src/LDObject.h + src/Primitives.h + src/Misc.h + src/MessageLog.h + src/Dialogs.h + src/Widgets.h + src/Documentation.h + src/Main.h + src/Types.h + src/ColorSelector.h + src/ConfigurationDialog.h + src/GLRenderer.h + src/Configuration.h + src/MainWindow.h + src/EditHistory.h +) + +set (LDForgeForms + ui/about.ui + ui/addhistoryline.ui + ui/bombbox.ui + ui/colorsel.ui + ui/config.ui + ui/coverer.ui + ui/downloadfrom.ui + ui/edger2.ui + ui/editraw.ui + ui/extprogpath.ui + ui/flip.ui + ui/intersector.ui + ui/isecalc.ui + ui/ldforge.ui + ui/ldrawpath.ui + ui/makeprim.ui + ui/newpart.ui + ui/openprogress.ui + ui/overlay.ui + ui/rectifier.ui + ui/replcoords.ui + ui/rotpoint.ui + ui/ytruder.ui +) + +set (LDForgeResources ldforge.qrc) +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall") +set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lGLU") +include_directories ("${PROJECT_BINARY_DIR}/src") +include_directories ("${PROJECT_BINARY_DIR}/src/misc") + +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG") +endif() + +qt4_wrap_cpp (LDForgeMOC ${LDForgeHeaders}) +qt4_wrap_ui (LDForgeFormsHeaders ${LDForgeForms}) +qt4_add_resources (LDForgeResourcesRCC ${LDForgeResources}) + +add_executable (ldforge + ${LDForgeSources} + ${LDForgeResourcesRCC} + ${LDForgeFormsHeaders} +) + +target_link_libraries (ldforge + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTOPENGL_LIBRARY} + ${OPENGL_LIBRARIES} +) + +install (TARGETS ldforge RUNTIME DESTINATION bin) diff -r 93272c0f9a80 -r 63e6243b880c src/AddObjectDialog.cc --- a/src/AddObjectDialog.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/AddObjectDialog.cc Thu Feb 06 20:43:22 2014 +0200 @@ -34,7 +34,7 @@ #include "Widgets.h" #include "Misc.h" #include "Primitives.h" -#include "moc_AddObjectDialog.cpp" +#include "moc_AddObjectDialog.cxx" // ============================================================================= // ----------------------------------------------------------------------------- diff -r 93272c0f9a80 -r 63e6243b880c src/ColorSelector.cc --- a/src/ColorSelector.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/ColorSelector.cc Thu Feb 06 20:43:22 2014 +0200 @@ -16,7 +16,7 @@ * along with this program. If not, see . * ===================================================================== * - * colorSelectDialog.cpp: Color selector box. + * colorSelectDialog.cxx: Color selector box. */ #include @@ -31,7 +31,7 @@ #include "Configuration.h" #include "Misc.h" #include "ui_colorsel.h" -#include "moc_ColorSelector.cpp" +#include "moc_ColorSelector.cxx" static const int g_numColumns = 16; static const int g_squareSize = 32; diff -r 93272c0f9a80 -r 63e6243b880c src/Colors.cc --- a/src/Colors.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Colors.cc Thu Feb 06 20:43:22 2014 +0200 @@ -16,7 +16,7 @@ * along with this program. If not, see . * ===================================================================== * - * colors.cpp: LDraw color management. LDConfig.ldr parsing is not here! + * colors.cxx: LDraw color management. LDConfig.ldr parsing is not here! * TODO: Make LDColor more full-fledged, add support for direct colors. * TODO: g_LDColors should probably be a map. */ diff -r 93272c0f9a80 -r 63e6243b880c src/Configuration.cc --- a/src/Configuration.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Configuration.cc Thu Feb 06 20:43:22 2014 +0200 @@ -16,7 +16,7 @@ * along with this program. If not, see . * ===================================================================== * - * config.cpp: Configuration management. I don't like how unsafe QSettings + * config.cxx: Configuration management. I don't like how unsafe QSettings * is so this implements a type-safer and identifer-safer wrapping system of * configuration variables. QSettings is used underlyingly, this is a matter * of interface. diff -r 93272c0f9a80 -r 63e6243b880c src/ConfigurationDialog.cc --- a/src/ConfigurationDialog.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/ConfigurationDialog.cc Thu Feb 06 20:43:22 2014 +0200 @@ -16,8 +16,8 @@ * along with this program. If not, see . * ===================================================================== * - * configDialog.cpp: Settings dialog and everything related to it. - * Actual configuration core is in config.cpp. + * configDialog.cxx: Settings dialog and everything related to it. + * Actual configuration core is in config.cxx. */ #include @@ -38,7 +38,7 @@ #include "ColorSelector.h" #include "GLRenderer.h" #include "ui_config.h" -#include "moc_ConfigurationDialog.cpp" +#include "moc_ConfigurationDialog.cxx" extern_cfg (String, gl_bgcolor); extern_cfg (String, gl_maincolor); diff -r 93272c0f9a80 -r 63e6243b880c src/Dialogs.cc --- a/src/Dialogs.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Dialogs.cc Thu Feb 06 20:43:22 2014 +0200 @@ -43,7 +43,7 @@ #include "ui_extprogpath.h" #include "ui_about.h" #include "ui_bombbox.h" -#include "moc_Dialogs.cpp" +#include "moc_Dialogs.cxx" extern const char* g_extProgPathFilter; extern_cfg (String, io_ldpath); diff -r 93272c0f9a80 -r 63e6243b880c src/Document.cc --- a/src/Document.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Document.cc Thu Feb 06 20:43:22 2014 +0200 @@ -29,7 +29,7 @@ #include "Dialogs.h" #include "GLRenderer.h" #include "misc/InvokationDeferer.h" -#include "moc_Document.cpp" +#include "moc_Document.cxx" cfg (String, io_ldpath, ""); cfg (List, io_recentfiles, {}); diff -r 93272c0f9a80 -r 63e6243b880c src/GLRenderer.cc --- a/src/GLRenderer.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/GLRenderer.cc Thu Feb 06 20:43:22 2014 +0200 @@ -38,7 +38,7 @@ #include "MessageLog.h" #include "Primitives.h" #include "misc/RingFinder.h" -#include "moc_GLRenderer.cpp" +#include "moc_GLRenderer.cxx" static const LDFixedCameraInfo g_FixedCameras[6] = { diff -r 93272c0f9a80 -r 63e6243b880c src/Main.cc --- a/src/Main.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Main.cc Thu Feb 06 20:43:22 2014 +0200 @@ -33,6 +33,7 @@ #include "ConfigurationDialog.h" #include "Dialogs.h" #include "CrashCatcher.h" +#include "GitInformation.h" QList g_loadedFiles; MainWindow* g_win = null; @@ -121,8 +122,8 @@ // ----------------------------------------------------------------------------- QString fullVersionString() { -#if BUILD_ID != BUILD_RELEASE && defined (GIT_DESCRIBE) - return GIT_DESCRIBE; +#if BUILD_ID != BUILD_RELEASE + return GIT_DESCRIPTION; #else return "v" + versionString(); #endif diff -r 93272c0f9a80 -r 63e6243b880c src/MainWindow.cc --- a/src/MainWindow.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/MainWindow.cc Thu Feb 06 20:43:22 2014 +0200 @@ -48,7 +48,7 @@ #include "MessageLog.h" #include "Configuration.h" #include "ui_ldforge.h" -#include "moc_MainWindow.cpp" +#include "moc_MainWindow.cxx" static bool g_isSelectionLocked = false; diff -r 93272c0f9a80 -r 63e6243b880c src/MessageLog.cc --- a/src/MessageLog.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/MessageLog.cc Thu Feb 06 20:43:22 2014 +0200 @@ -21,7 +21,7 @@ #include "MessageLog.h" #include "GLRenderer.h" #include "MainWindow.h" -#include "moc_MessageLog.cpp" +#include "moc_MessageLog.cxx" static const int g_maxMessages = 5; static const int g_expiry = 5; diff -r 93272c0f9a80 -r 63e6243b880c src/PartDownloader.cc --- a/src/PartDownloader.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/PartDownloader.cc Thu Feb 06 20:43:22 2014 +0200 @@ -29,7 +29,7 @@ #include "Document.h" #include "GLRenderer.h" #include "ConfigurationDialog.h" -#include "moc_PartDownloader.cpp" +#include "moc_PartDownloader.cxx" cfg (String, net_downloadpath, ""); cfg (Bool, net_guesspaths, true); diff -r 93272c0f9a80 -r 63e6243b880c src/Primitives.cc --- a/src/Primitives.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Primitives.cc Thu Feb 06 20:43:22 2014 +0200 @@ -25,7 +25,7 @@ #include "ui_makeprim.h" #include "Misc.h" #include "Colors.h" -#include "moc_Primitives.cpp" +#include "moc_Primitives.cxx" QList g_PrimitiveCategories; QList g_primitives; diff -r 93272c0f9a80 -r 63e6243b880c src/Widgets.cc --- a/src/Widgets.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/Widgets.cc Thu Feb 06 20:43:22 2014 +0200 @@ -27,7 +27,7 @@ #include #include "Widgets.h" -#include "moc_Widgets.cpp" +#include "moc_Widgets.cxx" // ============================================================================= // ----------------------------------------------------------------------------- diff -r 93272c0f9a80 -r 63e6243b880c src/misc/InvokationDeferer.cc --- a/src/misc/InvokationDeferer.cc Wed Feb 05 06:06:23 2014 +0200 +++ b/src/misc/InvokationDeferer.cc Thu Feb 06 20:43:22 2014 +0200 @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "moc_InvokationDeferer.cpp" +#include "moc_InvokationDeferer.cxx" #include "InvokationDeferer.h" #include "../Misc.h" diff -r 93272c0f9a80 -r 63e6243b880c updaterevision/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/updaterevision/CMakeLists.txt Thu Feb 06 20:43:22 2014 +0200 @@ -0,0 +1,2 @@ +cmake_minimum_required (VERSION 2.4) +add_executable (updaterevision updaterevision.c) \ No newline at end of file diff -r 93272c0f9a80 -r 63e6243b880c updaterevision/updaterevision.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/updaterevision/updaterevision.c Thu Feb 06 20:43:22 2014 +0200 @@ -0,0 +1,136 @@ +/* updaterevision.c + * + * Public domain. This program uses git commands command to get + * various bits of repository status for a particular directory + * and writes it into a header file so that it can be used for a + * project's versioning. + */ + +#define _CRT_SECURE_NO_DEPRECATE + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#define popen _popen +#define pclose _pclose +#endif + +// Used to strip newline characters from lines read by fgets. +void stripnl(char *str) +{ + if (*str != '\0') + { + size_t len = strlen(str); + if (str[len - 1] == '\n') + { + str[len - 1] = '\0'; + } + } +} + +int main(int argc, char **argv) +{ + char vertag[64], lastlog[64], lasthash[64], *hash = NULL; + FILE *stream = NULL; + int gotrev = 0, needupdate = 1; + + vertag[0] = '\0'; + lastlog[0] = '\0'; + + if (argc != 2) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + + // Use git describe --tags to get a version string. If we are sitting directly + // on a tag, it returns that tag. Otherwise it returns --. + // Use git log to get the time of the latest commit in ISO 8601 format and its full hash. + stream = popen("git describe --tags && git log -1 --format=%ai*%H", "r"); + + if (NULL != stream) + { + if (fgets(vertag, sizeof vertag, stream) == vertag && + fgets(lastlog, sizeof lastlog, stream) == lastlog) + { + stripnl(vertag); + stripnl(lastlog); + gotrev = 1; + } + + pclose(stream); + } + + if (gotrev) + { + hash = strchr(lastlog, '*'); + if (hash != NULL) + { + *hash = '\0'; + hash++; + } + } + if (hash == NULL) + { + fprintf(stderr, "Failed to get commit info: %s\n", strerror(errno)); + strcpy(vertag, ""); + lastlog[0] = '\0'; + lastlog[1] = '0'; + lastlog[2] = '\0'; + hash = lastlog + 1; + } + + stream = fopen (argv[1], "r"); + if (stream != NULL) + { + if (!gotrev) + { // If we didn't get a revision but the file does exist, leave it alone. + fclose (stream); + return 0; + } + // Read the revision that's in this file already. If it's the same as + // what we've got, then we don't need to modify it and can avoid rebuilding + // dependant files. + if (fgets(lasthash, sizeof lasthash, stream) == lasthash) + { + stripnl(lasthash); + if (strcmp(hash, lasthash + 3) == 0) + { + needupdate = 0; + } + } + fclose (stream); + } + + if (needupdate) + { + stream = fopen (argv[1], "w"); + if (stream == NULL) + { + return 1; + } + fprintf(stream, +"// %s\n" +"//\n" +"// This file was automatically generated by the\n" +"// updaterevision tool. Do not edit by hand.\n" +"\n" +"#define GIT_DESCRIPTION \"%s\"\n" +"#define GIT_HASH \"%s\"\n" +"#define GIT_TIME \"%s\"\n", + hash, vertag, hash, lastlog); + fclose(stream); + fprintf(stderr, "%s updated to commit %s.\n", argv[1], vertag); + } + else + { + fprintf (stderr, "%s is up to date at commit %s.\n", argv[1], vertag); + } + + return 0; +}