void GatherSources(const String& master_path, const String& path_, Vector<int>& parents) { RHITCOUNT("GatherSources"); String path = NormalizeSourcePath(path_); if(sSrcFile.Find(path) >= 0) return; int ii = sSrcFile.GetCount(); for(int i = 0; i < parents.GetCount(); i++) sIncludes.Add(MAKEQWORD(parents[i], ii)); sSrcFile.Add(path, master_path); parents.Add(ii); const PPFile& f = GetPPFile(path); for(int i = 0; i < f.includes.GetCount(); i++) { String p = GetIncludePath(f.includes[i], GetFileFolder(path)); if(p.GetCount()) GatherSources(master_path, p, parents); } parents.Drop(); }
const FlatPP& GetFlatPPFile(const char *path, Index<String>& visited) { LTIMING("GetFlatPPFile"); LLOG("GetFlatPPFile " << path); int q = sFlatPP.Find(path); if(q >= 0) { LLOG("From cache"); return sFlatPP[q]; } FlatPP& fp = sFlatPP.Add(path); const PPFile& pp = GetPPFile(path); int n = visited.GetCount(); visited.FindAdd(path); for(int i = 0; i < pp.item.GetCount(); i++) { const PPItem& m = pp.item[i]; if(m.type == PP_INCLUDE) { String s = GetIncludePath(m.text, GetFileFolder(path)); LLOG("#include " << m.text << " -> " << s); if(s.GetCount() && visited.Find(s) < 0) { visited.Add(s); const FlatPP& pp = GetFlatPPFile(s, visited); for(int i = 0; i < pp.segment_id.GetCount(); i++) fp.segment_id.FindAdd(pp.segment_id[i]); for(int i = 0; i < pp.usings.GetCount(); i++) fp.usings.FindAdd(pp.usings[i]); } } else if(m.type == PP_DEFINES) fp.segment_id.FindAdd(m.segment_id); else if(m.type == PP_USING) fp.usings.FindAdd(m.text); } visited.Trim(n); return fp; }