[cmake-commits] king committed cmMakefileLibraryTargetGenerator.cxx 1.36 1.37 cmMakefileTargetGenerator.cxx 1.58 1.59 cmMakefileTargetGenerator.h 1.13 1.14

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Mar 9 11:29:17 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv4522

Modified Files:
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmMakefileTargetGenerator.h 
Log Message:
ENH: Added cmMakefileTargetGenerator::GenerateExtraOutput to wrap up creation of rules to drive creation of extra outputs generated as side effects of another rule.  Reimplemented generation of custom command multiple output rules to use it.  Reimplemented soname symlink output dependencies to use it.  Now if a symlink is deleted the library will be recreated with the symlink.


Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- cmMakefileLibraryTargetGenerator.cxx	9 Mar 2007 16:26:10 -0000	1.36
+++ cmMakefileLibraryTargetGenerator.cxx	9 Mar 2007 16:29:15 -0000	1.37
@@ -653,26 +653,19 @@
                                       targetFullPathReal.c_str(),
                                       depends, commands, false);
 
-  // The symlink names for the target should depend on the real target
-  // so if the target version changes it rebuilds and recreates the
-  // symlinks.
-  if(targetFullPathSO != targetFullPathReal)
+  // Some targets have more than one output file.  Create rules to
+  // drive the build if any extra outputs are missing.
+  std::vector<std::string> extraOutputs;
+  if(targetNameSO != targetNameReal)
     {
-    depends.clear();
-    commands.clear();
-    depends.push_back(targetFullPathReal.c_str());
-    this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                        targetFullPathSO.c_str(),
-                                        depends, commands, false);
+    this->GenerateExtraOutput(targetFullPathSO.c_str(),
+                              targetFullPathReal.c_str());
     }
-  if(targetFullPath != targetFullPathSO)
+  if(targetName != targetNameSO &&
+     targetName != targetNameReal)
     {
-    depends.clear();
-    commands.clear();
-    depends.push_back(targetFullPathSO.c_str());
-    this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                        targetFullPath.c_str(),
-                                        depends, commands, false);
+    this->GenerateExtraOutput(targetFullPath.c_str(),
+                              targetFullPathReal.c_str());
     }
 
   // Write the main driver rule to build everything in this target.

Index: cmMakefileTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- cmMakefileTargetGenerator.h	16 Feb 2007 21:12:16 -0000	1.13
+++ cmMakefileTargetGenerator.h	9 Mar 2007 16:29:15 -0000	1.14
@@ -99,6 +99,11 @@
   // write the build rule for a custom command
   void GenerateCustomRuleFile(const cmCustomCommand& cc);
 
+  // write a rule to drive building of more than one output from
+  // another rule
+  void GenerateExtraOutput(const char* out, const char* in,
+                           bool symbolic = false);
+
   // write out the variable that lists the objects for this target
   void WriteObjectsVariable(std::string& variableName,
                             std::string& variableNameExternal);

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- cmMakefileTargetGenerator.cxx	8 Mar 2007 20:33:19 -0000	1.58
+++ cmMakefileTargetGenerator.cxx	9 Mar 2007 16:29:15 -0000	1.59
@@ -903,20 +903,8 @@
                                       symbolic);
   }
 
-  // If the rule has multiple outputs, add a rule for the extra
-  // outputs to just depend on the first output with no command.  Also
-  // register the extra outputs as paired with the first output so
-  // that the check-build-system step will remove the primary output
-  // if any extra outputs are missing, forcing the rule to regenerate
-  // all outputs.
-  depends.clear();
-  depends.push_back(*o);
-  commands.clear();
-  std::string emptyCommand = this->GlobalGenerator->GetEmptyCommandHack();
-  if(!emptyCommand.empty())
-    {
-    commands.push_back(emptyCommand);
-    }
+  // Write rules to drive building any outputs beyond the first.
+  const char* in = o->c_str();
   for(++o; o != outputs.end(); ++o)
     {
     bool symbolic = false;
@@ -927,12 +915,34 @@
         symbolic = sf->GetPropertyAsBool("SYMBOLIC");
         }
       }
-    this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                        o->c_str(), depends, commands,
-                                        symbolic);
-    this->GlobalGenerator->AddMultipleOutputPair(o->c_str(),
-                                                 depends[0].c_str());
+    this->GenerateExtraOutput(o->c_str(), in, symbolic);
+    }
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
+::GenerateExtraOutput(const char* out, const char* in, bool symbolic)
+{
+  // Add a rule to build the primary output if the extra output needs
+  // to be created.
+  std::vector<std::string> commands;
+  std::vector<std::string> depends;
+  std::string emptyCommand = this->GlobalGenerator->GetEmptyCommandHack();
+  if(!emptyCommand.empty())
+    {
+    commands.push_back(emptyCommand);
     }
+  depends.push_back(in);
+  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
+                                      out, depends, commands,
+                                      symbolic);
+
+  // Register the extra output as paired with the first output so that
+  // the check-build-system step will remove the primary output if any
+  // extra outputs are missing.  This forces the rule to regenerate
+  // all outputs.
+  this->GlobalGenerator->AddMultipleOutputPair(out, in);
 }
 
 //----------------------------------------------------------------------------



More information about the Cmake-commits mailing list