#10, manage exclusions (exact match only)

This commit is contained in:
Basile Burg 2015-09-23 03:37:35 +02:00
parent da958707dd
commit e3b15f84f9
1 changed files with 30 additions and 11 deletions

View File

@ -77,7 +77,6 @@ type
function targetUpToDate: boolean; function targetUpToDate: boolean;
// //
property json: TJSONObject read fJSON; property json: TJSONObject read fJSON;
//property sources: TStringList read fSrcs;
end; end;
// these 9 built types always exist // these 9 built types always exist
@ -184,7 +183,7 @@ begin
loader.Position:= 0; loader.Position:= 0;
// //
fJSON.Free; fJSON.Free;
parser := TJSONParser.Create(loader, false); parser := TJSONParser.Create(loader);
try try
fJSON := parser.Parse as TJSONObject; fJSON := parser.Parse as TJSONObject;
finally finally
@ -434,8 +433,8 @@ begin
fBuildTypes.Clear; fBuildTypes.Clear;
fConfigs.Clear; fConfigs.Clear;
// the CE interface for dub doesn't make a difference betwenn build type and config // the CE interface for dub doesn't make the difference between build type
// instead, each possible combination type+build is generated. //and config, instead each possible combination type + build is generated.
if fJSON.Find('configurations') <> nil then if fJSON.Find('configurations') <> nil then
begin begin
@ -474,8 +473,19 @@ var
item: TJSONData; item: TJSONData;
conf: TJSONObject; conf: TJSONObject;
arr: TJSONArray; arr: TJSONArray;
i, j: integer;
procedure getExclusion(from: TJSONObject);
var
i: integer; i: integer;
begin
item := from.Find('excludedSourceFiles');
if assigned(item) and (item.JSONType = jtArray) then
begin
arr := TJSONArray(item);
for i := 0 to arr.Count-1 do
lst.Add(patchPlateformPath(arr.Strings[i]));
end;
end;
procedure tryAddFromFolder(const pth: string); procedure tryAddFromFolder(const pth: string);
var var
abs: string; abs: string;
@ -498,7 +508,7 @@ begin
// auto folders & files // auto folders & files
item := fJSON.Find('mainSourceFile'); item := fJSON.Find('mainSourceFile');
if assigned(item) then if assigned(item) then
fSrcs.Add(ExtractRelativepath(fBasePath, item.AsString)); fSrcs.Add(patchPlateformPath(ExtractRelativepath(fBasePath, item.AsString)));
tryAddFromFolder(fBasePath + 'src'); tryAddFromFolder(fBasePath + 'src');
tryAddFromFolder(fBasePath + 'source'); tryAddFromFolder(fBasePath + 'source');
// custom folders // custom folders
@ -521,14 +531,14 @@ begin
begin begin
arr := TJSONArray(item); arr := TJSONArray(item);
for i := 0 to arr.Count-1 do for i := 0 to arr.Count-1 do
fSrcs.Add(ExtractRelativepath(fBasePath, arr.Strings[i])); fSrcs.Add(patchPlateformPath(ExtractRelativepath(fBasePath, arr.Strings[i])));
end; end;
conf := getCurrentCustomConfig; conf := getCurrentCustomConfig;
if assigned(conf) then if assigned(conf) then
begin begin
item := conf.Find('mainSourceFile'); item := conf.Find('mainSourceFile');
if assigned(item) then if assigned(item) then
fSrcs.Add(ExtractRelativepath(fBasePath, item.AsString)); fSrcs.Add(patchPlateformPath(ExtractRelativepath(fBasePath, item.AsString)));
// custom folders in current config // custom folders in current config
item := conf.Find('sourcePaths'); item := conf.Find('sourcePaths');
if assigned(item) then if assigned(item) then
@ -549,12 +559,21 @@ begin
begin begin
arr := TJSONArray(item); arr := TJSONArray(item);
for i := 0 to arr.Count-1 do for i := 0 to arr.Count-1 do
fSrcs.Add(ExtractRelativepath(fBasePath, arr.Strings[i])); fSrcs.Add(patchPlateformPath(ExtractRelativepath(fBasePath, arr.Strings[i])));
end; end;
end; end;
//
deleteDups(fSrcs); deleteDups(fSrcs);
// TODO-cDUB: manage exclusions from 'excludedSourceFiles' (global + curr conf) // exclusions
lst.Clear;
getExclusion(fJSON);
conf := getCurrentCustomConfig;
if assigned(conf) then
getExclusion(conf);
for i := fSrcs.Count-1 downto 0 do
for j := 0 to lst.Count-1 do
if SameFileName(fSrcs[i], lst[j]) then
fSrcs.Delete(i);
// TODO-cDUB: manage exclusions with http://dlang.org/phobos/std_path.html#.globMatch
finally finally
lst.Free; lst.Free;
end; end;