this sets up some variables for the script to use, creates the required cmake instance and generators, and then reads in the script
| 208 | // this sets up some variables for the script to use, creates the required |
| 209 | // cmake instance and generators, and then reads in the script |
| 210 | int cmCTestScriptHandler::ReadInScript(std::string const& total_script_arg) |
| 211 | { |
| 212 | // Reset the error flag so that the script is read in no matter what |
| 213 | cmSystemTools::ResetErrorOccurredFlag(); |
| 214 | |
| 215 | // if the argument has a , in it then it needs to be broken into the fist |
| 216 | // argument (which is the script) and the second argument which will be |
| 217 | // passed into the scripts as S_ARG |
| 218 | std::string script; |
| 219 | std::string script_arg; |
| 220 | std::string::size_type const comma_pos = total_script_arg.find(','); |
| 221 | if (comma_pos != std::string::npos) { |
| 222 | script = total_script_arg.substr(0, comma_pos); |
| 223 | script_arg = total_script_arg.substr(comma_pos + 1); |
| 224 | } else { |
| 225 | script = total_script_arg; |
| 226 | } |
| 227 | // make sure the file exists |
| 228 | if (!cmSystemTools::FileExists(script)) { |
| 229 | cmSystemTools::Error("Cannot find file: " + script); |
| 230 | return 1; |
| 231 | } |
| 232 | |
| 233 | // read in the list file to fill the cache |
| 234 | // create a cmake instance to read the configuration script |
| 235 | this->CreateCMake(); |
| 236 | |
| 237 | // set a variable with the path to the current script |
| 238 | this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY", |
| 239 | cmSystemTools::GetFilenamePath(script)); |
| 240 | this->Makefile->AddDefinition("CTEST_SCRIPT_NAME", |
| 241 | cmSystemTools::GetFilenameName(script)); |
| 242 | this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", |
| 243 | cmSystemTools::GetCTestCommand()); |
| 244 | this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", |
| 245 | cmSystemTools::GetCMakeCommand()); |
| 246 | this->UpdateElapsedTime(); |
| 247 | |
| 248 | // set the CTEST_CONFIGURATION_TYPE variable to the current value of the |
| 249 | // the -C argument on the command line. |
| 250 | if (!this->CTest->GetConfigType().empty()) { |
| 251 | this->Makefile->AddDefinition("CTEST_CONFIGURATION_TYPE", |
| 252 | this->CTest->GetConfigType()); |
| 253 | } |
| 254 | |
| 255 | // add the script arg if defined |
| 256 | if (!script_arg.empty()) { |
| 257 | this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg); |
| 258 | } |
| 259 | |
| 260 | // set a callback function to update the elapsed time |
| 261 | this->Makefile->OnExecuteCommand([this] { this->UpdateElapsedTime(); }); |
| 262 | |
| 263 | /* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and |
| 264 | CMakeSystemSpecificInformation, so |
| 265 | that variables like CMAKE_SYSTEM and also the search paths for libraries, |
| 266 | header and executables are set correctly and can be used. Makes new-style |
| 267 | ctest scripting easier. */ |
no test coverage detected