Index: ide/Builders/Builders.h =================================================================== --- ide/Builders/Builders.h (revisione 15939) +++ ide/Builders/Builders.h (copia di lavoro) @@ -30,6 +30,7 @@ void OnFinish(Event<> cb); bool Cp(const String& cmd, const String& package, bool& error); bool Cd(const String& cmd); + Vector CustomStep(const String& path, const String& package, bool& error); String Includes(const char *sep, const String& package, const Package& pkg); Index: ide/Builders/CppBuilder.cpp =================================================================== --- ide/Builders/CppBuilder.cpp (revisione 15939) +++ ide/Builders/CppBuilder.cpp (copia di lavoro) @@ -245,18 +245,30 @@ return out; } -void ExtExclude(CParser& p, Index& x) +static bool CheckImportCondition(CParser &p, Vector const &flag) { + // no condition == true + if(!p.IsChar('(')) + return true; + String s = ReadWhen(p); + return MatchWhen(s, flag); +} + +static void ExtExclude(CParser& p, Index& x, Vector const &flag) +{ + bool apply = CheckImportCondition(p, flag); Vector e = ReadPatterns(p); - Vector remove; - for(int i = 0; i < x.GetCount(); i++) - for(int j = 0; j < e.GetCount(); j++) { - if(PatternMatch(e[j], x[i])) { - remove.Add(i); - break; + if(apply) { + Vector remove; + for(int i = 0; i < x.GetCount(); i++) + for(int j = 0; j < e.GetCount(); j++) { + if(PatternMatch(e[j], x[i])) { + remove.Add(i); + break; + } } - } - x.Remove(remove); + x.Remove(remove); + } } Vector CppBuilder::CustomStep(const String& pf, const String& package_, bool& error) @@ -268,6 +280,7 @@ if(ext == ".ext") { Vector files; Vector dirs; + Vector const &flags = config.GetKeys(); sGatherAllExt(files, dirs, GetFileFolder(path), ""); Index pkg_files; @@ -283,43 +296,52 @@ CParser p(f); while(!p.IsEof()) { if(p.Id("files")) { + bool apply = CheckImportCondition(p, flags); Vector e = ReadPatterns(p); - for(int i = 0; i < files.GetCount(); i++) - for(int j = 0; j < e.GetCount(); j++) { - String f = files[i]; - if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) - out.FindAdd(f); - } + if(apply) { + for(int i = 0; i < files.GetCount(); i++) + for(int j = 0; j < e.GetCount(); j++) { + String f = files[i]; + if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) + out.FindAdd(f); + } + } } if(p.Id("exclude")) { - ExtExclude(p, out); + ExtExclude(p, out, flags); } if(p.Id("include_path")) { + bool apply = CheckImportCondition(p, flags); Vector e = ReadPatterns(p); - for(int j = 0; j < e.GetCount(); j++) { - String ee = e[j]; - if(ee.Find('*') >= 0) - for(int i = 0; i < dirs.GetCount(); i++) { - String d = dirs[i]; - if(PatternMatch(e[j], d)) { - include_path.FindAdd(d); + if(apply) { + for(int j = 0; j < e.GetCount(); j++) { + String ee = e[j]; + if(ee.Find('*') >= 0) + for(int i = 0; i < dirs.GetCount(); i++) { + String d = dirs[i]; + if(PatternMatch(e[j], d)) { + include_path.FindAdd(d); + } } - } - else - include_path.Add(ee); + else + include_path.Add(ee); + } } } if(p.Id("exclude_path")) { - ExtExclude(p, include_path); + ExtExclude(p, include_path, flags); } if(p.Id("includes")) { + bool apply = CheckImportCondition(p, flags); Vector e = ReadPatterns(p); - for(int i = 0; i < files.GetCount(); i++) - for(int j = 0; j < e.GetCount(); j++) { - String f = files[i]; - if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) - include_path.FindAdd(GetFileFolder(f)); - } + if(apply) { + for(int i = 0; i < files.GetCount(); i++) + for(int j = 0; j < e.GetCount(); j++) { + String f = files[i]; + if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) + include_path.FindAdd(GetFileFolder(f)); + } + } } } }