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 //----------------------------------------------------------------------------
17 cmCustomCommand::cmCustomCommand()
19 this->HaveComment = false;
20 this->EscapeOldStyle = true;
21 this->EscapeAllowMakeVars = false;
24 //----------------------------------------------------------------------------
25 cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
28 CommandLines(r.CommandLines),
29 HaveComment(r.HaveComment),
31 WorkingDirectory(r.WorkingDirectory),
32 EscapeAllowMakeVars(r.EscapeAllowMakeVars),
33 EscapeOldStyle(r.EscapeOldStyle),
34 Backtrace(new cmListFileBacktrace(*r.Backtrace))
38 //----------------------------------------------------------------------------
39 cmCustomCommand::cmCustomCommand(cmMakefile* mf,
40 const std::vector<std::string>& outputs,
41 const std::vector<std::string>& depends,
42 const cmCustomCommandLines& commandLines,
44 const char* workingDirectory):
47 CommandLines(commandLines),
48 HaveComment(comment?true:false),
49 Comment(comment?comment:""),
50 WorkingDirectory(workingDirectory?workingDirectory:""),
51 EscapeAllowMakeVars(false),
53 Backtrace(new cmListFileBacktrace)
55 this->EscapeOldStyle = true;
56 this->EscapeAllowMakeVars = false;
59 mf->GetBacktrace(*this->Backtrace);
63 //----------------------------------------------------------------------------
64 cmCustomCommand::~cmCustomCommand()
66 delete this->Backtrace;
69 //----------------------------------------------------------------------------
70 const std::vector<std::string>& cmCustomCommand::GetOutputs() const
75 //----------------------------------------------------------------------------
76 const char* cmCustomCommand::GetWorkingDirectory() const
78 if(this->WorkingDirectory.size() == 0)
82 return this->WorkingDirectory.c_str();
85 //----------------------------------------------------------------------------
86 const std::vector<std::string>& cmCustomCommand::GetDepends() const
91 //----------------------------------------------------------------------------
92 const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
94 return this->CommandLines;
97 //----------------------------------------------------------------------------
98 const char* cmCustomCommand::GetComment() const
100 const char* no_comment = 0;
101 return this->HaveComment? this->Comment.c_str() : no_comment;
104 //----------------------------------------------------------------------------
105 void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
107 for(cmCustomCommandLines::const_iterator i=commandLines.begin();
108 i != commandLines.end(); ++i)
110 this->CommandLines.push_back(*i);
114 //----------------------------------------------------------------------------
115 void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
117 for(std::vector<std::string>::const_iterator i=depends.begin();
118 i != depends.end(); ++i)
120 this->Depends.push_back(*i);
124 //----------------------------------------------------------------------------
125 bool cmCustomCommand::GetEscapeOldStyle() const
127 return this->EscapeOldStyle;
130 //----------------------------------------------------------------------------
131 void cmCustomCommand::SetEscapeOldStyle(bool b)
133 this->EscapeOldStyle = b;
136 //----------------------------------------------------------------------------
137 bool cmCustomCommand::GetEscapeAllowMakeVars() const
139 return this->EscapeAllowMakeVars;
142 //----------------------------------------------------------------------------
143 void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
145 this->EscapeAllowMakeVars = b;
148 //----------------------------------------------------------------------------
149 cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
151 return *this->Backtrace;
154 //----------------------------------------------------------------------------
155 cmCustomCommand::ImplicitDependsList const&
156 cmCustomCommand::GetImplicitDepends() const
158 return this->ImplicitDepends;
161 //----------------------------------------------------------------------------
162 void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
164 this->ImplicitDepends = l;
167 //----------------------------------------------------------------------------
168 void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
170 this->ImplicitDepends.insert(this->ImplicitDepends.end(),