diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-08-08 01:12:08 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-08-08 17:22:13 (GMT) |
commit | ec5f1c489a43456a97f849456e3c81b45bda05dd (patch) | |
tree | 2ad734f8a8ab8721c0539f1c4c6269d10b73db8b /Source | |
parent | 6b21d2bc9bbe241252b5ad30b7a8bb850518638c (diff) | |
download | CMake-ec5f1c489a43456a97f849456e3c81b45bda05dd.zip CMake-ec5f1c489a43456a97f849456e3c81b45bda05dd.tar.gz CMake-ec5f1c489a43456a97f849456e3c81b45bda05dd.tar.bz2 |
cmCryptoHash: prefer to cmSystemTools::ComputeStringMD5
The latter call is no longer post-bootstrap only since 596439b1bb
(cmCustomCommandGenerator: Add option to transform depfile, 2020-10-05)
via !5325. Convert callers to just use `cmCryptoHash` directly and
remove the bootstrap guard.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/WiX/cmWIXSourceWriter.cxx | 4 | ||||
-rw-r--r-- | Source/cmExportCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmIncludeGuardCommand.cxx | 13 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 6 |
7 files changed, 22 insertions, 21 deletions
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 82dc019..ef6712a 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -5,6 +5,7 @@ #include <windows.h> #include "cmCPackGenerator.h" +#include "cmCryptoHash.h" #include "cmUuid.h" cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, @@ -134,7 +135,8 @@ std::string cmWIXSourceWriter::CreateGuidFromComponentId( { std::string guid = "*"; if (this->ComponentGuidType == CMAKE_GENERATED_GUID) { - std::string md5 = cmSystemTools::ComputeStringMD5(componentId); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string md5 = hasher.HashString(componentId); cmUuid uuid; std::vector<unsigned char> ns; guid = uuid.FromMd5(ns, md5); diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index a58f2b7..273296d 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -14,6 +14,7 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" +#include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmExperimental.h" #include "cmExportBuildAndroidMKGenerator.h" @@ -310,7 +311,8 @@ static bool HandlePackage(std::vector<std::string> const& args, // named by a hash of its own content. This is deterministic and is // unique with high probability. const std::string& outDir = mf.GetCurrentBinaryDirectory(); - std::string hash = cmSystemTools::ComputeStringMD5(outDir); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string hash = hasher.HashString(outDir); StorePackageRegistry(mf, package, outDir.c_str(), hash.c_str()); return true; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7a852f8..aa8a895 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -18,6 +18,7 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" +#include "cmCryptoHash.h" #include "cmDocumentationEntry.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -1202,9 +1203,10 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile( { // The VS 10 generator needs to create the .rule files on disk. // Hide them away under the CMakeFiles directory. + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); std::string ruleDir = cmStrCat( this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeFiles/", - cmSystemTools::ComputeStringMD5(cmSystemTools::GetFilenamePath(output))); + hasher.HashString(cmSystemTools::GetFilenamePath(output))); std::string ruleFile = cmStrCat(ruleDir, '/', cmSystemTools::GetFilenameName(output), ".rule"); return ruleFile; diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx index e0a6958..2b0e03c 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIncludeGuardCommand.h" +#include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include "cmValue.h" #include "cmake.h" @@ -21,14 +22,8 @@ enum IncludeGuardScope std::string GetIncludeGuardVariableName(std::string const& filePath) { - std::string result = "__INCGUARD_"; -#ifndef CMAKE_BOOTSTRAP - result += cmSystemTools::ComputeStringMD5(filePath); -#else - result += cmSystemTools::MakeCidentifier(filePath); -#endif - result += "__"; - return result; + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + return cmStrCat("__INCGUARD_", hasher.HashString(filePath), "__"); } bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar) diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 32196d3..71d5471 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -8,6 +8,7 @@ #include <cm/memory> +#include "cmCryptoHash.h" #ifndef CMAKE_BOOTSTRAP # include "cmExportInstallAndroidMKGenerator.h" #endif @@ -64,11 +65,10 @@ std::string cmInstallExportGenerator::TempDirCalculate() const return path; } -#ifndef CMAKE_BOOTSTRAP + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); path += '/'; // Replace the destination path with a hash to keep it short. - path += cmSystemTools::ComputeStringMD5(this->Destination); -#endif + path += hasher.HashString(this->Destination); return path; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 499dd24..1a1a454 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3026,13 +3026,11 @@ void cmLocalGenerator::WriteUnitySourceInclude( } else { pathToHash = "ABS_" + sf_full_path; } + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); unity_file << "/* " << pathToHash << " */\n" << "#undef " << *uniqueIdName << "\n" << "#define " << *uniqueIdName << " unity_" -#ifndef CMAKE_BOOTSTRAP - << cmSystemTools::ComputeStringMD5(pathToHash) << "\n" -#endif - ; + << hasher.HashString(pathToHash) << "\n"; } if (beforeInclude) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 700631c..4bc3ce3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -22,6 +22,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmComputeLinkInformation.h" +#include "cmCryptoHash.h" #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmFileSet.h" @@ -1821,8 +1822,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } script += lg->FinishConstructScript(this->ProjectType); if (this->ProjectType == VsProjectType::csproj) { - std::string name = cmStrCat("CustomCommand_", c, '_', - cmSystemTools::ComputeStringMD5(sourcePath)); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string name = + cmStrCat("CustomCommand_", c, '_', hasher.HashString(sourcePath)); this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(), outputs.str(), comment, ccg); } else { |