Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmCustomCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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"
13
14 #include "cmMakefile.h"
15
16 //----------------------------------------------------------------------------
17 cmCustomCommand::cmCustomCommand()
18 {
19   this->HaveComment = false;
20   this->EscapeOldStyle = true;
21   this->EscapeAllowMakeVars = false;
22 }
23
24 //----------------------------------------------------------------------------
25 cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
26   Outputs(r.Outputs),
27   Depends(r.Depends),
28   CommandLines(r.CommandLines),
29   HaveComment(r.HaveComment),
30   Comment(r.Comment),
31   WorkingDirectory(r.WorkingDirectory),
32   EscapeAllowMakeVars(r.EscapeAllowMakeVars),
33   EscapeOldStyle(r.EscapeOldStyle),
34   Backtrace(new cmListFileBacktrace(*r.Backtrace))
35 {
36 }
37
38 //----------------------------------------------------------------------------
39 cmCustomCommand::cmCustomCommand(cmMakefile* mf,
40                                  const std::vector<std::string>& outputs,
41                                  const std::vector<std::string>& depends,
42                                  const cmCustomCommandLines& commandLines,
43                                  const char* comment,
44                                  const char* workingDirectory):
45   Outputs(outputs),
46   Depends(depends),
47   CommandLines(commandLines),
48   HaveComment(comment?true:false),
49   Comment(comment?comment:""),
50   WorkingDirectory(workingDirectory?workingDirectory:""),
51   EscapeAllowMakeVars(false),
52   EscapeOldStyle(true),
53   Backtrace(new cmListFileBacktrace)
54 {
55   this->EscapeOldStyle = true;
56   this->EscapeAllowMakeVars = false;
57   if(mf)
58     {
59     mf->GetBacktrace(*this->Backtrace);
60     }
61 }
62
63 //----------------------------------------------------------------------------
64 cmCustomCommand::~cmCustomCommand()
65 {
66   delete this->Backtrace;
67 }
68
69 //----------------------------------------------------------------------------
70 const std::vector<std::string>& cmCustomCommand::GetOutputs() const
71 {
72   return this->Outputs;
73 }
74
75 //----------------------------------------------------------------------------
76 const char* cmCustomCommand::GetWorkingDirectory() const
77 {
78   if(this->WorkingDirectory.size() == 0)
79     {
80     return 0;
81     }
82   return this->WorkingDirectory.c_str();
83 }
84
85 //----------------------------------------------------------------------------
86 const std::vector<std::string>& cmCustomCommand::GetDepends() const
87 {
88   return this->Depends;
89 }
90
91 //----------------------------------------------------------------------------
92 const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
93 {
94   return this->CommandLines;
95 }
96
97 //----------------------------------------------------------------------------
98 const char* cmCustomCommand::GetComment() const
99 {
100   const char* no_comment = 0;
101   return this->HaveComment? this->Comment.c_str() : no_comment;
102 }
103
104 //----------------------------------------------------------------------------
105 void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
106 {
107   for(cmCustomCommandLines::const_iterator i=commandLines.begin();
108       i != commandLines.end(); ++i)
109     {
110     this->CommandLines.push_back(*i);
111     }
112 }
113
114 //----------------------------------------------------------------------------
115 void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
116 {
117   for(std::vector<std::string>::const_iterator i=depends.begin();
118       i != depends.end(); ++i)
119     {
120     this->Depends.push_back(*i);
121     }
122 }
123
124 //----------------------------------------------------------------------------
125 bool cmCustomCommand::GetEscapeOldStyle() const
126 {
127   return this->EscapeOldStyle;
128 }
129
130 //----------------------------------------------------------------------------
131 void cmCustomCommand::SetEscapeOldStyle(bool b)
132 {
133   this->EscapeOldStyle = b;
134 }
135
136 //----------------------------------------------------------------------------
137 bool cmCustomCommand::GetEscapeAllowMakeVars() const
138 {
139   return this->EscapeAllowMakeVars;
140 }
141
142 //----------------------------------------------------------------------------
143 void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
144 {
145   this->EscapeAllowMakeVars = b;
146 }
147
148 //----------------------------------------------------------------------------
149 cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
150 {
151   return *this->Backtrace;
152 }
153
154 //----------------------------------------------------------------------------
155 cmCustomCommand::ImplicitDependsList const&
156 cmCustomCommand::GetImplicitDepends() const
157 {
158   return this->ImplicitDepends;
159 }
160
161 //----------------------------------------------------------------------------
162 void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
163 {
164   this->ImplicitDepends = l;
165 }
166
167 //----------------------------------------------------------------------------
168 void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
169 {
170   this->ImplicitDepends.insert(this->ImplicitDepends.end(),
171                                l.begin(), l.end());
172 }