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) @@ -235,6 +235,55 @@ } } +// gather files based on pattern -- pattern should be normalized +// if pattern doesn't contain wildcards is taken as a file name +static void sGatherFiles(Index &files, const String &pattern) +{ + if(!HasWildcards(pattern)) + { + if(FileExists(pattern)) + files.FindAdd(pattern); + return; + } + FindFile ff(pattern); + while(ff) + { + if(ff.IsFile()) + files.FindAdd(ff.GetPath()); + ff.Next(); + } + ff.Search(AppendFileName(GetFileFolder(pattern), "*.*")); + while(ff) + { + if(ff.IsFolder()) + sGatherFiles(files, AppendFileName(ff.GetPath(), GetFileName(pattern))); + ff.Next(); + } +} + +// gather folders based on pattern -- pattern should be normalized +// if pattern doesn't contain wildcards is taken as a folder name +static void sGatherFolders(Index &folders, const String &pattern) +{ + if(pattern.Find("*") < 0) + { + if(DirectoryExists(pattern)) + folders.FindAdd(pattern); + return; + } + String pth = GetFileFolder(pattern); + String pat = GetFileName(pattern); + if(DirectoryExists(pth)) + folders.FindAdd(pth); + FindFile ff(pattern); + while(ff) + { + if(ff.IsFolder()) + sGatherFolders(folders, AppendFileName(ff.GetPath(), pat)); + ff.Next(); + } +} + Vector ReadPatterns(CParser& p) { Vector out; @@ -245,18 +294,32 @@ 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, String const &packageFolder, 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) { + for(int i = 0; i < e.GetCount(); i++) + e[i] = NormalizePath(e[i], packageFolder); + 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) @@ -266,9 +329,12 @@ String file = path; String ext = ToLower(GetFileExt(pf)); if(ext == ".ext") { - Vector files; - Vector dirs; - sGatherAllExt(files, dirs, GetFileFolder(path), ""); +// Vector files; +// Vector dirs; + Vector const &flags = config.GetKeys(); + +// sGatherAllExt(files, dirs, GetFileFolder(path), ""); + String packageFolder = GetFileFolder(path); Index pkg_files; Package pkg; @@ -283,43 +349,49 @@ 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++) { + if(apply) { + Index files; + for(int iPat = 0; iPat < e.GetCount(); iPat++) + sGatherFiles(files, NormalizePath(e[iPat], packageFolder)); + for(int i = 0; i < files.GetCount(); i++) + { String f = files[i]; - if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) + if(pkg_files.Find(f) < 0) out.FindAdd(f); } + } } if(p.Id("exclude")) { - ExtExclude(p, out); + ExtExclude(p, packageFolder, 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); - } - } - else - include_path.Add(ee); + if(apply) { + Index dirs; + for(int iPat = 0; iPat < e.GetCount(); iPat++) + sGatherFolders(dirs, NormalizePath(e[iPat], packageFolder)); + for(int i = 0; i < dirs.GetCount(); i++) { + String d = dirs[i]; + include_path.FindAdd(d); + } } } if(p.Id("exclude_path")) { - ExtExclude(p, include_path); + ExtExclude(p, packageFolder, 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) { + Index files; + for(int iPat = 0; iPat < e.GetCount(); iPat++) + sGatherFiles(files, NormalizePath(e[iPat], packageFolder)); + for(int i = 0; i < files.GetCount(); i++) + include_path.FindAdd(GetFileFolder(files[i])); + } } } } @@ -330,7 +402,7 @@ } for(int i = 0; i < include_path.GetCount(); i++) - include.Add(NormalizePath(include_path[i], GetFileFolder(path))); + include.Add(include_path[i]); Vector o; for(int i = 0; i < out.GetCount(); i++) Index: ide/Builders/GccBuilder.cpp =================================================================== --- ide/Builders/GccBuilder.cpp (revisione 15939) +++ ide/Builders/GccBuilder.cpp (copia di lavoro) @@ -34,6 +34,27 @@ throw Exc(Format("Error compiling binary object '%s'.", objfile)); } +static String sSourceToObjName(String const &sName) +{ + String unixName = UnixPath(sName); + const char *s = ~unixName; + String res; + while(*s++) + { + if(*s == '/') + res.Cat('_'); + else if(*s == '.' && *(s+1) == '.') + { + res.Cat('_'); + res.Cat('_'); + s++; + } + else + res.Cat(*s); + } + return res; +} + bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, Vector& immfile, String& linkoptions, const Vector& all_uses, const Vector& all_libraries, int opt) @@ -234,7 +255,7 @@ bool rc = (ext == ".rc"); bool brc = (ext == ".brc"); bool init = (i >= first_ifile); - String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.o" : brc ? "$brc.o" : ".o")); + String objfile = CatAnyPath(outdir, sSourceToObjName(fn)) + (rc ? "$rc.o" : brc ? "$brc.o" : ".o"); if(GetFileName(fn) == "Info.plist") Info_plist = LoadFile(fn); if(HdependFileTime(fn) > GetFileTime(objfile)) {