Merge topic 'vs-deterministic-guid'
c85367f4
VS: Compute project GUIDs deterministically
This commit is contained in:
commit
2b083b19eb
|
@ -310,8 +310,6 @@ public:
|
||||||
{
|
{
|
||||||
return this->BinaryDirectories.insert(dir).second;
|
return this->BinaryDirectories.insert(dir).second;
|
||||||
}
|
}
|
||||||
/** Supported systems creates a GUID for the given name */
|
|
||||||
virtual void CreateGUID(const std::string&) {}
|
|
||||||
|
|
||||||
/** Return true if the generated build tree may contain multiple builds.
|
/** Return true if the generated build tree may contain multiple builds.
|
||||||
i.e. "Can I build Debug and Release in the same tree?" */
|
i.e. "Can I build Debug and Release in the same tree?" */
|
||||||
|
|
|
@ -513,8 +513,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
||||||
|
|
||||||
cumulativePath = cumulativePath + "/" + *iter;
|
cumulativePath = cumulativePath + "/" + *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->CreateGUID(cumulativePath.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cumulativePath.empty())
|
if (!cumulativePath.empty())
|
||||||
|
@ -899,7 +897,6 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
|
||||||
fname += ".vcproj";
|
fname += ".vcproj";
|
||||||
cmGeneratedFileStream fout(fname.c_str());
|
cmGeneratedFileStream fout(fname.c_str());
|
||||||
fout.SetCopyIfDifferent(true);
|
fout.SetCopyIfDifferent(true);
|
||||||
this->CreateGUID(pname.c_str());
|
|
||||||
std::string guid = this->GetGUID(pname.c_str());
|
std::string guid = this->GetGUID(pname.c_str());
|
||||||
|
|
||||||
fout <<
|
fout <<
|
||||||
|
@ -943,41 +940,28 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
|
||||||
return pname;
|
return pname;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name)
|
//----------------------------------------------------------------------------
|
||||||
|
std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
|
||||||
{
|
{
|
||||||
std::string guidStoreName = name;
|
std::string const& guidStoreName = name + "_GUID_CMAKE";
|
||||||
guidStoreName += "_GUID_CMAKE";
|
if (const char* storedGUID =
|
||||||
const char* storedGUID =
|
this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()))
|
||||||
this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
|
|
||||||
if(storedGUID)
|
|
||||||
{
|
{
|
||||||
return std::string(storedGUID);
|
return std::string(storedGUID);
|
||||||
}
|
}
|
||||||
cmSystemTools::Error("Unknown Target referenced : ",
|
// Compute a GUID that is deterministic but unique to the build tree.
|
||||||
name.c_str());
|
std::string input = this->CMakeInstance->GetState()->GetBinaryDirectory();
|
||||||
return "";
|
input += "|";
|
||||||
}
|
input += name;
|
||||||
|
std::string md5 = cmSystemTools::ComputeStringMD5(input);
|
||||||
|
assert(md5.length() == 32);
|
||||||
void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
|
std::string const& guid =
|
||||||
{
|
(md5.substr( 0,8)+"-"+
|
||||||
std::string guidStoreName = name;
|
md5.substr( 8,4)+"-"+
|
||||||
guidStoreName += "_GUID_CMAKE";
|
md5.substr(12,4)+"-"+
|
||||||
if(this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()))
|
md5.substr(16,4)+"-"+
|
||||||
{
|
md5.substr(20,12));
|
||||||
return;
|
return cmSystemTools::UpperCase(guid);
|
||||||
}
|
|
||||||
std::string ret;
|
|
||||||
UUID uid;
|
|
||||||
unsigned short *uidstr;
|
|
||||||
UuidCreate(&uid);
|
|
||||||
UuidToStringW(&uid,&uidstr);
|
|
||||||
ret = cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(uidstr));
|
|
||||||
RpcStringFreeW(&uidstr);
|
|
||||||
ret = cmSystemTools::UpperCase(ret);
|
|
||||||
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
|
|
||||||
ret.c_str(), "Stored GUID",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -80,9 +80,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void OutputSLNFile();
|
virtual void OutputSLNFile();
|
||||||
|
|
||||||
///! Create a GUID or get an existing one.
|
///! Lookup a stored GUID or compute one deterministically.
|
||||||
void CreateGUID(const std::string& name);
|
std::string GetGUID(std::string const& name);
|
||||||
std::string GetGUID(const std::string& name);
|
|
||||||
|
|
||||||
/** Append the subdirectory for the given configuration. */
|
/** Append the subdirectory for the given configuration. */
|
||||||
virtual void AppendDirectoryForConfig(const std::string& prefix,
|
virtual void AppendDirectoryForConfig(const std::string& prefix,
|
||||||
|
|
|
@ -185,7 +185,6 @@ void cmGlobalVisualStudio8Generator
|
||||||
void cmGlobalVisualStudio8Generator::Configure()
|
void cmGlobalVisualStudio8Generator::Configure()
|
||||||
{
|
{
|
||||||
this->cmGlobalVisualStudio7Generator::Configure();
|
this->cmGlobalVisualStudio7Generator::Configure();
|
||||||
this->CreateGUID(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -107,10 +107,9 @@ void cmLocalVisualStudio10Generator
|
||||||
cmVS10XMLParser parser;
|
cmVS10XMLParser parser;
|
||||||
parser.ParseFile(path);
|
parser.ParseFile(path);
|
||||||
|
|
||||||
// if we can not find a GUID then create one
|
// if we can not find a GUID then we will generate one later
|
||||||
if(parser.GUID.empty())
|
if(parser.GUID.empty())
|
||||||
{
|
{
|
||||||
this->GlobalGenerator->CreateGUID(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,6 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
|
||||||
// Now create GUIDs for targets
|
// Now create GUIDs for targets
|
||||||
cmTargets &tgts = this->Makefile->GetTargets();
|
cmTargets &tgts = this->Makefile->GetTargets();
|
||||||
|
|
||||||
cmGlobalVisualStudio7Generator* gg =
|
|
||||||
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
|
|
||||||
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
||||||
{
|
{
|
||||||
if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
|
if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
|
||||||
|
@ -96,10 +94,6 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
|
||||||
this->ReadAndStoreExternalGUID(
|
this->ReadAndStoreExternalGUID(
|
||||||
l->second.GetName().c_str(), path);
|
l->second.GetName().c_str(), path);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
gg->CreateGUID(l->first.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2312,12 +2306,9 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
|
||||||
{
|
{
|
||||||
cmVS7XMLParser parser;
|
cmVS7XMLParser parser;
|
||||||
parser.ParseFile(path);
|
parser.ParseFile(path);
|
||||||
// if we can not find a GUID then create one
|
// if we can not find a GUID then we will generate one later
|
||||||
if(parser.GUID.size() == 0)
|
if(parser.GUID.size() == 0)
|
||||||
{
|
{
|
||||||
cmGlobalVisualStudio7Generator* gg =
|
|
||||||
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
|
|
||||||
gg->CreateGUID(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string guidStoreName = name;
|
std::string guidStoreName = name;
|
||||||
|
|
|
@ -2116,25 +2116,10 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// build the whole source group path
|
// build the whole source group path
|
||||||
const char* fullname = sg->GetFullName();
|
|
||||||
cmGlobalGenerator* gg = this->GetGlobalGenerator();
|
|
||||||
if(strlen(fullname))
|
|
||||||
{
|
|
||||||
std::string guidName = "SG_Filter_";
|
|
||||||
guidName += fullname;
|
|
||||||
gg->CreateGUID(guidName);
|
|
||||||
}
|
|
||||||
for(++i; i<=lastElement; ++i)
|
for(++i; i<=lastElement; ++i)
|
||||||
{
|
{
|
||||||
sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
|
sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
|
||||||
sg = sg->LookupChild(name[i].c_str());
|
sg = sg->LookupChild(name[i].c_str());
|
||||||
fullname = sg->GetFullName();
|
|
||||||
if(strlen(fullname))
|
|
||||||
{
|
|
||||||
std::string guidName = "SG_Filter_";
|
|
||||||
guidName += fullname;
|
|
||||||
gg->CreateGUID(guidName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sg->SetGroupRegex(regex);
|
sg->SetGroupRegex(regex);
|
||||||
|
|
|
@ -178,7 +178,6 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
|
||||||
(cmLocalVisualStudio7Generator*)
|
(cmLocalVisualStudio7Generator*)
|
||||||
this->Makefile->GetLocalGenerator();
|
this->Makefile->GetLocalGenerator();
|
||||||
this->Name = this->Target->GetName();
|
this->Name = this->Target->GetName();
|
||||||
this->GlobalGenerator->CreateGUID(this->Name.c_str());
|
|
||||||
this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
|
this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
|
||||||
this->Platform = gg->GetPlatformName();
|
this->Platform = gg->GetPlatformName();
|
||||||
this->NsightTegra = gg->IsNsightTegra();
|
this->NsightTegra = gg->IsNsightTegra();
|
||||||
|
@ -1084,7 +1083,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
||||||
(*this->BuildFileStream) << name << "\">\n";
|
(*this->BuildFileStream) << name << "\">\n";
|
||||||
std::string guidName = "SG_Filter_";
|
std::string guidName = "SG_Filter_";
|
||||||
guidName += name;
|
guidName += name;
|
||||||
this->GlobalGenerator->CreateGUID(guidName.c_str());
|
|
||||||
this->WriteString("<UniqueIdentifier>", 3);
|
this->WriteString("<UniqueIdentifier>", 3);
|
||||||
std::string guid
|
std::string guid
|
||||||
= this->GlobalGenerator->GetGUID(guidName.c_str());
|
= this->GlobalGenerator->GetGUID(guidName.c_str());
|
||||||
|
@ -1099,7 +1097,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
||||||
{
|
{
|
||||||
this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
|
this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
|
||||||
std::string guidName = "SG_Filter_Object Libraries";
|
std::string guidName = "SG_Filter_Object Libraries";
|
||||||
this->GlobalGenerator->CreateGUID(guidName.c_str());
|
|
||||||
this->WriteString("<UniqueIdentifier>", 3);
|
this->WriteString("<UniqueIdentifier>", 3);
|
||||||
std::string guid =
|
std::string guid =
|
||||||
this->GlobalGenerator->GetGUID(guidName.c_str());
|
this->GlobalGenerator->GetGUID(guidName.c_str());
|
||||||
|
@ -1112,7 +1109,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
||||||
{
|
{
|
||||||
this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
|
this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
|
||||||
std::string guidName = "SG_Filter_Resource Files";
|
std::string guidName = "SG_Filter_Resource Files";
|
||||||
this->GlobalGenerator->CreateGUID(guidName.c_str());
|
|
||||||
this->WriteString("<UniqueIdentifier>", 3);
|
this->WriteString("<UniqueIdentifier>", 3);
|
||||||
std::string guid =
|
std::string guid =
|
||||||
this->GlobalGenerator->GetGUID(guidName.c_str());
|
this->GlobalGenerator->GetGUID(guidName.c_str());
|
||||||
|
|
Loading…
Reference in New Issue