cmCTestRunScriptCommand.cxx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCTestRunScriptCommand.h"
  4. #include "cmCTestScriptHandler.h"
  5. #include "cmExecutionStatus.h"
  6. #include "cmMakefile.h"
  7. #include "cmSystemTools.h"
  8. bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
  9. cmExecutionStatus& status) const
  10. {
  11. if (args.empty()) {
  12. status.SetError("called with incorrect number of arguments");
  13. return false;
  14. }
  15. cmMakefile& mf = status.GetMakefile();
  16. bool np = false;
  17. unsigned int i = 0;
  18. if (args[i] == "NEW_PROCESS") {
  19. np = true;
  20. i++;
  21. }
  22. int start = i;
  23. // run each script
  24. std::string returnVariable;
  25. for (i = start; i < args.size(); ++i) {
  26. if (args[i] == "RETURN_VALUE") {
  27. ++i;
  28. if (i < args.size()) {
  29. returnVariable = args[i];
  30. }
  31. }
  32. }
  33. for (i = start; i < args.size(); ++i) {
  34. if (args[i] == "RETURN_VALUE") {
  35. ++i;
  36. } else {
  37. int ret;
  38. cmCTestScriptHandler::RunScript(
  39. this->CTest, &mf, cmSystemTools::CollapseFullPath(args[i]), !np, &ret);
  40. mf.AddDefinition(returnVariable, std::to_string(ret));
  41. }
  42. }
  43. return true;
  44. }