cmCommand.cxx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "cmCommand.h"
  4. #include <utility>
  5. #include "cmExecutionStatus.h"
  6. #include "cmMakefile.h"
  7. struct cmListFileArgument;
  8. void cmCommand::SetExecutionStatus(cmExecutionStatus* status)
  9. {
  10. this->Status = status;
  11. this->Makefile = &status->GetMakefile();
  12. }
  13. bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
  14. cmExecutionStatus& status)
  15. {
  16. std::vector<std::string> expandedArguments;
  17. if (!this->Makefile->ExpandArguments(args, expandedArguments)) {
  18. // There was an error expanding arguments. It was already
  19. // reported, so we can skip this command without error.
  20. return true;
  21. }
  22. return this->InitialPass(expandedArguments, status);
  23. }
  24. void cmCommand::SetError(const std::string& e)
  25. {
  26. this->Status->SetError(e);
  27. }
  28. cmLegacyCommandWrapper::cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd)
  29. : Command(std::move(cmd))
  30. {
  31. }
  32. cmLegacyCommandWrapper::cmLegacyCommandWrapper(
  33. cmLegacyCommandWrapper const& other)
  34. : Command(other.Command->Clone())
  35. {
  36. }
  37. cmLegacyCommandWrapper& cmLegacyCommandWrapper::operator=(
  38. cmLegacyCommandWrapper const& other)
  39. {
  40. this->Command = other.Command->Clone();
  41. return *this;
  42. }
  43. bool cmLegacyCommandWrapper::operator()(
  44. std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) const
  45. {
  46. auto cmd = this->Command->Clone();
  47. cmd->SetExecutionStatus(&status);
  48. return cmd->InvokeInitialPass(args, status);
  49. }