MCPcopy Create free account
hub / github.com/Kitware/CMake / ConstructScript

Method ConstructScript

Source/cmLocalVisualStudioGenerator.cxx:171–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171std::string cmLocalVisualStudioGenerator::ConstructScript(
172 cmCustomCommandGenerator const& ccg, std::string const& newline_text)
173{
174 bool useLocal = this->CustomCommandUseLocal();
175 std::string workingDirectory = ccg.GetWorkingDirectory();
176
177 // Avoid leading or trailing newlines.
178 std::string newline;
179
180 // Line to check for error between commands.
181 std::string check_error;
182 if (useLocal) {
183 check_error = cmStrCat(newline_text, "if %errorlevel% neq 0 goto :cmEnd");
184 } else {
185 check_error = cmStrCat(newline_text, "if errorlevel 1 goto ",
186 this->GetReportErrorLabel());
187 }
188
189 // Store the script in a string.
190 std::string script;
191
192 // Open a local context.
193 if (useLocal) {
194 script = cmStrCat(newline, "setlocal");
195 newline = newline_text;
196 }
197
198 if (!workingDirectory.empty()) {
199 // Change the working directory.
200 script = cmStrCat(script, newline, "cd ",
201 this->ConvertToOutputFormat(workingDirectory, SHELL),
202 check_error);
203 newline = newline_text;
204
205 // Change the working drive.
206 if (workingDirectory.size() > 1 && workingDirectory[1] == ':') {
207 script = cmStrCat(script, newline, workingDirectory[0],
208 workingDirectory[1], check_error);
209 newline = newline_text;
210 }
211 }
212
213 // for visual studio IDE add extra stuff to the PATH
214 // if CMAKE_MSVCIDE_RUN_PATH is set.
215 if (this->GetGlobalGenerator()->IsVisualStudio()) {
216 cmValue extraPath =
217 this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
218 if (extraPath) {
219 script = cmStrCat(script, newline, "set PATH=", *extraPath, ";%PATH%");
220 newline = newline_text;
221 }
222 }
223
224 // Write each command on a single line.
225 for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
226 // Add this command line.
227 std::string cmd = ccg.GetCommand(c);
228

Callers

nothing calls this directly

Calls 15

CustomCommandUseLocalMethod · 0.95
GetReportErrorLabelMethod · 0.95
GetNumberOfCommandsMethod · 0.80
c_strMethod · 0.80
AppendArgumentsMethod · 0.80
cmStrCatFunction · 0.70
GetWorkingDirectoryMethod · 0.45
emptyMethod · 0.45
ConvertToOutputFormatMethod · 0.45
sizeMethod · 0.45
IsVisualStudioMethod · 0.45

Tested by

no test coverage detected