From 81dd17d5fc35e5c360ecc58912e4ec9a7af0e72d Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 7 Nov 2016 07:28:51 +0100 Subject: [PATCH] compilers paths, add setter to detect modifications, close #99 --- src/ce_compilers.lfm | 97 ++++++++-------- src/ce_compilers.pas | 263 ++++++++++++++++++++++++++++++++++++------- src/ce_dmdwrap.pas | 2 +- 3 files changed, 275 insertions(+), 87 deletions(-) diff --git a/src/ce_compilers.lfm b/src/ce_compilers.lfm index 221e34a2..92489d80 100644 --- a/src/ce_compilers.lfm +++ b/src/ce_compilers.lfm @@ -2,38 +2,38 @@ object Form1: TForm1 Left = 749 Height = 869 Top = 128 - Width = 473 + Width = 460 Caption = 'Form1' ClientHeight = 869 - ClientWidth = 473 + ClientWidth = 460 LCLVersion = '1.6.0.4' object ScrollBox1: TScrollBox Left = 0 Height = 869 Top = 0 - Width = 473 + Width = 460 HorzScrollBar.Page = 111 VertScrollBar.Page = 864 Align = alClient ClientHeight = 865 - ClientWidth = 469 + ClientWidth = 456 TabOrder = 0 object grpDMD: TGroupBox Left = 0 Height = 160 Top = 64 - Width = 469 + Width = 456 Align = alTop Caption = 'DMD' ClientHeight = 130 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 0 object selDMDexe: TFileNameEdit Left = 2 Height = 20 Hint = 'select the compiler' Top = 19 - Width = 461 + Width = 448 FilterIndex = 0 HideDirectories = False ButtonWidth = 23 @@ -49,7 +49,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of druntime sources' Top = 60 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -64,7 +64,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of phobos sources' Top = 101 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -78,7 +78,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 0 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'compiler' @@ -88,7 +88,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 41 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Runtime sources' @@ -98,7 +98,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 82 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Phobos sources' @@ -109,18 +109,18 @@ object Form1: TForm1 Left = 0 Height = 160 Top = 224 - Width = 469 + Width = 456 Align = alTop Caption = 'GDC' ClientHeight = 130 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 1 object selGDCexe: TFileNameEdit Left = 2 Height = 20 Hint = 'select the compiler' Top = 19 - Width = 461 + Width = 448 FilterIndex = 0 HideDirectories = False ButtonWidth = 23 @@ -136,7 +136,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of LDC runtime & phobos sources (can be a common folder)' Top = 60 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -151,7 +151,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of LDC runtime & phobos sources (can be a common folder)' Top = 101 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -165,7 +165,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 0 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'compiler' @@ -175,7 +175,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 41 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Runtime sources' @@ -185,7 +185,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 82 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Phobos sources' @@ -196,18 +196,18 @@ object Form1: TForm1 Left = 0 Height = 160 Top = 384 - Width = 469 + Width = 456 Align = alTop Caption = 'LDC' ClientHeight = 130 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 2 object selLDCexe: TFileNameEdit Left = 2 Height = 20 Hint = 'select the compiler' Top = 19 - Width = 461 + Width = 448 FilterIndex = 0 HideDirectories = False ButtonWidth = 23 @@ -223,7 +223,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of druntime sources' Top = 60 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -238,7 +238,7 @@ object Form1: TForm1 Height = 20 Hint = 'select the root of phobos sources' Top = 101 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -252,7 +252,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 0 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'compiler' @@ -262,7 +262,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 41 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Runtime sources' @@ -272,7 +272,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 82 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Phobos sources' @@ -283,17 +283,17 @@ object Form1: TForm1 Left = 0 Height = 160 Top = 544 - Width = 469 + Width = 456 Align = alTop Caption = 'User 1' ClientHeight = 130 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 3 object selUSER1exe: TFileNameEdit Left = 2 Height = 20 Top = 19 - Width = 461 + Width = 448 FilterIndex = 0 HideDirectories = False ButtonWidth = 23 @@ -308,7 +308,7 @@ object Form1: TForm1 Left = 2 Height = 20 Top = 60 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -322,7 +322,7 @@ object Form1: TForm1 Left = 2 Height = 20 Top = 101 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -336,7 +336,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 0 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'compiler' @@ -346,7 +346,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 41 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Runtime sources' @@ -356,7 +356,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 82 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Phobos sources' @@ -367,17 +367,17 @@ object Form1: TForm1 Left = 0 Height = 160 Top = 704 - Width = 469 + Width = 456 Align = alTop Caption = 'User 2' ClientHeight = 130 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 4 object selUSER2exe: TFileNameEdit Left = 2 Height = 20 Top = 19 - Width = 461 + Width = 448 FilterIndex = 0 HideDirectories = False ButtonWidth = 23 @@ -392,7 +392,7 @@ object Form1: TForm1 Left = 2 Height = 20 Top = 60 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -406,7 +406,7 @@ object Form1: TForm1 Left = 2 Height = 20 Top = 101 - Width = 461 + Width = 448 ShowHidden = False ButtonWidth = 23 NumGlyphs = 1 @@ -420,7 +420,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 0 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'compiler' @@ -430,7 +430,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 41 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Runtime sources' @@ -440,7 +440,7 @@ object Form1: TForm1 Left = 0 Height = 17 Top = 82 - Width = 465 + Width = 452 Align = alTop Alignment = taCenter Caption = 'Phobos sources' @@ -451,17 +451,18 @@ object Form1: TForm1 Left = 0 Height = 64 Top = 0 - Width = 469 + Width = 456 Align = alTop - Caption = 'Default compiler' + Caption = 'Default compiler for completion' ClientHeight = 34 - ClientWidth = 465 + ClientWidth = 452 TabOrder = 5 object selDefault: TComboBox Left = 2 Height = 30 + Hint = 'select which compiler paths are used by the completion daemon' Top = 2 - Width = 461 + Width = 448 Align = alClient BorderSpacing.Around = 2 ItemHeight = 0 diff --git a/src/ce_compilers.pas b/src/ce_compilers.pas index e3295c57..2af986df 100644 --- a/src/ce_compilers.pas +++ b/src/ce_compilers.pas @@ -32,23 +32,45 @@ type fUser2ExeName: string; fUser2RuntimePath: string; fUser2PhobosPath: string; + fModified: boolean; + fWouldNeedRestart: boolean; + procedure setDefaultCompiler(value: DCompiler); + procedure setDmdExeName(const value: string); + procedure setDmdRuntimePath(const value: string); + procedure setDmdPhobosPath(const value: string); + procedure setGdcExeName(const value: string); + procedure setGdcRuntimePath(const value: string); + procedure setGdcPhobosPath(const value: string); + procedure setLdcExeName(const value: string); + procedure setLdcRuntimePath(const value: string); + procedure setLdcPhobosPath(const value: string); + procedure setUser1ExeName(const value: string); + procedure setUser1RuntimePath(const value: string); + procedure setUser1PhobosPath(const value: string); + procedure setUser2ExeName(const value: string); + procedure setUser2RuntimePath(const value: string); + procedure setUser2PhobosPath(const value: string); + protected + procedure afterLoad; override; published - property defaultCompiler: DCompiler read fDefaultCompiler write fDefaultCompiler; - property DmdExeName: string read fDmdExeName write fDmdExeName; - property DmdRuntimePath: string read fDmdRuntimePath write fDmdRuntimePath; - property DmdPhobosPath: string read fDmdPhobosPath write fDmdPhobosPath; - property GdcExeName: string read fGdcExeName write fGdcExeName; - property GdcRuntimePath: string read fGdcRuntimePath write fGdcRuntimePath; - property GdcPhobosPath: string read fGdcPhobosPath write fGdcPhobosPath; - property LdcExeName: string read fLdcExeName write fLdcExeName; - property LdcRuntimePath: string read fLdcRuntimePath write fLdcRuntimePath; - property LdcPhobosPath: string read fLdcPhobosPath write fLdcPhobosPath; - property User1ExeName: string read fUser1ExeName write fUser1ExeName; - property User1RuntimePath: string read fUser1RuntimePath write fUser1RuntimePath; - property User1PhobosPath: string read fUser1PhobosPath write fUser1PhobosPath; - property User2ExeName: string read fUser2ExeName write fUser2ExeName; - property User2RuntimePath: string read fUser2RuntimePath write fUser2RuntimePath; - property User2PhobosPath: string read fUser2PhobosPath write fUser2PhobosPath; + property wouldNeedRestart: boolean read fWouldNeedRestart write fWouldNeedRestart; + property modified: boolean read fModified write fModified; + property defaultCompiler: DCompiler read fDefaultCompiler write setDefaultCompiler; + property DmdExeName: string read fDmdExeName write setDmdExeName; + property DmdRuntimePath: string read fDmdRuntimePath write setDmdRuntimePath; + property DmdPhobosPath: string read fDmdPhobosPath write setDmdPhobosPath; + property GdcExeName: string read fGdcExeName write setGdcExeName; + property GdcRuntimePath: string read fGdcRuntimePath write setGdcRuntimePath; + property GdcPhobosPath: string read fGdcPhobosPath write setGdcPhobosPath; + property LdcExeName: string read fLdcExeName write setLdcExeName; + property LdcRuntimePath: string read fLdcRuntimePath write setLdcRuntimePath; + property LdcPhobosPath: string read fLdcPhobosPath write setLdcPhobosPath; + property User1ExeName: string read fUser1ExeName write setUser1ExeName; + property User1RuntimePath: string read fUser1RuntimePath write setUser1RuntimePath; + property User1PhobosPath: string read fUser1PhobosPath write setUser1PhobosPath; + property User2ExeName: string read fUser2ExeName write setUser2ExeName; + property User2RuntimePath: string read fUser2RuntimePath write setUser2RuntimePath; + property User2PhobosPath: string read fUser2PhobosPath write setUser2PhobosPath; public procedure assign(source: TPersistent); override; end; @@ -196,25 +218,181 @@ begin if source is TCompilersPaths then begin src := TCompilersPaths(source); - fDefaultCompiler := src.fDefaultCompiler; - fDmdExeName := src.fDmdExeName; - fDmdRuntimePath := src.fDmdRuntimePath; - fDmdPhobosPath := src.fDmdPhobosPath; - fGdcExeName := src.fGdcExeName; - fGdcRuntimePath := src.fGdcRuntimePath; - fGdcPhobosPath := src.fGdcPhobosPath; - fLdcExeName := src.fLdcExeName; - fLdcRuntimePath := src.fLdcRuntimePath; - fLdcPhobosPath := src.fLdcPhobosPath; - fUser1ExeName := src.fUser1ExeName; - fUser1RuntimePath := src.fUser1RuntimePath; - fUser1PhobosPath := src.fUser1PhobosPath; - fUser2ExeName := src.fUser2ExeName; - fUser2RuntimePath := src.fUser2RuntimePath; - fUser2PhobosPath := src.fUser2PhobosPath; + DefaultCompiler := src.fDefaultCompiler; + DmdExeName := src.fDmdExeName; + DmdRuntimePath := src.fDmdRuntimePath; + DmdPhobosPath := src.fDmdPhobosPath; + GdcExeName := src.fGdcExeName; + GdcRuntimePath := src.fGdcRuntimePath; + GdcPhobosPath := src.fGdcPhobosPath; + LdcExeName := src.fLdcExeName; + LdcRuntimePath := src.fLdcRuntimePath; + LdcPhobosPath := src.fLdcPhobosPath; + User1ExeName := src.fUser1ExeName; + User1RuntimePath := src.fUser1RuntimePath; + User1PhobosPath := src.fUser1PhobosPath; + User2ExeName := src.fUser2ExeName; + User2RuntimePath := src.fUser2RuntimePath; + User2PhobosPath := src.fUser2PhobosPath; end else inherited; end; + +procedure TCompilersPaths.setDefaultCompiler(value: Dcompiler); +begin + if fDefaultCompiler = value then + exit; + fDefaultCompiler:=value; + fWouldNeedRestart := true; + fModified:=true; +end; + +procedure TCompilersPaths.setDmdExeName(const value: string); +begin + if fDmdExeName = value then + exit; + fDmdExeName:=value; + fModified:=true; +end; + +procedure TCompilersPaths.setDmdRuntimePath(const value: string); +begin + if fDmdRuntimePath = value then + exit; + fDmdRuntimePath:=value; + fModified:=true; + if fDefaultCompiler = dmd then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setDmdPhobosPath(const value: string); +begin + if fDmdPhobosPath = value then + exit; + fDmdPhobosPath:=value; + fModified:=true; + if fDefaultCompiler = dmd then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setGdcExeName(const value: string); +begin + if fGdcExeName = value then + exit; + fGdcExeName:=value; + fModified:=true; +end; + +procedure TCompilersPaths.setGdcRuntimePath(const value: string); +begin + if fGdcRuntimePath = value then + exit; + fGdcRuntimePath:=value; + fModified:=true; + if fDefaultCompiler in [gdc,gdmd] then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setGdcPhobosPath(const value: string); +begin + if fGdcPhobosPath = value then + exit; + fGdcPhobosPath:=value; + fModified:=true; + if fDefaultCompiler in [gdc,gdmd] then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setLdcExeName(const value: string); +begin + if fLdcExeName = value then + exit; + fLdcExeName:=value; + fModified:=true; +end; + +procedure TCompilersPaths.setLdcRuntimePath(const value: string); +begin + if fLdcRuntimePath = value then + exit; + fLdcRuntimePath:=value; + fModified:=true; + if fDefaultCompiler in [ldc,ldmd] then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setLdcPhobosPath(const value: string); +begin + if fLdcPhobosPath = value then + exit; + fLdcPhobosPath:=value; + fModified:=true; + if fDefaultCompiler in [ldc,ldmd] then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setUser1ExeName(const value: string); +begin + if fUser1ExeName = value then + exit; + fUser1ExeName:=value; + fModified:=true; +end; + +procedure TCompilersPaths.setUser1RuntimePath(const value: string); +begin + if fUser1RuntimePath = value then + exit; + fUser1RuntimePath:=value; + fModified:=true; + if fDefaultCompiler = user1 then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setUser1PhobosPath(const value: string); +begin + if fUser1PhobosPath = value then + exit; + fUser1PhobosPath:=value; + fModified:=true; + if fDefaultCompiler = user1 then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setUser2ExeName(const value: string); +begin + if fUser2ExeName = value then + exit; + fUser2ExeName:=value; + fModified:=true; +end; + +procedure TCompilersPaths.setUser2RuntimePath(const value: string); +begin + if fUser2RuntimePath = value then + exit; + fUser2RuntimePath:=value; + fModified:=true; + if fDefaultCompiler = user2 then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.setUser2PhobosPath(const value: string); +begin + if fUser2PhobosPath = value then + exit; + fUser2PhobosPath:=value; + fModified:=true; + if fDefaultCompiler = user2 then + fWouldNeedRestart := true; +end; + +procedure TCompilersPaths.afterLoad; +begin + inherited; + fModified:=false; + fWouldNeedRestart:=false; +end; {$ENDREGION} {$REGION ICEEditableOptions ----------------------------------------------------} @@ -237,15 +415,26 @@ end; procedure TForm1.optionedEvent(event: TOptionEditorEvent); begin case event of - oeeAccept: fPathsBackup.assign(fPaths); - oeeCancel: fPaths.assign(fPathsBackup); + oeeAccept: + begin + fPathsBackup.assign(fPaths); + if fPaths.wouldNeedRestart and fPaths.modified then + dlgOkInfo('A restart might be necessary so that DCD caches a different version' + + 'of the runtime and the standard library.'); + fPaths.modified:=false; + fPaths.wouldNeedRestart:=false; + end; + oeeCancel: + begin + fPaths.assign(fPathsBackup); + fPaths.modified:=false; + end; end; end; function TForm1.optionedOptionsModified: boolean; begin - //TODO-cCompilerPaths: add setters to detect if a TCompilersPaths is modified - exit(false); + exit(fPaths.modified); end; {$ENDREGION} @@ -387,8 +576,6 @@ end; procedure TForm1.selectedDefault(sender: TObject); begin fPaths.defaultCompiler:= DCompiler(selDefault.ItemIndex); - dlgOkInfo('A restart might be necessary so that DCD caches a different version' - + 'of the runtime and the standard library.'); end; procedure TForm1.autoDetectDMD; diff --git a/src/ce_dmdwrap.pas b/src/ce_dmdwrap.pas index 8c16e5fe..bfd038ca 100644 --- a/src/ce_dmdwrap.pas +++ b/src/ce_dmdwrap.pas @@ -1218,7 +1218,7 @@ var begin if base.isNil then begin - // TODO-cCompilers paths: add other options to CE proj format for the other comps + // TODO-cCompilerPaths paths: add other options to CE proj format for the other comps case compiler of dmd: lst := fDmdOthers; ldc: lst := fLdcOthers;