[2] | 1 | //----------------------------------------------------------- |
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | // arnault@lal.in2p3.fr |
---|
[663] | 4 | // Modified by Grigory Rybkin |
---|
[2] | 5 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 6 | //----------------------------------------------------------- |
---|
| 7 | |
---|
| 8 | #ifndef __cmt_deps_builder_h__ |
---|
| 9 | #define __cmt_deps_builder_h__ |
---|
| 10 | |
---|
| 11 | #include "cmt.h" |
---|
| 12 | #include "cmt_system.h" |
---|
[427] | 13 | #include "cmt_use.h" |
---|
[2] | 14 | |
---|
| 15 | class DepsBuilder |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | |
---|
[427] | 19 | class HeaderFilter |
---|
| 20 | { |
---|
| 21 | public: |
---|
| 22 | |
---|
| 23 | HeaderFilter () |
---|
| 24 | : m_use (0), m_filter (0) { } |
---|
| 25 | |
---|
[588] | 26 | HeaderFilter (const Use* use, cmt_regexp* filter, const cmt_string& stamp) |
---|
[427] | 27 | : m_use (use), m_filter (filter), m_stamp (stamp) { } |
---|
| 28 | |
---|
| 29 | ~HeaderFilter () |
---|
| 30 | { } |
---|
| 31 | |
---|
| 32 | inline const Use* use () const |
---|
| 33 | { return m_use; } |
---|
| 34 | |
---|
| 35 | inline bool use_stamp (const cmt_string& header, cmt_string& stamp) const |
---|
| 36 | { return m_filter->match (header) ? stamp = m_stamp, true : false ; } |
---|
| 37 | |
---|
| 38 | void clear () |
---|
| 39 | { |
---|
| 40 | m_use = 0; |
---|
[588] | 41 | if (m_filter) |
---|
| 42 | { |
---|
| 43 | m_filter->clear (); |
---|
| 44 | delete m_filter; |
---|
| 45 | } |
---|
[427] | 46 | m_filter = 0; |
---|
| 47 | m_stamp = cmt_string (); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | private: |
---|
| 51 | |
---|
| 52 | const Use* m_use; |
---|
[588] | 53 | cmt_regexp* m_filter; |
---|
[427] | 54 | cmt_string m_stamp; |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | typedef cmt_vector<HeaderFilter> HeaderFilters; |
---|
| 58 | |
---|
[2] | 59 | void clear (); |
---|
| 60 | void add (const cmt_string& path, const cmt_string& substitution); |
---|
| 61 | void add_includes (const Use& use); |
---|
[588] | 62 | void add_header_filter (const Use* use, cmt_regexp* filter, const cmt_string& stamp); |
---|
[427] | 63 | void add_header_filter (const HeaderFilter& hf); |
---|
[588] | 64 | CmtSystem::cmt_string_vector& run (const cmt_string& file_name, |
---|
| 65 | const cmt_string& constituent_name); |
---|
[2] | 66 | |
---|
[588] | 67 | DepsBuilder (); |
---|
| 68 | ~DepsBuilder (); |
---|
[427] | 69 | |
---|
[2] | 70 | private: |
---|
| 71 | |
---|
[588] | 72 | DepsBuilder (const DepsBuilder&); |
---|
| 73 | DepsBuilder& operator = (const DepsBuilder&); |
---|
[427] | 74 | |
---|
[2] | 75 | CmtSystem::cmt_string_vector m_include_paths; |
---|
| 76 | CmtSystem::cmt_string_vector m_substitutions; |
---|
[427] | 77 | HeaderFilters m_header_filters; |
---|
[2] | 78 | CmtSystem::cmt_string_vector m_deps; |
---|
| 79 | CmtSystem::cmt_string_vector m_all_deps; |
---|
| 80 | |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | #endif |
---|