1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmCustomCommand.h"
14 #include "cmMakefile.h"
16 #include <cmsys/auto_ptr.hxx>
18 //----------------------------------------------------------------------------
19 cmCustomCommand::cmCustomCommand()
21 this->HaveComment = false;
22 this->EscapeOldStyle = true;
23 this->EscapeAllowMakeVars = false;
26 //----------------------------------------------------------------------------
27 cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
30 CommandLines(r.CommandLines),
31 HaveComment(r.HaveComment),
33 WorkingDirectory(r.WorkingDirectory),
34 EscapeAllowMakeVars(r.EscapeAllowMakeVars),
35 EscapeOldStyle(r.EscapeOldStyle),
36 Backtrace(new cmListFileBacktrace(*r.Backtrace))
40 //----------------------------------------------------------------------------
41 cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
48 this->Outputs = r.Outputs;
49 this->Depends = r.Depends;
50 this->CommandLines = r.CommandLines;
51 this->HaveComment = r.HaveComment;
52 this->Comment = r.Comment;
53 this->WorkingDirectory = r.WorkingDirectory;
54 this->EscapeAllowMakeVars = r.EscapeAllowMakeVars;
55 this->EscapeOldStyle = r.EscapeOldStyle;
56 this->ImplicitDepends = r.ImplicitDepends;
58 cmsys::auto_ptr<cmListFileBacktrace>
59 newBacktrace(new cmListFileBacktrace(*r.Backtrace));
60 delete this->Backtrace;
61 this->Backtrace = newBacktrace.release();
66 //----------------------------------------------------------------------------
67 cmCustomCommand::cmCustomCommand(cmMakefile* mf,
68 const std::vector<std::string>& outputs,
69 const std::vector<std::string>& depends,
70 const cmCustomCommandLines& commandLines,
72 const char* workingDirectory):
75 CommandLines(commandLines),
76 HaveComment(comment?true:false),
77 Comment(comment?comment:""),
78 WorkingDirectory(workingDirectory?workingDirectory:""),
79 EscapeAllowMakeVars(false),
81 Backtrace(new cmListFileBacktrace)
83 this->EscapeOldStyle = true;
84 this->EscapeAllowMakeVars = false;
87 mf->GetBacktrace(*this->Backtrace);
91 //----------------------------------------------------------------------------
92 cmCustomCommand::~cmCustomCommand()
94 delete this->Backtrace;
97 //----------------------------------------------------------------------------
98 const std::vector<std::string>& cmCustomCommand::GetOutputs() const
100 return this->Outputs;
103 //----------------------------------------------------------------------------
104 const char* cmCustomCommand::GetWorkingDirectory() const
106 if(this->WorkingDirectory.size() == 0)
110 return this->WorkingDirectory.c_str();
113 //----------------------------------------------------------------------------
114 const std::vector<std::string>& cmCustomCommand::GetDepends() const
116 return this->Depends;
119 //----------------------------------------------------------------------------
120 const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
122 return this->CommandLines;
125 //----------------------------------------------------------------------------
126 const char* cmCustomCommand::GetComment() const
128 const char* no_comment = 0;
129 return this->HaveComment? this->Comment.c_str() : no_comment;
132 //----------------------------------------------------------------------------
133 void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
135 for(cmCustomCommandLines::const_iterator i=commandLines.begin();
136 i != commandLines.end(); ++i)
138 this->CommandLines.push_back(*i);
142 //----------------------------------------------------------------------------
143 void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
145 for(std::vector<std::string>::const_iterator i=depends.begin();
146 i != depends.end(); ++i)
148 this->Depends.push_back(*i);
152 //----------------------------------------------------------------------------
153 bool cmCustomCommand::GetEscapeOldStyle() const
155 return this->EscapeOldStyle;
158 //----------------------------------------------------------------------------
159 void cmCustomCommand::SetEscapeOldStyle(bool b)
161 this->EscapeOldStyle = b;
164 //----------------------------------------------------------------------------
165 bool cmCustomCommand::GetEscapeAllowMakeVars() const
167 return this->EscapeAllowMakeVars;
170 //----------------------------------------------------------------------------
171 void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
173 this->EscapeAllowMakeVars = b;
176 //----------------------------------------------------------------------------
177 cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
179 return *this->Backtrace;
182 //----------------------------------------------------------------------------
183 cmCustomCommand::ImplicitDependsList const&
184 cmCustomCommand::GetImplicitDepends() const
186 return this->ImplicitDepends;
189 //----------------------------------------------------------------------------
190 void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
192 this->ImplicitDepends = l;
195 //----------------------------------------------------------------------------
196 void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
198 this->ImplicitDepends.insert(this->ImplicitDepends.end(),