mirror of https://gitlab.com/basile.b/dexed.git
fix #406 - Should remember the DUB configuration and buildType
This commit is contained in:
parent
92cf60b04b
commit
3734a3e222
|
@ -110,6 +110,7 @@ type
|
||||||
private
|
private
|
||||||
fIsSdl: boolean;
|
fIsSdl: boolean;
|
||||||
fInGroup: boolean;
|
fInGroup: boolean;
|
||||||
|
fHasLoaded: boolean;
|
||||||
fDubProc: TDexedProcess;
|
fDubProc: TDexedProcess;
|
||||||
fPreCompilePath: string;
|
fPreCompilePath: string;
|
||||||
fPackageName: string;
|
fPackageName: string;
|
||||||
|
@ -146,18 +147,20 @@ type
|
||||||
procedure dubProcTerminated(proc: TObject);
|
procedure dubProcTerminated(proc: TObject);
|
||||||
function getCurrentCustomConfig: TJSONObject;
|
function getCurrentCustomConfig: TJSONObject;
|
||||||
procedure executeDub(command: TDubCommand; const runArgs: string = '');
|
procedure executeDub(command: TDubCommand; const runArgs: string = '');
|
||||||
|
procedure restorePersistentConfigId;
|
||||||
|
procedure storePersistentConfigId;
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
//
|
|
||||||
procedure beginModification;
|
procedure beginModification;
|
||||||
procedure endModification;
|
procedure endModification;
|
||||||
//
|
|
||||||
function filename: string;
|
function filename: string;
|
||||||
function basePath: string;
|
function basePath: string;
|
||||||
procedure loadFromFile(const fname: string);
|
procedure loadFromFile(const fname: string);
|
||||||
procedure saveToFile(const fname: string);
|
procedure saveToFile(const fname: string);
|
||||||
//
|
|
||||||
procedure updateSourcesList;
|
procedure updateSourcesList;
|
||||||
procedure activate;
|
procedure activate;
|
||||||
function inGroup: boolean;
|
function inGroup: boolean;
|
||||||
|
@ -170,25 +173,25 @@ type
|
||||||
function outputFilename: string;
|
function outputFilename: string;
|
||||||
procedure reload;
|
procedure reload;
|
||||||
procedure stopCompilation;
|
procedure stopCompilation;
|
||||||
//
|
|
||||||
function isSource(const fname: string): boolean;
|
function isSource(const fname: string): boolean;
|
||||||
function sourcesCount: integer;
|
function sourcesCount: integer;
|
||||||
function sourceRelative(index: integer): string;
|
function sourceRelative(index: integer): string;
|
||||||
function sourceAbsolute(index: integer): string;
|
function sourceAbsolute(index: integer): string;
|
||||||
function importsPathCount: integer;
|
function importsPathCount: integer;
|
||||||
function importPath(index: integer): string;
|
function importPath(index: integer): string;
|
||||||
//
|
|
||||||
function configurationCount: integer;
|
function configurationCount: integer;
|
||||||
function getActiveConfigurationIndex: integer;
|
function getActiveConfigurationIndex: integer;
|
||||||
procedure setActiveConfigurationIndex(index: integer);
|
procedure setActiveConfigurationIndex(index: integer);
|
||||||
function configurationName(index: integer): string;
|
function configurationName(index: integer): string;
|
||||||
//
|
|
||||||
procedure compile;
|
procedure compile;
|
||||||
function compiled: boolean;
|
function compiled: boolean;
|
||||||
procedure run(const runArgs: string = '');
|
procedure run(const runArgs: string = '');
|
||||||
procedure test;
|
procedure test;
|
||||||
function targetUpToDate: boolean;
|
function targetUpToDate: boolean;
|
||||||
//
|
|
||||||
property json: TJSONObject read fJSON;
|
property json: TJSONObject read fJSON;
|
||||||
property packageName: string read fPackageName;
|
property packageName: string read fPackageName;
|
||||||
property isSDL: boolean read fIsSdl;
|
property isSDL: boolean read fIsSdl;
|
||||||
|
@ -676,6 +679,8 @@ end;
|
||||||
|
|
||||||
destructor TDubProject.destroy;
|
destructor TDubProject.destroy;
|
||||||
begin
|
begin
|
||||||
|
if not inGroup and fHasLoaded then
|
||||||
|
storePersistentConfigId();
|
||||||
killProcess(fDubProc);
|
killProcess(fDubProc);
|
||||||
subjProjClosing(fProjectSubject, self);
|
subjProjClosing(fProjectSubject, self);
|
||||||
fProjectSubject.free;
|
fProjectSubject.free;
|
||||||
|
@ -812,9 +817,17 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not assigned(fJSON) then
|
if not assigned(fJSON) then
|
||||||
fJson := TJSONObject.Create(['name','invalid json']);
|
begin
|
||||||
|
fHasLoaded := false;
|
||||||
|
fJson := TJSONObject.Create(['name','invalid json'])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fHasLoaded := true;
|
||||||
|
|
||||||
updateFields;
|
updateFields;
|
||||||
|
if not inGroup then
|
||||||
|
restorePersistentConfigId();
|
||||||
|
|
||||||
subjProjChanged(fProjectSubject, self);
|
subjProjChanged(fProjectSubject, self);
|
||||||
fModified := false;
|
fModified := false;
|
||||||
end;
|
end;
|
||||||
|
@ -918,6 +931,66 @@ end;
|
||||||
{$ENDREGION --------------------------------------------------------------------}
|
{$ENDREGION --------------------------------------------------------------------}
|
||||||
|
|
||||||
{$REGION ICommonProject: configs ---------------------------------------------}
|
{$REGION ICommonProject: configs ---------------------------------------------}
|
||||||
|
procedure TDubProject.restorePersistentConfigId;
|
||||||
|
var
|
||||||
|
f: string;
|
||||||
|
t: string;
|
||||||
|
c: string;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
f := fBasePath + DirectorySeparator + '.dub' + DirectorySeparator + '.editor_meta_data.ini';
|
||||||
|
if f.fileExists then
|
||||||
|
with TStringList.Create do
|
||||||
|
try
|
||||||
|
try
|
||||||
|
LoadFromFile(f);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
t := values['last_dexed_buildType'];
|
||||||
|
c := values['last_dexed_config'];
|
||||||
|
if t.isNotEmpty and c.isNotEmpty then
|
||||||
|
for i := 0 to configurationCount-1 do
|
||||||
|
if configurationName(i) = t + ' - ' + c then
|
||||||
|
begin
|
||||||
|
setActiveConfigurationIndex(i);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDubProject.storePersistentConfigId;
|
||||||
|
var
|
||||||
|
f: string;
|
||||||
|
n: string;
|
||||||
|
c: string;
|
||||||
|
t: string;
|
||||||
|
p: integer;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
i := getActiveConfigurationIndex();
|
||||||
|
n := configurationName(i);
|
||||||
|
p := Pos(' ', n);
|
||||||
|
if (p < 4) and (p + 5 < n.length) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
t := n[1..p-1];
|
||||||
|
c := n[p + 3 .. n.length];
|
||||||
|
f := fBasePath + DirectorySeparator + '.dub' + DirectorySeparator + '.editor_meta_data.ini';
|
||||||
|
with TStringList.Create do
|
||||||
|
try
|
||||||
|
values['last_dexed_buildType'] := t;
|
||||||
|
values['last_dexed_config'] := c;
|
||||||
|
try
|
||||||
|
SaveToFile(f);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDubProject.configurationCount: integer;
|
function TDubProject.configurationCount: integer;
|
||||||
begin
|
begin
|
||||||
exit(fConfigsCount);
|
exit(fConfigsCount);
|
||||||
|
|
Loading…
Reference in New Issue