#include <cmt_deps_builder.h>
Public Methods | |
void | clear () |
void | add (const cmt_string& path, const cmt_string& substitution) |
void | add_includes (const Use& use) |
CmtSystem::cmt_string_vector& | run (const cmt_string& file_name) |
Private Attributes | |
CmtSystem::cmt_string_vector | m_include_paths |
CmtSystem::cmt_string_vector | m_substitutions |
CmtSystem::cmt_string_vector | m_deps |
CmtSystem::cmt_string_vector | m_all_deps |
|
Definition at line 624 of file cmt_deps_builder.cxx. Referenced by MakefileGenerator::prepare_use_context(). 00626 { 00627 if (path[path.size () - 1] == CmtSystem::file_separator ()) 00628 { 00629 cmt_string p = path; 00630 p.erase (path.size () - 1); 00631 m_include_paths.push_back (p); 00632 } 00633 else 00634 { 00635 m_include_paths.push_back (path); 00636 } 00637 00638 m_substitutions.push_back (substitution); 00639 } |
|
Definition at line 642 of file cmt_deps_builder.cxx. Referenced by MakefileGenerator::prepare_use_context(). 00644 { 00645 const Include::IncludeVector& includes = use.includes; 00646 int include_number; 00647 00648 for (include_number = 0; 00649 include_number < includes.size (); 00650 include_number++) 00651 { 00652 const Include& include = includes[include_number]; 00653 00654 cmt_string temp = include.name; 00655 cmt_string pattern; 00656 cmt_string name; 00657 char end_pattern; 00658 00659 int start = 0; 00660 00661 for (;;) 00662 { 00663 int begin; 00664 00665 begin = temp.find (start, "${"); 00666 if (begin != cmt_string::npos) 00667 { 00668 end_pattern = '}'; 00669 } 00670 else 00671 { 00672 begin = temp.find (start, "$("); 00673 if (begin != cmt_string::npos) 00674 { 00675 end_pattern = ')'; 00676 } 00677 else 00678 { 00679 break; 00680 } 00681 } 00682 00683 start = begin + 2; 00684 00685 int end; 00686 end = temp.find (start, end_pattern); 00687 if (end == cmt_string::npos) break; 00688 if (end < begin) break; 00689 start = end + 1; 00690 00691 temp.substr (begin, end - begin + 1, pattern); 00692 temp.substr (begin + 2, end - begin - 2, name); 00693 00694 Symbol* macro = Symbol::find (name); 00695 if (macro != 0) 00696 { 00697 cmt_string value = macro->resolve_macro_value (); 00698 value += CmtSystem::file_separator (); 00699 temp.replace_all (pattern, value); 00700 } 00701 else 00702 { 00703 cmt_string value = CmtSystem::getenv (name); 00704 value += CmtSystem::file_separator (); 00705 temp.replace_all (pattern, value); 00706 } 00707 } 00708 add (temp, include.name); 00709 } 00710 } |
|
Definition at line 616 of file cmt_deps_builder.cxx. Referenced by MakefileGenerator::prepare_use_context(). 00618 { 00619 m_include_paths.clear (); 00620 m_substitutions.clear (); 00621 } |
|
Definition at line 713 of file cmt_deps_builder.cxx. 00715 { 00716 m_deps.clear (); 00717 m_all_deps.clear (); 00718 00719 cmt_string preprocessor; 00720 Symbol* macro = Symbol::find ("preprocessor_command"); 00721 if (macro != 0) 00722 { 00723 preprocessor = macro->resolve_macro_value (); 00724 } 00725 00726 if (preprocessor == "") 00727 { 00728 // 00729 // Since no preprocessor command is defined, 00730 // we use the internal mechanism provided here. 00731 // 00732 cmt_string new_dir; 00733 00734 CmtSystem::dirname (file_name, new_dir); 00735 00736 build_deps (file_name, 00737 new_dir, 00738 0, 00739 m_include_paths, 00740 m_substitutions, 00741 m_all_deps, 00742 m_deps); 00743 } 00744 else 00745 { 00746 // 00747 // An external preprocessor command is defined. We expect it 00748 // to follow a "standard" syntax for its output, ie: 00749 // o It starts with: 00750 // <module>.o: ... 00751 // o There may be many lines with trailing back-slashes 00752 // o All entries are space-separated 00753 // o One of the entries is the source file name itself 00754 // 00755 // The preprocessor command expects the list of -I options 00756 // (resolved from the "includes" macro) and the list of 00757 // -D/-U options (resolved from the "*_pp_*flags" macros) 00758 // 00759 00760 // 00761 // Building the complete command (still the pp_*flags are 00762 // missing) 00763 // 00764 preprocessor += " "; 00765 macro = Symbol::find ("includes"); 00766 preprocessor += macro->resolve_macro_value (); 00767 preprocessor += " "; 00768 preprocessor += file_name; 00769 00770 cmt_string output; 00771 00772 CmtSystem::execute (preprocessor, output); 00773 00774 // 00775 // Make the output as one single big line. 00776 // 00777 00778 output.replace_all ("\n", " "); 00779 output.replace_all ("\\ ", " "); 00780 00781 CmtSystem::cmt_string_vector files; 00782 00783 CmtSystem::split (output, " \t", files); 00784 00785 // 00786 // Analyze each entry 00787 // 00788 00789 for (int i = 1; i < files.size (); i++) 00790 { 00791 const cmt_string& file = files[i]; 00792 if (file == file_name) continue; 00793 00794 cmt_string dir; 00795 cmt_string name; 00796 cmt_string full_name; 00797 00798 CmtSystem::dirname (file, dir); 00799 00800 // 00801 // Only declared include_paths will be taken into account 00802 // Others are considered as system include paths. 00803 // 00804 00805 for (int j = 0; j < m_include_paths.size (); j++) 00806 { 00807 const cmt_string& p = m_include_paths[j]; 00808 if (dir == p) 00809 { 00810 CmtSystem::basename (file, name); 00811 full_name = m_substitutions[j]; 00812 full_name += name; 00813 00814 // 00815 // We add in the "m_deps" list the symbolic form 00816 // of the path rather that the expanded one. 00817 // 00818 00819 m_deps.push_back (full_name); 00820 00821 break; 00822 } 00823 } 00824 } 00825 } 00826 00827 return (m_deps); 00828 } |
|
Definition at line 22 of file cmt_deps_builder.h. |
|
Definition at line 21 of file cmt_deps_builder.h. |
|
Definition at line 18 of file cmt_deps_builder.h. |
|
Definition at line 19 of file cmt_deps_builder.h. |