浏览代码

cmDepends: Refactor object file path conversion

Delay conversion of the path to object files (on the left-hand side
of dependencies) until just before they are written.  Also do not
convert the format of paths written to the 'depend.internal' file.
This is consistent with the way the right-hand side of dependencies
are already handled.
Brad King 11 年之前
父节点
当前提交
85cea8a7af
共有 3 个文件被更改,包括 23 次插入17 次删除
  1. 1 6
      Source/cmDepends.cxx
  2. 8 2
      Source/cmDependsC.cxx
  3. 14 9
      Source/cmDependsFortran.cxx

+ 1 - 6
Source/cmDepends.cxx

@@ -58,12 +58,7 @@ bool cmDepends::Write(std::ostream &makeDepends,
     // Get the source and object file.
     // Get the source and object file.
     std::string const& src = *si++;
     std::string const& src = *si++;
     if(si == pairs.end()) { break; }
     if(si == pairs.end()) { break; }
-    std::string obj = *si++;
-
-    // Make sure the object file is relative to the top of the build tree.
-    obj = this->LocalGenerator->Convert(obj,
-                                        cmLocalGenerator::HOME_OUTPUT,
-                                        cmLocalGenerator::MAKERULE);
+    std::string const& obj = *si++;
     dependencies[obj].insert(src);
     dependencies[obj].insert(src);
     }
     }
   for(std::map<std::string, std::set<std::string> >::const_iterator
   for(std::map<std::string, std::set<std::string> >::const_iterator

+ 8 - 2
Source/cmDependsC.cxx

@@ -269,11 +269,17 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
   // written by the original local generator for this directory
   // written by the original local generator for this directory
   // convert the dependencies to paths relative to the home output
   // convert the dependencies to paths relative to the home output
   // directory.  We must do the same here.
   // directory.  We must do the same here.
-  internalDepends << obj << std::endl;
+  std::string obj_i =
+    this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
+  std::string obj_m =
+    this->LocalGenerator->ConvertToOutputFormat(obj_i,
+                                                cmLocalGenerator::MAKERULE);
+  internalDepends << obj_i << std::endl;
+
   for(std::set<std::string>::const_iterator i=dependencies.begin();
   for(std::set<std::string>::const_iterator i=dependencies.begin();
       i != dependencies.end(); ++i)
       i != dependencies.end(); ++i)
     {
     {
-    makeDepends << obj << ": " <<
+    makeDepends << obj_m << ": " <<
       this->LocalGenerator->Convert(*i,
       this->LocalGenerator->Convert(*i,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::MAKERULE)
                                     cmLocalGenerator::MAKERULE)

+ 14 - 9
Source/cmDependsFortran.cxx

@@ -443,12 +443,17 @@ cmDependsFortran
   const char* src = info.Source.c_str();
   const char* src = info.Source.c_str();
 
 
   // Write the include dependencies to the output stream.
   // Write the include dependencies to the output stream.
-  internalDepends << obj << std::endl;
+  std::string obj_i =
+    this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
+  std::string obj_m =
+    this->LocalGenerator->ConvertToOutputFormat(obj_i,
+                                                cmLocalGenerator::MAKERULE);
+  internalDepends << obj_i << std::endl;
   internalDepends << " " << src << std::endl;
   internalDepends << " " << src << std::endl;
   for(std::set<std::string>::const_iterator i = info.Includes.begin();
   for(std::set<std::string>::const_iterator i = info.Includes.begin();
       i != info.Includes.end(); ++i)
       i != info.Includes.end(); ++i)
     {
     {
-    makeDepends << obj << ": " <<
+    makeDepends << obj_m << ": " <<
       this->LocalGenerator->Convert(*i,
       this->LocalGenerator->Convert(*i,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::MAKERULE)
                                     cmLocalGenerator::MAKERULE)
@@ -485,7 +490,7 @@ cmDependsFortran
                                             cmLocalGenerator::MAKERULE);
                                             cmLocalGenerator::MAKERULE);
 
 
       // since we require some things add them to our list of requirements
       // since we require some things add them to our list of requirements
-      makeDepends << obj << ".requires: " << proxy << std::endl;
+      makeDepends << obj_m << ".requires: " << proxy << std::endl;
       }
       }
 
 
     // The object file should depend on timestamped files for the
     // The object file should depend on timestamped files for the
@@ -500,7 +505,7 @@ cmDependsFortran
         this->LocalGenerator->Convert(required->second,
         this->LocalGenerator->Convert(required->second,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::MAKERULE);
                                       cmLocalGenerator::MAKERULE);
-      makeDepends << obj << ": " << stampFile << "\n";
+      makeDepends << obj_m << ": " << stampFile << "\n";
       }
       }
     else
     else
       {
       {
@@ -513,7 +518,7 @@ cmDependsFortran
           this->LocalGenerator->Convert(module,
           this->LocalGenerator->Convert(module,
                                         cmLocalGenerator::HOME_OUTPUT,
                                         cmLocalGenerator::HOME_OUTPUT,
                                         cmLocalGenerator::MAKERULE);
                                         cmLocalGenerator::MAKERULE);
-        makeDepends << obj << ": " << module << "\n";
+        makeDepends << obj_m << ": " << module << "\n";
         }
         }
       }
       }
     }
     }
@@ -529,7 +534,7 @@ cmDependsFortran
     proxy = this->LocalGenerator->Convert(proxy,
     proxy = this->LocalGenerator->Convert(proxy,
                                           cmLocalGenerator::HOME_OUTPUT,
                                           cmLocalGenerator::HOME_OUTPUT,
                                           cmLocalGenerator::MAKERULE);
                                           cmLocalGenerator::MAKERULE);
-    makeDepends << proxy << ": " << obj << ".provides" << std::endl;
+    makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
     }
     }
 
 
   // If any modules are provided then they must be converted to stamp files.
   // If any modules are provided then they must be converted to stamp files.
@@ -537,7 +542,7 @@ cmDependsFortran
     {
     {
     // Create a target to copy the module after the object file
     // Create a target to copy the module after the object file
     // changes.
     // changes.
-    makeDepends << obj << ".provides.build:\n";
+    makeDepends << obj_m << ".provides.build:\n";
     for(std::set<std::string>::const_iterator i = info.Provides.begin();
     for(std::set<std::string>::const_iterator i = info.Provides.begin();
         i != info.Provides.end(); ++i)
         i != info.Provides.end(); ++i)
       {
       {
@@ -575,7 +580,7 @@ cmDependsFortran
       }
       }
     // After copying the modules update the timestamp file so that
     // After copying the modules update the timestamp file so that
     // copying will not be done again until the source rebuilds.
     // copying will not be done again until the source rebuilds.
-    makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj
+    makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
                 << ".provides.build\n";
                 << ".provides.build\n";
 
 
     // Make sure the module timestamp rule is evaluated by the time
     // Make sure the module timestamp rule is evaluated by the time
@@ -585,7 +590,7 @@ cmDependsFortran
     driver = this->LocalGenerator->Convert(driver,
     driver = this->LocalGenerator->Convert(driver,
                                            cmLocalGenerator::HOME_OUTPUT,
                                            cmLocalGenerator::HOME_OUTPUT,
                                            cmLocalGenerator::MAKERULE);
                                            cmLocalGenerator::MAKERULE);
-    makeDepends << driver << ": " << obj << ".provides.build\n";
+    makeDepends << driver << ": " << obj_m << ".provides.build\n";
     }
     }
 
 
   return true;
   return true;