This commit is contained in:
Basile Burg 2014-07-12 01:56:05 +02:00
parent b05c28db0f
commit f908e60e26
7 changed files with 197 additions and 52 deletions

View File

@ -6,7 +6,11 @@ object _1: TCEProject
documentationOptions.generateJSON = False documentationOptions.generateJSON = False
documentationOptions.DocumentationDirectory = '..\doc' documentationOptions.DocumentationDirectory = '..\doc'
debugingOptions.debug = True debugingOptions.debug = True
debugingOptions.debugIdentifier = '2' debugingOptions.debugIdentifiers.Strings = (
'a'
'b'
)
debugingOptions.debugLevel = 2
debugingOptions.addDInformations = False debugingOptions.addDInformations = False
debugingOptions.addCInformations = False debugingOptions.addCInformations = False
debugingOptions.generateMapFile = False debugingOptions.generateMapFile = False
@ -35,6 +39,7 @@ object _1: TCEProject
documentationOptions.DocumentationDirectory = '..\doc' documentationOptions.DocumentationDirectory = '..\doc'
debugingOptions.debug = False debugingOptions.debug = False
debugingOptions.debugIdentifier = '3' debugingOptions.debugIdentifier = '3'
debugingOptions.debugLevel = 0
debugingOptions.addDInformations = False debugingOptions.addDInformations = False
debugingOptions.addCInformations = False debugingOptions.addCInformations = False
debugingOptions.generateMapFile = False debugingOptions.generateMapFile = False

View File

@ -12,5 +12,8 @@ class Bar{
debug(1) writeln("bar says: debug level < 2"); debug(1) writeln("bar says: debug level < 2");
debug(2) writeln("bar says: debug level < 3"); debug(2) writeln("bar says: debug level < 3");
debug(3) writeln("bar says: debug level < 4"); debug(3) writeln("bar says: debug level < 4");
debug(a) writeln("bar says: debug ident a");
debug(b) writeln("bar says: debug ident b");
debug(c) writeln("bar says: debug ident c");
} }
} }

View File

@ -838,6 +838,7 @@ var
mtok: boolean; mtok: boolean;
begin begin
result := ''; result := '';
mtok := false;
for ltk in aTokenList do for ltk in aTokenList do
begin begin
if mtok then if mtok then
@ -856,7 +857,6 @@ begin
mtok := true; mtok := true;
end; end;
end; end;
{$ENDREGION} {$ENDREGION}
initialization initialization

View File

@ -7,6 +7,14 @@ interface
uses uses
classes, sysutils; classes, sysutils;
(*
procedure to add a new compiler option:
- the option must be published with a setter proc, in the setter 'doChanged' must be called.
- getOpts must be updated to generate the new option.
- Assign() must be updated to copy the new option. (used when cloning a configuration)
*)
type type
@ -84,15 +92,20 @@ type
procedure getOpts(const aList: TStrings); override; procedure getOpts(const aList: TStrings); override;
end; end;
(***************************************************************************** (**
* Describes the target registry size * Describes the target registry size.
*) *)
TTargetSystem = (auto, os32bit, os64bit); TTargetSystem = (auto, os32bit, os64bit);
(** (**
* Describes the output kind * Describes the output kind.
*) *)
TBinaryKind = (executable, staticlib, sharedlib, obj); TBinaryKind = (executable, staticlib, sharedlib, obj);
(**
* Describes the bounds check kinds.
*)
TBoundCheckKind = (onAlways, safeOnly, offAlways);
(***************************************************************************** (*****************************************************************************
* Encapsulates the options/args related to the analysis & the code gen. * Encapsulates the options/args related to the analysis & the code gen.
@ -105,16 +118,19 @@ type
fVerId: string; fVerId: string;
fVerIds: TStringList; fVerIds: TStringList;
fInline: boolean; fInline: boolean;
fBoundsCheck: TBoundCheckKind;
fNoBounds: boolean; fNoBounds: boolean;
fOptimz: boolean; fOptimz: boolean;
fGenStack: boolean; fGenStack: boolean;
fMain: boolean; fMain: boolean;
fRelease: boolean; fRelease: boolean;
procedure depPatch;
procedure setUt(const aValue: boolean); procedure setUt(const aValue: boolean);
procedure setVerId(const aValue: string); procedure setVerId(const aValue: string);
procedure setTrgKind(const aValue: TTargetSystem); procedure setTrgKind(const aValue: TTargetSystem);
procedure setBinKind(const aValue: TBinaryKind); procedure setBinKind(const aValue: TBinaryKind);
procedure setInline(const aValue: boolean); procedure setInline(const aValue: boolean);
procedure setBoundsCheck(const aValue: TBoundCheckKind);
procedure setNoBounds(const aValue: boolean); procedure setNoBounds(const aValue: boolean);
procedure setOptims(const aValue: boolean); procedure setOptims(const aValue: boolean);
procedure setGenStack(const aValue: boolean); procedure setGenStack(const aValue: boolean);
@ -126,12 +142,13 @@ type
property binaryKind: TBinaryKind read fBinKind write setBinKind; property binaryKind: TBinaryKind read fBinKind write setBinKind;
property inlining: boolean read fInline write setInline; property inlining: boolean read fInline write setInline;
property noBoundsCheck: boolean read fNoBounds write setNoBounds; property noBoundsCheck: boolean read fNoBounds write setNoBounds;
property boundsCheck: TBoundCheckKind read fBoundsCheck write setBoundsCheck;
property optimizations: boolean read fOptimz write setOptims; property optimizations: boolean read fOptimz write setOptims;
property generateStackFrame: boolean read fGenStack write setGenStack; property generateStackFrame: boolean read fGenStack write setGenStack;
property addMain: boolean read fMain write setMain; property addMain: boolean read fMain write setMain;
property release: boolean read fRelease write setRelease; property release: boolean read fRelease write setRelease;
property unittest: boolean read fUt write setUt; property unittest: boolean read fUt write setUt;
property versionIdentifier: string read fVerId write setVerId; property versionIdentifier: string read fVerId write setVerId; // TODO-ccleaning:remove on beta1
property versionIdentifiers: TStringList read fVerIds write setVerIds; property versionIdentifiers: TStringList read fVerIds write setVerIds;
public public
constructor create; constructor create;
@ -150,18 +167,29 @@ type
fDbgD: boolean; fDbgD: boolean;
fDbgC: boolean; fDbgC: boolean;
fMap: boolean; fMap: boolean;
fDbgIdents: TStringList;
fDbgLevel: Integer;
fForceDbgBool: boolean;
procedure depPatch;
procedure updateForceDbgBool;
procedure setDbg(const aValue: boolean); procedure setDbg(const aValue: boolean);
procedure setDbgIdent(const aValue: string); procedure setDbgIdent(const aValue: string);
procedure setDbgD(const aValue: boolean); procedure setDbgD(const aValue: boolean);
procedure setDbgC(const aValue: boolean); procedure setDbgC(const aValue: boolean);
procedure setMap(const aValue: boolean); procedure setMap(const aValue: boolean);
procedure setDbgLevel(const aValue: Integer);
procedure setDbgIdents(const aValue: TStringList);
published published
property debug: boolean read fDbg write setDbg; property debug: boolean read fDbg write setDbg;
property debugIdentifier: string read fDbgIdent write setDbgIdent; property debugIdentifier: string read fDbgIdent write setDbgIdent; // TODO-ccleaning:remove on beta1
property debugIdentifiers: TStringList read fDbgIdents write setDbgIdents;
property debugLevel: Integer read fDbgLevel write setDbgLevel;
property addDInformations: boolean read fDbgD write setDbgD; property addDInformations: boolean read fDbgD write setDbgD;
property addCInformations: boolean read fDbgC write setDbgC; property addCInformations: boolean read fDbgC write setDbgC;
property generateMapFile: boolean read fMap write setMap; property generateMapFile: boolean read fMap write setMap;
public public
constructor create;
destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(const aList: TStrings); override;
end; end;
@ -255,17 +283,12 @@ implementation
uses uses
ce_common; ce_common;
(*******************************************************************************
* TOptsGroup
*)
procedure TOptsGroup.doChanged; procedure TOptsGroup.doChanged;
begin begin
if assigned(fOnChange) then fOnChange(self); if assigned(fOnChange) then fOnChange(self);
end; end;
(******************************************************************************* {$REGION TDocOpts **************************************************************}
* TDocOpts
*)
procedure TDocOpts.getOpts(const aList: TStrings); procedure TDocOpts.getOpts(const aList: TStrings);
begin begin
if fGenDoc then aList.Add('-D'); if fGenDoc then aList.Add('-D');
@ -330,10 +353,9 @@ begin
if fJsonFname <> '' then setGenJSON(true); if fJsonFname <> '' then setGenJSON(true);
doChanged; doChanged;
end; end;
{$ENDREGION}
(******************************************************************************* {$REGION TMsgOpts **************************************************************}
* TMsgOpts
*)
constructor TMsgOpts.create; constructor TMsgOpts.create;
begin begin
fDepHandling := TDepHandling.warning; fDepHandling := TDepHandling.warning;
@ -412,14 +434,12 @@ begin
fQuiet := aValue; fQuiet := aValue;
doChanged; doChanged;
end; end;
{$ENDREGION}
(******************************************************************************* {$REGION TOutputOpts ***********************************************************}
* TOutputOpts
*)
constructor TOutputOpts.create; constructor TOutputOpts.create;
begin begin
fVerIds := TStringList.Create; fVerIds := TStringList.Create;
//fVerId := 'deprecated_field';
end; end;
destructor TOutputOpts.destroy; destructor TOutputOpts.destroy;
@ -428,19 +448,32 @@ begin
inherited; inherited;
end; end;
procedure TOutputOpts.depPatch;
begin
// patch deprecated fields
if fVerId <> '' then
begin
if fVerIds.IndexOf(fVerId) = -1 then
fVerIds.Add(fVerId);
fVerId := '';
end;
end;
procedure TOutputOpts.getOpts(const aList: TStrings); procedure TOutputOpts.getOpts(const aList: TStrings);
var 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[TBinaryKind] of string = ('', '-lib', '-shared', '-c');
bchKindStr: array[TBoundCheckKind] of string = ('on', 'safeonly', 'off');
begin begin
depPatch;
//
opt := binKindStr[fBinKind]; opt := binKindStr[fBinKind];
if opt <> '' then aList.Add(opt); if opt <> '' then aList.Add(opt);
opt := trgKindStr[fTrgKind]; opt := trgKindStr[fTrgKind];
if opt <> '' then aList.Add(opt); if opt <> '' then aList.Add(opt);
if fUt then aList.Add('-unittest'); if fUt then aList.Add('-unittest');
if fVerId <> '' then aList.Add('-version=' + fVerId);
if fInline then aList.Add('-inline'); if fInline then aList.Add('-inline');
if fNoBounds then aList.Add('-noboundscheck'); if fNoBounds then aList.Add('-noboundscheck');
if fOptimz then aList.Add('-O'); if fOptimz then aList.Add('-O');
@ -449,6 +482,16 @@ begin
if fRelease then aList.Add('-release'); if fRelease then aList.Add('-release');
for opt in fVerIds do for opt in fVerIds do
aList.Add('-version=' + opt ); aList.Add('-version=' + opt );
//
if fRelease then
begin
if fBoundsCheck <> safeOnly then
(*generate option*);
end
else
if fBoundsCheck <> onAlways then
(*generate option*);
end; end;
procedure TOutputOpts.assign(aValue: TPersistent); procedure TOutputOpts.assign(aValue: TPersistent);
@ -462,12 +505,15 @@ begin
fTrgKind := src.fTrgKind; fTrgKind := src.fTrgKind;
fUt := src.fUt; fUt := src.fUt;
fVerId := src.fVerId; fVerId := src.fVerId;
fVerIds.Assign(src.fVerIds);
fInline := src.fInline; fInline := src.fInline;
fNoBounds := src.fNoBounds; fNoBounds := src.fNoBounds;
fOptimz := src.fOptimz; fOptimz := src.fOptimz;
fGenStack := src.fGenStack; fGenStack := src.fGenStack;
fMain := src.fMain; fMain := src.fMain;
fRelease := src.fRelease; fRelease := src.fRelease;
//
depPatch;
end end
else inherited; else inherited;
end; end;
@ -513,11 +559,20 @@ begin
doChanged; doChanged;
end; end;
procedure TOutputOpts.setBoundsCheck(const aValue: TBoundCheckKind);
begin
if fBoundsCheck = aValue then exit;
fBoundsCheck := aValue;
doChanged;
end;
procedure TOutputOpts.setNoBounds(const aValue: boolean); procedure TOutputOpts.setNoBounds(const aValue: boolean);
begin begin
if fNoBounds = aValue then exit; if fNoBounds = aValue then exit;
fNoBounds := aValue; fNoBounds := aValue;
doChanged; doChanged;
// turns old option to TBoundCheckKind.onAlways if true and set
// fNoBounds to false (wont be written anymore).
end; end;
procedure TOutputOpts.setOptims(const aValue: boolean); procedure TOutputOpts.setOptims(const aValue: boolean);
@ -547,14 +602,40 @@ begin
fRelease := aValue; fRelease := aValue;
doChanged; doChanged;
end; end;
{$ENDREGION}
(******************************************************************************* {$REGION TDebugOpts ************************************************************}
* TDebugOpts constructor TDebugOpts.create;
*)
procedure TDebugOpts.getOpts(const aList: TStrings);
begin begin
fDbgIdents := TStringList.Create;
end;
destructor TDebugOpts.destroy;
begin
fDbgIdents.Free;
inherited;
end;
procedure TDebugOpts.depPatch;
begin
// patch deprecated field
if fDbgIdent <> '' then
begin
if fDbgIdents.IndexOf(fDbgIdent) = -1 then
fDbgIdents.Add(fDbgIdent);
fDbgIdent := '';
end;
end;
procedure TDebugOpts.getOpts(const aList: TStrings);
var
idt: string;
begin
depPatch;
if fDbg then aList.Add('-debug'); if fDbg then aList.Add('-debug');
if fDbgIdent <> '' then aList.Add('-debug=' + fDbgIdent); if fDbgLevel <> 0 then aList.Add('-debug=' + intToStr(fDbgLevel));
for idt in fDbgIdents do
aList.Add('-debug=' + idt);
if fDbgD then aList.Add('-g'); if fDbgD then aList.Add('-g');
if fDbgC then aList.Add('-gc'); if fDbgC then aList.Add('-gc');
if fMap then aList.Add('-map'); if fMap then aList.Add('-map');
@ -569,15 +650,30 @@ begin
src := TDebugOpts(aValue); src := TDebugOpts(aValue);
fDbg := src.fDbg; fDbg := src.fDbg;
fDbgIdent := src.fDbgIdent; fDbgIdent := src.fDbgIdent;
fDbgIdents.Assign(src.fDbgIdents);
fDbgLevel := src.fDbgLevel;
fDbgD := src.fDbgD; fDbgD := src.fDbgD;
fDbgC := src.fDbgC; fDbgC := src.fDbgC;
fMap := src.fMap; fMap := src.fMap;
//
depPatch;
end end
else inherited; else inherited;
end; end;
procedure TDebugOpts.updateForceDbgBool;
begin
fForceDbgBool := (fDbgLevel > 0) or (fDbgIdents.Count > 0);
if fForceDbgBool then setDbg(true);
end;
procedure TDebugOpts.setDbg(const aValue: boolean); procedure TDebugOpts.setDbg(const aValue: boolean);
begin begin
if fForceDbgBool then
begin
fDbg := true;
exit;
end;
if fDbg = aValue then exit; if fDbg = aValue then exit;
fDbg := aValue; fDbg := aValue;
doChanged; doChanged;
@ -611,9 +707,24 @@ begin
doChanged; doChanged;
end; end;
(******************************************************************************* procedure TDebugOpts.setDbgLevel(const aValue: Integer);
* TPathsOpts begin
*) if fDbgLevel = aValue then exit;
fDbgLevel := aValue;
if fDbgLevel < 0 then fDbgLevel := 0;
updateForceDbgBool;
doChanged;
end;
procedure TDebugOpts.setDbgIdents(const aValue: TStringList);
begin
fDbgIdents.Assign(aValue);
updateForceDbgBool;
doChanged;
end;
{$ENDREGION}
{$REGION TPathsOpts ************************************************************}
constructor TPathsOpts.create; constructor TPathsOpts.create;
begin begin
fSrcs := TStringList.Create; fSrcs := TStringList.Create;
@ -693,10 +804,9 @@ begin
patchPlateformPaths(fImpt); patchPlateformPaths(fImpt);
doChanged; doChanged;
end; end;
{$ENDREGION}
(******************************************************************************* {$REGION TOtherOpts ************************************************************}
* TOtherOpts
*)
constructor TOtherOpts.create; constructor TOtherOpts.create;
begin begin
fCustom := TStringList.Create; fCustom := TStringList.Create;
@ -739,10 +849,9 @@ begin
fCustom.Assign(aValue); fCustom.Assign(aValue);
doChanged; doChanged;
end; end;
{$ENDREGION}
(******************************************************************************* {$REGION TCompilerConfiguration ************************************************}
* TCompilerConfiguration
*)
constructor TCompilerConfiguration.create(aCollection: TCollection); constructor TCompilerConfiguration.create(aCollection: TCollection);
begin begin
inherited create(aCollection); inherited create(aCollection);
@ -857,6 +966,7 @@ procedure TCompilerConfiguration.setOthers(const aValue: TOtherOpts);
begin begin
fOthers.Assign(aValue); fOthers.Assign(aValue);
end; end;
{$ENDREGION}
initialization initialization
RegisterClasses([TCompilerConfiguration, TOtherOpts, TPathsOpts, RegisterClasses([TCompilerConfiguration, TOtherOpts, TPathsOpts,

View File

@ -123,7 +123,7 @@ begin
if pageControl.ActivePageIndex <> -1 then if pageControl.ActivePageIndex <> -1 then
mainForm.docFocusedNotify(Self, pageControl.ActivePageIndex); mainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
// //
if (curr.modified or (pageCOntrol.ActivePage.Caption = '')) then if (curr.modified or (pageControl.ActivePage.Caption = '')) then
begin begin
fKeyChanged := true; fKeyChanged := true;
beginUpdateByDelay; beginUpdateByDelay;

View File

@ -1140,6 +1140,9 @@ object CEMainForm: TCEMainForm
91F4969391FF908D8B00969391FF969391F4979492008D8A8800 91F4969391FF908D8B00969391FF969391F4979492008D8A8800
} }
end end
object MenuItem55: TMenuItem
Action = actProjOptView
end
object MenuItem40: TMenuItem object MenuItem40: TMenuItem
Caption = '-' Caption = '-'
end end
@ -1786,10 +1789,30 @@ object CEMainForm: TCEMainForm
end end
object actProjSource: TAction object actProjSource: TAction
Category = 'Project' Category = 'Project'
Caption = 'View Project source' Caption = 'View project source'
ImageIndex = 12 ImageIndex = 12
OnExecute = actProjSourceExecute OnExecute = actProjSourceExecute
end end
object actEdIndent: TAction
Category = 'Edit'
Caption = 'Indent'
ImageIndex = 16
OnExecute = actEdIndentExecute
ShortCut = 24649
end
object actEdUnIndent: TAction
Category = 'Edit'
Caption = 'Unindent'
ImageIndex = 17
OnExecute = actEdUnIndentExecute
ShortCut = 24661
end
object actProjOptView: TAction
Category = 'Project'
Caption = 'View project options'
ImageIndex = 12
OnExecute = actProjOptViewExecute
end
object actProjCompile: TAction object actProjCompile: TAction
Category = 'Project' Category = 'Project'
Caption = 'Compile project' Caption = 'Compile project'
@ -1823,20 +1846,6 @@ object CEMainForm: TCEMainForm
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjRunWithArgsExecute OnExecute = actProjRunWithArgsExecute
end end
object actEdIndent: TAction
Category = 'Edit'
Caption = 'Indent'
ImageIndex = 16
OnExecute = actEdIndentExecute
ShortCut = 24649
end
object actEdUnIndent: TAction
Category = 'Edit'
Caption = 'Unindent'
ImageIndex = 17
OnExecute = actEdUnIndentExecute
ShortCut = 24661
end
end end
object imgList: TImageList object imgList: TImageList
left = 64 left = 64

View File

@ -63,6 +63,7 @@ type
actFileSaveAs: TAction; actFileSaveAs: TAction;
actFileSave: TAction; actFileSave: TAction;
actFileCompAndRunWithArgs: TAction; actFileCompAndRunWithArgs: TAction;
actProjOptView: TAction;
actProjSource: TAction; actProjSource: TAction;
actProjRun: TAction; actProjRun: TAction;
actProjRunWithArgs: TAction; actProjRunWithArgs: TAction;
@ -136,6 +137,7 @@ type
MenuItem52: TMenuItem; MenuItem52: TMenuItem;
MenuItem53: TMenuItem; MenuItem53: TMenuItem;
MenuItem54: TMenuItem; MenuItem54: TMenuItem;
MenuItem55: TMenuItem;
mnuItemMruFile: TMenuItem; mnuItemMruFile: TMenuItem;
mnuItemMruProj: TMenuItem; mnuItemMruProj: TMenuItem;
mnuItemWin: TMenuItem; mnuItemWin: TMenuItem;
@ -171,6 +173,7 @@ type
procedure actEdRedoExecute(Sender: TObject); procedure actEdRedoExecute(Sender: TObject);
procedure actFileSaveAsExecute(Sender: TObject); procedure actFileSaveAsExecute(Sender: TObject);
procedure actFileSaveExecute(Sender: TObject); procedure actFileSaveExecute(Sender: TObject);
procedure actProjOptViewExecute(Sender: TObject);
procedure actProjRunExecute(Sender: TObject); procedure actProjRunExecute(Sender: TObject);
procedure actProjRunWithArgsExecute(Sender: TObject); procedure actProjRunWithArgsExecute(Sender: TObject);
procedure actProjSaveAsExecute(Sender: TObject); procedure actProjSaveAsExecute(Sender: TObject);
@ -414,6 +417,7 @@ begin
actProjRun.Enabled := hasProj; actProjRun.Enabled := hasProj;
actProjRunWithArgs.Enabled := hasProj; actProjRunWithArgs.Enabled := hasProj;
actProjSource.Enabled := hasProj; actProjSource.Enabled := hasProj;
actProjOptView.Enabled := hasProj;
actFileAddToProj.Enabled := hasEd and hasProj; actFileAddToProj.Enabled := hasEd and hasProj;
@ -934,6 +938,7 @@ begin
getDir(0, olddir); getDir(0, olddir);
try try
fMesgWidg.Clear;
fMesgWidg.addCeInf( 'compiling ' + aProject.fileName ); fMesgWidg.addCeInf( 'compiling ' + aProject.fileName );
prjpath := extractFilePath(aProject.fileName); prjpath := extractFilePath(aProject.fileName);
@ -1220,6 +1225,19 @@ begin
openFile(fProject.fileName); openFile(fProject.fileName);
EditWidget.currentEditor.Highlighter := LfmSyn; EditWidget.currentEditor.Highlighter := LfmSyn;
end; end;
procedure TCEMainForm.actProjOptViewExecute(Sender: TObject);
var
lst: TStringList;
begin
lst := TStringList.Create;
try
fProject.getOpts(lst);
dlgOkInfo(lst.Text);
finally
lst.Free;
end;
end;
{$ENDREGION} {$ENDREGION}
{$REGION options ***************************************************************} {$REGION options ***************************************************************}