From ee73bb428f6f23b921e8c832778b0225618c35b8 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Wed, 9 Dec 2015 15:32:52 +0100 Subject: IOS: Compute MD5 identifiers instead of random To avoid recompiling the wole project each time we use the create_project tool. --- devtools/create_project/xcode.cpp | 25 +++++++++++++++++++++- devtools/create_project/xcode.h | 3 +++ .../xcode/create_project.xcodeproj/project.pbxproj | 19 ++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'devtools') diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index db91bb873d..1239974d11 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -26,6 +26,12 @@ #include #include +#ifdef MACOSX +#include +#include +#include +#endif + namespace CreateProjectTool { #define DEBUG_XCODE_HASH 0 @@ -1008,7 +1014,6 @@ void XcodeProvider::setupDefines(const BuildSetup &setup) { // Object hash ////////////////////////////////////////////////////////////////////////// -// TODO use md5 to compute a file hash (and fall back to standard key generation if not passed a file) std::string XcodeProvider::getHash(std::string key) { #if DEBUG_XCODE_HASH @@ -1020,7 +1025,12 @@ std::string XcodeProvider::getHash(std::string key) { return hashIterator->second; // Generate a new key from the file hash and insert it into the dictionary +#ifdef MACOSX + std::string hash = md5(key); +#else std::string hash = newHash(); +#endif + _hashDictionnary[key] = hash; return hash; @@ -1029,6 +1039,19 @@ std::string XcodeProvider::getHash(std::string key) { bool isSeparator (char s) { return (s == '-'); } +#ifdef MACOSX +std::string XcodeProvider::md5(std::string key) { + unsigned char md[CC_MD5_DIGEST_LENGTH]; + CC_MD5(key.c_str(), (CC_LONG) key.length(), md); + std::stringstream stream; + stream << std::hex << std::setfill('0') << std::setw(2); + for (int i=0; i