diff options
author | Vincent Bénony | 2015-12-09 15:32:52 +0100 |
---|---|---|
committer | Vincent Bénony | 2016-01-06 16:17:36 +0100 |
commit | ee73bb428f6f23b921e8c832778b0225618c35b8 (patch) | |
tree | 24767fffc2254526a383125dc9bcbc013fd16057 /devtools/create_project/xcode.cpp | |
parent | 66c195f55e0ddb1130a40219452287ea9165c84d (diff) | |
download | scummvm-rg350-ee73bb428f6f23b921e8c832778b0225618c35b8.tar.gz scummvm-rg350-ee73bb428f6f23b921e8c832778b0225618c35b8.tar.bz2 scummvm-rg350-ee73bb428f6f23b921e8c832778b0225618c35b8.zip |
IOS: Compute MD5 identifiers instead of random
To avoid recompiling the wole project each time we use the create_project tool.
Diffstat (limited to 'devtools/create_project/xcode.cpp')
-rw-r--r-- | devtools/create_project/xcode.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
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 <fstream> #include <algorithm> +#ifdef MACOSX +#include <sstream> +#include <iomanip> +#include <CommonCrypto/CommonCrypto.h> +#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<CC_MD5_DIGEST_LENGTH; i++) { + stream << (unsigned int) md[i]; + } + return stream.str(); +} +#endif + std::string XcodeProvider::newHash() const { std::string hash = createUUID(); |