cmAddCustomCommandCommand.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmAddCustomCommandCommand.h"
  12. // cmAddCustomCommandCommand
  13. bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& argsIn)
  14. {
  15. if (argsIn.size() < 6)
  16. {
  17. this->SetError("called with wrong number of arguments.");
  18. return false;
  19. }
  20. std::vector<std::string> args = argsIn;
  21. if(args[2] != "ARGS")
  22. {
  23. this->SetError("Wrong syntax. The third argument should be ARGS");
  24. return false;
  25. }
  26. int cc=3;
  27. std::vector<std::string> commandArgs;
  28. while(args[cc] != "DEPENDS" && cc < argsIn.size())
  29. {
  30. m_Makefile->ExpandVariablesInString(args[cc]);
  31. commandArgs.push_back(args[cc]);
  32. cc++;
  33. }
  34. if(cc == argsIn.size()-1)
  35. {
  36. this->SetError("Wrong syntax. Missing DEPENDS.");
  37. return false;
  38. }
  39. cc++ ; // Skip DEPENDS
  40. std::vector<std::string> depends;
  41. while(args[cc] != "OUTPUTS" && cc < argsIn.size())
  42. {
  43. m_Makefile->ExpandVariablesInString(args[cc]);
  44. depends.push_back(args[cc]);
  45. cc++;
  46. }
  47. if(cc == argsIn.size()-1)
  48. {
  49. this->SetError("Wrong syntax. Missing OUTPUTS.");
  50. return false;
  51. }
  52. cc ++; // Skip OUTPUTS
  53. std::vector<std::string> outputs;
  54. while(cc < argsIn.size()-1)
  55. {
  56. m_Makefile->ExpandVariablesInString(args[cc]);
  57. outputs.push_back(args[cc]);
  58. cc++;
  59. }
  60. m_Makefile->ExpandVariablesInString(args[0]);
  61. m_Makefile->ExpandVariablesInString(args[1]);
  62. m_Makefile->ExpandVariablesInString(args[argsIn.size()-1]);
  63. m_Makefile->AddCustomCommand(args[0].c_str(),
  64. args[1].c_str(),
  65. commandArgs,
  66. depends,
  67. outputs,
  68. args[argsIn.size()-1].c_str());
  69. return true;
  70. }