mirror of https://gitlab.com/basile.b/dexed.git
#10, get file list for curr conf
- still missing: exclusions + mainSourceFile
This commit is contained in:
parent
612b30c1a5
commit
5fd10645ac
|
|
@ -25,6 +25,7 @@ type
|
||||||
fBuiltTypeIx: integer;
|
fBuiltTypeIx: integer;
|
||||||
fConfigIx: integer;
|
fConfigIx: integer;
|
||||||
fBinKind: TProjectBinaryKind;
|
fBinKind: TProjectBinaryKind;
|
||||||
|
fBasePath: string;
|
||||||
//
|
//
|
||||||
procedure updateFields;
|
procedure updateFields;
|
||||||
procedure udpateConfigsFromJson;
|
procedure udpateConfigsFromJson;
|
||||||
|
|
@ -32,6 +33,7 @@ type
|
||||||
procedure updateTargetKindFromJson;
|
procedure updateTargetKindFromJson;
|
||||||
function findTargetKindIn(value: TJSONObject): boolean;
|
function findTargetKindIn(value: TJSONObject): boolean;
|
||||||
procedure dubProcOutput(proc: TProcess);
|
procedure dubProcOutput(proc: TProcess);
|
||||||
|
function getCurrentCustomConfig: TJSONObject;
|
||||||
//
|
//
|
||||||
function getFormat: TCEProjectFormat;
|
function getFormat: TCEProjectFormat;
|
||||||
function getProject: TObject;
|
function getProject: TObject;
|
||||||
|
|
@ -58,6 +60,7 @@ type
|
||||||
function run(const runArgs: string = ''): boolean;
|
function run(const runArgs: string = ''): 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
|
||||||
|
|
@ -130,11 +133,27 @@ begin
|
||||||
exit(fFilename);
|
exit(fFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCEDubProject.getCurrentCustomConfig: TJSONObject;
|
||||||
|
var
|
||||||
|
item: TJSONData;
|
||||||
|
confs: TJSONArray;
|
||||||
|
begin
|
||||||
|
result := nil;
|
||||||
|
if fConfigIx = 0 then exit;
|
||||||
|
//
|
||||||
|
item := fJSON.Find('configurations');
|
||||||
|
if item = nil then exit;
|
||||||
|
//
|
||||||
|
confs := TJSONArray(item);
|
||||||
|
if fConfigIx > confs.Count -1 then exit;
|
||||||
|
//
|
||||||
|
result := confs.Objects[fConfigIx];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEDubProject.udpateConfigsFromJson;
|
procedure TCEDubProject.udpateConfigsFromJson;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
builtTypes: TJSONArray = nil;
|
arr: TJSONArray = nil;
|
||||||
configs: TJSONArray = nil;
|
|
||||||
item: TJSONObject = nil;
|
item: TJSONObject = nil;
|
||||||
itemname: string;
|
itemname: string;
|
||||||
begin
|
begin
|
||||||
|
|
@ -147,26 +166,26 @@ begin
|
||||||
|
|
||||||
if fJSON.Find('configurations') <> nil then
|
if fJSON.Find('configurations') <> nil then
|
||||||
begin
|
begin
|
||||||
configs := fJSON.Arrays['configurations'];
|
arr := fJSON.Arrays['configurations'];
|
||||||
for i:= 0 to configs.Count-1 do
|
for i:= 0 to arr.Count-1 do
|
||||||
begin
|
begin
|
||||||
item := TJSONObject(configs.Items[i]);
|
item := TJSONObject(arr.Items[i]);
|
||||||
fConfigs.Add(item.Strings['name']);
|
fConfigs.Add(item.Strings['name']);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
fConfigs.Add('(dub default)'); // default
|
fConfigs.Add('(dub default)');
|
||||||
// default = what dub set as 'application' or 'library'
|
// default = what dub set as 'application' or 'library'
|
||||||
// in this case a project will pass nothing to DUB: eg DUB --build=release
|
// in this case Coedit will pass only the type to DUB: 'DUB --build=release'
|
||||||
end;
|
end;
|
||||||
|
|
||||||
fBuildTypes.AddStrings(DubBuiltTypeName);
|
fBuildTypes.AddStrings(DubBuiltTypeName);
|
||||||
if fJSON.Find('buildTypes') <> nil then
|
if fJSON.Find('buildTypes') <> nil then
|
||||||
begin
|
begin
|
||||||
builtTypes := fJSON.Arrays['buildTypes'];
|
arr := fJSON.Arrays['buildTypes'];
|
||||||
for i := 0 to builtTypes.Count-1 do
|
for i := 0 to arr.Count-1 do
|
||||||
begin
|
begin
|
||||||
item := TJSONObject(builtTypes.Items[i]);
|
item := TJSONObject(arr.Items[i]);
|
||||||
itemname := item.Strings['name'];
|
itemname := item.Strings['name'];
|
||||||
// defaults build types can be overridden
|
// defaults build types can be overridden
|
||||||
if fBuildTypes.IndexOf(itemname) <> -1 then continue;
|
if fBuildTypes.IndexOf(itemname) <> -1 then continue;
|
||||||
|
|
@ -177,8 +196,81 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEDubProject.updateSourcesFromJson;
|
procedure TCEDubProject.updateSourcesFromJson;
|
||||||
|
var
|
||||||
|
lst: TStringList;
|
||||||
|
item: TJSONData;
|
||||||
|
conf: TJSONObject;
|
||||||
|
arr: TJSONArray;
|
||||||
|
i: integer;
|
||||||
|
procedure tryAddFromFolder(const pth: string);
|
||||||
|
var
|
||||||
|
abs: string;
|
||||||
begin
|
begin
|
||||||
//TODO-cDUB: update the source files for the current configuration
|
if DirectoryExists(pth) then
|
||||||
|
begin
|
||||||
|
lst.Clear;
|
||||||
|
listFiles(lst, pth, true);
|
||||||
|
for abs in lst do
|
||||||
|
if isDlangCompilable(extractFileExt(abs)) then
|
||||||
|
fSrcs.Add(ExtractRelativepath(fBasePath, abs));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
fSrcs.Clear;
|
||||||
|
lst := TStringList.Create;
|
||||||
|
try
|
||||||
|
// auto folders
|
||||||
|
tryAddFromFolder(fBasePath + 'src');
|
||||||
|
tryAddFromFolder(fBasePath + 'source');
|
||||||
|
// custom folders
|
||||||
|
item := fJSON.Find('sourcePaths');
|
||||||
|
if item <> nil then
|
||||||
|
begin
|
||||||
|
arr := TJSONArray(item);
|
||||||
|
for i := 0 to arr.Count-1 do
|
||||||
|
begin
|
||||||
|
tryAddFromFolder(fBasePath + arr.Strings[i]);
|
||||||
|
tryAddFromFolder(arr.Strings[i]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// custom files
|
||||||
|
item := fJSON.Find('sourceFiles');
|
||||||
|
if item <> nil then
|
||||||
|
begin
|
||||||
|
arr := TJSONArray(item);
|
||||||
|
for i := 0 to arr.Count-1 do
|
||||||
|
fSrcs.Add(ExtractRelativepath(fBasePath, arr.Strings[i]));
|
||||||
|
end;
|
||||||
|
conf := getCurrentCustomConfig;
|
||||||
|
if conf <> nil then
|
||||||
|
begin
|
||||||
|
// custom folders in current config
|
||||||
|
item := conf.Find('sourcePaths');
|
||||||
|
if item <> nil then
|
||||||
|
begin
|
||||||
|
arr := TJSONArray(item);
|
||||||
|
for i := 0 to arr.Count-1 do
|
||||||
|
begin
|
||||||
|
tryAddFromFolder(fBasePath + arr.Strings[i]);
|
||||||
|
tryAddFromFolder(arr.Strings[i]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// custom files in current config
|
||||||
|
item := conf.Find('sourceFiles');
|
||||||
|
if item <> nil then
|
||||||
|
begin
|
||||||
|
arr := TJSONArray(item);
|
||||||
|
for i := 0 to arr.Count-1 do
|
||||||
|
fSrcs.Add(ExtractRelativepath(fBasePath, arr.Strings[i]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
//
|
||||||
|
deleteDups(fSrcs);
|
||||||
|
// TODO-cDUB: manage exclusions from 'excludedSourceFiles' (global + curr conf)
|
||||||
|
// + mainSourceFile.
|
||||||
|
finally
|
||||||
|
lst.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCEDubProject.findTargetKindIn(value: TJSONObject): boolean;
|
function TCEDubProject.findTargetKindIn(value: TJSONObject): boolean;
|
||||||
|
|
@ -202,27 +294,15 @@ end;
|
||||||
procedure TCEDubProject.updateTargetKindFromJson;
|
procedure TCEDubProject.updateTargetKindFromJson;
|
||||||
var
|
var
|
||||||
guess: boolean = false;
|
guess: boolean = false;
|
||||||
item: TJSONData;
|
conf: TJSONObject;
|
||||||
confs: TJSONArray;
|
|
||||||
i: integer;
|
|
||||||
begin
|
begin
|
||||||
fBinKind := executable;
|
fBinKind := executable;
|
||||||
if fJSON = nil then exit;
|
if fJSON = nil then exit;
|
||||||
|
// note: in Coedit this is only used to known if output can be launched
|
||||||
// actually for a DUB project this is only used to known if output can be
|
|
||||||
// ran from the 'project' menu
|
|
||||||
guess := not findTargetKindIn(fJSON);
|
guess := not findTargetKindIn(fJSON);
|
||||||
if fConfigIx <> 0 then
|
conf := getCurrentCustomConfig;
|
||||||
begin
|
if conf <> nil then
|
||||||
item := fJSON.Find('configurations');
|
guess := guess and findTargetKindIn(conf);
|
||||||
if item <> nil then
|
|
||||||
begin
|
|
||||||
confs := TJSONArray(item);
|
|
||||||
for i := 0 to confs.Count-1 do
|
|
||||||
if TJSONObject(confs.Objects[i]).Find('name') <> nil then
|
|
||||||
guess := guess and findTargetKindIn(confs.Objects[i]);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if guess then
|
if guess then
|
||||||
begin
|
begin
|
||||||
// TODO-cDUB: guess target kind
|
// TODO-cDUB: guess target kind
|
||||||
|
|
@ -249,6 +329,7 @@ var
|
||||||
begin
|
begin
|
||||||
loader := TMemoryStream.Create;
|
loader := TMemoryStream.Create;
|
||||||
try
|
try
|
||||||
|
fBasePath := extractFilePath(aFilename);
|
||||||
fFilename := aFilename;
|
fFilename := aFilename;
|
||||||
loader.LoadFromFile(fFilename);
|
loader.LoadFromFile(fFilename);
|
||||||
fJSON.Free;
|
fJSON.Free;
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,8 @@ begin
|
||||||
//
|
//
|
||||||
for i:= 0 to fProj.getConfigurationCount -1 do
|
for i:= 0 to fProj.getConfigurationCount -1 do
|
||||||
treeInspect.Items.AddChild(fNodeConfig, fProj.getConfigurationName(i));
|
treeInspect.Items.AddChild(fNodeConfig, fProj.getConfigurationName(i));
|
||||||
|
for i := 0 to fProj.sources.count-1 do
|
||||||
|
treeInspect.Items.AddChild(fNodeSources, fProj.sources.strings[i]);
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue