summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-06 21:15:11 (GMT)
committerBrad King <brad.king@kitware.com>2021-01-06 21:24:12 (GMT)
commit2892228dc9e70aab3a724058a043068f87c860f6 (patch)
tree221fe1a3abdc0d994e03d6f46d65a252d7b231ac /Source/cmGlobalXCodeGenerator.cxx
parentd250b67722abcfe1bcd22511943f3e032ef1ef3d (diff)
downloadCMake-2892228dc9e70aab3a724058a043068f87c860f6.zip
CMake-2892228dc9e70aab3a724058a043068f87c860f6.tar.gz
CMake-2892228dc9e70aab3a724058a043068f87c860f6.tar.bz2
cmGlobalXCodeGenerator: Add infrastructure for deterministic object ids
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx36
1 files changed, 23 insertions, 13 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index af8b2f0..419cf1e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -18,6 +18,7 @@
#include "cmsys/RegularExpression.hxx"
#include "cmComputeLinkInformation.h"
+#include "cmCryptoHash.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmCustomCommandLines.h"
@@ -797,10 +798,10 @@ void cmGlobalXCodeGenerator::addObject(std::unique_ptr<cmXCodeObject> obj)
}
cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
- cmXCodeObject::PBXType ptype)
+ cmXCodeObject::PBXType ptype, cm::string_view key)
{
auto obj = cm::make_unique<cmXCode21Object>(ptype, cmXCodeObject::OBJECT,
- this->GetObjectId());
+ this->GetObjectId(ptype, key));
auto ptr = obj.get();
this->addObject(std::move(obj));
return ptr;
@@ -3141,19 +3142,28 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
return i->second;
}
-std::string cmGlobalXCodeGenerator::GetObjectId()
+std::string cmGlobalXCodeGenerator::GetObjectId(cmXCodeObject::PBXType ptype,
+ cm::string_view key)
{
std::string objectId;
- char cUuid[40] = { 0 };
- CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
- CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
- objectId = cUuid;
- CFRelease(s);
- CFRelease(uuid);
- cmSystemTools::ReplaceString(objectId, "-", "");
- if (objectId.size() > 24) {
- objectId = objectId.substr(0, 24);
+ if (!key.empty()) {
+ cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
+ hash.Initialize();
+ hash.Append(&ptype, sizeof(ptype));
+ hash.Append(key);
+ objectId = cmSystemTools::UpperCase(hash.FinalizeHex().substr(0, 24));
+ } else {
+ char cUuid[40] = { 0 };
+ CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
+ CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
+ CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
+ objectId = cUuid;
+ CFRelease(s);
+ CFRelease(uuid);
+ cmSystemTools::ReplaceString(objectId, "-", "");
+ if (objectId.size() > 24) {
+ objectId = objectId.substr(0, 24);
+ }
}
return objectId;
}