Przeglądaj źródła

cmLocalUnixMakefileGenerator3: Pass strings instead of recomputing them

Sebastian Holtermann 6 lat temu
rodzic
commit
60a407b01c

+ 10 - 13
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1264,9 +1264,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
   // Check if any multiple output pairs have a missing file.
   // Check if any multiple output pairs have a missing file.
   this->CheckMultipleOutputs(verbose);
   this->CheckMultipleOutputs(verbose);
 
 
-  std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
-  std::string internalDependFile = dir + "/depend.internal";
-  std::string dependFile = dir + "/depend.make";
+  std::string const targetDir = cmSystemTools::GetFilenamePath(tgtInfo);
+  std::string const internalDependFile = targetDir + "/depend.internal";
+  std::string const dependFile = targetDir + "/depend.make";
 
 
   // If the target DependInfo.cmake file has changed since the last
   // If the target DependInfo.cmake file has changed since the last
   // time dependencies were scanned then force rescanning.  This may
   // time dependencies were scanned then force rescanning.  This may
@@ -1335,7 +1335,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
 
 
   if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
   if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
     // The dependencies must be regenerated.
     // The dependencies must be regenerated.
-    std::string targetName = cmSystemTools::GetFilenameName(dir);
+    std::string targetName = cmSystemTools::GetFilenameName(targetDir);
     targetName = targetName.substr(0, targetName.length() - 4);
     targetName = targetName.substr(0, targetName.length() - 4);
     std::string message = "Scanning dependencies of target ";
     std::string message = "Scanning dependencies of target ";
     message += targetName;
     message += targetName;
@@ -1343,7 +1343,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
                                        cmsysTerminal_Color_ForegroundBold,
                                        cmsysTerminal_Color_ForegroundBold,
                                      message.c_str(), true, color);
                                      message.c_str(), true, color);
 
 
-    return this->ScanDependencies(dir, validDependencies);
+    return this->ScanDependencies(targetDir, dependFile, internalDependFile,
+                                  validDependencies);
   }
   }
 
 
   // The dependencies are already up-to-date.
   // The dependencies are already up-to-date.
@@ -1351,7 +1352,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
 }
 }
 
 
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(
-  const std::string& targetDir,
+  std::string const& targetDir, std::string const& dependFile,
+  std::string const& internalDependFile,
   std::map<std::string, cmDepends::DependencyVector>& validDeps)
   std::map<std::string, cmDepends::DependencyVector>& validDeps)
 {
 {
   // Read the directory information file.
   // Read the directory information file.
@@ -1393,10 +1395,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
 
 
   // Open the make depends file.  This should be copy-if-different
   // Open the make depends file.  This should be copy-if-different
   // because the make tool may try to reload it needlessly otherwise.
   // because the make tool may try to reload it needlessly otherwise.
-  std::string ruleFileNameFull = targetDir;
-  ruleFileNameFull += "/depend.make";
   cmGeneratedFileStream ruleFileStream(
   cmGeneratedFileStream ruleFileStream(
-    ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
+    dependFile, false, this->GlobalGenerator->GetMakefileEncoding());
   ruleFileStream.SetCopyIfDifferent(true);
   ruleFileStream.SetCopyIfDifferent(true);
   if (!ruleFileStream) {
   if (!ruleFileStream) {
     return false;
     return false;
@@ -1405,11 +1405,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   // Open the cmake dependency tracking file.  This should not be
   // Open the cmake dependency tracking file.  This should not be
   // copy-if-different because dependencies are re-scanned when it is
   // copy-if-different because dependencies are re-scanned when it is
   // older than the DependInfo.cmake.
   // older than the DependInfo.cmake.
-  std::string internalRuleFileNameFull = targetDir;
-  internalRuleFileNameFull += "/depend.internal";
   cmGeneratedFileStream internalRuleFileStream(
   cmGeneratedFileStream internalRuleFileStream(
-    internalRuleFileNameFull, false,
-    this->GlobalGenerator->GetMakefileEncoding());
+    internalDependFile, false, this->GlobalGenerator->GetMakefileEncoding());
   if (!internalRuleFileStream) {
   if (!internalRuleFileStream) {
     return false;
     return false;
   }
   }

+ 2 - 1
Source/cmLocalUnixMakefileGenerator3.h

@@ -231,7 +231,8 @@ protected:
 
 
   // Helper methods for dependency updates.
   // Helper methods for dependency updates.
   bool ScanDependencies(
   bool ScanDependencies(
-    const std::string& targetDir,
+    std::string const& targetDir, std::string const& dependFile,
+    std::string const& internalDependFile,
     std::map<std::string, cmDepends::DependencyVector>& validDeps);
     std::map<std::string, cmDepends::DependencyVector>& validDeps);
   void CheckMultipleOutputs(bool verbose);
   void CheckMultipleOutputs(bool verbose);