mirror of https://gitlab.com/basile.b/dexed.git
di-6
- action related to run proj in main, ok, but sub routines missing for TCEDubProject - pretty format DUB proj on save - proj binary kind in TCECOmmonProject itf, moved enum so that TCEDubProject can use the same values
This commit is contained in:
parent
f389b08008
commit
c208316f14
|
|
@ -5,7 +5,8 @@ unit ce_dmdwrap;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
classes, sysutils, process, asyncprocess, ce_common, ce_inspectors, ce_processes;
|
classes, sysutils, process, asyncprocess, ce_common, ce_inspectors,
|
||||||
|
ce_processes, ce_interfaces;
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
|
||||||
|
|
@ -103,11 +104,6 @@ type
|
||||||
*)
|
*)
|
||||||
TTargetSystem = (auto, os32bit, os64bit);
|
TTargetSystem = (auto, os32bit, os64bit);
|
||||||
|
|
||||||
(**
|
|
||||||
* Describes the output kind.
|
|
||||||
*)
|
|
||||||
TBinaryKind = (executable, staticlib, sharedlib, obj);
|
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Describes the bounds check kinds.
|
* Describes the bounds check kinds.
|
||||||
*)
|
*)
|
||||||
|
|
@ -119,7 +115,7 @@ type
|
||||||
TOutputOpts = class(TOptsGroup)
|
TOutputOpts = class(TOptsGroup)
|
||||||
private
|
private
|
||||||
fTrgKind: TTargetSystem;
|
fTrgKind: TTargetSystem;
|
||||||
fBinKind: TBinaryKind;
|
fBinKind: TProjectBinaryKind;
|
||||||
fUnittest: boolean;
|
fUnittest: boolean;
|
||||||
fVerIds: TStringList;
|
fVerIds: TStringList;
|
||||||
fInline: boolean;
|
fInline: boolean;
|
||||||
|
|
@ -135,7 +131,7 @@ type
|
||||||
procedure setAllInst(const aValue: boolean);
|
procedure setAllInst(const aValue: boolean);
|
||||||
procedure setUnittest(const aValue: boolean);
|
procedure setUnittest(const aValue: boolean);
|
||||||
procedure setTrgKind(const aValue: TTargetSystem);
|
procedure setTrgKind(const aValue: TTargetSystem);
|
||||||
procedure setBinKind(const aValue: TBinaryKind);
|
procedure setBinKind(const aValue: TProjectBinaryKind);
|
||||||
procedure setInline(const aValue: boolean);
|
procedure setInline(const aValue: boolean);
|
||||||
procedure setBoundsCheck(const aValue: TBoundCheckKind);
|
procedure setBoundsCheck(const aValue: TBoundCheckKind);
|
||||||
procedure setOptims(const aValue: boolean);
|
procedure setOptims(const aValue: boolean);
|
||||||
|
|
@ -147,7 +143,7 @@ type
|
||||||
published
|
published
|
||||||
property alwaysLinkStaticLibs: boolean read fAlwayLinkLibs write setAlwaysLinkLibs default false;
|
property alwaysLinkStaticLibs: boolean read fAlwayLinkLibs write setAlwaysLinkLibs default false;
|
||||||
property targetKind: TTargetSystem read fTrgKind write setTrgKind default auto;
|
property targetKind: TTargetSystem read fTrgKind write setTrgKind default auto;
|
||||||
property binaryKind: TBinaryKind read fBinKind write setBinKind default executable;
|
property binaryKind: TProjectBinaryKind read fBinKind write setBinKind default executable;
|
||||||
property inlining: boolean read fInline write setInline default false;
|
property inlining: boolean read fInline write setInline default false;
|
||||||
property boundsCheck: TBoundCheckKind read fBoundsCheck write setBoundsCheck default safeOnly;
|
property boundsCheck: TBoundCheckKind read fBoundsCheck write setBoundsCheck default safeOnly;
|
||||||
property optimizations: boolean read fOptimz write setOptims default false;
|
property optimizations: boolean read fOptimz write setOptims default false;
|
||||||
|
|
@ -562,7 +558,7 @@ var
|
||||||
opt: string;
|
opt: string;
|
||||||
const
|
const
|
||||||
trgKindStr: array[TTargetSystem] of string = ('', '-m32','-m64');
|
trgKindStr: array[TTargetSystem] of string = ('', '-m32','-m64');
|
||||||
binKindStr: array[TBinaryKind] of string = ('', '-lib', '-shared', '-c');
|
binKindStr: array[TProjectBinaryKind] of string = ('', '-lib', '-shared', '-c');
|
||||||
bchKindStr: array[TBoundCheckKind] of string = ('on', 'safeonly', 'off');
|
bchKindStr: array[TBoundCheckKind] of string = ('on', 'safeonly', 'off');
|
||||||
begin
|
begin
|
||||||
opt := binKindStr[fBinKind];
|
opt := binKindStr[fBinKind];
|
||||||
|
|
@ -657,7 +653,7 @@ begin
|
||||||
doChanged;
|
doChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TOutputOpts.setBinKind(const aValue: TBinaryKind);
|
procedure TOutputOpts.setBinKind(const aValue: TProjectBinaryKind);
|
||||||
begin
|
begin
|
||||||
if fBinKind = aValue then exit;
|
if fBinKind = aValue then exit;
|
||||||
fBinKind := aValue;
|
fBinKind := aValue;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ type
|
||||||
procedure loadFromFile(const aFilename: string);
|
procedure loadFromFile(const aFilename: string);
|
||||||
procedure saveToFile(const aFilename: string);
|
procedure saveToFile(const aFilename: string);
|
||||||
function getIfModified: boolean;
|
function getIfModified: boolean;
|
||||||
|
function getBinaryKind: TProjectBinaryKind;
|
||||||
//
|
//
|
||||||
function getIfIsSource(const aFilename: string): boolean;
|
function getIfIsSource(const aFilename: string): boolean;
|
||||||
function getOutputFilename: string;
|
function getOutputFilename: string;
|
||||||
|
|
@ -39,6 +40,7 @@ type
|
||||||
function getConfigurationName(index: integer): string;
|
function getConfigurationName(index: integer): string;
|
||||||
//
|
//
|
||||||
function compile: boolean;
|
function compile: boolean;
|
||||||
|
function run(const runArgs: string = ''): boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
@ -93,6 +95,12 @@ begin
|
||||||
exit(fFilename);
|
exit(fFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCEDubProject.getBinaryKind: TProjectBinaryKind;
|
||||||
|
begin
|
||||||
|
//TODO-cDUB: implement
|
||||||
|
exit(executable);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEDubProject.loadFromFile(const aFilename: string);
|
procedure TCEDubProject.loadFromFile(const aFilename: string);
|
||||||
var
|
var
|
||||||
loader: TMemoryStream;
|
loader: TMemoryStream;
|
||||||
|
|
@ -116,7 +124,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//TODO -cDUB: conserve pretty formatting
|
|
||||||
procedure TCEDubProject.saveToFile(const aFilename: string);
|
procedure TCEDubProject.saveToFile(const aFilename: string);
|
||||||
var
|
var
|
||||||
saver: TMemoryStream;
|
saver: TMemoryStream;
|
||||||
|
|
@ -125,7 +132,7 @@ begin
|
||||||
saver := TMemoryStream.Create;
|
saver := TMemoryStream.Create;
|
||||||
try
|
try
|
||||||
fFilename := aFilename;
|
fFilename := aFilename;
|
||||||
str := fJson.AsJSON;
|
str := fJson.FormatJSON;
|
||||||
saver.Write(str[1], length(str));
|
saver.Write(str[1], length(str));
|
||||||
saver.SaveToFile(fFilename);
|
saver.SaveToFile(fFilename);
|
||||||
finally
|
finally
|
||||||
|
|
@ -203,5 +210,11 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCEDubProject.run(const runArgs: string = ''): boolean;
|
||||||
|
begin
|
||||||
|
//TODO-cDUB: implement
|
||||||
|
result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ type
|
||||||
// describes the project kind. Used as a hint to cast ICECommonProject.getProject()
|
// describes the project kind. Used as a hint to cast ICECommonProject.getProject()
|
||||||
TCEProjectFormat = (pfNative, pfDub);
|
TCEProjectFormat = (pfNative, pfDub);
|
||||||
|
|
||||||
|
// describes the binary kind produces when compiling a project
|
||||||
|
TProjectBinaryKind = (executable, staticlib, sharedlib, obj);
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Common project interface.
|
* Common project interface.
|
||||||
*
|
*
|
||||||
|
|
@ -28,7 +31,10 @@ type
|
||||||
|
|
||||||
// sub routines for the actions --------------------------------------------
|
// sub routines for the actions --------------------------------------------
|
||||||
|
|
||||||
|
// tries to compile and returns true if it does
|
||||||
function compile: boolean;
|
function compile: boolean;
|
||||||
|
// tries to un the project and returns true if it did
|
||||||
|
function run(const runArgs: string = ''): boolean;
|
||||||
|
|
||||||
// project file - allows main form to create/load/save ---------------------
|
// project file - allows main form to create/load/save ---------------------
|
||||||
|
|
||||||
|
|
@ -55,6 +61,8 @@ type
|
||||||
function getIfIsSource(const aFilename: string): boolean;
|
function getIfIsSource(const aFilename: string): boolean;
|
||||||
// returns the name of the file produced when a project is compiled
|
// returns the name of the file produced when a project is compiled
|
||||||
function getOutputFilename: string;
|
function getOutputFilename: string;
|
||||||
|
// returns the binary kind produced according to the current configuration
|
||||||
|
function getBinaryKind: TProjectBinaryKind;
|
||||||
|
|
||||||
// configs -----------------------------------------------------------------
|
// configs -----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,8 @@ type
|
||||||
fSymlWidg: TCESymbolListWidget;
|
fSymlWidg: TCESymbolListWidget;
|
||||||
fInfoWidg: TCEInfoWidget;
|
fInfoWidg: TCEInfoWidget;
|
||||||
|
|
||||||
|
//TODO-cDUB: widget to edit and view, select config of, a DUB project
|
||||||
|
|
||||||
fInitialized: boolean;
|
fInitialized: boolean;
|
||||||
fRunnableSw: string;
|
fRunnableSw: string;
|
||||||
fRunProc: TCEProcess;
|
fRunProc: TCEProcess;
|
||||||
|
|
@ -1509,21 +1511,19 @@ end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjCompileAndRunExecute(Sender: TObject);
|
procedure TCEMainForm.actProjCompileAndRunExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//TODO-cDUB: implement compile proj and run for DUB projects
|
if fProjectInterface.compile then
|
||||||
if fNativeProject.compile then
|
fProjectInterface.run;
|
||||||
fNativeProject.runProject;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject);
|
procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
runargs: string;
|
runargs: string;
|
||||||
begin
|
begin
|
||||||
// TODO-cDUB: implement compile proj and run with arg for DUB projects
|
if not fProjectInterface.compile then
|
||||||
if not fNativeProject.compile then
|
|
||||||
exit;
|
exit;
|
||||||
runargs := '';
|
runargs := '';
|
||||||
if InputQuery('Execution arguments', '', runargs) then
|
if InputQuery('Execution arguments', '', runargs) then
|
||||||
fNativeProject.runProject(runargs);
|
fProjectInterface.run(runargs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjRunExecute(Sender: TObject);
|
procedure TCEMainForm.actProjRunExecute(Sender: TObject);
|
||||||
|
|
@ -1534,33 +1534,40 @@ label
|
||||||
_rbld,
|
_rbld,
|
||||||
_run;
|
_run;
|
||||||
begin
|
begin
|
||||||
// TODO-cDUB: implement proj run for DUB projects
|
if fProjectInterface.getBinaryKind <> executable then
|
||||||
if fNativeProject.currentConfiguration.outputOptions.binaryKind <> executable then
|
|
||||||
begin
|
begin
|
||||||
dlgOkInfo('Non executable projects cant be run');
|
dlgOkInfo('Non executable projects cant be run');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if not fileExists(fNativeProject.getOutputFilename) then
|
if not fileExists(fProjectInterface.getOutputFilename) then
|
||||||
begin
|
begin
|
||||||
if dlgOkCancel('The project output is missing, build ?') <> mrOK then
|
if dlgOkCancel('The project output is missing, build ?') <> mrOK then
|
||||||
exit;
|
exit;
|
||||||
goto _rbld;
|
goto _rbld;
|
||||||
end;
|
end;
|
||||||
dt := fileAge(fNativeProject.getOutputFilename);
|
|
||||||
for i := 0 to fNativeProject.Sources.Count-1 do
|
// TODO-cICECommonInterface, add function to check if rebuild needed.
|
||||||
|
if fProjectInterface.getFormat = pfNative then
|
||||||
begin
|
begin
|
||||||
if fileAge(fNativeProject.getAbsoluteSourceName(i)) > dt then
|
dt := fileAge(fNativeProject.getOutputFilename);
|
||||||
if dlgOkCancel('The project sources have changed since last build, rebuild ?') = mrOK then
|
for i := 0 to fNativeProject.Sources.Count-1 do
|
||||||
goto _rbld
|
begin
|
||||||
else
|
if fileAge(fNativeProject.getAbsoluteSourceName(i)) > dt then
|
||||||
break;
|
if dlgOkCancel('The project sources have changed since last build, rebuild ?') = mrOK then
|
||||||
end;
|
goto _rbld
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
// DUB checks this automatically
|
||||||
|
else fProjectInterface.compile;
|
||||||
|
|
||||||
goto _run;
|
goto _run;
|
||||||
_rbld:
|
_rbld:
|
||||||
fNativeProject.compile;
|
fProjectInterface.compile;
|
||||||
_run:
|
_run:
|
||||||
if fileExists(fNativeProject.getOutputFilename) then
|
if fileExists(fProjectInterface.getOutputFilename) then
|
||||||
fNativeProject.runProject;
|
fProjectInterface.run;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject);
|
procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject);
|
||||||
|
|
@ -1568,9 +1575,8 @@ var
|
||||||
runargs: string;
|
runargs: string;
|
||||||
begin
|
begin
|
||||||
runargs := '';
|
runargs := '';
|
||||||
// TODO-cDUB: change to fProjInterface.runProject when sub routine implemented
|
|
||||||
if InputQuery('Execution arguments', '', runargs) then
|
if InputQuery('Execution arguments', '', runargs) then
|
||||||
fNativeProject.runProject(runargs);
|
fProjectInterface.run(runargs);
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
|
@ -1724,12 +1730,11 @@ end;
|
||||||
|
|
||||||
procedure TCEMainForm.saveProjSource(const aEditor: TCESynMemo);
|
procedure TCEMainForm.saveProjSource(const aEditor: TCESynMemo);
|
||||||
begin
|
begin
|
||||||
//TODO-cDUB: implement save project source for a DUB json file edited in CE
|
if fProjectInterface = nil then exit;
|
||||||
if fNativeProject = nil then exit;
|
if fProjectInterface.getFilename <> aEditor.fileName then exit;
|
||||||
if fNativeProject.fileName <> aEditor.fileName then exit;
|
|
||||||
//
|
//
|
||||||
aEditor.saveToFile(fNativeProject.fileName);
|
aEditor.saveToFile(fProjectInterface.getFilename);
|
||||||
openProj(fNativeProject.fileName);
|
openProj(fProjectInterface.getFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.closeProj;
|
procedure TCEMainForm.closeProj;
|
||||||
|
|
@ -1773,9 +1778,10 @@ end;
|
||||||
procedure TCEMainForm.openProj(const aFilename: string);
|
procedure TCEMainForm.openProj(const aFilename: string);
|
||||||
begin
|
begin
|
||||||
closeProj;
|
closeProj;
|
||||||
if ExtractFileExt(aFilename) = '.json' then newDubProj
|
if LowerCase(ExtractFileExt(aFilename)) = '.json' then
|
||||||
else newNativeProj;
|
newDubProj
|
||||||
|
else
|
||||||
|
newNativeProj;
|
||||||
//
|
//
|
||||||
fProjectInterface.loadFromFile(aFilename);
|
fProjectInterface.loadFromFile(aFilename);
|
||||||
showProjTitle;
|
showProjTitle;
|
||||||
|
|
@ -1856,11 +1862,11 @@ end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjSourceExecute(Sender: TObject);
|
procedure TCEMainForm.actProjSourceExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//TODO-cDUB: add json highligher to edit json project in CE
|
if fProjectInterface = nil then exit;
|
||||||
if fNativeProject = nil then exit;
|
if not fileExists(fProjectInterface.getFilename) then exit;
|
||||||
if not fileExists(fNativeProject.fileName) then exit;
|
|
||||||
//
|
//
|
||||||
openFile(fNativeProject.fileName);
|
openFile(fProjectInterface.getFilename);
|
||||||
|
//TODO-cDUB: add json highligher to edit json project in CE
|
||||||
fDoc.Highlighter := LfmSyn;
|
fDoc.Highlighter := LfmSyn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ type
|
||||||
procedure addSource(const aFilename: string);
|
procedure addSource(const aFilename: string);
|
||||||
function addConfiguration: TCompilerConfiguration;
|
function addConfiguration: TCompilerConfiguration;
|
||||||
procedure getOpts(const aList: TStrings);
|
procedure getOpts(const aList: TStrings);
|
||||||
function runProject(const runArgs: string = ''): Boolean;
|
function run(const runArgs: string = ''): Boolean;
|
||||||
function compile: Boolean;
|
function compile: Boolean;
|
||||||
//
|
//
|
||||||
function getIfModified: boolean;
|
function getIfModified: boolean;
|
||||||
|
|
@ -89,6 +89,7 @@ type
|
||||||
procedure setActiveConfiguration(index: integer);
|
procedure setActiveConfiguration(index: integer);
|
||||||
function getConfigurationName(index: integer): string;
|
function getConfigurationName(index: integer): string;
|
||||||
function getFilename: string;
|
function getFilename: string;
|
||||||
|
function getBinaryKind: TProjectBinaryKind;
|
||||||
//
|
//
|
||||||
property configuration[ix: integer]: TCompilerConfiguration read getConfig;
|
property configuration[ix: integer]: TCompilerConfiguration read getConfig;
|
||||||
property currentConfiguration: TCompilerConfiguration read getCurrConf;
|
property currentConfiguration: TCompilerConfiguration read getCurrConf;
|
||||||
|
|
@ -705,7 +706,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCENativeProject.runProject(const runArgs: string = ''): Boolean;
|
function TCENativeProject.run(const runArgs: string = ''): Boolean;
|
||||||
var
|
var
|
||||||
prm: string;
|
prm: string;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
|
@ -821,6 +822,11 @@ begin
|
||||||
exit(fFilename);
|
exit(fFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCENativeProject.getBinaryKind: TProjectBinaryKind;
|
||||||
|
begin
|
||||||
|
exit(currentConfiguration.outputOptions.binaryKind);
|
||||||
|
end;
|
||||||
|
|
||||||
function isValidNativeProject(const filename: string): boolean;
|
function isValidNativeProject(const filename: string): boolean;
|
||||||
var
|
var
|
||||||
maybe: TCENativeProject;
|
maybe: TCENativeProject;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue