cmCustomCommandGenerator.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2010 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCustomCommandGenerator.h"
  11. #include "cmMakefile.h"
  12. #include "cmCustomCommand.h"
  13. #include "cmLocalGenerator.h"
  14. //----------------------------------------------------------------------------
  15. cmCustomCommandGenerator::cmCustomCommandGenerator(
  16. cmCustomCommand const& cc, const char* config, cmMakefile* mf):
  17. CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
  18. OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars())
  19. {
  20. }
  21. //----------------------------------------------------------------------------
  22. unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
  23. {
  24. return static_cast<unsigned int>(this->CC.GetCommandLines().size());
  25. }
  26. //----------------------------------------------------------------------------
  27. std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
  28. {
  29. std::string const& argv0 = this->CC.GetCommandLines()[c][0];
  30. return this->LG->GetRealLocation(argv0.c_str(), this->Config);
  31. }
  32. //----------------------------------------------------------------------------
  33. void
  34. cmCustomCommandGenerator
  35. ::AppendArguments(unsigned int c, std::string& cmd) const
  36. {
  37. cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
  38. for(unsigned int j=1;j < commandLine.size(); ++j)
  39. {
  40. std::string const& arg = commandLine[j];
  41. cmd += " ";
  42. if(this->OldStyle)
  43. {
  44. cmd += this->LG->EscapeForShellOldStyle(arg.c_str());
  45. }
  46. else
  47. {
  48. cmd += this->LG->EscapeForShell(arg.c_str(), this->MakeVars);
  49. }
  50. }
  51. }