From 904138bae236cbad08afa6d46e5f68a21b457e1e Mon Sep 17 00:00:00 2001 From: Peter Wortmann Date: Sun, 1 Aug 2010 14:49:51 +0100 Subject: [PATCH] Moved version information to Version.txt, including the HG revision. From there it gets inserted into all relevant files by CMake. Used it to for properly setting up the Mac application bundles. --- CMakeLists.txt | 43 +++++--- src/C4Application.cpp | 3 +- src/C4Version.h | 74 ++++--------- src/config/C4Config.cpp | 2 +- {xcode => src/res}/C4D.icns | Bin {xcode => src/res}/C4F.icns | Bin {xcode => src/res}/C4G.icns | Bin {xcode => src/res}/C4K.icns | Bin {xcode => src/res}/C4P.icns | Bin {xcode => src/res}/C4S.icns | Bin {xcode => src/res}/C4U.icns | Bin {xcode => src/res}/Clonk.icns | Bin src/res/Info.plist | 188 ++++++++++++++++++++++++++++++++++ 13 files changed, 240 insertions(+), 70 deletions(-) rename {xcode => src/res}/C4D.icns (100%) rename {xcode => src/res}/C4F.icns (100%) rename {xcode => src/res}/C4G.icns (100%) rename {xcode => src/res}/C4K.icns (100%) rename {xcode => src/res}/C4P.icns (100%) rename {xcode => src/res}/C4S.icns (100%) rename {xcode => src/res}/C4U.icns (100%) rename {xcode => src/res}/Clonk.icns (100%) create mode 100644 src/res/Info.plist diff --git a/CMakeLists.txt b/CMakeLists.txt index 41f9ac3b0..39da5137f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ + cmake_minimum_required (VERSION 2.6.0) project (clonk CXX C) +include(Version.txt) + set(CMAKE_ADDITIONAL_DEPS_PATH deps CACHE PATH "Additional directory to search for libraries and headers") list(APPEND CMAKE_PREFIX_PATH ${CMAKE_ADDITIONAL_DEPS_PATH}) set(OC_CXX_FLAGS ${CMAKE_CXX_FLAGS}) @@ -95,20 +98,6 @@ if(MSVC_VERSION) list(APPEND OC_CXX_FLAGS "/wd4244") endif() -############################################################################ -# Generate hgrevision.h -############################################################################ -if(CMAKE_HOST_WIN32 AND NOT CMAKE_HOST_UNIX) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hgrevision.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/.hg/dirstate - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_hg_revision.bat" > "${CMAKE_CURRENT_BINARY_DIR}/hgrevision.h" - VERBATIM) -else() - # Assume all non-windows system to have /bin/sh. - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hgrevision.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/.hg/dirstate - COMMAND /bin/sh "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_hg_revision.sh" > "${CMAKE_CURRENT_BINARY_DIR}/hgrevision.h" - VERBATIM) -endif() - ############################################################################ # List target source files. Don't directly create a target since we condi- # tionally add more sources depending on configuration options later. @@ -507,7 +496,6 @@ set(OC_CLONK_SOURCES src/tinyxml/tinyxmlparser.cpp src/zlib/gzio.c src/zlib/zutil.h - ${CMAKE_CURRENT_BINARY_DIR}/hgrevision.h ) mark_as_advanced(OC_CLONK_SOURCES) mark_as_advanced(OC_SYSTEM_SOURCES) @@ -727,6 +715,27 @@ if(HAVE_PRECOMPILED_HEADERS) endif() endif() +############################################################################ +# Mac OS bundle setup +############################################################################ + +if(APPLE) + + list(APPEND OC_BUNDLE_RESOURCES + src/res/Clonk.icns + src/res/C4D.icns src/res/C4F.icns src/res/C4G.icns src/res/C4K.icns + src/res/C4P.icns src/res/C4S.icns src/res/C4U.icns + ) + + # Add icon resources + set_source_files_properties( + ${OC_BUNDLE_RESOURCES} + PROPERTIES MACOSX_PACKAGE_LOCATION Resources + ) + list(APPEND OC_SYSTEM_SOURCES ${OC_BUNDLE_RESOURCES}) + +endif() + ############################################################################ # Generate output files ############################################################################ @@ -768,6 +777,10 @@ target_link_libraries(c4group set_property(TARGET clonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) +# This expands some variables in Info.plist as a side-effect. XCode might then +# expand a second time, using the same syntax. Try not to get confused by this! +set_target_properties(clonk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "src/res/Info.plist") + ############################################################################ # build to planet ############################################################################ diff --git a/src/C4Application.cpp b/src/C4Application.cpp index 8e41b3900..c894f567e 100644 --- a/src/C4Application.cpp +++ b/src/C4Application.cpp @@ -43,7 +43,6 @@ #include #include #include -#include "hgrevision.h" #include // For DDraw emulation warning @@ -120,7 +119,7 @@ bool C4Application::DoInit() // Open log OpenLog(); - Revision.Ref(OC_HG_REVISION); + Revision.Ref(C4REVISION); // init system group if (!SystemGroup.Open(C4CFN_System)) diff --git a/src/C4Version.h b/src/C4Version.h index e13064faa..5069591d1 100644 --- a/src/C4Version.h +++ b/src/C4Version.h @@ -21,31 +21,31 @@ #define C4VERSION_H -#define C4ENGINENAME "OpenClonk" -#define C4ENGINENICK "openclonk" +// These are filled in automatically by CMake. When in doubt, edit +// Version.txt instead! -#define C4ENGINECAPTION C4ENGINENAME +#define C4CFG_Company "OpenClonk Project" +#define C4COPYRIGHT_YEAR "2010" +#define C4COPYRIGHT_COMPANY "OpenClonk Project" + +#define C4ENGINENAME "OpenClonk Reborn" +#define C4ENGINENICK "reborn" + +#define C4ENGINECAPTION "OpenClonk Reborn" #define C4EDITORCAPTION "Clonk Editor" +#define C4ENGINEID "org.openclonk.reborn" -#define C4CFG_Company "Redwolf Design" -#define C4COPYRIGHT_YEAR "2010" // might make this dynamic some time... -#define C4COPYRIGHT_COMPANY "OpenClonk Project" +#define C4XVER1 4 +#define C4XVER2 10 +#define C4XVER3 0 +#define C4XVER4 0 +#define C4XVERBUILD 2 +#define C4VERSIONBUILDNAME "Cerulean" +#define C4VERSIONEXTRA "Beta" +#define C4REVISION "25a791c06fff+" -#define C4VERSIONBUILDNAME "Cerulean" - -#define C4XVER1 4 -#define C4XVER2 10 -#define C4XVER3 0 -#define C4XVER4 0 -#define C4XVERBUILD 2 -#define C4VERSIONEXTRA "Beta" - -// Prepend space to version extra -#ifdef C4VERSIONEXTRA -#define C4VERSIONEX " " C4VERSIONEXTRA -#else -#define C4VERSIONEX -#endif +#define C4ENGINEINFO "OpenClonk Reborn Beta" +#define C4ENGINEINFOLONG "OpenClonk Reborn Beta (Cerulean)" // Build Options #ifdef _DEBUG @@ -53,37 +53,7 @@ #else #define C4BUILDDEBUG #endif - #define C4BUILDOPT C4BUILDDEBUG - -#define C4ENGINEINFO C4ENGINENAME C4VERSIONEX -#ifdef C4VERSIONBUILDNAME -#define C4ENGINEINFOLONG C4ENGINENAME C4VERSIONEX " (" C4VERSIONBUILDNAME ")" -#else -#define C4ENGINEINFOLONG C4ENGINEINFO -#endif - -#define C4XVERTOC4XVERS(s) C4XVERTOC4XVERS2(s) -#define C4XVERTOC4XVERS2(s) #s -#if C4XVERBUILD <= 9 -#define C4VERSION C4XVERTOC4XVERS(C4XVER1) "." C4XVERTOC4XVERS(C4XVER2) "." C4XVERTOC4XVERS(C4XVER3) "." C4XVERTOC4XVERS(C4XVER4) " [00" C4XVERTOC4XVERS(C4XVERBUILD) "]" C4VERSIONEX C4BUILDOPT -#elif C4XVERBUILD <= 99 -#define C4VERSION C4XVERTOC4XVERS(C4XVER1) "." C4XVERTOC4XVERS(C4XVER2) "." C4XVERTOC4XVERS(C4XVER3) "." C4XVERTOC4XVERS(C4XVER4) " [0" C4XVERTOC4XVERS(C4XVERBUILD) "]" C4VERSIONEX C4BUILDOPT -#else -#define C4VERSION C4XVERTOC4XVERS(C4XVER1) "." C4XVERTOC4XVERS(C4XVER2) "." C4XVERTOC4XVERS(C4XVER3) "." C4XVERTOC4XVERS(C4XVER4) " [" C4XVERTOC4XVERS(C4XVERBUILD) "]" C4VERSIONEX C4BUILDOPT -#endif - -/* entries for engine.rc (VC++ will overwrite them) - -#include "..\inc\C4Version.h" -[...] - FILEVERSION C4XVER1,C4XVER2,C4XVER3,C4XVER4 - PRODUCTVERSION C4XVER1,C4XVER2,C4XVER3,C4XVER4 -[...] - VALUE "FileDescription", C4ENGINECAPTION "\0" - VALUE "FileVersion", C4VERSION "\0" - VALUE "SpecialBuild", C4BUILDOPT "\0" - VALUE "ProductVersion", C4VERSION "\0" -*/ +#define C4VERSION "4.10.0.0 [002] Beta mac" C4BUILDOPT #endif diff --git a/src/config/C4Config.cpp b/src/config/C4Config.cpp index cc2c8b372..75f9470af 100644 --- a/src/config/C4Config.cpp +++ b/src/config/C4Config.cpp @@ -401,7 +401,7 @@ bool C4Config::Load(bool forceWorkingDirectory, const char *szConfigFile) if (home) { home += "/"; } filename.Copy(home); #ifdef __APPLE__ - filename += "Library/Preferences/de.clonk." C4ENGINENICK ".config"; + filename += "Library/Preferences/" C4ENGINEID ".config"; #else filename += ".clonk/" C4ENGINENICK "/config"; #endif diff --git a/xcode/C4D.icns b/src/res/C4D.icns similarity index 100% rename from xcode/C4D.icns rename to src/res/C4D.icns diff --git a/xcode/C4F.icns b/src/res/C4F.icns similarity index 100% rename from xcode/C4F.icns rename to src/res/C4F.icns diff --git a/xcode/C4G.icns b/src/res/C4G.icns similarity index 100% rename from xcode/C4G.icns rename to src/res/C4G.icns diff --git a/xcode/C4K.icns b/src/res/C4K.icns similarity index 100% rename from xcode/C4K.icns rename to src/res/C4K.icns diff --git a/xcode/C4P.icns b/src/res/C4P.icns similarity index 100% rename from xcode/C4P.icns rename to src/res/C4P.icns diff --git a/xcode/C4S.icns b/src/res/C4S.icns similarity index 100% rename from xcode/C4S.icns rename to src/res/C4S.icns diff --git a/xcode/C4U.icns b/src/res/C4U.icns similarity index 100% rename from xcode/C4U.icns rename to src/res/C4U.icns diff --git a/xcode/Clonk.icns b/src/res/Clonk.icns similarity index 100% rename from xcode/Clonk.icns rename to src/res/Clonk.icns diff --git a/src/res/Info.plist b/src/res/Info.plist new file mode 100644 index 000000000..0421285b5 --- /dev/null +++ b/src/res/Info.plist @@ -0,0 +1,188 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + c4k + + CFBundleTypeIconFile + C4K.icns + CFBundleTypeMIMETypes + + application/octet-stream + + CFBundleTypeName + Clonk Key + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4u + + CFBundleTypeIconFile + C4U.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Update + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4s + + CFBundleTypeIconFile + C4S.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Scenario + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4d + + CFBundleTypeIconFile + C4D.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Definition + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4g + + CFBundleTypeIconFile + C4G.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Group + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4p + + CFBundleTypeIconFile + C4P.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Player + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleTypeExtensions + + c4f + + CFBundleTypeIconFile + C4F.icns + CFBundleTypeMIMETypes + + application/vnd.clonk.c4group + + CFBundleTypeName + Clonk Folder + CFBundleTypeRole + Viewer + LSTypeIsPackage + + NSPersistentStoreTypeKey + Binary + + + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + Clonk + CFBundleIdentifier + ${C4ENGINEID} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${C4ENGINEINFO} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleURLName + Clonk Game Link + CFBundleURLSchemes + + clonk + + + + NSMainNibFile + MainMenu.nib + NSPrincipalClass + NSApplication + NSHumanReadableCopyright + (c) ${C4COPYRIGHT_YEAR}, ${C4PROJECT} + CFBundleDisplayName + ${C4ENGINEINFOLONG} + CFBundleShortVersionString + ${C4VERSION} + CFBundleVersion + ${C4XVERBUILD} + +