cmSourceGroup.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmSourceGroup_h
  14. #define cmSourceGroup_h
  15. #include "cmStandardIncludes.h"
  16. #include "cmRegularExpression.h"
  17. #include "cmCustomCommand.h"
  18. class cmSourceFile;
  19. /** \class cmSourceGroup
  20. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  21. *
  22. * cmSourceGroup holds all the source files and corresponding commands
  23. * for files matching the regular expression specified for the group.
  24. */
  25. class cmSourceGroup
  26. {
  27. public:
  28. cmSourceGroup(const char* name, const char* regex);
  29. cmSourceGroup(const cmSourceGroup&);
  30. ~cmSourceGroup() {}
  31. struct CommandFiles
  32. {
  33. CommandFiles() {}
  34. CommandFiles(const CommandFiles& r):
  35. m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {}
  36. void Merge(const CommandFiles &r);
  37. std::string m_Command;
  38. std::string m_Arguments;
  39. std::set<std::string> m_Outputs;
  40. std::set<std::string> m_Depends;
  41. };
  42. /**
  43. * Map from command to its output/depends sets.
  44. */
  45. typedef std::map<cmStdString, CommandFiles> Commands;
  46. struct SourceAndCommands
  47. {
  48. SourceAndCommands(): m_SourceFile(0) {}
  49. const cmSourceFile* m_SourceFile;
  50. Commands m_Commands;
  51. };
  52. /**
  53. * Map from source to command map.
  54. */
  55. typedef std::map<cmStdString, SourceAndCommands> BuildRules;
  56. bool Matches(const char* name);
  57. void SetGroupRegex(const char* regex)
  58. { m_GroupRegex.compile(regex); }
  59. void AddSource(const char* name, const cmSourceFile*);
  60. void AddCustomCommand(const cmCustomCommand &cmd);
  61. const char* GetName() const
  62. { return m_Name.c_str(); }
  63. const BuildRules& GetBuildRules() const
  64. { return m_BuildRules; }
  65. void Print() const;
  66. private:
  67. /**
  68. * The name of the source group.
  69. */
  70. std::string m_Name;
  71. /**
  72. * The regular expression matching the files in the group.
  73. */
  74. cmRegularExpression m_GroupRegex;
  75. /**
  76. * Map from source name to the commands to build from the source.
  77. * Some commands may build from files that the compiler also knows how to
  78. * build.
  79. */
  80. BuildRules m_BuildRules;
  81. };
  82. #endif