Browse Source

cmGlobalGenerator: add methods for use when implementing short dir support

John Parent 5 months ago
parent
commit
324907a60b
2 changed files with 20 additions and 0 deletions
  1. 17 0
      Source/cmGlobalGenerator.cxx
  2. 3 0
      Source/cmGlobalGenerator.h

+ 17 - 0
Source/cmGlobalGenerator.cxx

@@ -2006,6 +2006,23 @@ bool cmGlobalGenerator::UseShortObjectNames() const
     this->IntDirStrategy == IntermediateDirStrategy::Short;
 }
 
+std::string cmGlobalGenerator::GetShortBinaryOutputDir() const
+{
+  return ".o";
+}
+
+std::string cmGlobalGenerator::ComputeTargetShortName(
+  std::string const& bindir, std::string const& targetName) const
+{
+  auto const& rcwbd =
+    this->LocalGenerators[0]->MaybeRelativeToTopBinDir(bindir);
+  cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_512);
+  constexpr size_t HASH_TRUNCATION = 4;
+  auto dirHash = hasher.HashString(rcwbd).substr(0, HASH_TRUNCATION);
+  auto tgtHash = hasher.HashString(targetName).substr(0, HASH_TRUNCATION);
+  return cmStrCat(tgtHash, dirHash);
+}
+
 void cmGlobalGenerator::ComputeTargetObjectDirectory(
   cmGeneratorTarget* /*unused*/) const
 {

+ 3 - 0
Source/cmGlobalGenerator.h

@@ -631,6 +631,9 @@ public:
 
   virtual bool SupportsShortObjectNames() const;
   bool UseShortObjectNames() const;
+  virtual std::string GetShortBinaryOutputDir() const;
+  std::string ComputeTargetShortName(std::string const& bindir,
+                                     std::string const& targetName) const;
 
   virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;