prevent projects classes to extract the interface for each message

This commit is contained in:
Basile Burg 2018-04-15 12:28:57 +02:00
parent 40594f3e01
commit 2e7a274337
2 changed files with 32 additions and 32 deletions

View File

@ -50,6 +50,7 @@ type
fCompiled: boolean; fCompiled: boolean;
fSymStringExpander: ICESymStringExpander; fSymStringExpander: ICESymStringExpander;
fMsgs: ICEMessagesDisplay; fMsgs: ICEMessagesDisplay;
fAsProjectItf: ICECommonProject;
procedure updateOutFilename; procedure updateOutFilename;
procedure doChanged(modified: boolean = true); procedure doChanged(modified: boolean = true);
procedure getBaseConfig; procedure getBaseConfig;
@ -152,6 +153,7 @@ var
constructor TCENativeProject.create(aOwner: TComponent); constructor TCENativeProject.create(aOwner: TComponent);
begin begin
inherited create(aOwner); inherited create(aOwner);
fAsProjectItf := self as ICECommonProject;
fSymStringExpander := getSymStringExpander; fSymStringExpander := getSymStringExpander;
fMsgs:= getMessageDisplay; fMsgs:= getMessageDisplay;
// //
@ -201,7 +203,7 @@ end;
procedure TCENativeProject.activate; procedure TCENativeProject.activate;
begin begin
subjProjFocused(fProjectSubject, self as ICECommonProject); subjProjFocused(fProjectSubject, fAsProjectItf);
end; end;
function TCENativeProject.getFormat: TCEProjectFormat; function TCENativeProject.getFormat: TCEProjectFormat;
@ -731,7 +733,7 @@ begin
sleep(1); sleep(1);
com := prc.ExitStatus = 0; com := prc.ExitStatus = 0;
for j := 0 to lst.Count -1 do for j := 0 to lst.Count -1 do
fMsgs.message(lst[j], self as ICECommonProject, amcProj, amkAuto); fMsgs.message(lst[j], fAsProjectItf, amcProj, amkAuto);
finally finally
prc.Free; prc.Free;
lst.Free; lst.Free;
@ -783,7 +785,7 @@ begin
if fCompilProc.isNotNil and fCompilProc.Active then if fCompilProc.isNotNil and fCompilProc.Active then
begin begin
fMsgs.message('the project is already being compiled', fMsgs.message('the project is already being compiled',
self as ICECommonProject, amcProj, amkWarn); fAsProjectItf, amcProj, amkWarn);
exit; exit;
end; end;
killProcess(fCompilProc); killProcess(fCompilProc);
@ -792,11 +794,11 @@ begin
if config.isNil then if config.isNil then
begin begin
fMsgs.message('unexpected project error: no active configuration', fMsgs.message('unexpected project error: no active configuration',
self as ICECommonProject, amcProj, amkErr); fAsProjectItf, amcProj, amkErr);
exit; exit;
end; end;
// //
fMsgs.clearByData(self as ICECommonProject); fMsgs.clearByData(fAsProjectItf);
subjProjCompiling(fProjectSubject, Self); subjProjCompiling(fProjectSubject, Self);
// //
prjpath := fFileName.extractFilePath; prjpath := fFileName.extractFilePath;
@ -805,7 +807,7 @@ begin
// //
if not runPrePostProcess(config.preBuildProcess) then if not runPrePostProcess(config.preBuildProcess) then
fMsgs.message('warning: pre-compilation process or commands not properly executed', fMsgs.message('warning: pre-compilation process or commands not properly executed',
self as ICECommonProject, amcProj, amkWarn); fAsProjectItf, amcProj, amkWarn);
// //
SetCurrentDirUTF8(prjpath); SetCurrentDirUTF8(prjpath);
// //
@ -817,9 +819,9 @@ begin
// //
prjname := shortenPath(filename, 25); prjname := shortenPath(filename, 25);
fCompilProc := TCEProcess.Create(nil); fCompilProc := TCEProcess.Create(nil);
subjProjCompiling(fProjectSubject, self as ICECommonProject); subjProjCompiling(fProjectSubject, fAsProjectItf);
fMsgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf); fMsgs.message('compiling ' + prjname, fAsProjectItf, amcProj, amkInf);
fMsgs.message(usingCompilerInfo(CEProjectCompiler), self as ICECommonProject, amcProj, amkInf); fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf);
// this doesn't work under linux, so the previous ChDir. // this doesn't work under linux, so the previous ChDir.
if prjpath.dirExists then if prjpath.dirExists then
fCompilProc.CurrentDirectory := prjpath; fCompilProc.CurrentDirectory := prjpath;
@ -863,7 +865,7 @@ begin
if not outputFilename.fileExists then if not outputFilename.fileExists then
begin begin
fMsgs.message('output executable missing: ' + shortenPath(outputFilename, 25), fMsgs.message('output executable missing: ' + shortenPath(outputFilename, 25),
self as ICECommonProject, amcProj, amkErr); fAsProjectItf, amcProj, amkErr);
exit; exit;
end; end;
// //
@ -897,7 +899,7 @@ begin
else else
processOutputToStrings(TProcess(sender), lst); processOutputToStrings(TProcess(sender), lst);
for str in lst do for str in lst do
fMsgs.message(str, self as ICECommonProject, amcProj, amkBub); fMsgs.message(str, fAsProjectItf, amcProj, amkBub);
finally finally
lst.Free; lst.Free;
end; end;
@ -910,7 +912,7 @@ begin
if (proc.ExitStatus <> 0) then if (proc.ExitStatus <> 0) then
fMsgs.message(format('error: the process (%s) has returned the status %s', fMsgs.message(format('error: the process (%s) has returned the status %s',
[proc.Executable, prettyReturnStatus(proc)]), self as ICECommonProject, amcProj, amkErr); [proc.Executable, prettyReturnStatus(proc)]), fAsProjectItf, amcProj, amkErr);
end; end;
end; end;
@ -923,7 +925,7 @@ begin
try try
fCompilProc.getFullLines(lst); fCompilProc.getFullLines(lst);
for str in lst do for str in lst do
fMsgs.message(str, self as ICECommonProject, amcProj, amkAuto); fMsgs.message(str, fAsProjectItf, amcProj, amkAuto);
finally finally
lst.Free; lst.Free;
end; end;
@ -939,15 +941,15 @@ begin
updateOutFilename; updateOutFilename;
if fCompiled then if fCompiled then
fMsgs.message(prjname + ' has been successfully compiled', fMsgs.message(prjname + ' has been successfully compiled',
self as ICECommonProject, amcProj, amkInf) fAsProjectItf, amcProj, amkInf)
else else
fMsgs.message(prjname + ' has not been compiled', fMsgs.message(prjname + ' has not been compiled',
self as ICECommonProject, amcProj, amkWarn); fAsProjectItf, amcProj, amkWarn);
// //
if not runPrePostProcess(getCurrConf.postBuildProcess) then if not runPrePostProcess(getCurrConf.postBuildProcess) then
fMsgs.message( 'warning: post-compilation process or commands not properly executed', fMsgs.message( 'warning: post-compilation process or commands not properly executed',
self as ICECommonProject, amcProj, amkWarn); fAsProjectItf, amcProj, amkWarn);
subjProjCompiled(fProjectSubject, self as ICECommonProject, fCompiled); subjProjCompiled(fProjectSubject, fAsProjectItf, fCompiled);
// //
SetCurrentDirUTF8(fPreCompilePath); SetCurrentDirUTF8(fPreCompilePath);
end; end;

View File

@ -133,6 +133,7 @@ type
fMsgs: ICEMessagesDisplay; fMsgs: ICEMessagesDisplay;
fLocalPackages: TDubLocalPackages; fLocalPackages: TDubLocalPackages;
fNextTerminatedCommand: TDubCommand; fNextTerminatedCommand: TDubCommand;
fAsProjectItf: ICECommonProject;
procedure doModified; procedure doModified;
procedure updateFields; procedure updateFields;
procedure updatePackageNameFromJson; procedure updatePackageNameFromJson;
@ -585,6 +586,7 @@ end;
constructor TCEDubProject.create(aOwner: TComponent); constructor TCEDubProject.create(aOwner: TComponent);
begin begin
inherited; inherited;
fAsProjectItf := self as ICECommonProject;
fSaveAsUtf8 := true; fSaveAsUtf8 := true;
fJSON := TJSONObject.Create(); fJSON := TJSONObject.Create();
fProjectSubject := TCEProjectSubject.Create; fProjectSubject := TCEProjectSubject.Create;
@ -627,7 +629,7 @@ end;
{$REGION ICECommonProject: project props ---------------------------------------} {$REGION ICECommonProject: project props ---------------------------------------}
procedure TCEDubProject.activate; procedure TCEDubProject.activate;
begin begin
subjProjFocused(fProjectSubject, self as ICECommonProject); subjProjFocused(fProjectSubject, fAsProjectItf);
end; end;
function TCEDubProject.inGroup: boolean; function TCEDubProject.inGroup: boolean;
@ -886,7 +888,7 @@ begin
try try
fDubProc.getFullLines(lst); fDubProc.getFullLines(lst);
for str in lst do for str in lst do
fMsgs.message(str, self as ICECommonProject, amcProj, amkAuto); fMsgs.message(str, fAsProjectItf, amcProj, amkAuto);
finally finally
lst.Free; lst.Free;
end; end;
@ -895,9 +897,7 @@ end;
procedure TCEDubProject.dubProcTerminated(proc: TObject); procedure TCEDubProject.dubProcTerminated(proc: TObject);
var var
n: string; n: string;
i: ICECommonProject;
begin begin
i := self as ICECommonProject;
dubProcOutput(proc); dubProcOutput(proc);
n := shortenPath(filename); n := shortenPath(filename);
if fNextTerminatedCommand = dcBuild then if fNextTerminatedCommand = dcBuild then
@ -907,16 +907,16 @@ begin
if fCompiled or (fDubProc.ExitStatus = 0) then if fCompiled or (fDubProc.ExitStatus = 0) then
begin begin
fMsgs.message(n + ' has been successfully ' + fMsgs.message(n + ' has been successfully ' +
dubCmd2PostMsg[fNextTerminatedCommand], i, amcProj, amkInf) dubCmd2PostMsg[fNextTerminatedCommand], fAsProjectItf, amcProj, amkInf)
end end
else else
begin begin
fMsgs.message(n + ' has not been successfully ' + fMsgs.message(n + ' has not been successfully ' +
dubCmd2PostMsg[fNextTerminatedCommand], i, amcProj, amkWarn); dubCmd2PostMsg[fNextTerminatedCommand], fAsProjectItf, amcProj, amkWarn);
fMsgs.message(format('error: DUB has returned the status %s', fMsgs.message(format('error: DUB has returned the status %s',
[prettyReturnStatus(fDubProc)]), i, amcProj, amkErr); [prettyReturnStatus(fDubProc)]), fAsProjectItf, amcProj, amkErr);
end; end;
subjProjCompiled(fProjectSubject, i, fCompiled); subjProjCompiled(fProjectSubject, fAsProjectItf, fCompiled);
SetCurrentDirUTF8(fPreCompilePath); SetCurrentDirUTF8(fPreCompilePath);
end; end;
@ -925,12 +925,10 @@ var
olddir: string; olddir: string;
prjname: string; prjname: string;
rargs: TStringList; rargs: TStringList;
prj: ICECommonProject;
begin begin
prj := self as ICECommonProject;;
if fDubProc.isNotNil and fDubProc.Active then if fDubProc.isNotNil and fDubProc.Active then
begin begin
fMsgs.message('the project is already being processed by DUB', prj, amcProj, amkWarn); fMsgs.message('the project is already being processed by DUB', fAsProjectItf, amcProj, amkWarn);
exit; exit;
end; end;
killProcess(fDubProc); killProcess(fDubProc);
@ -942,13 +940,13 @@ begin
exit; exit;
end; end;
fNextTerminatedCommand := command; fNextTerminatedCommand := command;
fMsgs.clearByData(prj); fMsgs.clearByData(fAsProjectItf);
prjname := shortenPath(fFilename); prjname := shortenPath(fFilename);
fDubProc:= TCEProcess.Create(nil); fDubProc:= TCEProcess.Create(nil);
olddir := GetCurrentDir; olddir := GetCurrentDir;
try try
subjProjCompiling(fProjectSubject, prj); subjProjCompiling(fProjectSubject, fAsProjectItf);
fMsgs.message(dubCmd2PreMsg[command] + prjname, prj, amcProj, amkInf); fMsgs.message(dubCmd2PreMsg[command] + prjname, fAsProjectItf, amcProj, amkInf);
if modified then if modified then
saveToFile(fFilename); saveToFile(fFilename);
chDir(fFilename.extractFilePath); chDir(fFilename.extractFilePath);
@ -1509,7 +1507,7 @@ begin
fModificationCount := 0; fModificationCount := 0;
fModified:=true; fModified:=true;
updateFields; updateFields;
subjProjChanged(fProjectSubject, self as ICECommonProject); subjProjChanged(fProjectSubject, fAsProjectItf);
end; end;
{$ENDREGION} {$ENDREGION}