Browse Source

ENH: some updates to the provides requires code

Ken Martin 20 years ago
parent
commit
1c95c08ccf
2 changed files with 28 additions and 3 deletions
  1. 9 0
      Source/cmDependsFortran.cxx
  2. 19 3
      Source/cmLocalUnixMakefileGenerator3.cxx

+ 9 - 0
Source/cmDependsFortran.cxx

@@ -185,6 +185,15 @@ bool cmDependsFortran::WriteDependencies(std::ostream& os)
     os << "\t@touch " << m_TargetFile.c_str() << ".provides\n";
     }
 
+  // if it provides something then connect the requires rule to the build rule
+  if(!parser.Provides.empty())
+    {
+    os << m_TargetFile.c_str() << ".requires: " << m_TargetFile.c_str()
+       << ".requires.build" << std::endl;
+    // provide empty build rule for old gen for now, TODO remove later
+    os << m_TargetFile.c_str() << ".requires.build:" << std::endl;    
+    }
+  
   /*
   // TODO:
   What about .mod files provided in another directory and found with a

+ 19 - 3
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -625,15 +625,20 @@ cmLocalUnixMakefileGenerator3
 
   // If the language needs provides-requires mode, create the
   // corresponding targets.
+  std::string objectRequires = obj;
+  objectRequires += ".requires";
+  std::vector<std::string> no_commands;
+
+  // always provide an empty requires target
+  this->WriteMakeRule(ruleFileStream, 0,
+                      objectRequires.c_str(), no_commands, no_commands);
+  
   if(strcmp(lang, "Fortran") == 0)
     {
-    std::string objectRequires = obj;
     std::string objectProvides = obj;
-    objectRequires += ".requires";
     objectProvides += ".provides";
     {
     // Add the provides target to build the object file.
-    std::vector<std::string> no_commands;
     std::vector<std::string> p_depends;
     p_depends.push_back(obj);
     this->WriteMakeRule(ruleFileStream, 0,
@@ -642,7 +647,18 @@ cmLocalUnixMakefileGenerator3
 
     // Add this to the set of provides-requires objects on the target.
     provides_requires.push_back(objectRequires);
+    {
+    // Add the requires.build target to recursively build the provides
+    // target after needed information is up to date.
+    std::vector<std::string> no_depends;
+    std::vector<std::string> r_commands;
+    r_commands.push_back(this->GetRecursiveMakeCall("Makefile",objectProvides.c_str()));
+    objectRequires += ".build";
+    this->WriteMakeRule(ruleFileStream, 0,
+                        objectRequires.c_str(), no_depends, r_commands);
     }
+    }
+
 }
 
 //----------------------------------------------------------------------------