Browse Source

ENH: Give target in which custom commands build

This gives the cmTarget instance for which custom command rules are
being generated to cmLocalUnixMakefileGenerator3::AppendCustomCommands.
It will be useful in the future.
Brad King 16 years ago
parent
commit
c895d9f2e0

+ 8 - 2
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -954,12 +954,13 @@ void
 cmLocalUnixMakefileGenerator3
 ::AppendCustomCommands(std::vector<std::string>& commands,
                        const std::vector<cmCustomCommand>& ccs,
+                       cmTarget* target,
                        cmLocalGenerator::RelativeRoot relative)
 {
   for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
       i != ccs.end(); ++i)
     {
-    this->AppendCustomCommand(commands, *i, true, relative);
+    this->AppendCustomCommand(commands, *i, target, true, relative);
     }
 }
 
@@ -967,10 +968,13 @@ cmLocalUnixMakefileGenerator3
 void
 cmLocalUnixMakefileGenerator3
 ::AppendCustomCommand(std::vector<std::string>& commands,
-                      const cmCustomCommand& cc, bool echo_comment,
+                      const cmCustomCommand& cc,
+                      cmTarget* target,
+                      bool echo_comment,
                       cmLocalGenerator::RelativeRoot relative,
                       std::ostream* content)
 {
+  static_cast<void>(target); // Future use
   // Optionally create a command to display the custom command's
   // comment text.  This is used for pre-build, pre-link, and
   // post-build command comments.  Custom build step commands have
@@ -1621,9 +1625,11 @@ void cmLocalUnixMakefileGenerator3
                                 glIt->second.GetPostBuildCommands());
       this->AppendCustomCommands(commands, 
                                  glIt->second.GetPreBuildCommands(),
+                                 &glIt->second,
                                  cmLocalGenerator::START_OUTPUT);
       this->AppendCustomCommands(commands, 
                                  glIt->second.GetPostBuildCommands(),
+                                 &glIt->second,
                                  cmLocalGenerator::START_OUTPUT);
       std::string targetName = glIt->second.GetName();
       this->WriteMakeRule(ruleFileStream, targetString.c_str(), 

+ 2 - 0
Source/cmLocalUnixMakefileGenerator3.h

@@ -326,10 +326,12 @@ protected:
                           const cmCustomCommand& cc);
   void AppendCustomCommands(std::vector<std::string>& commands,
                             const std::vector<cmCustomCommand>& ccs,
+                            cmTarget* target,
                             cmLocalGenerator::RelativeRoot relative =
                             cmLocalGenerator::HOME_OUTPUT);
   void AppendCustomCommand(std::vector<std::string>& commands,
                            const cmCustomCommand& cc,
+                           cmTarget* target,
                            bool echo_comment=false,
                            cmLocalGenerator::RelativeRoot relative =
                            cmLocalGenerator::HOME_OUTPUT,

+ 6 - 3
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -299,9 +299,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   if(!relink)
     {
     this->LocalGenerator
-      ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands());
+      ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(),
+                             this->Target);
     this->LocalGenerator
-      ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands());
+      ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(),
+                             this->Target);
     }
 
   // Determine whether a link script will be used.
@@ -436,7 +438,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   if(!relink)
     {
     this->LocalGenerator->
-      AppendCustomCommands(commands, this->Target->GetPostBuildCommands());
+      AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
+                           this->Target);
     }
 
   // Write the build rule.

+ 6 - 3
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -600,9 +600,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   if(!relink)
     {
     this->LocalGenerator
-      ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands());
+      ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(),
+                             this->Target);
     this->LocalGenerator
-      ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands());
+      ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(),
+                             this->Target);
     }
 
   // Determine whether a link script will be used.
@@ -867,7 +869,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   if(!relink)
     {
     this->LocalGenerator->
-      AppendCustomCommands(commands, this->Target->GetPostBuildCommands());
+      AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
+                           this->Target);
     }
 
   // Write the build rule.

+ 1 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -1125,7 +1125,7 @@ void cmMakefileTargetGenerator
 
   // Now append the actual user-specified commands.
   cmOStringStream content;
-  this->LocalGenerator->AppendCustomCommand(commands, cc, false,
+  this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false,
                                             cmLocalGenerator::HOME_OUTPUT,
                                             &content);
 

+ 2 - 2
Source/cmMakefileUtilityTargetGenerator.cxx

@@ -54,13 +54,13 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
     (depends, this->Target->GetPostBuildCommands());
 
   this->LocalGenerator->AppendCustomCommands
-    (commands, this->Target->GetPreBuildCommands());
+    (commands, this->Target->GetPreBuildCommands(), this->Target);
 
   // Depend on all custom command outputs for sources
   this->DriveCustomCommands(depends);
 
   this->LocalGenerator->AppendCustomCommands
-    (commands, this->Target->GetPostBuildCommands());
+    (commands, this->Target->GetPostBuildCommands(), this->Target);
 
   // Add dependencies on targets that must be built first.
   this->AppendTargetDepends(depends);