MCPcopy Create free account
hub / github.com/Kitware/CMake / cmLocalGeneratorShortenObjectName

Function cmLocalGeneratorShortenObjectName

Source/cmLocalGenerator.cxx:4120–4144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4118
4119namespace {
4120bool cmLocalGeneratorShortenObjectName(std::string& objName,
4121 std::string::size_type max_len)
4122{
4123 // Check if the path can be shortened using an md5 sum replacement for
4124 // a portion of the path.
4125 std::string::size_type md5Len = 32;
4126 std::string::size_type numExtraChars = objName.size() - max_len + md5Len;
4127 std::string::size_type pos = objName.find('/', numExtraChars);
4128 if (pos == std::string::npos) {
4129 pos = objName.rfind('/', numExtraChars);
4130 if (pos == std::string::npos || pos <= md5Len) {
4131 return false;
4132 }
4133 }
4134
4135 // Replace the beginning of the path portion of the object name with
4136 // its own md5 sum.
4137 cmCryptoHash md5(cmCryptoHash::AlgoMD5);
4138 std::string md5name = cmStrCat(md5.HashString(objName.substr(0, pos)),
4139 cm::string_view(objName).substr(pos));
4140 objName = md5name;
4141
4142 // The object name is now shorter, check if it is short enough.
4143 return pos >= numExtraChars;
4144}
4145
4146bool cmLocalGeneratorCheckObjectName(std::string& objName,
4147 std::string::size_type dir_len,

Callers 1

Calls 6

rfindMethod · 0.80
HashStringMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
findMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…