From da889090dbd32ed1cdcd0b8747961f5b521f08d3 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 14 Apr 2018 02:19:04 +0200 Subject: [PATCH] add support for dub test, close #289 --- icons/other/check_boxes_series.png | Bin 0 -> 1339 bytes icons/other/check_boxes_series24.png | Bin 0 -> 1090 bytes icons/other/check_boxes_series32.png | Bin 0 -> 1889 bytes lazproj/coedit.lpi | 5 +- src/ce_ceproject.pas | 5 ++ src/ce_dubproject.pas | 83 ++++++++++++++++----------- src/ce_interfaces.pas | 2 + src/ce_main.lfm | 18 ++++++ src/ce_main.pas | 18 ++++++ 9 files changed, 95 insertions(+), 36 deletions(-) create mode 100644 icons/other/check_boxes_series.png create mode 100644 icons/other/check_boxes_series24.png create mode 100644 icons/other/check_boxes_series32.png diff --git a/icons/other/check_boxes_series.png b/icons/other/check_boxes_series.png new file mode 100644 index 0000000000000000000000000000000000000000..4e4d313bae8accfbdf2b45a8aae0a757cfffd68f GIT binary patch literal 1339 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHnECv!ss17kN+OGigTLsugUQzsKQa~Ed= zS4&4rV+&W9UYGpj(%jU%5}4i;xLy+joO(e?A-4c%vrB4GW?5>ATTy_D*&b`Iq+Y2)mH^e#N~n>;(k5bCc3HCvEI)?da9N5me3XsIx|7V=(8A zjD<^XxVZ>y47hlTMI?5Sx#4$H<8w1-AIVtg+9mt$VcqwFeed@?Gg@mp%TmTyZsVq% z`-Qz`26{2}9yO?vut*m;bhFe#UTu3wmb=$f#Wxl;;Vx}9mR4U#Ke_dxJug(UC7cV%xnBo9(IA>+TC{^wM}(S(mHw&8NTrkJ0*&ubVYI zuJSvp+!l_wW4B#&%XSM6rOwT*iXvU_+P8&m=gZ4lym0KF{IzXx zzux@&RlUHEEv-t+Z_PW+SoHbt2dCUqVHR`V9uC%YxY-}@(P_4(+@^K;jb|QAnR{@x z{G(6r#hIt8pUXO@ GgeCwSz2l<* literal 0 HcmV?d00001 diff --git a/icons/other/check_boxes_series24.png b/icons/other/check_boxes_series24.png new file mode 100644 index 0000000000000000000000000000000000000000..e8fc9ef11684b52d536759dfaec94836ef2878a3 GIT binary patch literal 1090 zcmV-I1ikx-P)u# zJ!WKlqW8u{y{un(YXgY>Av)&lg_&-E>6z-nRm+#K=(>41T*^O3hRb7P6TJ%W$gKs4 zGV9HsHO-v~AsE2yc>jpm_WI`rAS=?Z$c%?*E=h^Cpo~)ZA~T$G ze^6^3C8H1#Ufpwo4-Qr6iVXmvFbPI0k~CwkkyCHxBuz^#$;tAZIF2w%3APoXT#86D zOPYHS=qecy;gvnd`EaO0cR50&K*9R}5F(>>ZataxDf6>43A=4B#B~Ul17R#IHN=r zxdwRj%`e!#VJR;@yb6GqcK^Uf-;B^xj>vsr$L2eEXzgOEjSL6^^c>u`d*|qx;mG>X zNeH$GuC!51{dnxF<3=mN`+x!#&+p{p!(+_ri~-nnc$AJvV?8{-=?=E7>1T2}0WEEa z<~D44OCw6OR_a1rYSq9wPcyS9C3MAxokJr4l#C{KffpWJ!M3&i{5q51 zJ*XhK2lp) zZ(ZHbxoQ*V14`NfgxorOi`wlzs5f%b%%KFFhtyh1kq$@eU%K zYa7kR&49k_H3G~6mG(kf7p_L-iKm`z+p51hzihhxFaM(a1_<%@==R2CsQ>@~07*qo IM6N<$f*L6VC;$Ke literal 0 HcmV?d00001 diff --git a/icons/other/check_boxes_series32.png b/icons/other/check_boxes_series32.png new file mode 100644 index 0000000000000000000000000000000000000000..b88502716ae7b281adb27ebc78872ac6bd3af207 GIT binary patch literal 1889 zcmaJ?Yfuws6b%pvk3mqWMhd!wq9W!^z$}TH5HPWXVuZnJRYJ0o=Wg6xB*a3g*kW64 z9RcZBT6u^Fj0z$aA4NbdRTNMQSSb>uilPXJSlWtqqhkA`bZ2(I$DDKSx%a!@>}N62 zE8JbZT}dR8yG$xk5F=oFot=m;X0bdWhB>7NHJPK4HMuyUcVVI33f=wa`mYGdTl^()@L?}rM3u!~A&(Z*`T1boM z$yst!IHb`^Ehx0w5*@3u=v90*ZP`*lUYbMG%?u>mMx`8pj`g{P^0k;8p9RP zKYssH7>i9cK}-dNA<3wUIJiyzwooQ89EFrPg2p0e^For8(6(o}gX@mkpt5t*C2o75;7De#*A`zP%!QqDliS`>%tZ+#z2)fN_LZqH-g_J|qL&}zw{k_*L}Ut71i743-T z-2d*;z~i*`IBxfx8En^+2MRdtaU0W`x5ga}69-19emQTp?{g{Gx;_uy5HB`Fsl~dS zXrInr9b7ZieLT1S6yw~2hNL|)ErC0IDJRHX!m`1f(LAK=#nl@gfA!rOqwHV*W5>Du ziF=;S^WM3?$oE~rsY6SekJWQq*R5ON7*IoU@Vanuhj1@X+WNtR;y);-xq%Ctotp}; zEnj|zb@1Z?#o)8cqm94ym4uNmSUey%Au4RXV$t$XS_EZ*#>IYBn885F` z6uPqYi^cYWyRHKA@G8G^b9xU*9egRw#6d&KyzVij~?T{6VSC_R(r5r4t4u< z_nfnxzT(d0F^jK#de!nPO>kSw9jpv%QY?zUR^!xD$aPL18tc~$H%JxwW&>DL@`+Q> z^thrWZW#kF{^%R2?nmNH>|`)wapm*vgMzST=So3Tpyi46%Isa|?;Gisn&SRAhB?Ff zVDIIF+27=~9c|b_EtRfxKy~PcFOE!%fBPMsbA3q{V#q7bs2=k)C;G{Ytl-UkO*K}R z!|w~eh&HT^3Lq!#BQLy`RU0Y#a6~sWbKKw)?UK9G;_;~K)DMv#*Y(esmb>MAe$R@8 z!?WrtJZ4Zfb_=qdIK_?vuh( zbu$0qdlT{dcHb?Xx%Q;S$rsiarIWwPI&*wD@#^HB>jy9_QSGl@u(k%}u!VUU8gQd89BlBe&3PrVd%Z{H;vCuimY_zIU|H zReQ8*JTyR^C@F`jdEqij2cu0d=*Tb2znQcllh(a#Z2%qx?yqaF*ejIyr|+gFSEoPU z;F3G=(beB!bkSO!*G7prj4|T2#-yCX%ZMp4xR! zWVV*mnSb8P9)I+_k21Y;&al3b?0Ye(V~e3{{Dotm%g$8$vyN1f6u5_OS{USD`{~Id Lq9sSf3ETb#$S(XP literal 0 HcmV?d00001 diff --git a/lazproj/coedit.lpi b/lazproj/coedit.lpi index 60aea56d..b121b71d 100644 --- a/lazproj/coedit.lpi +++ b/lazproj/coedit.lpi @@ -13,7 +13,7 @@ - + @@ -387,6 +387,9 @@ + + + diff --git a/src/ce_ceproject.pas b/src/ce_ceproject.pas index b509de37..2f15e7fd 100644 --- a/src/ce_ceproject.pas +++ b/src/ce_ceproject.pas @@ -124,6 +124,7 @@ type procedure run(const runArgs: string = ''); function compiled: Boolean; procedure compile; + procedure test; function targetUpToDate: boolean; procedure checkMissingFiles; // @@ -1098,6 +1099,10 @@ begin result := expandFilenameEx(fBasePath, result); end; +procedure TCENativeProject.test; +begin +end; + function isValidNativeProject(const filename: string): boolean; var maybe: TCENativeProject; diff --git a/src/ce_dubproject.pas b/src/ce_dubproject.pas index 27f3dde4..6b782336 100644 --- a/src/ce_dubproject.pas +++ b/src/ce_dubproject.pas @@ -104,6 +104,8 @@ type destructor destroy; override; end; + TDubCommand = (dcBuild, dcRun, dcTest); + TCEDubProject = class(TComponent, ICECommonProject) private fIsSdl: boolean; @@ -130,6 +132,7 @@ type fCompiled: boolean; fMsgs: ICEMessagesDisplay; fLocalPackages: TDubLocalPackages; + fNextTerminatedCommand: TDubCommand; procedure doModified; procedure updateFields; procedure updatePackageNameFromJson; @@ -142,7 +145,7 @@ type procedure dubProcOutput(proc: TObject); procedure dubProcTerminated(proc: TObject); function getCurrentCustomConfig: TJSONObject; - procedure compileOrRun(run: boolean; const runArgs: string = ''); + procedure executeDub(command: TDubCommand; const runArgs: string = ''); public constructor create(aOwner: TComponent); override; destructor destroy; override; @@ -182,6 +185,7 @@ type procedure compile; function compiled: boolean; procedure run(const runArgs: string = ''); + procedure test; function targetUpToDate: boolean; // property json: TJSONObject read fJSON; @@ -225,6 +229,10 @@ const DubDefaultConfigName = '(default config)'; + dubCmd2Arg: array[TDubCommand] of string = ('build', 'run', 'test'); + dubCmd2PreMsg: array[TDubCommand] of string = ('compiling ', 'running ', 'testing '); + dubCmd2PostMsg: array[TDubCommand] of string = ('compiled', 'executed', 'tested'); + {$REGION TDubLocalPackages -----------------------------------------------------} constructor TDubLocalPackage.create; begin @@ -886,55 +894,63 @@ end; procedure TCEDubProject.dubProcTerminated(proc: TObject); var - prjname: string; + n: string; + i: ICECommonProject; begin + i := self as ICECommonProject; dubProcOutput(proc); - prjname := shortenPath(filename); - fCompiled := fDubProc.ExitStatus = 0; - if fCompiled then - fMsgs.message(prjname + ' has been successfully compiled', - self as ICECommonProject, amcProj, amkInf) + n := shortenPath(filename); + if fNextTerminatedCommand = dcBuild then + fCompiled := fDubProc.ExitStatus = 0; + // note: fCompiled is also used to indicate if there's something produced + // so the 'or' RHS is there for fNextTerminatedCommand <> dcBuild; + if fCompiled or (fDubProc.ExitStatus = 0) then + begin + fMsgs.message(n + ' has been successfully ' + + dubCmd2PostMsg[fNextTerminatedCommand], i, amcProj, amkInf) + end else begin - fMsgs.message(prjname + ' has not been compiled', - self as ICECommonProject, amcProj, amkWarn); + fMsgs.message(n + ' has not been successfully ' + + dubCmd2PostMsg[fNextTerminatedCommand], i, amcProj, amkWarn); fMsgs.message(format('error: DUB has returned the status %s', - [prettyReturnStatus(fDubProc)]), self as ICECommonProject, amcProj, amkErr); + [prettyReturnStatus(fDubProc)]), i, amcProj, amkErr); end; - subjProjCompiled(fProjectSubject, self as ICECommonProject, fCompiled); + subjProjCompiled(fProjectSubject, i, fCompiled); SetCurrentDirUTF8(fPreCompilePath); end; -procedure TCEDubProject.compileOrRun(run: boolean; const runArgs: string = ''); +procedure TCEDubProject.executeDub(command: TDubCommand; const runArgs: string = ''); var olddir: string; prjname: string; rargs: TStringList; + prj: ICECommonProject; begin + prj := self as ICECommonProject;; if fDubProc.isNotNil and fDubProc.Active then begin - fMsgs.message('the project is already being compiled', - self as ICECommonProject, amcProj, amkWarn); + fMsgs.message('the project is already being processed by DUB', prj, amcProj, amkWarn); exit; end; killProcess(fDubProc); fCompiled := false; if not fFilename.fileExists then begin - dlgOkInfo('The DUB project must be saved before being compiled or run !'); + dlgOkInfo('The project must be saved before being ' + + dubCmd2PreMsg[command] + 'by DUB !'); exit; end; - fMsgs.clearByData(Self as ICECommonProject); + fNextTerminatedCommand := command; + fMsgs.clearByData(prj); prjname := shortenPath(fFilename); fDubProc:= TCEProcess.Create(nil); olddir := GetCurrentDir; try - if not run then - begin - subjProjCompiling(fProjectSubject, self as ICECommonProject); - fMsgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf); - if modified then saveToFile(fFilename); - end; + subjProjCompiling(fProjectSubject, prj); + fMsgs.message(dubCmd2PreMsg[command] + prjname, prj, amcProj, amkInf); + if modified then + saveToFile(fFilename); chDir(fFilename.extractFilePath); fDubProc.Executable := 'dub' + exeExt; if not dubBuildOptions.showConsole then @@ -949,22 +965,14 @@ begin end; fDubProc.CurrentDirectory := fFilename.extractFilePath; fDubProc.XTermProgram:=consoleProgram; - if not run then - begin - fDubProc.Parameters.Add('build'); - fDubProc.OnTerminate:= @dubProcTerminated; - end - else - begin - fDubProc.Parameters.Add('run'); - fDubProc.OnTerminate:= @dubProcOutput; - end; + fDubProc.Parameters.Add(dubCmd2Arg[command]); + fDubProc.OnTerminate:= @dubProcTerminated; fDubProc.Parameters.Add('--build=' + fBuildTypes[fBuiltTypeIx]); if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]); fDubProc.Parameters.Add('--compiler=' + DubCompilerFilename); dubBuildOptions.getOpts(fDubProc.Parameters); - if run and runArgs.isNotEmpty then + if (command <> dcBuild) and runArgs.isNotEmpty then begin fDubProc.Parameters.Add('--'); rargs := TStringList.Create; @@ -984,7 +992,7 @@ end; procedure TCEDubProject.compile; begin fPreCompilePath := GetCurrentDirUTF8; - compileOrRun(false); + executeDub(dcBuild); end; function TCEDubProject.compiled: boolean; @@ -994,7 +1002,12 @@ end; procedure TCEDubProject.run(const runArgs: string = ''); begin - compileOrRun(true, runArgs); + executeDub(dcRun, runArgs); +end; + +procedure TCEDubProject.test; +begin + executeDub(dcTest); end; function TCEDubProject.targetUpToDate: boolean; diff --git a/src/ce_interfaces.pas b/src/ce_interfaces.pas index e6ee2e02..f3143beb 100644 --- a/src/ce_interfaces.pas +++ b/src/ce_interfaces.pas @@ -90,6 +90,8 @@ type function compiled: boolean; // tries to execute the project output. procedure run(const runArgs: string = ''); + // test the project (only for DUB) + procedure test; // returns true if the target has not to be recompiled function targetUpToDate: boolean; diff --git a/src/ce_main.lfm b/src/ce_main.lfm index f662fcc2..1b835111 100644 --- a/src/ce_main.lfm +++ b/src/ce_main.lfm @@ -1807,6 +1807,12 @@ object CEMainForm: TCEMainForm object MenuItem49: TMenuItem Action = actProjRunWithArgs end + object MenuItem76: TMenuItem + Caption = '-' + end + object MenuItem110: TMenuItem + Action = actProjTest + end end object MenuItem100: TMenuItem Caption = 'Projects group' @@ -1955,6 +1961,12 @@ object CEMainForm: TCEMainForm object MenuItem46: TMenuItem Action = actProjRunWithArgs end + object MenuItem111: TMenuItem + Caption = '-' + end + object MenuItem112: TMenuItem + Action = actProjTest + end end object mnuOpts: TMenuItem Caption = 'Options' @@ -2376,6 +2388,12 @@ object CEMainForm: TCEMainForm OnExecute = actEdFormatExecute OnUpdate = updateDocumentBasedAction end + object actProjTest: TAction + Category = 'Project' + Caption = 'Test project' + OnExecute = actProjTestExecute + OnUpdate = updateProjectBasedAction + end end object ApplicationProperties1: TApplicationProperties OnActivate = ApplicationProperties1Activate diff --git a/src/ce_main.pas b/src/ce_main.pas index 4b0be157..ef247f8a 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -106,6 +106,7 @@ type actFileCloseAll: TAction; actFileNewClip: TAction; actEdFormat: TAction; + actProjTest: TAction; actLayoutReset: TAction; actProjDscan: TAction; actProjGroupCompileCustomSync: TAction; @@ -159,7 +160,11 @@ type MenuItem107: TMenuItem; MenuItem108: TMenuItem; MenuItem109: TMenuItem; + MenuItem110: TMenuItem; + MenuItem111: TMenuItem; + MenuItem112: TMenuItem; MenuItem31: TMenuItem; + MenuItem76: TMenuItem; MenuItem77: TMenuItem; mnuOpts: TMenuItem; mnuItemMruGroup: TMenuItem; @@ -289,6 +294,7 @@ type procedure actProjSaveGroupAsExecute(Sender: TObject); procedure actProjSaveGroupExecute(Sender: TObject); procedure actProjSelUngroupedExecute(Sender: TObject); + procedure actProjTestExecute(Sender: TObject); procedure actSetRunnableSwExecute(Sender: TObject); procedure ApplicationProperties1Activate(Sender: TObject); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); @@ -1423,6 +1429,9 @@ begin actProjRun.ImageIndex:= i; actProjRunWithArgs.ImageIndex:= i; + i := loadIcon('CHECK_BOXES_SERIES'); + actProjTest.ImageIndex:=i; + i := loadIcon('LAYOUT'); mnuLayout.ImageIndex:= i; @@ -3803,6 +3812,15 @@ begin dlgOkInfo(fProject.getCommandLine, 'Compilation command line'); end; +procedure TCEMainForm.actProjTestExecute(Sender: TObject); +begin + if not assigned(fProject) then + exit; + if checkProjectLock then + exit; + fProject.test; +end; + procedure TCEMainForm.actProjDscanExecute(Sender: TObject); var lst: TStringList;