cmCTestUpdateCommand.cxx 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "cmCTestUpdateCommand.h"
  4. #include "cmCTest.h"
  5. #include "cmCTestGenericHandler.h"
  6. #include "cmMakefile.h"
  7. #include "cmSystemTools.h"
  8. #include <vector>
  9. cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
  10. {
  11. if (this->Values[ct_SOURCE]) {
  12. this->CTest->SetCTestConfiguration(
  13. "SourceDirectory",
  14. cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
  15. this->Quiet);
  16. } else {
  17. this->CTest->SetCTestConfiguration(
  18. "SourceDirectory",
  19. cmSystemTools::CollapseFullPath(
  20. this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"))
  21. .c_str(),
  22. this->Quiet);
  23. }
  24. std::string source_dir =
  25. this->CTest->GetCTestConfiguration("SourceDirectory");
  26. this->CTest->SetCTestConfigurationFromCMakeVariable(
  27. this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
  28. this->CTest->SetCTestConfigurationFromCMakeVariable(
  29. this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
  30. this->CTest->SetCTestConfigurationFromCMakeVariable(
  31. this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
  32. this->CTest->SetCTestConfigurationFromCMakeVariable(
  33. this->Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS",
  34. this->Quiet);
  35. this->CTest->SetCTestConfigurationFromCMakeVariable(
  36. this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
  37. this->CTest->SetCTestConfigurationFromCMakeVariable(
  38. this->Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS",
  39. this->Quiet);
  40. this->CTest->SetCTestConfigurationFromCMakeVariable(
  41. this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
  42. this->CTest->SetCTestConfigurationFromCMakeVariable(
  43. this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
  44. this->CTest->SetCTestConfigurationFromCMakeVariable(
  45. this->Makefile, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS",
  46. this->Quiet);
  47. this->CTest->SetCTestConfigurationFromCMakeVariable(
  48. this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
  49. this->CTest->SetCTestConfigurationFromCMakeVariable(
  50. this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS",
  51. this->Quiet);
  52. this->CTest->SetCTestConfigurationFromCMakeVariable(
  53. this->Makefile, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES",
  54. this->Quiet);
  55. this->CTest->SetCTestConfigurationFromCMakeVariable(
  56. this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
  57. this->CTest->SetCTestConfigurationFromCMakeVariable(
  58. this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY",
  59. this->Quiet);
  60. this->CTest->SetCTestConfigurationFromCMakeVariable(
  61. this->Makefile, "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
  62. this->CTest->SetCTestConfigurationFromCMakeVariable(
  63. this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
  64. this->CTest->SetCTestConfigurationFromCMakeVariable(
  65. this->Makefile, "P4Command", "CTEST_P4_COMMAND", this->Quiet);
  66. this->CTest->SetCTestConfigurationFromCMakeVariable(
  67. this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
  68. this->CTest->SetCTestConfigurationFromCMakeVariable(
  69. this->Makefile, "P4Client", "CTEST_P4_CLIENT", this->Quiet);
  70. this->CTest->SetCTestConfigurationFromCMakeVariable(
  71. this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
  72. cmCTestGenericHandler* handler =
  73. this->CTest->GetInitializedHandler("update");
  74. if (!handler) {
  75. this->SetError("internal CTest error. Cannot instantiate update handler");
  76. return nullptr;
  77. }
  78. handler->SetCommand(this);
  79. if (source_dir.empty()) {
  80. this->SetError("source directory not specified. Please use SOURCE tag");
  81. return nullptr;
  82. }
  83. handler->SetOption("SourceDirectory", source_dir.c_str());
  84. handler->SetQuiet(this->Quiet);
  85. return handler;
  86. }