Browse Source

bootstrap: Do not declare cmSystemTools functions that are not implemented

Convert runtime error messages into compile-time errors.
Brad King 4 years ago
parent
commit
efc6c23a47

+ 2 - 0
Source/cmInstallExportGenerator.cxx

@@ -85,7 +85,9 @@ void cmInstallExportGenerator::ComputeTempDir()
   }
   if (useMD5) {
     // Replace the destination path with a hash to keep it short.
+#ifndef CMAKE_BOOTSTRAP
     this->TempDir += cmSystemTools::ComputeStringMD5(this->Destination);
+#endif
   } else {
     std::string dest = this->Destination;
     // Avoid unix full paths.

+ 4 - 1
Source/cmLocalGenerator.cxx

@@ -2831,7 +2831,10 @@ void cmLocalGenerator::IncludeFileInUnitySources(
     unity_file << "/* " << pathToHash << " */\n"
                << "#undef " << *uniqueIdName << "\n"
                << "#define " << *uniqueIdName << " unity_"
-               << cmSystemTools::ComputeStringMD5(pathToHash) << "\n";
+#ifndef CMAKE_BOOTSTRAP
+               << cmSystemTools::ComputeStringMD5(pathToHash) << "\n"
+#endif
+      ;
   }
 
   if (beforeInclude) {

+ 4 - 20
Source/cmSystemTools.cxx

@@ -1158,39 +1158,26 @@ void cmSystemTools::MoveFileIfDifferent(const std::string& source,
   RemoveFile(source);
 }
 
+#ifndef CMAKE_BOOTSTRAP
 std::string cmSystemTools::ComputeFileHash(const std::string& source,
                                            cmCryptoHash::Algo algo)
 {
-#if !defined(CMAKE_BOOTSTRAP)
   cmCryptoHash hash(algo);
   return hash.HashFile(source);
-#else
-  (void)source;
-  cmSystemTools::Message("hashsum not supported in bootstrapping mode",
-                         "Error");
-  return std::string();
-#endif
 }
 
 std::string cmSystemTools::ComputeStringMD5(const std::string& input)
 {
-#if !defined(CMAKE_BOOTSTRAP)
   cmCryptoHash md5(cmCryptoHash::AlgoMD5);
   return md5.HashString(input);
-#else
-  (void)input;
-  cmSystemTools::Message("md5sum not supported in bootstrapping mode",
-                         "Error");
-  return "";
-#endif
 }
 
+#  ifdef _WIN32
 std::string cmSystemTools::ComputeCertificateThumbprint(
   const std::string& source)
 {
   std::string thumbprint;
 
-#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
   CRYPT_INTEGER_BLOB cryptBlob;
   HCERTSTORE certStore = NULL;
   PCCERT_CONTEXT certContext = NULL;
@@ -1247,14 +1234,11 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
     }
     CloseHandle(certFile);
   }
-#else
-  (void)source;
-  cmSystemTools::Message("ComputeCertificateThumbprint is not implemented",
-                         "Error");
-#endif
 
   return thumbprint;
 }
+#  endif
+#endif
 
 void cmSystemTools::Glob(const std::string& directory,
                          const std::string& regexp,

+ 4 - 0
Source/cmSystemTools.h

@@ -179,6 +179,7 @@ public:
   static void MoveFileIfDifferent(const std::string& source,
                                   const std::string& destination);
 
+#ifndef CMAKE_BOOTSTRAP
   //! Compute the hash of a file
   static std::string ComputeFileHash(const std::string& source,
                                      cmCryptoHash::Algo algo);
@@ -186,8 +187,11 @@ public:
   /** Compute the md5sum of a string.  */
   static std::string ComputeStringMD5(const std::string& input);
 
+#  ifdef _WIN32
   //! Get the SHA thumbprint for a certificate file
   static std::string ComputeCertificateThumbprint(const std::string& source);
+#  endif
+#endif
 
   /**
    * Run a single executable command

+ 5 - 1
Source/cmcmd.cxx

@@ -1588,7 +1588,11 @@ int cmcmd::HashSumFile(std::vector<std::string> const& args,
       std::cerr << "Error: " << filename << " is a directory" << std::endl;
       retval++;
     } else {
-      std::string value = cmSystemTools::ComputeFileHash(filename, algo);
+      std::string value
+#ifndef CMAKE_BOOTSTRAP
+        = cmSystemTools::ComputeFileHash(filename, algo)
+#endif
+        ;
       if (value.empty()) {
         // To mimic "md5sum/shasum" behavior in a shell:
         std::cerr << filename << ": No such file or directory" << std::endl;